Skip to content

Commit

Permalink
Use new packfile API
Browse files Browse the repository at this point in the history
  • Loading branch information
gerdr committed Feb 20, 2013
1 parent 2c730f5 commit 8e7165b
Show file tree
Hide file tree
Showing 15 changed files with 52 additions and 14 deletions.
1 change: 1 addition & 0 deletions compilers/data_json/data_json.pir
Expand Up @@ -85,6 +85,7 @@ the documentation at L<http://www.json.org/>.
.local pmc pirc, result
pirc = compreg 'PIR'
result = pirc(pir)
result = result.'first_sub_in_const_table'()
.return (result)

failed:
Expand Down
9 changes: 9 additions & 0 deletions compilers/pct/src/PCT/HLLCompiler.pir
Expand Up @@ -550,6 +550,15 @@ Transform PAST C<source> into POST.
$P0 = compreg 'PIR'
$P1 = $P0(source)
$P2 = $P1.'subs_by_tag'('init')
$P3 = iter $P2
loop_top:
unless $P3 goto loop_bottom
$P4 = shift $P3
$P4()
goto loop_top
loop_bottom:
$P1 = $P1.'first_sub_in_const_table'()
.return($P1)
.end
Expand Down
5 changes: 5 additions & 0 deletions compilers/pct/src/POST/Compiler.pir
Expand Up @@ -433,9 +433,14 @@ the sub.
compiler = compreg $S0
$I0 = isa compiler, 'Sub'
if $I0 goto compiler_sub
$I0 = isa compiler, 'PackfileView'
if $I0 goto compiler_packfileview
.tailcall compiler.'compile'(source, options :flat :named)
compiler_sub:
.tailcall compiler(source, options :flat :named)
compiler_packfileview:
$P0 = compiler.'first_sub_in_const_table'()
.tailcall $P0(source, options :flat :named)
.end
=back
Expand Down
2 changes: 2 additions & 0 deletions compilers/pge/PGE/Exp.pir
Expand Up @@ -90,6 +90,7 @@ C<target> adverbs.
bytecode:
$P0 = compreg 'PIR'
$P1 = $P0(code)
$P1 = $P1.'first_sub_in_const_table'()
make_grammar:
if grammar == '' goto end
.local pmc p6meta
Expand Down Expand Up @@ -1525,6 +1526,7 @@ tree as a PIR code object that can be compiled.
unless null $P1 goto %0_1
$P1 = compreg %1
$P1 = $P1($S1)
$P1 = $P1.'first_sub_in_const_table'()
$P0[$S1] = $P1
%0_1:
CODE
Expand Down
1 change: 1 addition & 0 deletions compilers/tge/TGE/Compiler.pir
Expand Up @@ -345,6 +345,7 @@ loop_end:
code = $S1 . code
named_grammar:
libloader = compiler(code)
libloader = libloader.'first_sub_in_const_table'()
libloader()

