# HG changeset patch # User paulb@jeremy # Date 1155075914 -7200 # Node ID b483cd117b5f0fcbe47f7dea89a7c90d9d483a3c # Parent df3d2b28e2aeb98c089e058539507a514814dab6 Added missing subprogram namespace initialisation. diff -r df3d2b28e2ae -r b483cd117b5f fixnames.py --- a/fixnames.py Wed Aug 09 00:25:00 2006 +0200 +++ b/fixnames.py Wed Aug 09 00:25:14 2006 +0200 @@ -55,15 +55,26 @@ def process(self, node): """ - Process a subprogram or module 'node', indicating any initial 'locals' - and 'globals' if either are defined. Return an annotated subprogram or - module. Note that this method may mutate nodes in the original program. + Process a subprogram or module 'node', discovering from attributes on + 'node' any initial locals. Return a modified subprogram or module. """ # Obtain a namespace either based on locals or on a structure. self.namespace = NameOrganiser(structure=getattr(node, "structure", None)) + # NOTE: Check this. + + if hasattr(node, "params"): + for param, default in node.params: + self.namespace.store(param) + if hasattr(node, "star"): + param = node.star + self.namespace.store(param) + if hasattr(node, "dstar"): + param = node.dstar + self.namespace.store(param) + # Add namespace details to any structure involved. if hasattr(node, "structure") and node.structure is not None: @@ -113,6 +124,7 @@ return global_ def visitLoadName(self, loadname): + print "Name", loadname.name, "in", self.namespace scope = self.namespace.find_for_load(loadname.name) if scope == "structure": result = self.dispatch(LoadAttr(expr=LoadRef(ref=self.namespace.structure), name=loadname.name)) @@ -177,4 +189,7 @@ else: return self.names[name] + def __repr__(self): + return repr(self.names) + # vim: tabstop=4 expandtab shiftwidth=4