Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Switch to having a $! and $/ per routine, not per block. Also consist…
…ently use assignment, not binding, for $! and $/.
  • Loading branch information
jnthn committed Sep 19, 2011
1 parent 35ec9c7 commit 7563146
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
11 changes: 7 additions & 4 deletions src/Perl6/Actions.pm
Expand Up @@ -559,7 +559,10 @@ class Perl6::Actions is HLL::Actions {
# Perl6LexPad will generate containers (and maybe fill them with
# the outer's value) on demand.
my $BLOCK := $*ST.cur_lexpad();
for <$_ $/ $!> {
my $type := $BLOCK<IN_DECL>;
my $is_routine := $type eq 'sub' || $type eq 'method' ||
$type eq 'submethod' || $type eq 'mainline';
for ($is_routine ?? <$_ $/ $!> !! ['$_']) {
# Generate the lexical variable except if...
# (1) the block already has one, or
# (2) the variable is '$_' and $*IMPLICIT is set
Expand Down Expand Up @@ -815,14 +818,14 @@ class Perl6::Actions is HLL::Actions {

# On failure, capture the exception object into $!.
$past.push(
PAST::Op.new(:pasttype<bind_6model>,
PAST::Op.new(:pirop('perl6_container_store__0PP'),
PAST::Var.new(:name<$!>, :scope<lexical_6model>),
PAST::Op.new(:name<&EXCEPTION>, :pasttype<call>,
PAST::Op.new(:inline(" .get_results (%r)\n finalize %r")))));

# Otherwise, put Mu into $!.
$past.push(
PAST::Op.new(:pasttype<bind_6model>,
PAST::Op.new(:pirop('perl6_container_store__0PP'),
PAST::Var.new( :name<$!>, :scope<lexical_6model> ),
PAST::Var.new( :name<Mu>, :scope<lexical_6model> )));
}
Expand Down Expand Up @@ -3352,7 +3355,7 @@ class Perl6::Actions is HLL::Actions {
block_closure($coderef)
);
self.handle_and_check_adverbs($/, %MATCH_ALLOWED_ADVERBS, 'm', $past);
make PAST::Op.new( :pasttype('bind_6model'),
make PAST::Op.new( :pirop('perl6_container_store__0PP'),
PAST::Var.new(:name('$/'), :scope('lexical_6model')),
$past
);
Expand Down
1 change: 1 addition & 0 deletions src/Perl6/Grammar.pm
Expand Up @@ -414,6 +414,7 @@ grammar Perl6::Grammar is HLL::Grammar {
# from e.g. REPL) and the real UNIT.
$*UNIT_OUTER := $*ST.push_lexpad($/);
$*UNIT := $*ST.push_lexpad($/);
$*UNIT<IN_DECL> := 'mainline';

# If we already have a specified outer context, then that's
# our setting. Otherwise, load one.
Expand Down
6 changes: 1 addition & 5 deletions src/core/control.pm
Expand Up @@ -146,10 +146,6 @@ sub eval(Str $code, :$lang = 'perl6') {
$P0 = getinterp
%r = $P0['context';1]
};
my $caller_lexpad := Q:PIR {
$P0 = getinterp
%r = $P0['lexpad';1]
};
my $result;
my $success;
try {
Expand All @@ -159,7 +155,7 @@ sub eval(Str $code, :$lang = 'perl6') {
$result := $pbc();
$success = 1;
}
nqp::bindkey($caller_lexpad, '$!', $!);
pir::find_caller_lex__Ps('$!') = $!;
$success ?? $result !! Any # XXX fail($!)
}

Expand Down

0 comments on commit 7563146

Please sign in to comment.