cvsuser 02/06/09 21:29:25
Modified: . assemble.pl
t/op macro.t
Log:
Constants are now expanded within macro invocation, and a test to that effect
added to the suite. In other words, you can now do '.Debug(.String)'.
Revision Changes Path
1.65 +7 -2 parrot/assemble.pl
Index: assemble.pl
===================================================================
RCS file: /cvs/public/parrot/assemble.pl,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -w -r1.64 -r1.65
--- assemble.pl 7 Jun 2002 23:18:56 -0000 1.64
+++ assemble.pl 10 Jun 2002 04:29:21 -0000 1.65
@@ -314,10 +314,15 @@
elsif(/\.($label_re) \s*
\(([^)]*)\)/x) { # .{name} (...
if(defined $self->{macros}{$1}) {
- my @arguments = split /,/,$2;
+ my $macro_name = $1;
+ my $arguments = $2;
+ $arguments =~ s{\.(\w+)}
+ {defined $self->{constants}{$1} ?
+ $self->{constants}{$1} : ".$1"}egx;
+ my @arguments = split /,/,$arguments;
s/(^\s+|\s+$)//g for @arguments;
push @{$self->{contents}},
- $self->_expand_macro($1,\@arguments);
+ $self->_expand_macro($macro_name,\@arguments);
}
else {
push @{$self->{contents}},$_;
1.10 +11 -1 parrot/t/op/macro.t
Index: macro.t
===================================================================
RCS file: /cvs/public/parrot/t/op/macro.t,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -w -r1.9 -r1.10
--- macro.t 7 Jun 2002 04:17:08 -0000 1.9
+++ macro.t 10 Jun 2002 04:29:25 -0000 1.10
@@ -1,6 +1,6 @@
#! perl -w
-use Parrot::Test tests => 12;
+use Parrot::Test tests => 13;
use Test::More;
output_is( <<'CODE', <<OUTPUT, "macro, zero parameters" );
@@ -135,5 +135,15 @@
.constant FOO S0
set .FOO,"foo"
print .FOO
+ end
+CODE
+
+output_is(<<'CODE', 'foo', "constant defined, used in a macro call");
+.constant FOO S0
+.macro answer (bar)
+ print .bar
+.endm
+ set .FOO,"foo"
+ .answer(.FOO)
end
CODE