1.1 --- a/simplify/simplified/program.py Sun Jul 29 01:53:25 2007 +0200
1.2 +++ b/simplify/simplified/program.py Sun Jul 29 20:33:09 2007 +0200
1.3 @@ -366,11 +366,21 @@
1.4
1.5 "A function or method invocation."
1.6
1.7 - def __init__(self, *args, **kw):
1.8 - self.args = []
1.9 - self.star = None
1.10 - self.dstar = None
1.11 - Invoke.__init__(self, *args, **kw)
1.12 + def __init__(self, original=None, defining=0, expr=None, args=None, star=None, dstar=None, **kw):
1.13 +
1.14 + """
1.15 + Initialise the invocation with the following optional parameters:
1.16 +
1.17 + * The 'original' AST node represented by this invocation.
1.18 + * Whether this invocation is 'defining' (false by default).
1.19 + * The 'expr' or expression indicating the invoked subprogram.
1.20 + * The 'args' or arguments to be supplied, yielding the 'pos_args' and
1.21 + 'kw_args' attributes on this object.
1.22 + * The 'star' argument containing additional unlabelled arguments.
1.23 + * The 'dstar' argument containing keyword arguments.
1.24 + """
1.25 +
1.26 + Invoke.__init__(self, original, defining, expr=expr, args=(args or []), star=star, dstar=dstar, **kw)
1.27 self.set_args(self.args)
1.28 self.share_locals = 0
1.29
1.30 @@ -397,9 +407,21 @@
1.31
1.32 "A block or loop invocation."
1.33
1.34 - def __init__(self, *args, **kw):
1.35 - self.share_locals = 1
1.36 - Invoke.__init__(self, *args, **kw)
1.37 + def __init__(self, original=None, defining=0, ref=None, produces_result=1, share_locals=1, **kw):
1.38 +
1.39 + """
1.40 + Initialise the invocation with the following optional parameters:
1.41 +
1.42 + * The 'original' AST node represented by this invocation.
1.43 + * Whether this invocation is 'defining' (false by default).
1.44 + * The 'ref' indicating the subprogram to be invoked.
1.45 + * Whether a result is produced as indicated by 'produces_result' (true
1.46 + by default).
1.47 + * Whether the subprogram shares the locals of the caller as indicated
1.48 + by 'share_locals' (true by default).
1.49 + """
1.50 +
1.51 + Invoke.__init__(self, original, defining, ref=ref, produces_result=produces_result, share_locals=share_locals, **kw)
1.52
1.53 # Program structure nodes.
1.54
1.55 @@ -414,23 +436,37 @@
1.56
1.57 "A subprogram: functions, methods and loops."
1.58
1.59 - def __init__(self, *args, **kw):
1.60 - Node.__init__(self, *args, **kw)
1.61 + def __init__(self, original=None, defining=0, name=None, module=None, structure=None,
1.62 + structures=None, internal=0, returns_value=1, params=None, star=None,
1.63 + dstar=None, **kw):
1.64 +
1.65 + """
1.66 + Initialise the subprogram with the following optional parameters:
1.67 +
1.68 + * The 'original' AST node represented by this subprogram.
1.69 + * Whether this subprogram is 'defining' or not (false by default).
1.70 + * The 'name' of this subprogram which may be None.
1.71 + * The 'module' in which this subprogram is found.
1.72 + * The 'structure' initialised by this subprogram.
1.73 + * The 'structures' within which this subprogram resides.
1.74 + * The 'internal' status of this subprogram (false by default), which
1.75 + if true typically means that a loop or operation is being
1.76 + represented.
1.77 + * Whether a value is returned, as specified by 'returns_value' (true
1.78 + 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 + """
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 +
1.88 WithName.__init__(self)
1.89 self.raises = set()
1.90 self.returns = set()
1.91 self.return_locals = set()
1.92 self.namespace = Namespace() # NOTE: Temporary.
1.93
1.94 - # NOTE: Logic similar to that below is used in simplify.fixinstances to
1.95 - # NOTE: identify equivalent attributes which are subprograms.
1.96 -
1.97 - """
1.98 - def __eq__(self, other):
1.99 - return self is other or \
1.100 - not getattr(self, "internal", 0) and not getattr(other, "internal", 0) and \
1.101 - getattr(self, "copy_of", self) is getattr(other, "copy_of", other) and \
1.102 - getattr(self, "paramtypes", None) == getattr(other, "paramtypes", None)
1.103 - """
1.104 -
1.105 # vim: tabstop=4 expandtab shiftwidth=4