Skip to content

Commit 9ac6475

Browse files
committed
Implement nqp::takedispatcher on MoarVM backend.
1 parent 661eeb6 commit 9ac6475

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/vm/moar/QAST/QASTOperationsMAST.nqp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,6 +1911,19 @@ QAST::MASTOperations.add_core_moarop_mapping('getcodename', 'getcodename');
19111911
QAST::MASTOperations.add_core_moarop_mapping('setcodename', 'setcodename', 0);
19121912
QAST::MASTOperations.add_core_moarop_mapping('forceouterctx', 'forceouterctx', 0);
19131913
QAST::MASTOperations.add_core_moarop_mapping('setdispatcher', 'setdispatcher', 0);
1914+
QAST::MASTOperations.add_core_op('takedispatcher', -> $qastcomp, $op {
1915+
unless nqp::istype($op[0], QAST::SVal) {
1916+
nqp::die("takedispatcher must have a single QAST::SVal child");
1917+
}
1918+
my @ops;
1919+
my $disp_reg := $*REGALLOC.fresh_register($MVM_reg_obj);
1920+
push_op(@ops, 'takedispatcher', $disp_reg);
1921+
if $*BLOCK.lexical($op[0].value) -> $lex {
1922+
push_op(@ops, 'bindlex', $lex, $disp_reg);
1923+
}
1924+
$*REGALLOC.release_register($disp_reg, $MVM_reg_obj);
1925+
MAST::InstructionList.new(@ops, $MVM_reg_void, MAST::VOID)
1926+
});
19141927
QAST::MASTOperations.add_core_op('setup_blv', -> $qastcomp, $op {
19151928
if +@($op) != 1 || !nqp::ishash($op[0]) {
19161929
nqp::die('setup_blv requires one hash operand');

0 commit comments

Comments
 (0)