Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement my @x := foo syntax
  • Loading branch information
sorear committed Jul 20, 2010
1 parent f4ddde8 commit 1789938
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Niecza/Actions.pm
Expand Up @@ -801,11 +801,12 @@ sub variable_declarator { my ($cl, $M) = @_;
}

if ($scope eq 'state') {
my $ts = $cl->statevar;
my $ts = $cl->statevar(list => scalar ($M->{variable}->Str =~ /^\@/));
$cl->add_decl(Decl::StateVar->new(backing => $ts, slot => $slot));
$M->{_ast} = Op::Lexical->new(name => $slot, state_decl => 1);
} else {
$cl->add_decl(Decl::SimpleVar->new(slot => $slot));
$cl->add_decl(Decl::SimpleVar->new(slot => $slot,
list => scalar ($M->{variable}->Str =~ /^\@/)));

$M->{_ast} = Op::Lexical->new(name => $slot);
}
Expand Down Expand Up @@ -1039,7 +1040,7 @@ sub routine_declarator__S_method { my ($cl, $M) = @_;
my $next_anon_id = 0;
sub gensym { 'anon_' . ($next_anon_id++) }

sub statevar { my ($cl) = @_;
sub statevar { my ($cl, %ex) = @_;
my $var = $cl->gensym;
my $blk = $::CURLEX;

Expand All @@ -1049,7 +1050,7 @@ sub statevar { my ($cl) = @_;
}

push @{ $blk->{'!decls'} //= [] },
Decl::SimpleVar->new(slot => $var);
Decl::SimpleVar->new(slot => $var, %ex);

$var;
}
Expand Down

0 comments on commit 1789938

Please sign in to comment.