Skip to content

Commit

Permalink
Switch to using lexical returns. A return invocation now attaches
Browse files Browse the repository at this point in the history
to the lexical environment in which it is written, instead of being
purely dynamic.  This implementation uses continuations directly
instead of Parrot's exception handling, which may be both good and
bad.  We'll have to see how it all works out.
  • Loading branch information
pmichaud committed Jun 27, 2011
1 parent 30f5cc9 commit f647b57
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/Perl6/Actions.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,8 @@ class Perl6::Actions is HLL::Actions {
$block := $<blockoid>.ast;
$block.blocktype('declaration');
unless is_clearly_returnless($block) {
$block.control('return_pir');
$block[1] := PAST::Op.new(:pasttype<lexotic>, :name<RETURN>, $block[1]);
# $block.control('return_pir');
}
}

Expand Down Expand Up @@ -1173,7 +1174,8 @@ class Perl6::Actions is HLL::Actions {
$past := $<blockoid>.ast;
$past.blocktype('declaration');
unless is_clearly_returnless($past) {
$past.control('return_pir');
$past[1] := PAST::Op.new(:pasttype<lexotic>, :name<RETURN>, $past[1]);
# $past.control('return_pir');
}
}
$past.name(~$<longname>);
Expand Down
9 changes: 5 additions & 4 deletions src/core/control.pm
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ my &THROW :=
};

my &return-rw := -> \$parcel = Nil {
THROW($parcel, pir::const::CONTROL_RETURN)
pir::find_caller_lex__Ps('RETURN')($parcel);
$parcel
};
my &return := -> \$parcel = Nil {
THROW(pir::perl6_decontainerize__PP($parcel),
pir::const::CONTROL_RETURN)
my &return := -> \$parcel = Nil {
pir::find_caller_lex__Ps('RETURN')(pir::perl6_decontainerize__PP($parcel));
$parcel
};

my &take-rw := -> \$parcel = Nil {
Expand Down
2 changes: 1 addition & 1 deletion tools/build/NQP_REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2011.06-2-g97315f3
2011.06-6-gfa94a60

0 comments on commit f647b57

Please sign in to comment.