Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
$/ and $! are contextuals
  • Loading branch information
sorear committed Oct 21, 2010
1 parent 2a653c8 commit 876edf3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/Metamodel.pm
Expand Up @@ -794,11 +794,6 @@ sub Body::begin {
ltm => $self->ltm,
run_once => $args{once} && (!@opensubs || $rtop->run_once));

if ($self->signature && @{ $self->signature->params } >= 1 &&
$self->signature->params->[0]->slot eq '') {
$metabody->lexicals->{'$/'} = Metamodel::Lexical::Alias->new('');
}

$unit->get_stash(@{ $metabody->cur_pkg });

push @opensubs, $metabody; # always visible in the signature XXX
Expand All @@ -810,8 +805,20 @@ sub Body::begin {

pop @opensubs if $self->transparent;

$self->do->begin;
$metabody->code($self->do);
my $do = $self->do;

if ($self->signature && @{ $self->signature->params } >= 1 &&
$self->signature->params->[0]->slot eq '') {
$do = Op::StatementList->new(children => [
Op::CallSub->new(
invocant => Op::Lexical->new(name => '&infix:<=>'),
args => [ Op::Lexical->new(name => '$*/', declaring => 1),
Op::Lexical->new(name => '') ]),
$do]);
}

$do->begin;
$metabody->code($do);

$metabody->close;
pop @opensubs unless $self->transparent;
Expand Down
2 changes: 2 additions & 0 deletions src/Niecza/Actions.pm
Expand Up @@ -1702,6 +1702,7 @@ sub variable { my ($cl, $M) = @_;
}
} elsif ($M->{special_variable}) {
$name = substr($M->{special_variable}->Str, 1);
$twigil = '*' if $name eq '/' or $name eq '!';
} elsif ($M->{index}) {
$M->{_ast} = { capid => $M->{index}{_ast}, term =>
# maybe a little of a cheat
Expand Down Expand Up @@ -1737,6 +1738,7 @@ sub variable { my ($cl, $M) = @_;

sub special_variable {}
sub special_variable__S_DollarSlash {}
sub special_variable__S_DollarBang {}
sub special_variable__S_Dollar_a2_ {}

sub param_sep {}
Expand Down

0 comments on commit 876edf3

Please sign in to comment.