mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 20:29:18 +00:00
LibRegex: Remove orphaned save points in nested LookAhead
This commit is contained in:
parent
80d7350ee5
commit
f2678bfcb8
Notes:
github-actions[bot]
2025-03-14 08:42:39 +00:00
Author: https://github.com/mikiubo
Commit: f2678bfcb8
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3915
Reviewed-by: https://github.com/alimpfard ✅
Reviewed-by: https://github.com/gmta
3 changed files with 23 additions and 0 deletions
|
@ -31,6 +31,7 @@ using ByteCodeValueType = u64;
|
|||
__ENUMERATE_OPCODE(ForkReplaceJump) \
|
||||
__ENUMERATE_OPCODE(ForkReplaceStay) \
|
||||
__ENUMERATE_OPCODE(FailForks) \
|
||||
__ENUMERATE_OPCODE(PopSaved) \
|
||||
__ENUMERATE_OPCODE(SaveLeftCaptureGroup) \
|
||||
__ENUMERATE_OPCODE(SaveRightCaptureGroup) \
|
||||
__ENUMERATE_OPCODE(SaveRightNamedCaptureGroup) \
|
||||
|
@ -266,9 +267,15 @@ public:
|
|||
switch (type) {
|
||||
case LookAroundType::LookAhead: {
|
||||
// SAVE
|
||||
// FORKJUMP _BODY
|
||||
// POPSAVED
|
||||
// LABEL _BODY
|
||||
// REGEXP BODY
|
||||
// RESTORE
|
||||
empend((ByteCodeValueType)OpCodeId::Save);
|
||||
empend((ByteCodeValueType)OpCodeId::ForkJump);
|
||||
empend((ByteCodeValueType)1);
|
||||
empend((ByteCodeValueType)OpCodeId::PopSaved);
|
||||
extend(move(lookaround_body));
|
||||
empend((ByteCodeValueType)OpCodeId::Restore);
|
||||
return;
|
||||
|
@ -613,6 +620,14 @@ public:
|
|||
ByteString arguments_string() const override { return ByteString::empty(); }
|
||||
};
|
||||
|
||||
class OpCode_PopSaved final : public OpCode {
|
||||
public:
|
||||
ExecutionResult execute(MatchInput const& input, MatchState& state) const override;
|
||||
ALWAYS_INLINE OpCodeId opcode_id() const override { return OpCodeId::PopSaved; }
|
||||
ALWAYS_INLINE size_t size() const override { return 1; }
|
||||
ByteString arguments_string() const override { return ByteString::empty(); }
|
||||
};
|
||||
|
||||
class OpCode_Save final : public OpCode {
|
||||
public:
|
||||
ExecutionResult execute(MatchInput const& input, MatchState& state) const override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue