From 31d3bceebd9e8801fee2a10a635e0b41b06674e3 Mon Sep 17 00:00:00 2001 From: jnthn Date: Thu, 5 Dec 2013 21:17:39 +0100 Subject: [PATCH] Fix lexical code-gen/dyn-comp interaction. --- src/vm/moar/QAST/QASTCompilerMAST.nqp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/vm/moar/QAST/QASTCompilerMAST.nqp b/src/vm/moar/QAST/QASTCompilerMAST.nqp index f3a55f58bb..f433f43eaf 100644 --- a/src/vm/moar/QAST/QASTCompilerMAST.nqp +++ b/src/vm/moar/QAST/QASTCompilerMAST.nqp @@ -1086,7 +1086,11 @@ class QAST::MASTCompiler { my $outer := 0; my $block := $*BLOCK; # find the block where the lexical was declared, if any - while !($lex := $block.lexical($name)) && ($block := $block.outer) ~~ BlockInfo { + while nqp::istype($block, BlockInfo) { + last if $block.qast; + $lex := $block.lexical($name); + last if $lex; + $block := $block.outer; $outer++; } if $lex { @@ -1120,17 +1124,15 @@ class QAST::MASTCompiler { } } else { + $res_kind := self.type_to_register_kind($node.returns); if $*BINDVAL { - my $valmast := $node.returns - ?? self.as_mast_clear_bindval($*BINDVAL, :want(self.type_to_register_kind($node.returns))) - !! self.as_mast_clear_bindval($*BINDVAL); + my $valmast := self.as_mast_clear_bindval($*BINDVAL, :want($res_kind)); $res_reg := $valmast.result_reg; push_ilist(@ins, $valmast); push_op(@ins, "bind"~@lex_n_opnames[@kind_to_op_slot[$res_kind]], MAST::SVal.new( :value($name) ), $res_reg); $res_kind := $valmast.result_kind; } else { - $res_kind := $node.returns ?? self.type_to_register_kind($node.returns) !! $MVM_reg_obj; $res_reg := $*REGALLOC.fresh_register($res_kind); push_op(@ins, "get"~@lex_n_opnames[@kind_to_op_slot[$res_kind]], $res_reg, MAST::SVal.new( :value($name) ));