Author: tene
Date: Mon Dec 15 18:28:10 2008
New Revision: 33943
Modified:
trunk/languages/perl6/src/parser/actions.pm
Log:
[rakudo]: Refactor some copypasta out of my last commit.
Modified: trunk/languages/perl6/src/parser/actions.pm
==============================================================================
--- trunk/languages/perl6/src/parser/actions.pm (original)
+++ trunk/languages/perl6/src/parser/actions.pm Mon Dec 15 18:28:10 2008
@@ -258,31 +258,12 @@
}
method when_statement($/) {
- our $?BLOCK;
my $block := $( $<block> );
$block.blocktype('immediate');
# Push a handler onto the innermost block so that we can exit if we
# successfully match
- # XXX TODO: This isn't quite the right way to check this...
- unless $?BLOCK.handlers() {
- my @handlers;
- @handlers.push(
- PAST::Control.new(
- PAST::Op.new(
- :pasttype('pirop'),
- :pirop('return'),
- PAST::Var.new(
- :scope('keyed'),
- PAST::Var.new( :name('exception'), :scope('register')
),
- 'payload',
- ),
- ),
- :handle_types('BREAK')
- )
- );
- $?BLOCK.handlers(@handlers);
- }
+ when_handler_helper();
# push a control exception throw onto the end of the block so we
# exit the innermost block in which $_ was set.
@@ -331,32 +312,13 @@
}
method default_statement($/) {
- our $?BLOCK;
# Always executed if reached, so just produce the block.
my $block := $( $<block> );
$block.blocktype('immediate');
# Push a handler onto the innermost block so that we can exit if we
# successfully match
- # XXX TODO: This isn't quite the right way to check this...
- unless $?BLOCK.handlers() {
- my @handlers;
- @handlers.push(
- PAST::Control.new(
- PAST::Op.new(
- :pasttype('pirop'),
- :pirop('return'),
- PAST::Var.new(
- :scope('keyed'),
- PAST::Var.new( :name('exception'), :scope('register')
),
- 'payload',
- ),
- ),
- :handle_types('BREAK')
- )
- );
- $?BLOCK.handlers(@handlers);
- }
+ when_handler_helper();
# push a control exception throw onto the end of the block so we
# exit the innermost block in which $_ was set.
@@ -388,6 +350,29 @@
make $block;
}
+sub when_handler_helper() {
+ our $?BLOCK;
+ # XXX TODO: This isn't quite the right way to check this...
+ unless $?BLOCK.handlers() {
+ my @handlers;
+ @handlers.push(
+ PAST::Control.new(
+ PAST::Op.new(
+ :pasttype('pirop'),
+ :pirop('return'),
+ PAST::Var.new(
+ :scope('keyed'),
+ PAST::Var.new( :name('exception'), :scope('register')
),
+ 'payload',
+ ),
+ ),
+ :handle_types('BREAK')
+ )
+ );
+ $?BLOCK.handlers(@handlers);
+ }
+}
+
method loop_statement($/) {
my $block := $( $<block> );
$block.blocktype('immediate');