-
-
Save cygx/5fa39ff2c3a12d0a0727865ac16d6aca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ perl6 test.p6 | |
$ PERL6_OPSDLL=.../share/perl6/runtime/dynext/perl6_ops_moar.dll moar --libpath=.../share/nqp/lib trampoline.moarvm | |
No current compiling SC | |
in block <unit> at test.p6 line 55 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use nqp; | |
use QAST:from<NQP>; | |
my $p6comp := nqp::getcomp('perl6'); | |
my $qcomp := nqp::getcomp('QAST'); | |
my $mcomp := nqp::getcomp('MAST'); | |
my $script := QAST::CompUnit.new( | |
QAST::Block.new( | |
QAST::VM.new(:moarop<p6init>) | |
) | |
); | |
my $bc := $mcomp.assemble($qcomp.to_mast($script)).bytecode; | |
my $sc := nqp::createsc('42'); | |
nqp::setobjsc($bc, $sc); | |
nqp::scsetobj($sc, 0, $bc); | |
my $trampoline := QAST::CompUnit.new(); | |
$trampoline.sc($sc); | |
$trampoline.pre_deserialize(nqp::list( | |
QAST::Stmts.new( | |
QAST::Op.new(:op<loadbytecode>, | |
QAST::SVal.new(:value('ModuleLoader.moarvm'))), | |
QAST::Op.new(:op<callmethod>, :name<load_module>, | |
QAST::Op.new(:op<gethllsym>, | |
QAST::SVal.new(:value('nqp')), | |
QAST::SVal.new(:value('ModuleLoader')) | |
), | |
QAST::SVal.new(:value<QAST>) | |
) | |
) | |
)); | |
$trampoline.set_children(nqp::list( | |
QAST::Block.new( | |
QAST::VM.new(:moarop<loadlib>, | |
QAST::SVal.new(:value<p6extops>), | |
QAST::Op.new(:op<unbox_s>, | |
QAST::Op.new(:op<atkey>, | |
QAST::Op.new(:op<getenvhash>), | |
QAST::SVal.new(:value<PERL6_OPSDLL>) | |
) | |
) | |
), | |
QAST::VM.new(:moarop<loadext>, | |
QAST::SVal.new(:value<p6extops>), | |
QAST::SVal.new(:value<Rakudo_ops_init>) | |
), | |
QAST::Op.new(:op<loadbytecodebuffer>, | |
QAST::WVal.new(:value($bc)) | |
) | |
) | |
)); | |
$mcomp.assemble_to_file($qcomp.to_mast($trampoline), 'trampoline.moarvm'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment