# HG changeset patch # User Paul Boddie # Date 1240761776 -7200 # Node ID d4374945c3f868cbbf1693808a1485bebab53ed6 # Parent 7165b3c8dca892dc9b1066fc52df30c9d56ebf9a Moved reserved name declarations into the inspect module in places corresponding to the usage of such names when generating code. diff -r 7165b3c8dca8 -r d4374945c3f8 micropython/__init__.py --- a/micropython/__init__.py Sun Apr 26 03:24:12 2009 +0200 +++ b/micropython/__init__.py Sun Apr 26 18:02:56 2009 +0200 @@ -416,10 +416,9 @@ # Name records (used to track actual use of names). # Include names which may not be explicitly used in programs. - # NOTE: Potentially declare these when inspecting. For example, __iter__ - # NOTE: and next are usually implicitly invoked by "for" statements. + # NOTE: Potentially declare these when inspecting. - self.names_used = set(["__init__", "__call__", "__getitem__", "__bool__", "__iter__", "next"]) + self.names_used = set(["__init__", "__call__", "__bool__"]) # Status information. diff -r 7165b3c8dca8 -r d4374945c3f8 micropython/inspect.py --- a/micropython/inspect.py Sun Apr 26 03:24:12 2009 +0200 +++ b/micropython/inspect.py Sun Apr 26 18:02:56 2009 +0200 @@ -406,6 +406,13 @@ return None def visitAssList(self, node): + + # Declare names which will be used by generated code. + + self.importer.use_name("__getitem__") + + # Process the assignment. + for i, n in enumerate(node.nodes): self.dispatch(n) self.importer.make_constant(i) # for __getitem__(i) at run-time @@ -539,6 +546,14 @@ visitFloorDiv = _visitBinary def visitFor(self, node): + + # Declare names which will be used by generated code. + + self.importer.use_name("__iter__") + self.importer.use_name("next") + + # Enter the loop. + self.in_loop = 1 self.NOP(node) self.in_loop = 0