From 4d6e7ac0aa307271e0b265dd41dea4eb0fc1dee7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Tue, 14 Dec 2010 06:35:54 +0100
Subject: beam_makeops: Refactor packing code to facilitate extensions

We don't want the packable types listed in two places.
---
 erts/emulator/utils/beam_makeops | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

(limited to 'erts')

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;
 
-- 
cgit v1.2.3