1.1 --- a/annotate.py Tue Jul 25 23:03:33 2006 +0200
1.2 +++ b/annotate.py Tue Jul 25 23:04:14 2006 +0200
1.3 @@ -135,6 +135,10 @@
1.4 self.types = None
1.5 self.temp = {}
1.6
1.7 + # Satisfy visitor issues.
1.8 +
1.9 + self.visitor = self
1.10 +
1.11 def process(self, node, locals=None, globals=None):
1.12
1.13 """
1.14 @@ -154,14 +158,26 @@
1.15 self.global_namespace = globals or self.namespace # NOTE: Improve this.
1.16 node.namespace = self.namespace
1.17
1.18 + # Remember return values.
1.19 +
1.20 + self.returns = []
1.21 +
1.22 # Add namespace details to any structure involved.
1.23
1.24 if hasattr(node, "structure") and node.structure is not None:
1.25 node.structure.namespace = self.namespace
1.26
1.27 - # Satisfy visitor issues and then dispatch.
1.28 + # Initialise bases where appropriate.
1.29
1.30 - self.visitor = self
1.31 + if hasattr(node.structure, "bases"):
1.32 + base_refs = []
1.33 + for base in node.structure.bases:
1.34 + self.dispatch(base)
1.35 + base_refs.append(self.types)
1.36 + node.structure.base_refs = base_refs
1.37 +
1.38 + # Dispatch to the code itself.
1.39 +
1.40 result = self.dispatch(node)
1.41
1.42 return result
1.43 @@ -275,6 +291,12 @@
1.44 ref.namespace.store(storeattr.name, expr)
1.45 return storeattr
1.46
1.47 + def visitReturn(self, return_):
1.48 + if hasattr(return_, "expr"):
1.49 + return_.expr = self.dispatch(return_.expr)
1.50 + self.returns += self.types
1.51 + return return_
1.52 +
1.53 def visitInvoke(self, invoke):
1.54 invoke.expr = self.dispatch(invoke.expr)
1.55 expr = self.types
1.56 @@ -310,6 +332,10 @@
1.57 # NOTE: Now locate and invoke the subprogram.
1.58
1.59 for subprogram in expr:
1.60 +
1.61 + # NOTE: Deal with class invocations by providing instance objects,
1.62 + # NOTE: and with object invocations by using __call__ methods.
1.63 +
1.64 if hasattr(invoke, "same_frame") and invoke.same_frame:
1.65 namespace = self.namespace
1.66 else:
1.67 @@ -320,6 +346,11 @@
1.68 annotator.process(subprogram, namespace, self.global_namespace)
1.69
1.70 # NOTE: Annotate the node with invocation details.
1.71 + # NOTE: This should really be as part of a table of alternatives.
1.72 +
1.73 + if hasattr(subprogram, "returns_value") and subprogram.returns_value:
1.74 + self.types = annotator.returns
1.75 + self.annotate(invoke)
1.76
1.77 return invoke
1.78