1.1 --- a/simplified.py Sun Nov 26 15:45:53 2006 +0100
1.2 +++ b/simplified.py Sun Nov 26 21:28:11 2006 +0100
1.3 @@ -233,17 +233,6 @@
1.4 if getattr(self, "structure", 0):
1.5 self._pprint(indent + 2, "( ", "structure '%s'" % self.structure.name, stream=stream)
1.6
1.7 - # Statement-related details.
1.8 -
1.9 - if hasattr(self, "test"):
1.10 - self.test.pprint(indent + 2, "? ", stream=stream)
1.11 - for attr in "code", "body", "else_", "handler", "finally_", "choices":
1.12 - if hasattr(self, attr) and getattr(self, attr):
1.13 - self._pprint(indent, "", "%s {" % attr, stream=stream)
1.14 - for node in getattr(self, attr):
1.15 - node.pprint(indent + 2, stream=stream)
1.16 - self._pprint(indent, "", "}", stream=stream)
1.17 -
1.18 # Expression-related details.
1.19
1.20 if hasattr(self, "expr"):
1.21 @@ -265,6 +254,17 @@
1.22 if hasattr(self, "dstar") and self.dstar:
1.23 self.dstar.pprint(indent + 2, "( ", stream=stream)
1.24
1.25 + # Statement-related details.
1.26 +
1.27 + if hasattr(self, "test"):
1.28 + self.test.pprint(indent + 2, "? ", stream=stream)
1.29 + for attr in "code", "body", "else_", "handler", "finally_", "choices":
1.30 + if hasattr(self, attr) and getattr(self, attr):
1.31 + self._pprint(indent, "", "%s {" % attr, stream=stream)
1.32 + for node in getattr(self, attr):
1.33 + node.pprint(indent + 2, stream=stream)
1.34 + self._pprint(indent, "", "}", stream=stream)
1.35 +
1.36 # Annotations.
1.37
1.38 if hasattr(self, "accesses"):
1.39 @@ -291,16 +291,27 @@
1.40 class LoadAttr(Node): "Load an object attribute."
1.41 class LoadRef(Node): "Load a reference, typically a subprogram or a constant."
1.42 class LoadExc(Node): "Load a handled exception."
1.43 +class CheckExc(Node): "Check a handled exception."
1.44 class StoreTemp(Node): "Store a temporary value."
1.45 class StoreName(Node): "Associate a name with an object."
1.46 class StoreAttr(Node): "Associate an object's attribute with a value."
1.47 class ReleaseTemp(Node): "Release a temporary value."
1.48 -class Conditional(Node): "A conditional node consisting of a test and outcomes."
1.49 class Try(Node): "A try...except...else...finally grouping node."
1.50 class Raise(Node): "An exception raising node."
1.51 class Not(Node): "A negation of an expression."
1.52 class Invoke(Node): "An invocation."
1.53
1.54 +# Some behaviour is set as the default in conditional nodes but may be
1.55 +# overridden.
1.56 +
1.57 +class Conditional(Node):
1.58 +
1.59 + "A conditional node consisting of a test and outcomes."
1.60 +
1.61 + def __init__(self, *args, **kw):
1.62 + self.isolate_test = 0
1.63 + Node.__init__(self, *args, **kw)
1.64 +
1.65 # Invocations involve some more work to process calculated attributes.
1.66
1.67 class InvokeFunction(Invoke):
1.68 @@ -392,7 +403,10 @@
1.69 def full_name(self):
1.70 # NOTE: Wrap the result in a call to name(self, ...) where multiple
1.71 # NOTE: instances per class can occur.
1.72 - return self.namespace.load("__class__")[0].type._full_name
1.73 + return self.get_class()._full_name
1.74 +
1.75 + def get_class(self):
1.76 + return self.namespace.load("__class__")[0].type
1.77
1.78 def __repr__(self):
1.79 return "Instance of type '%s'" % self.full_name()