Skip to content

Commit

Permalink
Enable regexes to use beta-opt
Browse files Browse the repository at this point in the history
  • Loading branch information
sorear committed Aug 17, 2010
1 parent d059983 commit aae0b1f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
5 changes: 4 additions & 1 deletion Op.pm
Expand Up @@ -985,6 +985,8 @@ use CgOp;
extends 'Op';

has signature => (isa => 'Sig', is => 'ro', required => 1);
# positionals *really* should be a bunch of gensym Lexical's, or else
# you risk shadowing hell. this needs to be handled at a different level
has positionals => (isa => 'ArrayRef[Op]', is => 'ro', required => 1);

sub zyg { @{ $_[0]->positionals } }
Expand All @@ -998,7 +1000,8 @@ use CgOp;
my ($self, $body) = @_;

CgOp::prog(
$self->signature->bind_inline($body, @{ $self->positionals }),
$self->signature->bind_inline($body,
map { $_->cgop($body) } @{ $self->positionals }),
CgOp::null('Variable'));
}

Expand Down
2 changes: 1 addition & 1 deletion Optimizer/Beta.pm
Expand Up @@ -87,7 +87,7 @@ sub beta_optimize {
@{ $body->decls } = grep { !$_->isa('Decl::Sub') ||
$_->code != $ib } @{ $body->decls };

my @pos = (map { Op::Lexical->new(name => $_->[0]) } @args);
my @pos = (map { Op::Lexical->new(name => $_->[1]) } @args);

my $nop = Op::StatementList->new(children => [
Op::SigBind->new(signature => $ib->signature,
Expand Down
11 changes: 6 additions & 5 deletions RxOp.pm
Expand Up @@ -18,7 +18,7 @@ use CgOp;
sub _close {
my ($self, $type, $parms, $op) = @_;
Op::SubDef->new(var => Niecza::Actions->gensym, class => ucfirst($type),
body => Body->new(
once => 1, body => Body->new(
type => $type,
signature => Sig->simple(@$parms),
do => $op));
Expand Down Expand Up @@ -123,7 +123,8 @@ use CgOp;
invocant => Op::Lexical->new(name => $lpn),
positionals => [Op::Lexical->new(name => $zzcn)]));
$cn, Op::CallSub->new(
invocant => Op::SubDef->new(var => $lpn, class => 'Sub', body =>
invocant => Op::SubDef->new(var => $lpn, class => 'Sub',
once => 1, body =>
Body->new(type => 'sub', signature => Sig->simple($zcn), do =>
Op::StatementList->new(children => [ $zcont,
Op::CallSub->new(
Expand All @@ -144,9 +145,9 @@ use CgOp;
$cont
]));
$cn, Op::CallSub->new(
invocant => Op::SubDef->new(var => $lpn, class => 'Sub', body =>
Body->new(type => 'sub', signature => Sig->simple($zcn), do =>
$zcont)),
invocant => Op::SubDef->new(var => $lpn, class => 'Sub', once => 1,
body => Body->new(type => 'sub', signature =>
Sig->simple($zcn), do => $zcont)),
positionals => [Op::Lexical->new(name => $cn)]);
}

Expand Down

0 comments on commit aae0b1f

Please sign in to comment.