diff options
author | Björn Gustavsson <[email protected]> | 2017-05-18 12:24:07 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2017-05-18 12:47:53 +0200 |
commit | 29aea1a92e25ee47e55b4a3c48edfc62e8aa4a42 (patch) | |
tree | c46f3662a8fe52c3ab0a3202de5b4985a698ad22 /erts/emulator/utils/beam_makeops | |
parent | 027b178bdc20f4a4b813d030bc7cb7f834d2980e (diff) | |
download | otp-29aea1a92e25ee47e55b4a3c48edfc62e8aa4a42.tar.gz otp-29aea1a92e25ee47e55b4a3c48edfc62e8aa4a42.tar.bz2 otp-29aea1a92e25ee47e55b4a3c48edfc62e8aa4a42.zip |
Allow multiple types per argument for specific instructions
Inroduce syntactic sugar so that we can write:
get_list xy xy xy
instead of:
get_list x x x
get_list x x y
get_list x y x
get_list x y y
get_list y x x
get_list y x y
get_list y y x
get_list y y y
Diffstat (limited to 'erts/emulator/utils/beam_makeops')
-rwxr-xr-x | erts/emulator/utils/beam_makeops | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/erts/emulator/utils/beam_makeops b/erts/emulator/utils/beam_makeops index bfa5236764..05cd48d434 100755 --- a/erts/emulator/utils/beam_makeops +++ b/erts/emulator/utils/beam_makeops @@ -402,7 +402,7 @@ while (<>) { if (defined $gen_opnum{$name,$arity} and $obsolete[$gen_opnum{$name,$arity}]) { error("specific instructions may not be specified for obsolete instructions"); } - push(@{$specific_op{"$name/$arity"}}, [$name, $hot, @args]); + save_specific_ops($name, $arity, $hot, @args); if (defined $op_num) { error("specific instructions must not be numbered"); } elsif (!defined($gen_arity{$name}) && !defined($unnumbered{$name,$arity})) { @@ -866,8 +866,30 @@ sub syntax_check { error("Bad opcode name '$name'") unless $name =~ /^[a-z][\w\d_]*$/; for ($i = 0; $i < @args; $i++) { - error("Argument " . ($i+1) . ": invalid type '$args[$i]'") - unless defined $arg_size{$args[$i]}; + foreach my $type (split(//, $args[$i])) { + error("Argument " . ($i+1) . ": invalid type '$type'") + unless defined $arg_size{$type}; + } + } +} + +sub save_specific_ops { + my($name,$arity,$hot,@args) = @_; + my(@res) = (""); + + foreach my $arg (@args) { + my @new_res = (); + foreach my $type (split(//, $arg)) { + foreach my $args (@res) { + push @new_res, "$args$type"; + } + } + @res = @new_res; + } + my $key = "$name/$arity"; + foreach my $args (@res) { + @args = split //, $args; + push @{$specific_op{$key}}, [$name,$hot,@args]; } } |