1.1 --- a/simplified.py Thu Jan 25 01:03:33 2007 +0100
1.2 +++ b/simplified.py Fri Jan 26 00:05:20 2007 +0100
1.3 @@ -151,7 +151,7 @@
1.4 choices Any choices which may be included in the final program.
1.5 """
1.6
1.7 - common_attributes = "name", "index", "value", "nstype", "internal", "returns_value", "is_method", "ref", "module", "structures", "original_def"
1.8 + common_attributes = "name", "index", "value", "nstype", "internal", "returns_value", "is_method", "ref", "module", "structures", "original"
1.9 expression_attributes = "expr", "lvalue", "test", "star", "dstar"
1.10 invocation_attributes = "params", # not "args" - see "pos_args", "kw_args"
1.11 grouping_attributes = "code", "body", "else_", "handler", "finally_", "choices"
1.12 @@ -285,20 +285,13 @@
1.13
1.14 # Node manipulation functions.
1.15
1.16 - def copy(self, new_name=None, original_def=None):
1.17 + def copy(self, new_name=None):
1.18
1.19 """
1.20 Perform a deep copy of the node, optionally specifying a 'new_name',
1.21 returning a new unannotated copy.
1.22 -
1.23 - The 'original_def' parameter is used to assign a particular AST node to
1.24 - copied regions of the simplified node tree.
1.25 """
1.26
1.27 - # Obtain an AST node to be assigned to the copied nodes.
1.28 -
1.29 - original_def = getattr(self, "original", None) or original_def or getattr(self, "original_def", None)
1.30 -
1.31 # Copy the common attributes of this node.
1.32
1.33 common = {}
1.34 @@ -309,13 +302,9 @@
1.35 if new_name is not None:
1.36 common["name"] = new_name
1.37
1.38 - if original_def is not None:
1.39 - common["original_def"] = original_def
1.40 -
1.41 # Instantiate the copy, avoiding side-effects with original and defining.
1.42
1.43 node = self.__class__(**common)
1.44 - node.original = self.original
1.45 node.defining = self.defining
1.46
1.47 # Add links to copied nodes from original AST nodes.
1.48 @@ -333,7 +322,7 @@
1.49 if n is None:
1.50 n2 = n
1.51 else:
1.52 - n2 = n.copy(original_def=original_def)
1.53 + n2 = n.copy()
1.54 setattr(node, attr, n2)
1.55
1.56 for attr in self.invocation_attributes:
1.57 @@ -344,23 +333,23 @@
1.58 if n is None:
1.59 l2.append((name, n))
1.60 else:
1.61 - l2.append((name, n.copy(original_def=original_def)))
1.62 + l2.append((name, n.copy()))
1.63 setattr(node, attr, l2)
1.64
1.65 for attr in self.grouping_attributes:
1.66 if hasattr(self, attr):
1.67 l = getattr(self, attr)
1.68 - setattr(node, attr, [n.copy(original_def=original_def) for n in l])
1.69 + setattr(node, attr, [n.copy() for n in l])
1.70
1.71 # Arguments are usually processed further - "args" is useless.
1.72
1.73 if hasattr(self, "pos_args"):
1.74 - node.pos_args = [n.copy(original_def=original_def) for n in self.pos_args]
1.75 + node.pos_args = [n.copy() for n in self.pos_args]
1.76
1.77 if hasattr(self, "kw_args"):
1.78 node.kw_args = {}
1.79 for name, n in self.kw_args.items():
1.80 - node.kw_args[name] = n.copy(original_def=original_def)
1.81 + node.kw_args[name] = n.copy()
1.82
1.83 return node
1.84
1.85 @@ -549,7 +538,7 @@
1.86 self.attributes_for_instances = {}
1.87
1.88 def _get_key(self, node):
1.89 - return getattr(node, "original_def", None) or getattr(node, "original", None) # self.module.original
1.90 + return id(getattr(node, "original", None)) # self.module.original
1.91
1.92 def has_instance(self, node):
1.93 return self.instances.has_key(self._get_key(node))