Skip to content

Commit b1d897d

Browse files
committed
Add :nohandler option to PAST::Op loop nodes.
1 parent 6255819 commit b1d897d

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

src/QAST/Operations.nqp

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -547,11 +547,15 @@ for ('', 'repeat_') -> $repness {
547547
# Emit the prelude.
548548
my $ops := PIRT::Ops.new();
549549
$ops.result($res_reg);
550-
my $exc_reg := $*REGALLOC.fresh_p();
551-
$ops.push_pirop('new', $exc_reg, "'ExceptionHandler'",
552-
'[.CONTROL_LOOP_NEXT;.CONTROL_LOOP_REDO;.CONTROL_LOOP_LAST]');
553-
$ops.push_pirop('set_label', $exc_reg, $hand_lbl);
554-
$ops.push_pirop('push_eh', $exc_reg);
550+
551+
my $exc_reg;
552+
if $handler {
553+
$exc_reg := $*REGALLOC.fresh_p();
554+
$ops.push_pirop('new', $exc_reg, "'ExceptionHandler'",
555+
'[.CONTROL_LOOP_NEXT;.CONTROL_LOOP_REDO;.CONTROL_LOOP_LAST]');
556+
$ops.push_pirop('set_label', $exc_reg, $hand_lbl);
557+
$ops.push_pirop('push_eh', $exc_reg);
558+
}
555559

556560
# Test the condition and jump to the loop end if it's
557561
# not met.
@@ -590,15 +594,17 @@ for ('', 'repeat_') -> $repness {
590594
$ops.push_pirop('goto ' ~ $test_lbl.result);
591595

592596
# Emit postlude, with exception handlers.
593-
$ops.push($hand_lbl);
594-
$ops.push_pirop('.get_results', '(' ~ $exc_reg ~ ')');
595-
$ops.push_pirop('pop_upto_eh', $exc_reg);
596-
$ops.push_pirop('getattribute', $exc_reg, $exc_reg, "'type'");
597-
$ops.push_pirop('eq', $exc_reg, '.CONTROL_LOOP_NEXT',
598-
$operands == 3 ?? $next_lbl !! $test_lbl);
599-
$ops.push_pirop('eq', $exc_reg, '.CONTROL_LOOP_REDO', $redo_lbl);
600-
$ops.push($done_lbl);
601-
$ops.push_pirop('pop_eh');
597+
if $handler {
598+
$ops.push($hand_lbl);
599+
$ops.push_pirop('.get_results', '(' ~ $exc_reg ~ ')');
600+
$ops.push_pirop('pop_upto_eh', $exc_reg);
601+
$ops.push_pirop('getattribute', $exc_reg, $exc_reg, "'type'");
602+
$ops.push_pirop('eq', $exc_reg, '.CONTROL_LOOP_NEXT',
603+
$operands == 3 ?? $next_lbl !! $test_lbl);
604+
$ops.push_pirop('eq', $exc_reg, '.CONTROL_LOOP_REDO', $redo_lbl);
605+
$ops.push($done_lbl);
606+
$ops.push_pirop('pop_eh');
607+
}
602608

603609
$ops;
604610
});

0 commit comments

Comments
 (0)