Skip to content

Commit c6cd504

Browse files
committed
Start moving altnfas into the code object.
1 parent a7352d1 commit c6cd504

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/NQP/Actions.pm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,4 +1640,12 @@ class NQP::RegexActions is QRegex::P6Regex::Actions {
16401640
method store_regex_caps($code_obj, $block, %caps) {
16411641
$code_obj.SET_CAPS(%caps);
16421642
}
1643+
1644+
method store_regex_alt_nfa($code_obj, $block, $key, @alternatives) {
1645+
my @saved;
1646+
for @alternatives {
1647+
@saved.push($_.save(:non_empty));
1648+
}
1649+
$code_obj.SET_ALT_NFA($key, @saved);
1650+
}
16431651
}

src/QRegex/Cursor.nqp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,9 @@ role NQPCursorRole is export {
249249
my @fates := $nfa.states[0];
250250
my int $start := 1;
251251
my int $fate := 0;
252-
for $!regexsub.nqpattr($name) {
252+
for nqp::ifnull(
253+
nqp::can($!regexsub, 'ALT_NFA') ?? $!regexsub.ALT_NFA($name) !! nqp::null(),
254+
$!regexsub.nqpattr($name)) {
253255
my $label := @labels[$fate];
254256
$fate := $fate + 1;
255257
@fates[$fate] := $label;

src/core/NQPRoutine.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ my knowhow NQPRegex {
8787
method NFA() {
8888
$!nfa
8989
}
90-
method ALT_NFA($name) {
91-
%!alt_nfas{$name}
90+
method ALT_NFA(str $name) {
91+
nqp::isnull(%!alt_nfas) ?? nqp::null() !! %!alt_nfas{$name}
9292
}
9393
}
9494
pir::stable_publish_vtable_handler_mapping__vPP(NQPRegex,

0 commit comments

Comments
 (0)