# HG changeset patch # User paulb@localhost.localdomain # Date 1182556466 -7200 # Node ID 016ca6f457d52247791fb091758933358bda01c7 # Parent cdb79a7c1abb9b47213feb2d012e7a847c307cd7 Made current_subprograms a set. Added some commentary. diff -r cdb79a7c1abb -r 016ca6f457d5 simplify/annotate.py --- a/simplify/annotate.py Sat Jun 23 01:53:53 2007 +0200 +++ b/simplify/annotate.py Sat Jun 23 01:54:26 2007 +0200 @@ -159,7 +159,7 @@ """ self.subprograms = [] - self.current_subprograms = [] + self.current_subprograms = set() self.current_namespaces = [] self.rerun_subprograms = {} self.namespace = None @@ -196,7 +196,7 @@ # Record the current subprogram and namespace. - self.current_subprograms.append(node) + self.current_subprograms.add(node) # Determine the namespace. @@ -225,6 +225,10 @@ self.dispatch(node) self.extract_results(node) + # We may need to "re-run" subprograms because they were called + # recursively with potentially different arguments. These argument types + # are now tried out here. + while self.rerun_subprograms.has_key(node): all_rerun_locals = self.rerun_subprograms[node] del self.rerun_subprograms[node] @@ -241,7 +245,7 @@ # Restore the previous subprogram and namespace. self.namespace = self.current_namespaces.pop() - self.current_subprograms.pop() + self.current_subprograms.remove(node) self.reset_module_namespace(using_module_namespace) def set_module_namespace(self, using_module_namespace):