cvsuser 03/07/02 06:37:22
Modified: . MANIFEST MANIFEST.detailed
languages/imcc imcc.l imcc.y
languages/imcc/t/syn bsr.t
Added: languages/imcc/t/syn file.t
Log:
switch PASM,PIR mode for include files
Revision Changes Path
1.360 +1 -0 parrot/MANIFEST
Index: MANIFEST
===================================================================
RCS file: /cvs/public/parrot/MANIFEST,v
retrieving revision 1.359
retrieving revision 1.360
diff -u -w -r1.359 -r1.360
--- MANIFEST 1 Jul 2003 22:58:55 -0000 1.359
+++ MANIFEST 2 Jul 2003 13:37:18 -0000 1.360
@@ -1472,6 +1472,7 @@
languages/imcc/t/syn/clash.t
languages/imcc/t/syn/const.t
languages/imcc/t/syn/eval.t
+languages/imcc/t/syn/file.t
languages/imcc/t/syn/labels.t
languages/imcc/t/syn/namespace.t
languages/imcc/t/syn/scope.t
1.32 +1 -0 parrot/MANIFEST.detailed
Index: MANIFEST.detailed
===================================================================
RCS file: /cvs/public/parrot/MANIFEST.detailed,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -w -r1.31 -r1.32
--- MANIFEST.detailed 1 Jul 2003 22:58:55 -0000 1.31
+++ MANIFEST.detailed 2 Jul 2003 13:37:18 -0000 1.32
@@ -1471,6 +1471,7 @@
[] languages/imcc/t/syn/clash.t
[] languages/imcc/t/syn/const.t
[] languages/imcc/t/syn/eval.t
+[] languages/imcc/t/syn/file.t
[] languages/imcc/t/syn/labels.t
[] languages/imcc/t/syn/namespace.t
[] languages/imcc/t/syn/scope.t
1.36 +19 -2 parrot/languages/imcc/imcc.l
Index: imcc.l
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/imcc.l,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -w -r1.35 -r1.36
--- imcc.l 31 May 2003 23:37:41 -0000 1.35
+++ imcc.l 2 Jul 2003 13:37:20 -0000 1.36
@@ -43,6 +43,7 @@
struct params_t expansion;
int label;
int line;
+ int pasm_file; /* pasm_file mode of previous frame */
};
struct macro_frame_t *frames = NULL;
@@ -383,10 +384,13 @@
*/
yy_delete_buffer(YY_CURRENT_BUFFER);
- /* pop old frames */
+ /* pop old frame */
if (frames) {
struct macro_frame_t *tmp;
tmp = frames;
+ pasm_file = frames->pasm_file;
+ if (YYSTATE == INITIAL || YYSTATE == emit)
+ BEGIN(pasm_file ? emit : INITIAL);
frames = frames->next;
destroy_frame(tmp);
return 0;
@@ -404,6 +408,7 @@
tmp = mem_sys_allocate_zeroed(sizeof(struct macro_frame_t));
tmp->label = ++label;
tmp->line = line;
+ tmp->pasm_file = pasm_file;
return tmp;
}
@@ -643,12 +648,24 @@
{
struct macro_frame_t *frame;
FILE *file;
+ char *ext;
frame = new_frame();
file = fopen(file_name, "r");
if (!file)
fataly(EX_SOFTWARE, file_name, line, strerror(errno));
+ ext = strrchr(file_name, '.');
+ if (ext) {
+ if (strcmp (ext, ".pasm") == 0) {
+ pasm_file = 1;
+ BEGIN(emit);
+ }
+ else if (strcmp (ext, ".imc") == 0) {
+ pasm_file = 0;
+ BEGIN(INITIAL);
+ }
+ }
scan_file (frame, file);
}
1.64 +1 -0 parrot/languages/imcc/imcc.y
Index: imcc.y
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/imcc.y,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -w -r1.63 -r1.64
--- imcc.y 30 Jun 2003 07:47:34 -0000 1.63
+++ imcc.y 2 Jul 2003 13:37:20 -0000 1.64
@@ -487,6 +487,7 @@
statement: { clear_state(); }
instruction { $$ = $2; }
+ | MACRO '\n' { $$ = 0; }
;
labels: /* none */ { $$ = NULL; }
1.10 +1 -60 parrot/languages/imcc/t/syn/bsr.t
Index: bsr.t
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/t/syn/bsr.t,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -w -r1.9 -r1.10
--- bsr.t 18 Jun 2003 12:28:56 -0000 1.9
+++ bsr.t 2 Jul 2003 13:37:22 -0000 1.10
@@ -1,6 +1,6 @@
#!perl
use strict;
-use TestCompiler tests => 12;
+use TestCompiler tests => 11;
##############################
# this tests register allocation/preserving of local bsr calls
@@ -75,62 +75,6 @@
OUT
##############################
-my $file = '_test.inc';
-open F, ">$file";
-print F <<'EOF';
-.sub _foo # sub foo(int a, int b)
- saveall
- .param int a
- .param int b
- print "a = "
- print a
- print "\n"
- print "b = "
- print b
- print "\n"
- .local int pl
- .local int mi
- pl = a + b
- mi = a - b
- .return mi # from right to left
- .return pl # return (pl, mi)
- restoreall
- ret
-.end
-EOF
-close F;
-
-output_is(<<'CODE', <<'OUT', "subroutine in external file");
-.sub _main
- .local int x
- x = 10
- .const int y = 20
-
- .arg y # save args in reversed order
- .arg x
- call _foo #(r, s) = _foo(x,y)
- .local int r
- .local int s
- .result r
- .result s # restore results in order
-
- print "r = "
- print r
- print "\n"
- print "s = "
- print s
- print "\n"
- end
-.end
-.include "_test.inc"
-CODE
-a = 10
-b = 20
-r = 30
-s = -10
-OUT
-
-##############################
#
output_is(<<'CODE', <<'OUT', "fact with stack calling conventions");
.sub _main
@@ -342,9 +286,6 @@
Hello perl6.
OUT
-END {
- unlink $file;
-}
##############################
# nested subs
# NOTE: global labels necessary
1.1 parrot/languages/imcc/t/syn/file.t
Index: file.t
===================================================================
#!perl
use strict;
use TestCompiler tests => 4;
# include file tests
##############################
open FOO, ">temp.pasm" or die "Cant write temp.pasm\n";
print FOO <<'ENDF';
.constant BAR 42
ENDF
close FOO;
output_is(<<'CODE', <<'OUT', "include pasm");
.sub _main
print "before\n"
.include "temp.pasm"
print .BAR
print "\nafter\n"
end
.end
CODE
before
42
after
OUT
unlink "temp.pasm";
##############################
open FOO, ">temp.imc" or die "Cant write temp.imc\n";
print FOO <<'ENDF';
.const int BAR = 42
ENDF
close FOO;
output_is(<<'CODE', <<'OUT', "include pir");
.sub _main
print "before\n"
.include "temp.imc"
print BAR
print "\nafter\n"
end
.end
CODE
before
42
after
OUT
unlink "temp.imc";
##############################
open FOO, ">temp.inc" or die "Cant write temp.inc\n";
print FOO <<'ENDF';
.const int BAR = 42
ENDF
close FOO;
output_is(<<'CODE', <<'OUT', "include .inc");
.sub _main
print "before\n"
.include "temp.inc"
print BAR
print "\nafter\n"
end
.end
CODE
before
42
after
OUT
unlink "temp.inc";
##############################
my $file = '_test.inc';
open F, ">$file";
print F <<'EOF';
.sub _foo # sub foo(int a, int b)
saveall
.param int a
.param int b
print "a = "
print a
print "\n"
print "b = "
print b
print "\n"
.local int pl
.local int mi
pl = a + b
mi = a - b
.return mi # from right to left
.return pl # return (pl, mi)
restoreall
ret
.end
EOF
close F;
output_is(<<'CODE', <<'OUT', "subroutine in external file");
.sub _main
.local int x
x = 10
.const int y = 20
.arg y # save args in reversed order
.arg x
call _foo #(r, s) = _foo(x,y)
.local int r
.local int s
.result r
.result s # restore results in order
print "r = "
print r
print "\n"
print "s = "
print s
print "\n"
end
.end
.include "_test.inc"
CODE
a = 10
b = 20
r = 30
s = -10
OUT
END {
unlink $file;
}