new_grammar = new grammarname
Expand Down
4 changes: 3 additions & 1 deletion runtime/parrot/library/PGE/Perl6Grammar.pir
Expand Up @@ -227,7 +227,9 @@ the output to the correct output file.
compile_pir:
$P0 = compreg 'PIR'
.tailcall $P0(out)
$P1 = $P0(out)
$P2 = $P1.'first_sub_in_const_table'()
.return($P2)
.end
Expand Down
15 changes: 10 additions & 5 deletions runtime/parrot/library/Test/More.pir
Expand Up @@ -1114,7 +1114,8 @@ Otherwise, fail the test.
.local string source
source = invokable
compiler = compreg 'PIR'
invokable = compiler(source)
$P9 = compiler(source)
invokable = $P9.'first_sub_in_const_table'()
goto invokeit
badinvoke:
Expand Down Expand Up @@ -1168,7 +1169,8 @@ Passes a test if the PIR code throws any exception, fails a test otherwise.
push_eh eh
compfun = compiler(target)
compfun() # eval the target code
$P9 = compfun.'first_sub_in_const_table'()
$P9() # eval the target code
pop_eh
Expand Down Expand Up @@ -1229,7 +1231,8 @@ Passes a test if the PIR does not throw any exception, fails a test otherwise.
push_eh eh
compfun = compiler(target)
compfun() # eval the target code
$P9 = compfun.'first_sub_in_const_table'()
$P9() # eval the target code
pop_eh
Expand Down Expand Up @@ -1293,7 +1296,8 @@ an exception that matches the pattern, fails the test otherwise.
push_eh eh
compfun = compiler(target)
compfun() # eval the target code
$P9 = compfun.'first_sub_in_const_table'()
$P9() # eval the target code
pop_eh
Expand Down Expand Up @@ -1352,7 +1356,8 @@ an exception that matches the pattern, fails the test otherwise.
push_eh eh
compfun = compiler(target)
compfun() # eval the target code
$P9 = compfun.'first_sub_in_const_table'()
$P9() # eval the target code
pop_eh
Expand Down
4 changes: 4 additions & 0 deletions t/compilers/imcc/syn/tail.t
Expand Up @@ -351,6 +351,10 @@ pir_output_is( <<'CODE', <<'OUTPUT', ".tailcall into an NCI" );
say "A"
$P0 = 'Foo'("C")
$S0 = typeof $P0
$P9 = $P0.'subs_by_tag'('init')
$P8 = $P9[0]
$P8()
$P0 = $P0.'all_subs'()
$P1 = $P0[0]
$P1 = 'Bar'($P1, "F")
say $P1
Expand Down
1 change: 1 addition & 0 deletions t/compilers/pge/pge_examples.t
Expand Up @@ -96,6 +96,7 @@ END_FASTA
( code ) = p6grammar.'compile'(fasta_grammar, 'target'=>'PIR')
$P0 = compreg 'PIR'
$P1 = $P0(code)
$P1 = $P1.'first_sub_in_const_table'()
$P1()
# print code
Expand Down
1 change: 1 addition & 0 deletions t/op/calling.t
Expand Up @@ -1307,6 +1307,7 @@ OUTPUT
pir_output_is( <<'CODE', <<'OUTPUT', "tailcall to NCI - 2" );
.sub main :main
$P0 = eval("print \"Foo!\\n\"")
$P0 = $P0.'first_sub_in_const_table'()
$P0()
end
.end
Expand Down
2 changes: 1 addition & 1 deletion t/op/lexicals.t
Expand Up @@ -798,7 +798,7 @@ EOC
.local pmc compiler
compiler = compreg "PIR"
$P1 = compiler(code)
$P2 = $P1[0] # first sub of eval
$P2 = $P1.'main_sub'()
$P3 = newclosure $P2
.return($P3)
.end
Expand Down
2 changes: 1 addition & 1 deletion t/pmc/key.t
Expand Up @@ -173,7 +173,7 @@ code
.local pmc pir_compiler
pir_compiler = compreg 'PIR'
$P0 = pir_compiler($S0)
$P0 = $P0[0]
$P0 = $P0.'first_sub_in_const_table'()
$P1 = new ['TclProc']
assign $P1, $P0
.local pmc ns_target
Expand Down
2 changes: 2 additions & 0 deletions t/pmc/namespace.t
Expand Up @@ -543,6 +543,7 @@ CODE
CODE
$P0 = compreg "PIR"
$P1 = $P0($S0)
$P1 = $P1.'main_sub'()
$P2 = $P1()
$S0 = typeof $P2
is($S0, "NameSpace", "get_namespace from anon sub")
Expand Down Expand Up @@ -574,6 +575,7 @@ CODE
CODE
$P0 = compreg "PIR"
$P1 = $P0($S0)
$P1 = $P1.'main_sub'()
$I0 = $P1()
is($I0, 1, "find_name sub with sigil in namespace")
.end
Expand Down
7 changes: 5 additions & 2 deletions t/pmc/sub.t
Expand Up @@ -1464,10 +1464,10 @@ PIR
$P3 = new 'ParrotInterpreter'
$P3 = $P3['sub']
$P2 = $P1[0]
$P2 = $P1.'main_sub'()
$P2.'set_outer'($P3)
$P1()
$P2()
.end
CODE
I can has outer from eval?
Expand Down Expand Up @@ -1625,7 +1625,10 @@ PIR
$P0 = compreg 'PIR'
say "got compiler"
$P1 = $P0($S0)
$P2 = $P1.'single_sub_by_tag'('init')
$P2()
say "compiled"
$P1 = $P1.'main_sub'()
$P1()
say "lived"
.end
Expand Down
10 changes: 6 additions & 4 deletions t/profiling/profiling.t
Expand Up @@ -2,10 +2,9 @@

# Copyright (C) 2010, Parrot Foundation.

INIT {
pir::load_bytecode('ProfTest.pbc');
Q:PIR{ .include "test_more.pir" };
}
my $lib := pir::load_bytecode__ps('ProfTest.pbc');
for $lib.subs_by_tag('load') -> $sub { $sub(); }
Q:PIR{ .include "test_more.pir" };
plan(13);
Expand Down Expand Up @@ -178,6 +177,9 @@ CODE
push_eh eh
f = comp(s)
f = f."main_sub"()
$S0 = typeof f
say $S0
f()
pop_eh
Expand Down

0 comments on commit 8e7165b

Please sign in to comment.