Skip to content

Commit

Permalink
Stop relying on !slots, SPOT lexicals into Decl
Browse files Browse the repository at this point in the history
  • Loading branch information
sorear committed Jul 21, 2010
1 parent 03f7ce1 commit 3963e68
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
7 changes: 6 additions & 1 deletion Body.pm
Expand Up @@ -12,7 +12,6 @@ use CgOp ();
has do => (isa => 'Op', is => 'rw');
has enter => (isa => 'ArrayRef[Op]', is => 'ro',
default => sub { [] });
has lexical => (isa => 'HashRef', is => 'ro', default => sub { +{} });
has outer => (isa => 'Body', is => 'rw', init_arg => undef);
has decls => (isa => 'ArrayRef', is => 'ro', default => sub { [] });
has code => (isa => 'CodeGen', is => 'ro', init_arg => undef,
Expand All @@ -24,6 +23,12 @@ use CgOp ();
# also '' for incorrectly contextualized {p,x,}block, blast
has type => (isa => 'Str', is => 'rw');

sub lexical {
my ($self) = @_;

+{ map { $_, 1 } map { $_->used_slots } @{ $self->decls } };
}

sub is_mainline {
my $self = shift;

Expand Down
12 changes: 5 additions & 7 deletions CodeGen.pm
Expand Up @@ -280,10 +280,6 @@ use 5.010;
sub lextypes {
my ($self, %args) = @_;
#say STDERR "lextypes: @args";
my $body = $self->body // $self->bodies->[-1];
if ($body) {
for (keys %args) { $body->lexical->{$_} = 1 }
}
%{ $self->lex2type } = (%{ $self->lex2type }, %args);
}

Expand Down Expand Up @@ -552,9 +548,11 @@ use 5.010;
my ($self, $name, $set) = @_;
my $body = $self->body // $self->bodies->[-1];
my ($order, $scope) = (0, $body);
while ($scope && !$scope->lexical->{$name}) {
$scope = $scope->outer;
$order++;
if (! $self->lex2type->{$name}) {
while ($scope && !$scope->lexical->{$name}) {
$scope = $scope->outer;
$order++;
}
}
if (!$scope) {
die "Failed to resolve lexical $name in " . $body->name;
Expand Down
8 changes: 1 addition & 7 deletions Niecza/Actions.pm
Expand Up @@ -1056,11 +1056,6 @@ sub statevar { my ($cl, %ex) = @_;
}

sub blockcheck { my ($cl) = @_;
for my $d (@{ $::CURLEX->{'!decls'} // [] }) {
for my $sl ($d->used_slots) {
$::CURLEX->{'!slots'}{$sl} = 1;
}
}
}

sub sl_to_block { my ($cl, $type, $ast, %args) = @_;
Expand All @@ -1077,8 +1072,7 @@ sub sl_to_block { my ($cl, $type, $ast, %args) = @_;
type => $type,
$args{bare} ? () : (
decls => ($::CURLEX->{'!decls'} // []),
enter => ($::CURLEX->{'!enter'} // []),
lexical => ($::CURLEX->{'!slots'} // {})),
enter => ($::CURLEX->{'!enter'} // [])),
signature => $args{signature},
do => $ast);
}
Expand Down

0 comments on commit 3963e68

Please sign in to comment.