1.1 --- a/simplified.py Sat Sep 30 18:54:06 2006 +0200
1.2 +++ b/simplified.py Tue Oct 03 00:50:03 2006 +0200
1.3 @@ -94,15 +94,15 @@
1.4
1.5 def __repr__(self):
1.6 if hasattr(self, "name"):
1.7 - return "%s '%s' (at %x)" % (self.__class__, self.name, id(self))
1.8 + return "%s '%s' (at %x)" % (self.__class__.__name__, self.name, id(self))
1.9 if hasattr(self, "index"):
1.10 - return "%s (%s) (at %x)" % (self.__class__, self.index, id(self))
1.11 + return "%s (%s)" % (self.__class__.__name__, self.index)
1.12 elif hasattr(self, "value"):
1.13 - return "%s %s (at %x)" % (self.__class__, repr(self.value), id(self))
1.14 + return "%s %s" % (self.__class__.__name__, repr(self.value))
1.15 elif hasattr(self, "ref"):
1.16 - return "%s '%x' (at %x)" % (self.__class__, id(self.ref), id(self))
1.17 + return "%s '%x' (at %x)" % (self.__class__.__name__, id(self.ref), id(self))
1.18 else:
1.19 - return "%s (at %x)" % (self.__class__, id(self))
1.20 + return "%s" % (self.__class__.__name__,)
1.21
1.22 def _pprint(self, indent, continuation, s):
1.23 if continuation:
1.24 @@ -135,7 +135,7 @@
1.25 self.test.pprint(indent + 2, "? ")
1.26 for attr in "code", "body", "else_", "handler", "finally_", "choices":
1.27 if hasattr(self, attr) and getattr(self, attr):
1.28 - self._pprint(indent, "", "{ (%s)" % attr)
1.29 + self._pprint(indent, "", "%s {" % attr)
1.30 for node in getattr(self, attr):
1.31 node.pprint(indent + 2)
1.32 self._pprint(indent, "", "}")
1.33 @@ -148,7 +148,7 @@
1.34 for node in self.nodes:
1.35 node.pprint(indent + 2, "- ")
1.36 if hasattr(self, "lvalue"):
1.37 - self.lvalue.pprint(indent + 2, "= ")
1.38 + self.lvalue.pprint(indent + 2, "->")
1.39 if hasattr(self, "nstype"):
1.40 self._pprint(indent + 2, "", self.nstype)
1.41 if hasattr(self, "args"):
1.42 @@ -164,13 +164,22 @@
1.43 if hasattr(self, "accesses"):
1.44 self._pprint(indent, "", "--------")
1.45 for ref, attributes in self.accesses.items():
1.46 - self._pprint(indent + 2, "| ", "%s: %s" % (ref, attributes))
1.47 + self._pprint(indent + 2, "| ", "when %s: %s" % (ref, ", ".join([("%s via %s" % attr_acc) for attr_acc in attributes])))
1.48 + self._pprint(indent, "", "--------")
1.49 + if hasattr(self, "writes"):
1.50 + self._pprint(indent, "", "--------")
1.51 + for ref, attribute in self.writes.items():
1.52 + self._pprint(indent + 2, "| ", "when %s: %s" % (ref, attribute))
1.53 self._pprint(indent, "", "--------")
1.54
1.55 class Module(Node): "A Python module."
1.56 class Subprogram(Node): "A subprogram: functions, methods and loops."
1.57 class Pass(Node): "A placeholder node corresponding to pass."
1.58 -class Invoke(Node): "A function, method or loop invocation."
1.59 +
1.60 +class Invoke(Node): "An invocation."
1.61 +class InvokeFunction(Invoke): "A function or method invocation."
1.62 +class InvokeBlock(Invoke): "A block or loop invocation."
1.63 +
1.64 class Return(Node): "Return an evaluated expression."
1.65 class Assign(Node): "A grouping node for assignment-related operations."
1.66 class Keyword(Node): "A grouping node for keyword arguments."
1.67 @@ -203,9 +212,9 @@
1.68
1.69 def __repr__(self):
1.70 if hasattr(self, "name"):
1.71 - return "%s '%s' (at %x)" % (self.__class__, self.name, id(self))
1.72 + return "%s '%s' (at %x)" % (self.__class__.__name__, self.name, id(self))
1.73 else:
1.74 - return "%s (at %x)" % (self.__class__, id(self))
1.75 + return "%s (at %x)" % (self.__class__.__name__, id(self))
1.76
1.77 class Class(Structure):
1.78