1.1 --- a/simplify/simplified/program.py Sun Jul 29 20:33:09 2007 +0200
1.2 +++ b/simplify/simplified/program.py Sun Jul 29 23:29:19 2007 +0200
1.3 @@ -326,7 +326,6 @@
1.4 class StoreAttr(Node): "Associate an object's attribute with a value."
1.5 class ReleaseTemp(Node): "Release a temporary value."
1.6 class Try(Node): "A try...except...else...finally grouping node."
1.7 -class Raise(Node): "An exception raising node."
1.8 class Not(Node): "A negation of an expression."
1.9 class CheckType(Node): "Check a value's type from a list of choices."
1.10 class Return(Node): "Return an evaluated expression."
1.11 @@ -362,6 +361,25 @@
1.12
1.13 # Invocations involve some more work to process calculated attributes.
1.14
1.15 +class Raise(Invoke):
1.16 +
1.17 + "An exception raising node which may behave like an invocation."
1.18 +
1.19 + def __init__(self, original=None, defining=0, expr=None, traceback=None, **kw):
1.20 +
1.21 + """
1.22 + Initialise the invocation with the following optional parameters:
1.23 +
1.24 + * The 'original' AST node represented by this invocation.
1.25 + * Whether this invocation is 'defining' (false by default).
1.26 + * The 'expr' or expression indicating the invoked subprogram.
1.27 + * The 'traceback' associated with the raised exception.
1.28 + """
1.29 +
1.30 + Invoke.__init__(self, original, defining, expr=expr, traceback=traceback, **kw)
1.31 + self.share_locals = 0
1.32 + self.raises = set()
1.33 +
1.34 class InvokeFunction(Invoke):
1.35
1.36 "A function or method invocation."
1.37 @@ -383,6 +401,7 @@
1.38 Invoke.__init__(self, original, defining, expr=expr, args=(args or []), star=star, dstar=dstar, **kw)
1.39 self.set_args(self.args)
1.40 self.share_locals = 0
1.41 + self.raises = set()
1.42
1.43 def set_args(self, args):
1.44
1.45 @@ -422,6 +441,7 @@
1.46 """
1.47
1.48 Invoke.__init__(self, original, defining, ref=ref, produces_result=produces_result, share_locals=share_locals, **kw)
1.49 + self.raises = set()
1.50
1.51 # Program structure nodes.
1.52
1.53 @@ -429,6 +449,10 @@
1.54
1.55 "A Python module."
1.56
1.57 + def __init__(self, *args, **kw):
1.58 + Node.__init__(self, *args, **kw)
1.59 + self.structure = None
1.60 +
1.61 def full_name(self):
1.62 return "module %s" % self.name
1.63
1.64 @@ -437,7 +461,7 @@
1.65 "A subprogram: functions, methods and loops."
1.66
1.67 def __init__(self, original=None, defining=0, name=None, module=None, structure=None,
1.68 - structures=None, internal=0, returns_value=1, params=None, star=None,
1.69 + structures=None, internal=0, returns_value=1, is_method=0, params=None, star=None,
1.70 dstar=None, **kw):
1.71
1.72 """
1.73 @@ -454,6 +478,8 @@
1.74 represented.
1.75 * Whether a value is returned, as specified by 'returns_value' (true
1.76 by default).
1.77 + * Whether the subprogram is a method, as specified by 'is_method'
1.78 + (false by default).
1.79 * The 'params' (a parameter list which is empty by default).
1.80 * The 'star' parameter which collects excess positional arguments.
1.81 * The 'dstar' parameter which collects unmatched keyword arguments.
1.82 @@ -461,12 +487,13 @@
1.83
1.84 Node.__init__(self, original, defining, name=name, module=module, structure=structure,
1.85 structures=structures, internal=internal, returns_value=returns_value,
1.86 - params=(params or []), star=star, dstar=dstar, **kw)
1.87 + is_method=is_method, params=(params or []), star=star, dstar=dstar, **kw)
1.88
1.89 WithName.__init__(self)
1.90 self.raises = set()
1.91 self.returns = set()
1.92 self.return_locals = set()
1.93 + self.paramtypes = {}
1.94 self.namespace = Namespace() # NOTE: Temporary.
1.95
1.96 # vim: tabstop=4 expandtab shiftwidth=4