1.1 --- a/micropython/report.py Fri Nov 02 01:16:08 2012 +0100
1.2 +++ b/micropython/report.py Sat Nov 03 00:35:47 2012 +0100
1.3 @@ -91,6 +91,11 @@
1.4 color: white;
1.5 }
1.6
1.7 + .any-target {
1.8 + background-color: #d60;
1.9 + color: white;
1.10 + }
1.11 +
1.12 .attr,
1.13 .accessor,
1.14 .name,
1.15 @@ -1039,6 +1044,14 @@
1.16
1.17 def visitAssAttr(self, node):
1.18 possible_types = self.possible_accessor_types(node, defining_users=0)
1.19 +
1.20 + # Record whether types were already deduced. If not, get types using
1.21 + # only this attribute.
1.22 +
1.23 + deduced = possible_types
1.24 + if not possible_types:
1.25 + possible_types = self._get_possible_types(node.attrname)
1.26 +
1.27 attributes = self._get_attributes(possible_types, node.attrname)
1.28
1.29 wraps_getattr = self._has_descendant(node.expr, compiler.ast.Getattr)
1.30 @@ -1051,7 +1064,7 @@
1.31 self._accessor_end(possible_types)
1.32 self.stream.write(".")
1.33 self._attribute_start(node.attrname, self._attributes_to_attribute_names(attributes, node.attrname))
1.34 - self._span(node.attrname, "attrname" + (not possible_types and " no-targets" or ""))
1.35 + self._span(node.attrname, "attrname" + (not possible_types and " no-targets" or not deduced and " any-target" or ""))
1.36 self._attribute_end(attributes)
1.37 if not wraps_getattr:
1.38 self._span_end()
1.39 @@ -1137,6 +1150,14 @@
1.40
1.41 def visitGetattr(self, node):
1.42 possible_types = self.possible_accessor_types(node, defining_users=0)
1.43 +
1.44 + # Record whether types were already deduced. If not, get types using
1.45 + # only this attribute.
1.46 +
1.47 + deduced = possible_types
1.48 + if not possible_types:
1.49 + possible_types = self._get_possible_types(node.attrname)
1.50 +
1.51 attributes = self._get_attributes(possible_types, node.attrname)
1.52
1.53 wraps_getattr = self._has_descendant(node.expr, compiler.ast.Getattr)
1.54 @@ -1153,7 +1174,7 @@
1.55 self.stream.write(".")
1.56
1.57 self._attribute_start(node.attrname, self._attributes_to_attribute_names(attributes, node.attrname))
1.58 - self._span(node.attrname, "attrname" + (not possible_types and " no-targets" or ""))
1.59 + self._span(node.attrname, "attrname" + (not possible_types and " no-targets" or not deduced and " any-target" or ""))
1.60 self._attribute_end(attributes)
1.61
1.62 if not wraps_getattr:
1.63 @@ -1431,8 +1452,6 @@
1.64 def possible_accessor_types(self, node, defining_users=1):
1.65 possible_types = [tn for (tn, st) in ASTVisitor.possible_accessor_types(self, node, defining_users)]
1.66 if not possible_types:
1.67 - possible_types = self._get_possible_types(node.attrname)
1.68 - if not possible_types:
1.69 self.program.unknown_target_nodes.append((self.units[-1], node))
1.70 return possible_types
1.71