# HG changeset patch # User paulb@jeremy # Date 1160325960 -7200 # Node ID 58958c11e55e48c1f885924b7b72ee8c426d6850 # Parent fe0d6544097093886f076a2e4eb7379c391ad26e Made the invocations annotation a list. Added return value merging to merge_namespace. Added annotation of Return nodes. diff -r fe0d65440970 -r 58958c11e55e annotate.py --- a/annotate.py Sat Oct 07 19:46:21 2006 +0200 +++ b/annotate.py Sun Oct 08 18:46:00 2006 +0200 @@ -330,6 +330,7 @@ if hasattr(return_, "expr"): return_.expr = self.dispatch(return_.expr) self.namespace.returns += self.namespace.types + self.annotate(return_) self.namespace.snapshot() return return_ @@ -344,7 +345,7 @@ # the target may be a class or object, and there may be many different # related subprograms. - invocations = {} + invocations = [] # Visit each callable in turn, finding subprograms. @@ -398,10 +399,11 @@ # If a subprogram is defined, invoke it. self.invoke_subprogram(invoke, attribute) - invocations[callable] = attribute.type + if attribute.type not in invocations: + invocations.append(attribute.type) else: - print "Invocation type is None" + print "Invocation type is None for", accessor if isinstance(attr.type, Class): @@ -615,6 +617,14 @@ def load(self, name): return self.names[name] + def merge_namespace(self, namespace): + self.merge_items(namespace.names.items()) + self.returns += namespace.returns + + def merge_items(self, items): + for name, types in items: + self.merge(name, types) + def merge(self, name, types): if not self.names.has_key(name): self.names[name] = types[:] @@ -624,13 +634,6 @@ if type not in existing: existing.append(type) - def merge_namespace(self, namespace): - self.merge_items(namespace.names.items()) - - def merge_items(self, items): - for name, types in items: - self.merge(name, types) - def snapshot(self): "Make a snapshot of the locals and remember them."