# HG changeset patch # User Paul Boddie # Date 1259019649 -3600 # Node ID f4955e0b5b03a63d44a079502a5b02f95883e5a8 # Parent 54a2867eb4651d381769dee67263cfcb9bac2be4 Introduced proper object visit tracking when collecting attributes. Fixed deletion flags testing where augmented assignment employs AssName nodes. Fixed loop assignment so that outer loop variables are not considered constant. Exposed the importer via a convenience variable in the test program. diff -r 54a2867eb465 -r f4955e0b5b03 micropython/__init__.py --- a/micropython/__init__.py Mon Nov 23 01:22:06 2009 +0100 +++ b/micropython/__init__.py Tue Nov 24 00:40:49 2009 +0100 @@ -369,6 +369,7 @@ self.attributes_used = {} self.name_references = {} self.specific_name_references = {} + self.attribute_users_visited = set() # Status information. @@ -508,7 +509,7 @@ an object according to the register of names. """ - if self.attributes_used.has_key(from_name): + if from_name in self.attribute_users_visited: return # Get name references and find possible objects which support such @@ -526,6 +527,8 @@ self.use_attribute(objname, attrname) self._collect_attributes(objname + "." + attrname, objtable) + self.attribute_users_visited.add(from_name) + # Constant accounting. def init_predefined_constants(self): diff -r 54a2867eb465 -r f4955e0b5b03 micropython/ast.py --- a/micropython/ast.py Mon Nov 23 01:22:06 2009 +0100 +++ b/micropython/ast.py Tue Nov 24 00:40:49 2009 +0100 @@ -501,7 +501,7 @@ "Assign the assignment expression to the recipient 'node'." - if node.flags == "OP_DELETE": + if hasattr(node, "flags") and node.flags == "OP_DELETE": raise TranslationNotImplementedError(self.module.full_name(), node, "AssName(OP_DELETE)") self._visitName(node, self.name_store_instructions) diff -r 54a2867eb465 -r f4955e0b5b03 micropython/inspect.py --- a/micropython/inspect.py Mon Nov 23 01:22:06 2009 +0100 +++ b/micropython/inspect.py Tue Nov 24 00:40:49 2009 +0100 @@ -511,7 +511,7 @@ return None def visitAssName(self, node): - if node.flags == "OP_DELETE": + if hasattr(node, "flags") and node.flags == "OP_DELETE": raise InspectError(self.full_name(), node, "Deletion of attribute %r is not supported." % node.name) self.store(node.name, self.expr) @@ -665,13 +665,13 @@ self.use_name("__iter__") self.use_name("next") + self.in_loop = 1 self.dispatch(node.assign) self.dispatch(node.list) # Enter the loop. # Propagate attribute usage to branches. - self.in_loop = 1 self.new_branch() self.dispatch(node.body) self.shelve_branch() diff -r 54a2867eb465 -r f4955e0b5b03 test.py --- a/test.py Mon Nov 23 01:22:06 2009 +0100 +++ b/test.py Tue Nov 24 00:40:49 2009 +0100 @@ -57,6 +57,7 @@ ot = p.get_object_table() pt = p.get_parameter_table() + i = p.get_importer() # Report any errors.