Skip to content

Commit

Permalink
Pass lexical types directly to CodeGen instead of using (lextypes)
Browse files Browse the repository at this point in the history
  • Loading branch information
sorear committed Jul 21, 2010
1 parent 3963e68 commit f0c3f28
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
9 changes: 5 additions & 4 deletions Body.pm
Expand Up @@ -23,10 +23,12 @@ use CgOp ();
# also '' for incorrectly contextualized {p,x,}block, blast
has type => (isa => 'Str', is => 'rw');

sub lexical {
has lexical => (isa => 'HashRef[Str]', is => 'ro', lazy_build => 1);

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

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

sub is_mainline {
Expand All @@ -51,15 +53,14 @@ use CgOp ();
my ($self) = @_;
# TODO: Bind a return value here to catch non-ro sub use
CodeGen->new(name => $self->name, body => $self,
lex2type => +{ %{ $self->lexical } },
ops => CgOp::prog($self->enter_code,
CgOp::return($self->do->code($self))));
}

sub enter_code {
my ($self) = @_;
my @p;
push @p, CgOp::lextypes(map { $_, 'Variable' }
keys %{ $self->lexical });
push @p, map { $_->enter_code($self) } @{ $self->decls };
push @p, $self->signature->binder if $self->signature;
push @p, map { CgOp::sink($_->code($self)) } @{ $self->enter };
Expand Down
19 changes: 8 additions & 11 deletions Decl.pm
Expand Up @@ -10,7 +10,7 @@ use CgOp;

has zyg => (is => 'ro', isa => 'ArrayRef', default => sub { [] });

sub used_slots { }
sub used_slots { () }
sub preinit_code { CgOp::noop }
sub enter_code { CgOp::noop }
sub write {}
Expand All @@ -30,7 +30,7 @@ use CgOp;

sub used_slots {
my ($self) = @_;
return $self->has_var ? ($self->var) : ();
$self->has_var ? ($self->var, 'Variable') : ();
}

sub preinit_code {
Expand Down Expand Up @@ -66,7 +66,7 @@ use CgOp;
has code => (isa => 'Body', is => 'ro', required => 1);

sub used_slots {
return $_[0]->var;
$_[0]->var, 'Variable';
}

sub preinit_code {
Expand Down Expand Up @@ -103,7 +103,7 @@ use CgOp;
has list => (isa => 'Bool', is => 'ro', default => 0);

sub used_slots {
return $_[0]->slot;
$_[0]->slot, 'Variable';
}

sub preinit_code {
Expand Down Expand Up @@ -143,7 +143,7 @@ use CgOp;
has backing => (isa => 'Str', is => 'ro', required => 1);

sub used_slots {
return $_[0]->slot;
$_[0]->slot, 'Variable';
}

sub preinit_code {
Expand All @@ -165,7 +165,7 @@ use CgOp;
use Moose;
extends 'Decl';

sub used_slots { '!mainline' }
sub used_slots { '!mainline', 'Variable' }

sub preinit_code {
my ($self, $body) = @_;
Expand Down Expand Up @@ -206,11 +206,8 @@ use CgOp;

sub used_slots {
my ($self) = @_;
if ($self->stub) {
($self->var, $self->var . '!HOW');
} else {
($self->var, $self->var . '!HOW', $self->bodyvar);
}
$self->var, 'Variable', ($self->var . '!HOW'), 'Variable',
(!$self->stub ? ($self->bodyvar, 'Variable') : ());
}

sub preinit_code {
Expand Down

0 comments on commit f0c3f28

Please sign in to comment.