1.1 --- a/micropython/inspect.py Tue Jun 12 23:54:41 2012 +0200
1.2 +++ b/micropython/inspect.py Wed Jun 13 01:20:12 2012 +0200
1.3 @@ -124,7 +124,12 @@
1.4
1.5 def process(self, module):
1.6
1.7 - "Process the given 'module'."
1.8 + """
1.9 + Process the given 'module', visiting only module-level code and only
1.10 + extracting global declarations from functions. In order to support
1.11 + deferred imports, the function code is processed separately after all
1.12 + modules have been initially processed.
1.13 + """
1.14
1.15 self.astnode = module
1.16
1.17 @@ -144,12 +149,6 @@
1.18
1.19 self.finalise_attribute_usage()
1.20
1.21 - # Then, visit each function, recording other names.
1.22 -
1.23 - for node, namespaces in self.functions:
1.24 - self._visitFunctionBody(node, namespaces)
1.25 - namespaces[-1].finalise_attribute_usage()
1.26 -
1.27 # Add references to other modules declared using the __all__ global.
1.28
1.29 if self.has_key("__all__"):
1.30 @@ -160,6 +159,19 @@
1.31
1.32 return processed
1.33
1.34 + def process_functions(self):
1.35 +
1.36 + """
1.37 + Process all function bodies. Deferred imports may occur during this
1.38 + process.
1.39 + """
1.40 +
1.41 + # Then, visit each function, recording other names.
1.42 +
1.43 + for node, namespaces in self.functions:
1.44 + self._visitFunctionBody(node, namespaces)
1.45 + namespaces[-1].finalise_attribute_usage()
1.46 +
1.47 def process_globals(self, node):
1.48
1.49 """