1.1 --- a/README.txt Sat Feb 09 02:35:57 2008 +0100
1.2 +++ b/README.txt Sat Feb 09 19:37:38 2008 +0100
1.3 @@ -82,16 +82,18 @@
1.4 function locals are completely distinct from this structure and are not
1.5 comparable to attributes.
1.6
1.7 -For modules, the invocation reference would point to the start of the
1.8 -module's code:
1.9 +For modules, there is no meaningful invocation reference:
1.10
1.11 Module m:
1.12
1.13 0 1 2 3 4
1.14 - code for m code module type attribute ...
1.15 - reference reference (global)
1.16 + code for m (unused) module type attribute ...
1.17 + reference (global)
1.18 reference
1.19
1.20 +Both classes and modules have code in their definitions, but this would be
1.21 +generated in order and not referenced externally.
1.22 +
1.23 Invocation Operation
1.24 --------------------
1.25
2.1 --- a/micropython/__init__.py Sat Feb 09 02:35:57 2008 +0100
2.2 +++ b/micropython/__init__.py Sat Feb 09 19:37:38 2008 +0100
2.3 @@ -134,17 +134,7 @@
2.4 image += module.to_list(attributes)
2.5 pos += len(attributes.keys())
2.6
2.7 - # Append the class-level code to the image.
2.8 - # NOTE: An extra optimisation would involve
2.9 - # NOTE: pre-initialisation of attributes and no code being
2.10 - # NOTE: generated here, or perhaps the pre-initialisation of
2.11 - # NOTE: methods and only other attribute-related code being
2.12 - # NOTE: generated here.
2.13 -
2.14 - obj.code_location = pos
2.15 - code = trans.get_code(obj)
2.16 - image += code
2.17 - pos += len(code)
2.18 + # Class-level code is generated separately.
2.19
2.20 # NOTE: Generate module and function code here.
2.21
3.1 --- a/micropython/ast.py Sat Feb 09 02:35:57 2008 +0100
3.2 +++ b/micropython/ast.py Sat Feb 09 19:37:38 2008 +0100
3.3 @@ -142,7 +142,7 @@
3.4 if scope == "local":
3.5 unit = self.unit
3.6 if isinstance(unit, micropython.inspect.Function):
3.7 - self.new_op(NameInstruction(unit.locals()[name]))
3.8 + self.new_op(NameInstruction(unit.all_locals()[name]))
3.9 elif isinstance(unit, micropython.inspect.Class):
3.10 self.new_op(AttrInstruction(unit.all_class_attributes()[name]))
3.11 elif isinstance(unit, micropython.inspect.Module):
3.12 @@ -269,7 +269,11 @@
3.13
3.14 self.new_op(DropFrame())
3.15
3.16 - def visitClass(self, node): pass
3.17 + def visitClass(self, node):
3.18 + unit = self.unit
3.19 + self.unit = node.cls
3.20 + self.dispatch(node.code)
3.21 + self.unit = unit
3.22
3.23 def visitCompare(self, node):
3.24