1.1 --- a/micropython/inspect.py Wed Aug 11 00:04:11 2010 +0200
1.2 +++ b/micropython/inspect.py Sun Aug 15 21:49:47 2010 +0200
1.3 @@ -108,7 +108,6 @@
1.4
1.5 # Namespace state.
1.6
1.7 - self.in_init = 0 # Find instance attributes in __init__ methods.
1.8 self.in_method = 0 # Find instance attributes in all methods.
1.9 self.in_function = 0 # Note function presence, affecting definitions.
1.10 self.in_loop = 0 # Note loop "membership", affecting assignments.
1.11 @@ -409,28 +408,25 @@
1.12 # Generic support for classes of operations.
1.13
1.14 def _ensureOperators(self):
1.15 - if not self.has_key("$operator"):
1.16 + attr, scope, namespace = self._get_with_scope("$operator")
1.17 + if attr is None:
1.18 module = self.importer.load("operator")
1.19 self["$operator"] = module
1.20 - return self["$operator"].get_value()
1.21 + else:
1.22 + module = attr.get_value()
1.23 + return module
1.24
1.25 def _visitUnary(self, node):
1.26
1.27 - "Accounting method for the unary operator 'node'."
1.28 -
1.29 - method = unary_methods[node.__class__.__name__]
1.30 - self.use_name(method, node)
1.31 - return self.OP(node)
1.32 -
1.33 - def _visitBinary(self, node):
1.34 -
1.35 - "Accounting method for the binary operator 'node'."
1.36 + "Accounting method for the operator 'node'."
1.37
1.38 operator_module = self._ensureOperators()
1.39 operator_fn = operator_functions[node.__class__.__name__]
1.40 self.use_specific_attribute(operator_module.full_name(), operator_fn)
1.41 return self.OP(node)
1.42
1.43 + _visitBinary = _visitUnary
1.44 +
1.45 def _visitFunction(self, node, name):
1.46
1.47 """
1.48 @@ -487,8 +483,6 @@
1.49 # Previous namespace is the class.
1.50
1.51 if self.in_class(namespaces):
1.52 - if namespaces[-1].name == "__init__":
1.53 - self.in_init = 1
1.54 self.in_method = 1
1.55
1.56 in_function = self.in_function
1.57 @@ -501,7 +495,6 @@
1.58
1.59 self.in_loop = in_loop
1.60 self.in_function = in_function
1.61 - self.in_init = 0
1.62 self.in_method = 0
1.63
1.64 # Specific handler methods.