1.1 --- a/fixnames.py Wed Aug 09 00:25:00 2006 +0200
1.2 +++ b/fixnames.py Wed Aug 09 00:25:14 2006 +0200
1.3 @@ -55,15 +55,26 @@
1.4 def process(self, node):
1.5
1.6 """
1.7 - Process a subprogram or module 'node', indicating any initial 'locals'
1.8 - and 'globals' if either are defined. Return an annotated subprogram or
1.9 - module. Note that this method may mutate nodes in the original program.
1.10 + Process a subprogram or module 'node', discovering from attributes on
1.11 + 'node' any initial locals. Return a modified subprogram or module.
1.12 """
1.13
1.14 # Obtain a namespace either based on locals or on a structure.
1.15
1.16 self.namespace = NameOrganiser(structure=getattr(node, "structure", None))
1.17
1.18 + # NOTE: Check this.
1.19 +
1.20 + if hasattr(node, "params"):
1.21 + for param, default in node.params:
1.22 + self.namespace.store(param)
1.23 + if hasattr(node, "star"):
1.24 + param = node.star
1.25 + self.namespace.store(param)
1.26 + if hasattr(node, "dstar"):
1.27 + param = node.dstar
1.28 + self.namespace.store(param)
1.29 +
1.30 # Add namespace details to any structure involved.
1.31
1.32 if hasattr(node, "structure") and node.structure is not None:
1.33 @@ -113,6 +124,7 @@
1.34 return global_
1.35
1.36 def visitLoadName(self, loadname):
1.37 + print "Name", loadname.name, "in", self.namespace
1.38 scope = self.namespace.find_for_load(loadname.name)
1.39 if scope == "structure":
1.40 result = self.dispatch(LoadAttr(expr=LoadRef(ref=self.namespace.structure), name=loadname.name))
1.41 @@ -177,4 +189,7 @@
1.42 else:
1.43 return self.names[name]
1.44
1.45 + def __repr__(self):
1.46 + return repr(self.names)
1.47 +
1.48 # vim: tabstop=4 expandtab shiftwidth=4