1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:48:12 +00:00

LibRegex: Add some more information to Compare::Reference debug output

This commit is contained in:
Ali Mohammad Pur 2022-01-21 23:44:50 +03:30 committed by Linus Groh
parent 97dde09170
commit bc20e4f71d

View file

@ -900,6 +900,21 @@ Vector<String> OpCode_Compare::variable_arguments_to_string(Optional<MatchInput>
} else if (compare_type == CharacterCompareType::Reference) {
auto ref = m_bytecode->at(offset++);
result.empend(String::formatted("number={}", ref));
if (input.has_value()) {
if (state().capture_group_matches.size() > input->match_index) {
auto& match = state().capture_group_matches[input->match_index];
if (match.size() > ref) {
auto& group = match[ref];
result.empend(String::formatted("left={}", group.left_column));
result.empend(String::formatted("right={}", group.left_column + group.view.length_in_code_units()));
result.empend(String::formatted("contents='{}'", group.view));
} else {
result.empend(String::formatted("(invalid ref, max={})", match.size() - 1));
}
} else {
result.empend(String::formatted("(invalid index {}, max={})", input->match_index, state().capture_group_matches.size() - 1));
}
}
} else if (compare_type == CharacterCompareType::String) {
auto& length = m_bytecode->at(offset++);
StringBuilder str_builder;