mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:57:44 +00:00
LibRegex: Preserve capture groups and matches across ForkReplace
This makes the (flawed) ForkStay inserted as a loop header unnecessary, and finally fixes LibRegex rewriting weird loops in weird ways.
This commit is contained in:
parent
bc20e4f71d
commit
cd83325c7c
2 changed files with 2 additions and 10 deletions
|
@ -223,7 +223,6 @@ void Regex<Parser>::attempt_rewrite_loops_as_atomic_groups(BasicBlockList const&
|
|||
// -------------------------
|
||||
// bb1 | RE1
|
||||
// can be rewritten as:
|
||||
// loop.hdr | ForkStay bb1 (if RE1 matches _something_, empty otherwise)
|
||||
// -------------------------
|
||||
// bb0 | RE0
|
||||
// | ForkReplaceX bb0
|
||||
|
@ -371,15 +370,6 @@ void Regex<Parser>::attempt_rewrite_loops_as_atomic_groups(BasicBlockList const&
|
|||
} else {
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
if (candidate.form == AlternateForm::DirectLoopWithoutHeader) {
|
||||
if (candidate.new_target_block.has_value()) {
|
||||
// Insert a fork-stay targeted at the second block.
|
||||
bytecode.insert(candidate.forking_block.start, (ByteCodeValueType)OpCodeId::ForkStay);
|
||||
bytecode.insert(candidate.forking_block.start + 1, candidate.new_target_block->start - candidate.forking_block.start + 2);
|
||||
needed_patches.insert(candidate.forking_block.start, 2u);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!needed_patches.is_empty()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue