1.1 --- a/TO_DO.txt Sun Jun 27 20:55:48 2010 +0200
1.2 +++ b/TO_DO.txt Sun Jun 27 21:26:13 2010 +0200
1.3 @@ -1,3 +1,7 @@
1.4 +Consider references to defaults as occurring only within the context of a particular
1.5 +function, thus eliminating default value classes if such functions are not themselves
1.6 +invoked.
1.7 +
1.8 Consider labelling _scope on assignments and dealing with the assignment of removed
1.9 attributes, possibly removing the entire assignment, and distinguishing between such cases
1.10 and unknown names.
1.11 @@ -18,7 +22,9 @@
1.12 Check context_value initialisation (avoiding or handling None effectively).
1.13
1.14 __getitem__ could be written in Python, using a native method only to access fragments.
1.15 +
1.16 Support slicing.
1.17 +
1.18 Consider better "macro" support where new expressions need to be generated and processed.
1.19
1.20 **** Constant attribute users need not maintain usage since they are already resolved. ****
2.1 --- a/micropython/inspect.py Sun Jun 27 20:55:48 2010 +0200
2.2 +++ b/micropython/inspect.py Sun Jun 27 21:26:13 2010 +0200
2.3 @@ -614,17 +614,34 @@
2.4
2.5 cls = Class(node.name, self.get_namespace(), self, node)
2.6
2.7 + # Make a back reference from the node for code generation.
2.8 +
2.9 + node.unit = cls
2.10 +
2.11 + # Process base classes in the context of the class's namespace.
2.12 + # This confines references to such classes to the class instead of
2.13 + # the namespace in which it is defined.
2.14 +
2.15 + self.namespaces.append(cls)
2.16 +
2.17 # Visit the base class expressions, attempting to find concrete
2.18 # definitions of classes.
2.19
2.20 for base in node.bases:
2.21 expr = self.dispatch(base)
2.22 +
2.23 + # Each base class must be constant and known at compile-time.
2.24 +
2.25 if isinstance(expr, Attr):
2.26 if expr.assignments != 1:
2.27 raise InspectError("Base class %r for %r is not constant." % (base, cls.full_name()))
2.28 else:
2.29 cls.add_base(expr.get_value())
2.30 - else: # if expr is None:
2.31 +
2.32 + # Where no expression value is available, the base class is
2.33 + # not identifiable.
2.34 +
2.35 + else:
2.36 raise InspectError("Base class %r for %r is not found: it may be hidden in some way." % (base, cls.full_name()))
2.37
2.38 # NOTE: Potentially dubious measure to permit __init__ availability.
2.39 @@ -634,22 +651,19 @@
2.40 expr = self.dispatch(compiler.ast.Name("object"))
2.41 cls.add_base(expr.get_value())
2.42
2.43 - # Make a back reference from the node for code generation.
2.44 + # Make an entry for the class in the parent namespace.
2.45
2.46 - node.unit = cls
2.47 -
2.48 - # Make an entry for the class.
2.49 -
2.50 + self.namespaces.pop()
2.51 self.store(node.name, cls)
2.52 self.add_object(cls)
2.53
2.54 - # Process the class body.
2.55 + # Process the class body in its own namespace.
2.56
2.57 self.namespaces.append(cls)
2.58 self.dispatch(node.code)
2.59 - cls.finalise_attribute_usage()
2.60 self.namespaces.pop()
2.61
2.62 + cls.finalise_attribute_usage()
2.63 return cls
2.64
2.65 def visitCompare(self, node):