1.1 --- a/lib/builtins.py Sat Nov 06 00:57:43 2010 +0100
1.2 +++ b/lib/builtins.py Thu Jan 13 23:58:12 2011 +0100
1.3 @@ -611,6 +611,9 @@
1.4
1.5 def _isinstance(obj, cls): pass
1.6
1.7 +def _print(dest, *args): pass
1.8 +def _printnl(dest, *args): pass
1.9 +
1.10 # Reference some names to ensure their existence. This should be everything
1.11 # mentioned in a get_builtin or load_builtin call. Instances from this module
1.12 # should be predefined constants.
2.1 --- a/micropython/ast.py Sat Nov 06 00:57:43 2010 +0100
2.2 +++ b/micropython/ast.py Thu Jan 13 23:58:12 2011 +0100
2.3 @@ -812,9 +812,11 @@
2.4
2.5 def visitPass(self, node): pass
2.6
2.7 - def visitPrint(self, node): raise TranslationNotImplementedError("Print")
2.8 + def visitPrint(self, node):
2.9 + self._visitPrint(node, "_print")
2.10
2.11 - def visitPrintnl(self, node): raise TranslationNotImplementedError("Printnl")
2.12 + def visitPrintnl(self, node):
2.13 + self._visitPrint(node, "_printnl")
2.14
2.15 def visitRaise(self, node):
2.16 # NOTE: expr1 only => instance provided
3.1 --- a/micropython/inspect.py Sat Nov 06 00:57:43 2010 +0100
3.2 +++ b/micropython/inspect.py Thu Jan 13 23:58:12 2011 +0100
3.3 @@ -210,7 +210,7 @@
3.4 # have been defined within the object and therefore are not
3.5 # redefined by other code regions.
3.6
3.7 - if attr.assignments == 1:
3.8 + if attr is not None and attr.assignments == 1:
3.9 value = attr.get_value()
3.10
3.11 if value is not obj and value in self.all_objects:
3.12 @@ -1006,9 +1006,15 @@
3.13
3.14 visitPower = _visitBinary
3.15
3.16 - visitPrint = NOP
3.17 + def _visitPrint(self, node, function_name):
3.18 + self.NOP(node)
3.19 + self.use_specific_attribute("__builtins__", function_name)
3.20
3.21 - visitPrintnl = NOP
3.22 + def visitPrint(self, node):
3.23 + self._visitPrint(node, "_print")
3.24 +
3.25 + def visitPrintnl(self, node):
3.26 + self._visitPrint(node, "_printnl")
3.27
3.28 visitRaise = NOP_ABANDON
3.29
4.1 --- a/micropython/trans.py Sat Nov 06 00:57:43 2010 +0100
4.2 +++ b/micropython/trans.py Thu Jan 13 23:58:12 2011 +0100
4.3 @@ -1460,4 +1460,14 @@
4.4
4.5 self.set_block(end_block)
4.6
4.7 + def _visitPrint(self, node, function_name):
4.8 + self._startCallFunc()
4.9 + self.load_builtin(function_name, node)
4.10 +
4.11 + args = [node.dest or compiler.ast.Name("None")] + node.nodes
4.12 +
4.13 + temp_target, target, temp_context = self._generateCallFunc(args, node)
4.14 + self._doCallFunc(temp_target, target)
4.15 + self._endCallFunc(temp_target, temp_context)
4.16 +
4.17 # vim: tabstop=4 expandtab shiftwidth=4
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/tests/print.py Thu Jan 13 23:58:12 2011 +0100
5.3 @@ -0,0 +1,5 @@
5.4 +#!/usr/bin/env python
5.5 +
5.6 +print "Hello world"
5.7 +
5.8 +# vim: tabstop=4 expandtab shiftwidth=4