Skip to content

Commit

Permalink
Merge branch 'new-packfile-api' of github.com:gerdr/parrot
Browse files Browse the repository at this point in the history
  • Loading branch information
Benabik committed Oct 8, 2013
2 parents 4edb3d1 + e38b4cb commit 47634a6
Show file tree
Hide file tree
Showing 26 changed files with 156 additions and 1,277 deletions.
3 changes: 0 additions & 3 deletions MANIFEST
Expand Up @@ -1376,7 +1376,6 @@ src/pmc/continuation.pmc []
src/pmc/coroutine.pmc []
src/pmc/default.pmc []
src/pmc/env.pmc []
src/pmc/eval.pmc []
src/pmc/eventhandler.pmc []
src/pmc/exception.pmc []
src/pmc/exceptionhandler.pmc []
Expand Down Expand Up @@ -1535,7 +1534,6 @@ t/compilers/imcc/reg/spill_old.t [test]
t/compilers/imcc/syn/clash.t [test]
t/compilers/imcc/syn/const.t [test]
t/compilers/imcc/syn/errors.t [test]
t/compilers/imcc/syn/eval.t [test]
t/compilers/imcc/syn/file.t [test]
t/compilers/imcc/syn/hll.t [test]
t/compilers/imcc/syn/keyed.t [test]
Expand Down Expand Up @@ -1890,7 +1888,6 @@ t/pmc/continuation.t [test]
t/pmc/coroutine.t [test]
t/pmc/default.t [test]
t/pmc/env.t [test]
t/pmc/eval.t [test]
t/pmc/eventhandler.t [test]
t/pmc/exception-old.t [test]
t/pmc/exception.t [test]
Expand Down
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
13 changes: 13 additions & 0 deletions include/parrot/packfile.h
Expand Up @@ -712,6 +712,15 @@ void Parrot_pf_set_current_packfile(PARROT_INTERP, ARGIN(PMC *pbc))
__attribute__nonnull__(1)
__attribute__nonnull__(2);

PARROT_EXPORT
PARROT_CANNOT_RETURN_NULL
PMC * Parrot_pf_single_sub_by_tag(PARROT_INTERP,
ARGIN(PMC * pfpmc),
ARGIN(STRING * flag))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(3);

PARROT_EXPORT
PARROT_CANNOT_RETURN_NULL
PMC * Parrot_pf_subs_by_tag(PARROT_INTERP,
Expand Down Expand Up @@ -886,6 +895,10 @@ void Parrot_pf_mark_packfile(PARROT_INTERP, ARGMOD_NULLOK(PackFile * pf))
__attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(pbc))
#define ASSERT_ARGS_Parrot_pf_single_sub_by_tag __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(pfpmc) \
, PARROT_ASSERT_ARG(flag))
#define ASSERT_ARGS_Parrot_pf_subs_by_tag __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(pfpmc) \
Expand Down
3 changes: 1 addition & 2 deletions include/parrot/sub.h
Expand Up @@ -125,8 +125,7 @@ typedef struct Parrot_sub_arginfo {
do { \
const INTVAL type = (pmc)->vtable->base_type; \
if (type == enum_class_Sub || \
type == enum_class_Coroutine || \
type == enum_class_Eval) \
type == enum_class_Coroutine) \
{\
(sub) = PARROT_SUB((pmc)); \
} \
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
1 change: 0 additions & 1 deletion src/call/pcc.c
Expand Up @@ -268,7 +268,6 @@ do_run_ops(PARROT_INTERP, ARGIN(PMC *sub_obj))
switch (sub_obj->vtable->base_type) {
case enum_class_Sub:
case enum_class_MultiSub:
case enum_class_Eval:
case enum_class_Continuation:
return 1;
case enum_class_Object:
Expand Down
27 changes: 27 additions & 0 deletions src/packfile/api.c
Expand Up @@ -507,6 +507,32 @@ Parrot_pf_subs_by_tag(PARROT_INTERP, ARGIN(PMC * pfpmc), ARGIN(STRING * flag))

/*
=item C<PMC * Parrot_pf_single_sub_by_tag(PARROT_INTERP, PMC * pfpmc, STRING *
flag)>
Get a single Sub from the packfile by named flag. If there are more than one
Subs with the given flag, it is unspecified which one is returned.
=cut
*/

PARROT_EXPORT
PARROT_CANNOT_RETURN_NULL
PMC *
Parrot_pf_single_sub_by_tag(PARROT_INTERP, ARGIN(PMC * pfpmc), ARGIN(STRING * flag))
{
ASSERT_ARGS(Parrot_pf_single_sub_by_tag)

/* XXX use custom implementation */
PMC * const subs = Parrot_pf_subs_by_tag(interp, pfpmc, flag);
return PMC_IS_NULL(subs)
? PMCNULL
: VTABLE_get_pmc_keyed_int(interp, subs, 0);
}

/*
=item C<PMC * Parrot_pf_all_tags_list(PARROT_INTERP, PMC * pfpmc)>
Return a ResizableStringArray of all tags in the packfile.
Expand Down Expand Up @@ -621,6 +647,7 @@ Parrot_pf_all_subs(PARROT_INTERP, ARGIN(PMC *pfpmc))
return array;
}
}

/*
=item C<static int sub_pragma(PARROT_INTERP, pbc_action_enum_t action, const PMC
Expand Down

0 comments on commit 47634a6

Please sign in to comment.