Skip to content

Commit

Permalink
Beta-reduction: decls and bare blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
sorear committed Aug 17, 2010
1 parent f6ca7b8 commit 1a512a6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Op.pm
Expand Up @@ -769,7 +769,8 @@ use CgOp;
}

sub statement_level {
Op::CallSub->new(invocant => $_[0]);
Op::CallSub->new(invocant => Op::SubDef->new(var => $_[0]->var,
body => $_[0]->body, once => 1));
}

__PACKAGE__->meta->make_immutable;
Expand Down
8 changes: 6 additions & 2 deletions Optimizer/Beta.pm
Expand Up @@ -94,8 +94,12 @@ sub beta_optimize {
positionals => \@pos),
$ib->do]);

for my $ke (reverse map { $_->used_slots(0) } @{ $ib->decls }) {
$nop = Op::Let->new(var => $ke->[0], type => $ke->[1], in => $nop);
for my $d (reverse @{ $ib->decls }) {
my $to = $d->hash ? CgOp::newblankhash :
$d->list ? CgOp::newblanklist :
CgOp::newblankrwscalar;
$nop = Op::Let->new(var => $d->slot,
to => Op::CgOp->new(op => $to), in => $nop);
}

for my $a (reverse @args) {
Expand Down

0 comments on commit 1a512a6

Please sign in to comment.