# HG changeset patch # User Paul Boddie # Date 1477336617 -7200 # Node ID 16b19e447eadc3c05a40393ac7101d5377ba8157 # Parent b881a39ca2fd634a7845f3ae433af31d8e5a5f46 Account for the context position in parameter lists and table entries. diff -r b881a39ca2fd -r 16b19e447ead optimiser.py --- a/optimiser.py Sun Oct 23 14:56:33 2016 +0200 +++ b/optimiser.py Mon Oct 24 21:16:57 2016 +0200 @@ -567,20 +567,33 @@ param_locations = self.param_locations = {} for i, argnames in enumerate(self.arg_locations): + + # Position the arguments after the first context argument. + for argname in argnames: - param_locations[argname] = i + param_locations[argname] = i + 1 for name, argnames in self.importer.function_parameters.items(): - l = self.parameters[name] = [None] * len(argnames) + + # Allocate an extra context parameter in the table. + + l = self.parameters[name] = [None] + [None] * len(argnames) # Store an entry for the name along with the name's position in the # parameter list. for pos, argname in enumerate(argnames): + + # Position the argument in the table. + position = param_locations[argname] if position >= len(l): l.extend([None] * (position - len(l) + 1)) - l[position] = (argname, pos) + + # Indicate an argument list position starting from 1 (after the + # initial context argument). + + l[position] = (argname, pos + 1) def populate_tables(self):