LibJS+LibWeb: Replace JS::Utf16String with AK::Utf16String

This commit is contained in:
Timothy Flynn 2025-07-09 14:13:22 -04:00 committed by Tim Flynn
parent d40e3af697
commit a43cb15e81
Notes: github-actions[bot] 2025-07-18 16:46:59 +00:00
24 changed files with 172 additions and 526 deletions

View file

@ -94,7 +94,7 @@ void update_legacy_regexp_static_properties(RegExpConstructor& constructor, Utf1
legacy_static_properties.set_input(string);
// 8. Set the value of Cs [[RegExpLastMatch]] internal slot to a String whose length is endIndex - startIndex and containing the code units from S with indices startIndex through endIndex - 1, in ascending order.
auto last_match = string.view().substring_view(start_index, end_index - start_index);
auto last_match = string.substring_view(start_index, end_index - start_index);
legacy_static_properties.set_last_match(last_match);
// 9. If n > 0, set the value of Cs [[RegExpLastParen]] internal slot to the last element of capturedValues.
@ -104,22 +104,22 @@ void update_legacy_regexp_static_properties(RegExpConstructor& constructor, Utf1
}
// 10. Else, set the value of Cs [[RegExpLastParen]] internal slot to the empty String.
else {
legacy_static_properties.set_last_paren(Utf16String::create());
legacy_static_properties.set_last_paren({});
}
// 11. Set the value of Cs [[RegExpLeftContext]] internal slot to a String whose length is startIndex and containing the code units from S with indices 0 through startIndex - 1, in ascending order.
auto left_context = string.view().substring_view(0, start_index);
auto left_context = string.substring_view(0, start_index);
legacy_static_properties.set_left_context(left_context);
// 12. Set the value of Cs [[RegExpRightContext]] internal slot to a String whose length is len - endIndex and containing the code units from S with indices endIndex through len - 1, in ascending order.
auto right_context = string.view().substring_view(end_index, len - end_index);
auto right_context = string.substring_view(end_index, len - end_index);
legacy_static_properties.set_right_context(right_context);
// 13. For each integer i such that 1 ≤ i ≤ 9
for (size_t i = 1; i <= 9; i++) {
// i. If i ≤ n, set the value of Cs [[RegExpPareni]] internal slot to the ith element of capturedValues.
// ii. Else, set the value of Cs [[RegExpPareni]] internal slot to the empty String.
auto value = (i <= group_count) ? captured_values[i - 1] : Utf16String::create();
auto value = (i <= group_count) ? captured_values[i - 1] : Utf16String {};
if (i == 1) {
legacy_static_properties.set_$1(move(value));