# HG changeset patch # User Paul Boddie # Date 1384549049 -3600 # Node ID 5026bed6b41b5fcbe75474d285aa886d3229d5c5 # Parent b7eb6cf6072c4c912e6921ece6a241ee4db329a9 Handled uncertain invocation targets in a more satisfactory manner. Added "exec" and "with" statement placeholder methods. diff -r b7eb6cf6072c -r 5026bed6b41b micropython/syspython.py --- a/micropython/syspython.py Fri Nov 15 21:56:10 2013 +0100 +++ b/micropython/syspython.py Fri Nov 15 21:57:29 2013 +0100 @@ -747,12 +747,18 @@ # Determine whether the invocation target is known. - n = node.node - attr = n._attr - args = [self.dispatch(node.node)] + [self.dispatch(arg) for arg in node.args] - if not attr or isinstance(attr, Instance): + target = node.node + + # Attribute information is only known for specific accessors. + + if isinstance(target, compiler.ast.AttributeAccessor): + attr = target._attr + else: + attr = None + + if not attr or isinstance(attr, (Instance, UnresolvedName)): op = "apply" # Invocations with some knowledge available. @@ -835,6 +841,12 @@ def visitDiv(self, node): return self._visitBinary(node) + def visitExec(self, node): + + # NOTE: Return the statement for now. + + return node + def visitFloorDiv(self, node): return self._visitBinary(node) @@ -1140,6 +1152,32 @@ def visitUnarySub(self, node): return self._visitUnary(node) + def visitWith(self, node): + + """ + Convert from... + + with as : + ... + + ...to... + + _manager = = # may be absent + _exit = _manager.__exit__ + _manager.__enter__() + try: + ... + except Exception, exc: + if not _exit(exc.type, exc.value, exc.tb): + raise + else: + _exit(None, None, None) + """ + + # NOTE: For now, not adding this exuberance to the output. + + return node + # Convenience functions. def convert(module, program, filename):