Skip to content

Commit

Permalink
Add eqatim and indexim ops. Fix a bug when using ignoremark
Browse files Browse the repository at this point in the history
There was a bug with ignoremark if the first two codepoints in the haystack
matched, it would act as if the entire needle had matched. This was only with
ignoremark by itself, as ignorecase+ignoremark had already been fixed.

This bug was less noticable than the previously fixed bug in
ignorecase+ignoremark, but it has been solved the same way as the
ignorecase+igoremark had been solved — adding new MoarVM ops.

In this case there already was a nqp::eqatim op, but it did not work properly.
This op has been fixed upstream in MoarVM in addition to the nqp::indexim op
being added.
  • Loading branch information
samcv committed Aug 7, 2017
1 parent f6c2458 commit 9b94aae
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/vm/moar/QAST/QASTOperationsMAST.nqp
Expand Up @@ -2205,6 +2205,7 @@ QAST::MASTOperations.add_core_moarop_mapping('ordat', 'ordat');
QAST::MASTOperations.add_core_moarop_mapping('ordbaseat', 'ordbaseat');
QAST::MASTOperations.add_core_moarop_mapping('indexfrom', 'index_s');
QAST::MASTOperations.add_core_moarop_mapping('indexic', 'indexic_s');
QAST::MASTOperations.add_core_moarop_mapping('indexim', 'indexim_s');
QAST::MASTOperations.add_core_moarop_mapping('indexicim', 'indexicim_s');
QAST::MASTOperations.add_core_moarop_mapping('rindexfrom', 'rindexfrom');
QAST::MASTOperations.add_core_moarop_mapping('substr_s', 'substr_s');
Expand Down Expand Up @@ -2249,6 +2250,7 @@ QAST::MASTOperations.add_core_op('tclc', -> $qastcomp, $op {

QAST::MASTOperations.add_core_moarop_mapping('eqat', 'eqat_s');
QAST::MASTOperations.add_core_moarop_mapping('eqatic', 'eqatic_s');
QAST::MASTOperations.add_core_moarop_mapping('eqatim', 'eqatim_s');
QAST::MASTOperations.add_core_moarop_mapping('eqaticim', 'eqaticim_s');


Expand Down
5 changes: 3 additions & 2 deletions src/vm/moar/QAST/QASTRegexCompilerMAST.nqp
Expand Up @@ -987,9 +987,10 @@ class QAST::MASTRegexCompiler {
nqp::push(@ins, op('eq_i', $ireg0, %!reg<pos>, %!reg<negone>));
$!regalloc.release_register($lit, $MVM_reg_str);
}
elsif $node.list && ($node.subtype eq 'ignorecase'|| $node.subtype eq 'ignorecase+ignoremark') {
elsif $node.list && ($node.subtype eq 'ignorecase' || $node.subtype eq 'ignorecase+ignoremark' || $node.subtype eq 'ignoremark') {
my $lit := $!regalloc.fresh_s();
my $op := $node.subtype eq 'ignorecase' ?? 'indexic_s' !! 'indexicim_s';
my $op := $node.subtype eq 'ignorecase' ?? 'indexic_s' !!
$node.subtype eq 'ignoremark' ?? 'indexim_s' !! 'indexicim_s';
nqp::push(@ins, op('const_s', $lit, sval($node[0])));
nqp::push(@ins, op($op, %!reg<pos>, %!reg<tgt>, $lit, %!reg<pos>));
nqp::push(@ins, op('eq_i', $ireg0, %!reg<pos>, %!reg<negone>));
Expand Down

0 comments on commit 9b94aae

Please sign in to comment.