# HG changeset patch # User Paul Boddie # Date 1382720610 -7200 # Node ID b2b7c0834b043bfe6cd01f6dd9fe6dc7e3452b52 # Parent c9630f7ba1dc07aa65941006ca9dbd73f053b5f9 Added a specific _values annotation collecting assignment values on nodes. diff -r c9630f7ba1dc -r b2b7c0834b04 docs/annotations.txt --- a/docs/annotations.txt Fri Oct 25 01:02:10 2013 +0200 +++ b/docs/annotations.txt Fri Oct 25 19:03:30 2013 +0200 @@ -56,6 +56,8 @@ _attrtypes defines types deduced either from combined attribute usage details (for users) +_values defines a name-to-value mapping for objects that may be + used to access attributes Attribute Contributors ---------------------- diff -r c9630f7ba1dc -r b2b7c0834b04 micropython/data.py --- a/micropython/data.py Fri Oct 25 01:02:10 2013 +0200 +++ b/micropython/data.py Fri Oct 25 19:03:30 2013 +0200 @@ -257,8 +257,19 @@ if not self.namespace.has_key(name): self.namespace[name] = Attr(None, self, name) + attr = self.namespace[name] - attr = self.namespace[name] + # Also direct assignments to individual name users. + + users = self.attribute_users[-1] + + if users.has_key(name): + for user in users[name]: + user._values = user._values or {} + user._values[name] = attr_or_value + + # Update the attribute records. + self._set_using_attr(attr, attr_or_value, single_assignment) def _set_using_attr(self, attr, attr_or_value, single_assignment=1): diff -r c9630f7ba1dc -r b2b7c0834b04 micropython/deduce.py --- a/micropython/deduce.py Fri Oct 25 01:02:10 2013 +0200 +++ b/micropython/deduce.py Fri Oct 25 19:03:30 2013 +0200 @@ -327,15 +327,12 @@ else: return - attr = node._attr - - if attr: - value = attr.get_value() + value = node._values and node._values.get(node.name) or None - # Need to replace any uncertain value with a concrete value. + # Need to replace any uncertain value with a concrete value. - if value and isinstance(value, Instance) and not isinstance(value, TypedInstance): - attr.context_values = set([get_context_and_value(expr)]) + if value and isinstance(value, Instance) and not isinstance(value, TypedInstance): + node._values[node.name] = expr def visitCallFunc(self, node): diff -r c9630f7ba1dc -r b2b7c0834b04 micropython/inspect.py --- a/micropython/inspect.py Fri Oct 25 01:02:10 2013 +0200 +++ b/micropython/inspect.py Fri Oct 25 19:03:30 2013 +0200 @@ -914,8 +914,8 @@ self._visitAssName(node) def _visitAssName(self, node): - node._attr = self.store(node.name, self.expr) self.define_attribute_user(node) + self.store(node.name, self.expr) # Ensure the presence of the given name in this namespace. # NOTE: Consider not registering assignments involving methods, since