Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix x**0 compilation for MoarVM backend.
  • Loading branch information
jnthn committed Oct 9, 2013
1 parent da02211 commit 85ab267
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/vm/moar/QAST/QASTRegexCompilerMAST.nqp
Expand Up @@ -521,15 +521,21 @@ class QAST::MASTRegexCompiler {

method quant($node) {
my @ins := nqp::list();
my $min := $node.min;
my $max := $node.max;

if $min == 0 && $max == 0 {
# Nothing to do, and nothing to backtrack into.
return @ins;
}

my $backtrack := $node.backtrack || 'g';
my $sep := $node[1];
my $prefix := self.unique($*RXPREFIX ~ '_rxquant_' ~ $backtrack);
my $looplabel_index := rxjump($prefix ~ '_loop');
my $looplabel := @*RXJUMPS[$looplabel_index];
my $donelabel_index := rxjump($prefix ~ '_done');
my $donelabel := @*RXJUMPS[$donelabel_index];
my $min := $node.min;
my $max := $node.max;
my $needrep := $min > 1 || $max > 1;
my $needmark := $needrep || $backtrack eq 'r';
my $rep := %*REG<rep>;
Expand All @@ -540,10 +546,7 @@ class QAST::MASTRegexCompiler {
nqp::push(@ins, op('const_i64', $maxreg, ival($max))) if $max > 1;
my $ireg := fresh_i();

if $min == 0 && $max == 0 {
# Nothing to do, and nothing to backtrack into.
}
elsif $backtrack eq 'f' {
if $backtrack eq 'f' {
my $seplabel := label($prefix ~ '_sep');
nqp::push(@ins, op('set', $rep, %*REG<zero>));
if $min < 1 {
Expand Down

0 comments on commit 85ab267

Please sign in to comment.