1.1 --- a/micropython/__init__.py Wed May 01 23:17:32 2013 +0200
1.2 +++ b/micropython/__init__.py Wed May 01 23:19:29 2013 +0200
1.3 @@ -614,7 +614,9 @@
1.4 "Collect attribute references for the entire program."
1.5
1.6 # Include names which may not be explicitly used in programs.
1.7 - # NOTE: Potentially declare these when inspecting.
1.8 + # NOTE: These would potentially be declared when inspecting, but the
1.9 + # NOTE: only name involved currently (__call__) is implicit in
1.10 + # NOTE: invocations and cannot be detected.
1.11
1.12 for attrname in self.names_always_used:
1.13 for objname in objtable.all_possible_objects([attrname]):
1.14 @@ -629,6 +631,13 @@
1.15 for name in self.modules.keys():
1.16 self._collect_attributes(name, objtable)
1.17
1.18 + # Even after all modules have been visited, there may be a need to
1.19 + # re-evaluate getattr invocations in the context of constants now known
1.20 + # to be used.
1.21 +
1.22 + if "__builtins__.getattr" in self.attribute_users_visited:
1.23 + self._collect_attributes("__builtins__.getattr", objtable)
1.24 +
1.25 def add_attribute_to_visit(self, objname, attrname):
1.26
1.27 """
1.28 @@ -663,7 +672,7 @@
1.29 types.
1.30 """
1.31
1.32 - if from_name in self.attribute_users_visited:
1.33 + if from_name != "__builtins__.getattr" and from_name in self.attribute_users_visited:
1.34 return
1.35
1.36 self.attribute_users_visited.add(from_name)