Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Do not require aux stacks to be predeclared
  • Loading branch information
sorear committed Jul 21, 2010
1 parent cf25c36 commit a8fb8a5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 26 deletions.
9 changes: 2 additions & 7 deletions CgOp.pm
Expand Up @@ -294,10 +294,6 @@ use warnings;
CgOp::Primitive->new(op => [ 'lextypes', @_ ]);
}

sub new_aux {
CgOp::Primitive->new(op => [ 'new_aux', $_[0], $_[1] ]);
}

sub share_lex {
scopedlex($_[0], protolget($_[0]));
}
Expand Down Expand Up @@ -350,7 +346,6 @@ use warnings;
zyg => \@args);
}

# the aux stacks probably ought to die.
sub protosub {
my ($body, @extra) = @_;
prog(
Expand All @@ -360,9 +355,9 @@ use warnings;
}

sub with_aux {
my ($name, $value, @stuff) = @_;
my ($name, $type, $value, @stuff) = @_;
prog(
CgOp::Primitive->new(op => [ 'push_aux', $name ],
CgOp::Primitive->new(op => [ 'push_aux', $name, $type ],
zyg => [ $value ]),
@stuff,
sink(CgOp::Primitive->new(op => [ 'pop_aux', $name ])));
Expand Down
13 changes: 3 additions & 10 deletions CodeGen.pm
Expand Up @@ -93,7 +93,6 @@ use 5.010;
has unreach => (isa => 'Bool', is => 'rw', default => 0);

has auxdepths => (isa => 'HashRef', is => 'ro', default => sub { +{} });
has auxtypes => (isa => 'HashRef', is => 'ro', default => sub { +{} });
has body => (isa => 'Body', is => 'ro');
has bodies => (isa => 'ArrayRef', is => 'ro', default => sub { [] });

Expand Down Expand Up @@ -208,16 +207,10 @@ use 5.010;
@{ $self->stacktype }[-1,-2] = @{ $self->stacktype }[-2,-1];
}

sub new_aux {
my ($self, $name, $type) = @_;
$self->auxdepths->{$name} = 0;
$self->auxtypes->{$name} = $type;
}

sub push_aux {
my ($self, $which) = @_;
my ($self, $which, $ty) = @_;
my $var = "aux!${which}!" . ($self->auxdepths->{$which}++);
$self->lextypes($var, $self->auxtypes->{$which});
$self->lex2type->{$var} = $ty;
$self->rawlexput($var);
}

Expand Down Expand Up @@ -568,7 +561,7 @@ use 5.010;
my ($self, $body) = @_;
$self->peek_aux('protopad');
$self->clr_new('Frame', 1);
$self->push_aux('protopad');
$self->push_aux('protopad', 'Frame');
push @{ $self->bodies }, $body;
}

Expand Down
2 changes: 1 addition & 1 deletion Decl.pm
Expand Up @@ -221,7 +221,7 @@ use CgOp;

$self->body->outer($body);

CgOp::with_aux("how",
CgOp::with_aux("how", "Variable",
CgOp::methodcall(CgOp::scopedlex("ClassHOW"), "new",
CgOp::wrap(CgOp::clr_string($self->name // 'ANON'))),

Expand Down
13 changes: 5 additions & 8 deletions Unit.pm
Expand Up @@ -20,14 +20,11 @@ use 5.010;
my ($self) = @_;
$self->mainline->outer($self->setting) if $self->setting;
CodeGen->new(name => 'BOOT', entry => 1,
ops => CgOp::prog(
CgOp::new_aux('protopad', 'Frame'),
CgOp::new_aux('how', 'Variable'),
CgOp::with_aux('protopad',
CgOp::cast('Frame', CgOp::fetch(CgOp::pos(0))),
CgOp::return(
CgOp::newscalar(
CgOp::protosub($self->mainline))))));
ops => CgOp::with_aux('protopad', 'Frame',
CgOp::cast('Frame', CgOp::fetch(CgOp::pos(0))),
CgOp::return(
CgOp::newscalar(
CgOp::protosub($self->mainline)))));
}

sub write {
Expand Down

0 comments on commit a8fb8a5

Please sign in to comment.