1.1 --- a/simplified.py Thu Feb 15 20:32:37 2007 +0100
1.2 +++ b/simplified.py Fri Feb 16 00:13:09 2007 +0100
1.3 @@ -165,6 +165,7 @@
1.4
1.5 self.original = original
1.6 self.defining = defining
1.7 + self.copies = []
1.8
1.9 if self.original is not None and defining:
1.10 self.original._node = self
1.11 @@ -282,6 +283,14 @@
1.12 self._pprint(indent + 2, "| ", "when %s: %s" % (ref, attribute), stream=stream)
1.13 self._pprint(indent, "", "--------", stream=stream)
1.14
1.15 + # Node discovery functions.
1.16 +
1.17 + def active(self):
1.18 +
1.19 + "Return the active copies of this node or a list containing this node."
1.20 +
1.21 + return self.copies or [self]
1.22 +
1.23 # Node manipulation functions.
1.24
1.25 def copy(self, new_name=None):
1.26 @@ -307,12 +316,9 @@
1.27 node = self.__class__(**common)
1.28 node.defining = self.defining
1.29
1.30 - # Add links to copied nodes from original AST nodes.
1.31 + # Add links to copies from originals.
1.32
1.33 - if node.original is not None and node.defining:
1.34 - if not hasattr(node.original, "_nodes"):
1.35 - node.original._nodes = []
1.36 - node.original._nodes.append(node)
1.37 + self.copies.append(node)
1.38
1.39 # Copy attributes of different types.
1.40