1.1 --- a/micropython/inspect.py Sat Jul 10 23:23:29 2010 +0200
1.2 +++ b/micropython/inspect.py Sun Jul 11 01:17:11 2010 +0200
1.3 @@ -192,20 +192,19 @@
1.4 all_objects = list(self.all_objects)
1.5
1.6 for obj in all_objects:
1.7 - if isinstance(obj, Class):
1.8 - self.vacuum_object(obj)
1.9 + self.vacuum_object(obj)
1.10
1.11 def vacuum_object(self, obj, delete_all=0):
1.12
1.13 "Vacuum the given object 'obj'."
1.14
1.15 - for name, attr in obj.items():
1.16 + for name, attr in obj.items_for_vacuum():
1.17
1.18 # Only consider deleting entire unused objects or things accessible
1.19 # via names which are never used.
1.20
1.21 if delete_all or not self.importer.uses_attribute(obj.full_name(), name):
1.22 - del obj[name]
1.23 + obj.vacuum_item(name)
1.24
1.25 # Delete any unambiguous attribute value. Such values can only
1.26 # have been defined within the object and therefore are not
1.27 @@ -217,10 +216,9 @@
1.28 if value is not obj and value in self.all_objects:
1.29 self.all_objects.remove(value)
1.30
1.31 - # Delete class contents.
1.32 + # Delete class contents and lambdas from functions.
1.33
1.34 - if isinstance(value, Class):
1.35 - self.vacuum_object(value, 1)
1.36 + self.vacuum_object(value, 1)
1.37
1.38 def unfinalise(self):
1.39
1.40 @@ -286,6 +284,7 @@
1.41 "Store a lambda function 'obj'."
1.42
1.43 self.add_object(obj)
1.44 + self.get_namespace().add_lambda(obj)
1.45
1.46 def store_module_attr(self, name, module):
1.47
1.48 @@ -382,7 +381,8 @@
1.49
1.50 """
1.51 Note usage on the object having the given 'objname' of the attribute
1.52 - 'attrname'.
1.53 + 'attrname'. If 'objname' is None, the current namespace is chosen as the
1.54 + object providing the attribute.
1.55 """
1.56
1.57 return self.get_namespace()._use_specific_attribute(objname, attrname)
1.58 @@ -881,8 +881,9 @@
1.59 return None
1.60
1.61 def visitLambda(self, node):
1.62 - self.use_name(None) # lambda functions have no names but are assumed to be invoked
1.63 - return self._visitFunction(node, None)
1.64 + fn = self._visitFunction(node, None)
1.65 + self.use_specific_attribute(None, fn.name)
1.66 + return fn
1.67
1.68 visitLeftShift = _visitBinary
1.69