# HG changeset patch # User paulb@localhost.localdomain # Date 1185666805 -7200 # Node ID 410f07366c9b6162a606e817d57704820e98f5d6 # Parent 41d635a383c7129b2a878e85f501ebbaea76db7c Removed redundant attributes and methods. Reordered code processing when fixing instances - this can help module-level code arrive at the correct usage of instances. diff -r 41d635a383c7 -r 410f07366c9b simplify/fixinstances.py --- a/simplify/fixinstances.py Sun Jul 29 01:51:44 2007 +0200 +++ b/simplify/fixinstances.py Sun Jul 29 01:53:25 2007 +0200 @@ -72,13 +72,11 @@ # recursion issues) and a list of current namespaces (used to recall # namespaces upon invoking internal subprograms). - self.subprograms = set() self.current_subprograms = [] self.module = module - self.process_node(module) - # Then, process all functions and methods. + # Process all functions and methods. for subprogram in self.module.simplifier.subprograms: @@ -87,7 +85,16 @@ if not getattr(subprogram, "internal", 0): for specialised in subprogram.active(): - self.subprograms.add(self.process_node(specialised)) + self.process_node(specialised) + + self.process_node(module) + + # Fix the simplifier's subprograms list itself. + + #subprograms = set() + #for subprogram in self.module.simplifier.subprograms: + # subprograms.add(self._get_replacement(subprogram)) + #self.module.simplifier.subprograms = subprograms def process_structures(self, module): @@ -231,9 +238,6 @@ else: return value - def dispatch(self, node, *args): - return Visitor.dispatch(self, node, *args) - def visitInvokeFunction(self, invoke): "Transform the 'invoke' node, performing processing on subprograms." @@ -247,10 +251,7 @@ # The special case of internal subprogram invocation is addressed by # propagating namespace information to the subprogram and processing it. - subprogram = self.process_node(invoke.ref) - - if subprogram is not None: - self.subprograms.add(subprogram) + self.process_node(invoke.ref) return invoke # Convenience functions. diff -r 41d635a383c7 -r 410f07366c9b simplify/fixnames.py --- a/simplify/fixnames.py Sun Jul 29 01:51:44 2007 +0200 +++ b/simplify/fixnames.py Sun Jul 29 01:53:25 2007 +0200 @@ -240,9 +240,6 @@ setattr(node, attr, self.dispatches(value)) return node - def dispatch(self, node, *args): - return Visitor.dispatch(self, node, *args) - def visitGlobal(self, global_): for name in global_.names: self.namespace.make_global(name) diff -r 41d635a383c7 -r 410f07366c9b simplify/simplified/program.py --- a/simplify/simplified/program.py Sun Jul 29 01:51:44 2007 +0200 +++ b/simplify/simplified/program.py Sun Jul 29 01:53:25 2007 +0200 @@ -422,4 +422,15 @@ self.return_locals = set() self.namespace = Namespace() # NOTE: Temporary. + # NOTE: Logic similar to that below is used in simplify.fixinstances to + # NOTE: identify equivalent attributes which are subprograms. + + """ + def __eq__(self, other): + return self is other or \ + not getattr(self, "internal", 0) and not getattr(other, "internal", 0) and \ + getattr(self, "copy_of", self) is getattr(other, "copy_of", other) and \ + getattr(self, "paramtypes", None) == getattr(other, "paramtypes", None) + """ + # vim: tabstop=4 expandtab shiftwidth=4