# HG changeset patch # User paulb@localhost.localdomain # Date 1186354432 -7200 # Node ID ec716eb53281859dd4cd182a719fac903aafe3e8 # Parent 90a475a21cc75fd28e6001e7cf92598b461016b2 Added a consumed_args attribute to InvokeFunction in order to help with the construction of invocations in generated code. diff -r 90a475a21cc7 -r ec716eb53281 simplify/annotate.py --- a/simplify/annotate.py Sun Aug 05 21:38:40 2007 +0200 +++ b/simplify/annotate.py Mon Aug 06 00:53:52 2007 +0200 @@ -1135,18 +1135,21 @@ params = subprogram.params items = [] star_args = [] + consumed_args = [] # Match each positional argument, taking excess arguments as star args. for arg in pos_args: if params: param, default = params[0] - if arg is None: - arg = default if hasattr(arg, "types"): items.append((param, arg.types)) else: items.append((param, set())) # Annotation has not succeeded. + + # Record consumption order. + + consumed_args.append(arg) params = params[1:] else: star_args.append(arg) @@ -1167,6 +1170,10 @@ items.append((param, arg.types)) else: items.append((param, set())) # Annotation has not succeeded. + + # Record consumption order (this is not the Keyword node, however). + + consumed_args.append(arg) params = params[1:] dstar_args = kw_args.items() @@ -1221,6 +1228,7 @@ # Record the parameter types. self.annotate_parameters(subprogram, items) + invocation.consumed_args[subprogram] = consumed_args return subprogram.paramtypes.items() def make_star_args(self, invocation, subprogram, star_args): diff -r 90a475a21cc7 -r ec716eb53281 simplify/fixinstances.py --- a/simplify/fixinstances.py Sun Aug 05 21:38:40 2007 +0200 +++ b/simplify/fixinstances.py Mon Aug 06 00:53:52 2007 +0200 @@ -164,6 +164,15 @@ for name in ("accesses", "writes", "paramtypes"): if hasattr(node, name): self._replace_dict(node, name) + for name in ("consumed_args",): + if hasattr(node, name): + new_d = {} + for subprogram, args in getattr(node, name).items(): + for arg in args: + if isinstance(arg, Self): + self.dispatch(arg) + new_d[self._get_replacement(subprogram)] = args + setattr(node, name, new_d) # Visit program nodes. @@ -212,7 +221,7 @@ else: new_items = set() - for item in list(items): + for item in items: if name == "accesses": attr, accessor = item value = attr.type diff -r 90a475a21cc7 -r ec716eb53281 simplify/simplified/program.py --- a/simplify/simplified/program.py Sun Aug 05 21:38:40 2007 +0200 +++ b/simplify/simplified/program.py Mon Aug 06 00:53:52 2007 +0200 @@ -401,6 +401,7 @@ Invoke.__init__(self, original, defining, expr=expr, args=(args or []), star=star, dstar=dstar, **kw) self.set_args(self.args) self.share_locals = 0 + self.consumed_args = {} self.raises = set() def set_args(self, args):