aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/utils/beam_makeops
diff options
context:
space:
mode:
authorBjörn Gustavsson <bjorn@erlang.org>2010-12-14 06:35:54 +0100
committerBjörn Gustavsson <bjorn@erlang.org>2011-01-17 15:23:40 +0100
commit4d6e7ac0aa307271e0b265dd41dea4eb0fc1dee7 (patch)
tree45b3b24bfdf9adafef128764da96fb7970bb5900 /erts/emulator/utils/beam_makeops
parentd734f64cc5b4e8b906f0d4f1b28f67c492a05bae (diff)
downloadotp-4d6e7ac0aa307271e0b265dd41dea4eb0fc1dee7.tar.gz
otp-4d6e7ac0aa307271e0b265dd41dea4eb0fc1dee7.tar.bz2
otp-4d6e7ac0aa307271e0b265dd41dea4eb0fc1dee7.zip
beam_makeops: Refactor packing code to facilitate extensions
We don't want the packable types listed in two places.
Diffstat (limited to 'erts/emulator/utils/beam_makeops')
-rwxr-xr-xerts/emulator/utils/beam_makeops15
1 files changed, 9 insertions, 6 deletions
diff --git a/erts/emulator/utils/beam_makeops b/erts/emulator/utils/beam_makeops
index ea06a48d29..00bddd2548 100755
--- a/erts/emulator/utils/beam_makeops
+++ b/erts/emulator/utils/beam_makeops
@@ -954,18 +954,21 @@ sub basic_generator {
sub do_pack {
my(@args) = @_;
- my($i);
my($packable_args) = 0;
+ my @is_packable; # Packability (boolean) for each argument.
#
# Count the number of packable arguments. If we encounter any 's' or 'd'
# arguments, packing is not possible.
#
- for ($i = 0; $i < @args; $i++) {
- if ($args[$i] =~ /[xytQ]/) {
+ foreach my $arg (@args) {
+ if ($arg =~ /^[xytQ]/) {
$packable_args++;
- } elsif ($args[$i] =~ /[sd]/) {
+ push @is_packable, 1;
+ } elsif ($arg =~ /^[sd]/) {
return ('', '', @args);
+ } else {
+ push @is_packable, 0;
}
}
@@ -1005,10 +1008,10 @@ sub do_pack {
my($ap) = 0; # Argument number within word.
my($tmpnum) = 1; # Number of temporary variable.
my($expr) = '';
- for ($i = 0; $i < @args; $i++) {
+ for (my $i = 0; $i < @args; $i++) {
my($reg) = $args[$i];
my($this_size) = $arg_size{$reg};
- if ($reg =~ /[xytQ]/) {
+ if ($is_packable[$i]) {
$this_size = 0;
$did_some_packing = 1;