some param fixes

This commit is contained in:
David Halter
2013-02-08 23:16:04 +01:00
parent 2fef25b1b1
commit 07f4c08069

View File

@@ -495,16 +495,20 @@ class Execution(Executable):
""" """
Create a param with the original scope (of varargs) as parent. Create a param with the original scope (of varargs) as parent.
""" """
parent_stmt = self.var_args.parent_stmt if isinstance(self.var_args, pr.Array):
pos = parent_stmt.start_pos if parent_stmt else None parent = self.var_args.parent
calls = pr.Array(pos, pr.Array.NOARRAY, parent_stmt) start_pos = self.var_args.start_pos
else:
parent = self.base
start_pos = None
calls = pr.Array(start_pos, pr.Array.NOARRAY, parent)
calls.values = values calls.values = values
calls.keys = keys calls.keys = keys
calls.type = array_type calls.type = array_type
new_param = copy.copy(param) new_param = copy.copy(param)
if parent_stmt is not None: if parent is not None:
new_param.parent = parent_stmt new_param.parent = parent
new_param._assignment_calls = calls new_param._commands = calls
new_param.is_generated = True new_param.is_generated = True
name = copy.copy(param.get_name()) name = copy.copy(param.get_name())
name.parent = new_param name.parent = new_param
@@ -548,12 +552,11 @@ class Execution(Executable):
values=[value])) values=[value]))
key, value = next(var_arg_iterator, (None, None)) key, value = next(var_arg_iterator, (None, None))
commands = param.get_commands().values commands = param.get_commands()
assignment = commands[0]
keys = [] keys = []
values = [] values = []
array_type = None array_type = None
if assignment[0] == '*': if commands[0] == '*':
# *args param # *args param
array_type = pr.Array.TUPLE array_type = pr.Array.TUPLE
if value: if value:
@@ -564,7 +567,7 @@ class Execution(Executable):
var_arg_iterator.push_back((key, value)) var_arg_iterator.push_back((key, value))
break break
values.append(value) values.append(value)
elif assignment[0] == '**': elif commands[0] == '**':
# **kwargs param # **kwargs param
array_type = pr.Array.DICT array_type = pr.Array.DICT
if non_matching_keys: if non_matching_keys:
@@ -585,7 +588,7 @@ class Execution(Executable):
# Just ignore all the params that are without a key, after one # Just ignore all the params that are without a key, after one
# keyword argument was set. # keyword argument was set.
if not keys_only or assignment[0] == '**': if not keys_only or commands[0] == '**':
keys_used.add(str(key)) keys_used.add(str(key))
result.append(gen_param_name_copy(param, keys=keys, result.append(gen_param_name_copy(param, keys=keys,
values=values, array_type=array_type)) values=values, array_type=array_type))