Commit 6a4ea002 authored by Andy Polyakov's avatar Andy Polyakov
Browse files

perlasm/x86_64-xlate.pl: refactor argument parsing loop.



Reviewed-by: default avatarRich Salz <rsalz@openssl.org>
parent c25278db
Loading
Loading
Loading
Loading
+12 −11
Original line number Diff line number Diff line
@@ -317,15 +317,16 @@ my %globals;
}
{ package register;	# pick up registers, which start with %.
    sub re {
	my	($class, $line) = @_;
	my	($class, $line, $opcode) = @_;
	my	$self = {};
	my	$ret;

	# optional * ---vvv--- appears in indirect jmp/call
	# optional * ----vvv--- appears in indirect jmp/call
	if ($$line =~ /^(\*?)%(\w+)/) {
	    bless $self,$class;
	    $self->{asterisk} = $1;
	    $self->{value} = $2;
	    $opcode->size($self->size());
	    $ret = $self;
	    $$line = substr($$line,@+[0]); $$line =~ s/^\s+//;
	}
@@ -894,11 +895,11 @@ while(defined(my $line=<>)) {
	ARGUMENT: while (1) {
	    my $arg;

	if ($arg=register->re(\$line))		{ $opcode->size($arg->size()); }
	elsif ($arg=const->re(\$line))		{ }
	elsif ($arg=ea->re(\$line, $opcode))	{ }
	elsif ($arg=expr->re(\$line, $opcode))	{ }
	else					{ last ARGUMENT; }
	    ($arg=register->re(\$line, $opcode))||
	    ($arg=const->re(\$line))		||
	    ($arg=ea->re(\$line, $opcode))	||
	    ($arg=expr->re(\$line, $opcode))	||
	    last ARGUMENT;

	    push @args,$arg;