load_bytecode, loadlib, and HLL
Stephen Weeks
tene at allalone.org
Tue Jan 6 20:05:01 UTC 2009
This works fine:
# demo.pir
.sub main :main
load_bytecode 'perl6.pbc'
.end
This fails, due to Perl6Str not existing
# demo.pir
.HLL 'foo'
.sub main :main
load_bytecode 'perl6.pbc'
.end
The runtime version using the 'loadlib' op can work, kind of.
Adding this to perl6.pir doesn't help:
# perl6.pir
.HLL 'parrot'
.sub '' :anon :load :init :immediate
$P0 = loadlib 'perl6_group'
$P0 = loadlib 'perl6_ops'
.end
Adding that same code to the example does work:
# demo.pir
.HLL 'parrot'
.sub '' :anon :load :init :immediate
$P0 = loadlib 'perl6_group'
$P0 = loadlib 'perl6_ops'
.end
.HLL 'foo'
.sub main :main
load_bytecode 'perl6.pbc'
.end
This rather complicates attempts to use rakudo from another HLL.
I did a little bit of digging, and found this:
.loadlib is handled by do_loadlib in imcparser.c, which is:
/* imcparser.c */
do_loadlib(PARROT_INTERP, ARGIN(const char *lib))
{
ASSERT_ARGS(do_loadlib);
STRING * const s = string_unescape_cstring(interp, lib + 1, '"', NULL);
PMC *ignored = Parrot_load_lib(interp, s, NULL);
UNUSED(ignored);
Parrot_register_HLL_lib(interp, s);
}
The loadlib op is handled by 'op loadlib' in core.ops:
/* core.ops */
inline op loadlib(out PMC, in STR) {
$1 = Parrot_load_lib(interp, $2, NULL);
}
You'll notice that the op version doesn't call Parrot_register_HLL_lib, but adding that to 'op loadlib' doesn't help. That's as far as I got in investigating this issue.
More information about the parrot-dev
mailing list