Skip to content

Commit 2fdbe0b

Browse files
committed
Start storing NFA directly.
This means it should now be serialized instead of needing to be turned into a QAST tree.
1 parent cfd0d54 commit 2fdbe0b

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/NQP/Actions.pm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,4 +1632,8 @@ class NQP::RegexActions is QRegex::P6Regex::Actions {
16321632
method create_regex_code_object($block) {
16331633
$*W.create_code($block, '', 0, :code_type_name<NQPRegex>);
16341634
}
1635+
1636+
method store_regex_nfa($code_obj, $block, $nfa) {
1637+
$code_obj.SET_NFA($nfa.save);
1638+
}
16351639
}

src/QRegex/NFA.nqp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class QRegex::NFA {
3434
$to := self.addstate() if $to < 0;
3535
my $st := $!states[$from];
3636
nqp::push($st, $action);
37-
nqp::push($st, $value);
37+
nqp::push($st, nqp::istype($value, QAST::SVal) ?? $value.value !! $value);
3838
nqp::push($st, $to);
3939
$to;
4040
}
@@ -278,9 +278,6 @@ class QRegex::NFA {
278278
}
279279
$list.push($arglist);
280280
}
281-
elsif $_ ~~ QAST::SVal {
282-
$list.push($_);
283-
}
284281
elsif +$_ eq $_ {
285282
$list.push(QAST::IVal.new( :value($_) ));
286283
}
@@ -300,7 +297,12 @@ class QRegex::NFA {
300297
if nqp::can($cursor, $name) {
301298
if !nqp::existskey(%seen, $name) {
302299
my $meth := $cursor.HOW.find_method($cursor, $name, :no_trace(1));
303-
@substates := $meth.nqpattr('nfa') if nqp::can($meth, 'nqpattr');
300+
if nqp::can($meth, 'NFA') {
301+
@substates := $meth.NFA();
302+
}
303+
elsif nqp::can($meth, 'nqpattr') {
304+
@substates := $meth.nqpattr('nfa');
305+
}
304306
@substates := [] if nqp::isnull(@substates);
305307
}
306308
if !@substates && !nqp::existskey(%seen, $name) {

0 commit comments

Comments
 (0)