1.1 --- a/simplify/annotate.py Sun Aug 05 21:38:40 2007 +0200
1.2 +++ b/simplify/annotate.py Mon Aug 06 00:53:52 2007 +0200
1.3 @@ -1135,18 +1135,21 @@
1.4 params = subprogram.params
1.5 items = []
1.6 star_args = []
1.7 + consumed_args = []
1.8
1.9 # Match each positional argument, taking excess arguments as star args.
1.10
1.11 for arg in pos_args:
1.12 if params:
1.13 param, default = params[0]
1.14 - if arg is None:
1.15 - arg = default
1.16 if hasattr(arg, "types"):
1.17 items.append((param, arg.types))
1.18 else:
1.19 items.append((param, set())) # Annotation has not succeeded.
1.20 +
1.21 + # Record consumption order.
1.22 +
1.23 + consumed_args.append(arg)
1.24 params = params[1:]
1.25 else:
1.26 star_args.append(arg)
1.27 @@ -1167,6 +1170,10 @@
1.28 items.append((param, arg.types))
1.29 else:
1.30 items.append((param, set())) # Annotation has not succeeded.
1.31 +
1.32 + # Record consumption order (this is not the Keyword node, however).
1.33 +
1.34 + consumed_args.append(arg)
1.35 params = params[1:]
1.36
1.37 dstar_args = kw_args.items()
1.38 @@ -1221,6 +1228,7 @@
1.39 # Record the parameter types.
1.40
1.41 self.annotate_parameters(subprogram, items)
1.42 + invocation.consumed_args[subprogram] = consumed_args
1.43 return subprogram.paramtypes.items()
1.44
1.45 def make_star_args(self, invocation, subprogram, star_args):
2.1 --- a/simplify/fixinstances.py Sun Aug 05 21:38:40 2007 +0200
2.2 +++ b/simplify/fixinstances.py Mon Aug 06 00:53:52 2007 +0200
2.3 @@ -164,6 +164,15 @@
2.4 for name in ("accesses", "writes", "paramtypes"):
2.5 if hasattr(node, name):
2.6 self._replace_dict(node, name)
2.7 + for name in ("consumed_args",):
2.8 + if hasattr(node, name):
2.9 + new_d = {}
2.10 + for subprogram, args in getattr(node, name).items():
2.11 + for arg in args:
2.12 + if isinstance(arg, Self):
2.13 + self.dispatch(arg)
2.14 + new_d[self._get_replacement(subprogram)] = args
2.15 + setattr(node, name, new_d)
2.16
2.17 # Visit program nodes.
2.18
2.19 @@ -212,7 +221,7 @@
2.20 else:
2.21 new_items = set()
2.22
2.23 - for item in list(items):
2.24 + for item in items:
2.25 if name == "accesses":
2.26 attr, accessor = item
2.27 value = attr.type
3.1 --- a/simplify/simplified/program.py Sun Aug 05 21:38:40 2007 +0200
3.2 +++ b/simplify/simplified/program.py Mon Aug 06 00:53:52 2007 +0200
3.3 @@ -401,6 +401,7 @@
3.4 Invoke.__init__(self, original, defining, expr=expr, args=(args or []), star=star, dstar=dstar, **kw)
3.5 self.set_args(self.args)
3.6 self.share_locals = 0
3.7 + self.consumed_args = {}
3.8 self.raises = set()
3.9
3.10 def set_args(self, args):