On 8/9/06, Allison Randal <[EMAIL PROTECTED]> wrote:
Chip Salzenberg wrote:
>> pbc_merge doesn't allow multiple :load routines.
>
> That's a bug, Shirley.
Currently it's a feature. Only one :load routine is allowed per PIR
file, and pbc_merge basically just packs all the compiled code together.
I could argue that maybe we should allow multiple :load routines, but
what about :main routines?
i don't think you're correct about C<:load> here, at least not from my
reading of the (somewhat hard-to-find) docs (see
F<docs/imcc/calling_conventions.pod>):
=head2 Subpragma
This is a list of zero or more items with the following meanings:
=over 4
=item :main
Define "main" entry point to start execution. If multiple subroutines
are marked as B<:main>, the B<last> marked subroutine is entered.
=item :load
Run this subroutine during the B<load_library> opcode.
B<:load> is ignored, if another subroutine in that file is marked with
B<:main>. If multiple subs have the B<:load> pragma, the subs are
run in source code order.
=cut
please also see the tests, at F<t/pmc/sub.t:558-605> (inline below)
which seem to match the docs.
open S, ">$temp" or die "Can't write $temp";
print S <<'EOF';
.pcc_sub :load _sub1:
print "in sub1\n"
returncc
.pcc_sub :load _sub2:
print "in sub2\n"
returncc
EOF
close S;
pasm_output_is(<<'CODE', <<'OUTPUT', "load_bytecode autorun both");
.pcc_sub _main:
print "main\n"
load_bytecode "temp.pasm"
print "loaded\n"
find_global P0, "_sub1"
invokecc P0
print "back\n"
end
CODE
main
in sub1
in sub2
loaded
in sub1
back
OUTPUT
system(".$PConfig{slash}parrot$PConfig{exe} -o temp.pbc $temp");
pasm_output_is(<<'CODE', <<'OUTPUT', "load_bytecode autorun both in pbc");
.pcc_sub _main:
print "main\n"
load_bytecode "temp.pbc"
print "loaded\n"
find_global P0, "_sub1"
invokecc P0
print "back\n"
end
CODE
main
in sub1
in sub2
loaded
in sub1
back
OUTPUT
hope that helps clarify the current behavior a bit.
~jerry