Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement bare block case of if/unless s.m.
  • Loading branch information
jnthn committed Apr 28, 2015
1 parent b317d0a commit a5f38ae
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/Perl6/Actions.nqp
Expand Up @@ -817,9 +817,16 @@ Compilation unit '$file' contained the following violations:
my $ml := $<statement_mod_loop>;
$past := $<EXPR>.ast;
if $mc {
$mc.ast.push($past);
$mc.ast.push(QAST::WVal.new( :value($*W.find_symbol(['Nil'])) ));
$past := $mc.ast;
my $mc_ast := $mc.ast;
if $past.ann('bare_block') {
my $cond_block := $past.ann('past_block');
remove_block($*W.cur_lexpad(), $cond_block);
$cond_block.blocktype('immediate');
$past := $cond_block;
}
$mc_ast.push($past);
$mc_ast.push(QAST::WVal.new( :value($*W.find_symbol(['Nil'])) ));
$past := $mc_ast;
}
if $ml {
my $cond := $ml<smexpr>.ast;
Expand Down Expand Up @@ -7314,10 +7321,17 @@ Compilation unit '$file' contained the following violations:
my int $i := 0;
my int $n := nqp::elems(@decls);
while $i < $n {
if @decls[$i] =:= $block {
my $consider := @decls[$i];
if $consider =:= $block {
@decls[$i] := QAST::Op.new( :op('null') );
return 1;
}
elsif nqp::istype($consider, QAST::Stmt) || nqp::istype($consider, QAST::Stmts) {
if $consider[0] =:= $block {
$consider[0] := QAST::Op.new( :op('null') );
return 1;
}
}
$i++;
}
nqp::die('Internal error: failed to remove block');
Expand Down

0 comments on commit a5f38ae

Please sign in to comment.