1.1 --- a/micropython/report.py Fri Nov 02 00:58:26 2012 +0100
1.2 +++ b/micropython/report.py Fri Nov 02 01:16:08 2012 +0100
1.3 @@ -1041,7 +1041,7 @@
1.4 possible_types = self.possible_accessor_types(node, defining_users=0)
1.5 attributes = self._get_attributes(possible_types, node.attrname)
1.6
1.7 - wraps_getattr = isinstance(node.expr, compiler.ast.Getattr)
1.8 + wraps_getattr = self._has_descendant(node.expr, compiler.ast.Getattr)
1.9
1.10 if not wraps_getattr:
1.11 self._span_start("assattr")
1.12 @@ -1139,7 +1139,7 @@
1.13 possible_types = self.possible_accessor_types(node, defining_users=0)
1.14 attributes = self._get_attributes(possible_types, node.attrname)
1.15
1.16 - wraps_getattr = isinstance(node.expr, compiler.ast.Getattr)
1.17 + wraps_getattr = self._has_descendant(node.expr, compiler.ast.Getattr)
1.18
1.19 if not wraps_getattr:
1.20 self._span_start("getattr")
1.21 @@ -1436,6 +1436,17 @@
1.22 self.program.unknown_target_nodes.append((self.units[-1], node))
1.23 return possible_types
1.24
1.25 + # Utility methods.
1.26 +
1.27 + def _has_descendant(self, node, nodetype):
1.28 + if isinstance(node, nodetype):
1.29 + return True
1.30 + else:
1.31 + for n in node.getChildNodes():
1.32 + if self._has_descendant(n, nodetype):
1.33 + return True
1.34 + return False
1.35 +
1.36 # Convenience functions.
1.37
1.38 def summarise(module, program, filename):