Simplify the arguments() return type.

Now that variable arguments are always stored in a value list with the
fixed arguments, we no longer need the arcane [&[Value]; 2] return type.

Arguments are always stored contiguously, so just return a &[Value]
slice.

Also remove the each_arg() methods which were just trying to make it
easier to work with the old slice pair.
This commit is contained in:
Jakob Stoklund Olesen
2017-03-09 22:04:13 -08:00
parent 703762a67c
commit f451cf42c8
5 changed files with 9 additions and 34 deletions

View File

@@ -67,7 +67,7 @@ def gen_arguments_method(fmt, is_mut):
with fmt.indented(
'pub fn {f}<\'a>(&\'a {m}self, pool: &\'a {m}ValueListPool) -> '
'[&{m}[Value]; 2] {{'
'&{m}[Value] {{'
.format(f=method, m=mut), '}'):
with fmt.indented('match *self {', '}'):
for f in InstructionFormat.all_formats:
@@ -79,9 +79,8 @@ def gen_arguments_method(fmt, is_mut):
if f.has_value_list:
arg = ''.format(mut)
fmt.line(
'{} {{ ref {}args, .. }} => '
'[ &{}[], args.{}(pool) ],'
.format(n, mut, mut, as_slice))
'{} {{ ref {}args, .. }} => args.{}(pool),'
.format(n, mut, as_slice))
continue
# Fixed args.
@@ -103,8 +102,8 @@ def gen_arguments_method(fmt, is_mut):
capture = 'ref {}args, '.format(mut)
arg = 'args'
fmt.line(
'{} {{ {} .. }} => [{}, &{}[]],'
.format(n, capture, arg, mut))
'{} {{ {} .. }} => {},'
.format(n, capture, arg))
def gen_instruction_data_impl(fmt):