From 3963e68c05822629deaae8a6c4e28b37d4d62a71 Mon Sep 17 00:00:00 2001 From: Stefan O'Rear Date: Tue, 20 Jul 2010 21:10:32 -0700 Subject: [PATCH] Stop relying on !slots, SPOT lexicals into Decl --- Body.pm | 7 ++++++- CodeGen.pm | 12 +++++------- Niecza/Actions.pm | 8 +------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/Body.pm b/Body.pm index efd04c65..d6564b06 100644 --- a/Body.pm +++ b/Body.pm @@ -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, @@ -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; diff --git a/CodeGen.pm b/CodeGen.pm index 1a21588b..26efdf96 100644 --- a/CodeGen.pm +++ b/CodeGen.pm @@ -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); } @@ -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; diff --git a/Niecza/Actions.pm b/Niecza/Actions.pm index a31d43e0..6dd80adf 100644 --- a/Niecza/Actions.pm +++ b/Niecza/Actions.pm @@ -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) = @_; @@ -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); }