LibJS: Port RegExp flags and patterns to UTF-16

This commit is contained in:
Timothy Flynn 2025-08-06 11:28:18 -04:00 committed by Tim Flynn
commit 62d85dd90a
Notes: github-actions[bot] 2025-08-13 13:57:14 +00:00
8 changed files with 55 additions and 46 deletions

View file

@ -605,6 +605,11 @@ public:
return JS::PrimitiveString::create(m_vm, string);
};
auto decode_utf16_string = [&]() {
auto string = m_serialized.decode<Utf16String>();
return JS::PrimitiveString::create(m_vm, string);
};
auto decode_big_int = [&]() {
auto string = m_serialized.decode<String>();
return JS::BigInt::create(m_vm, MUST(::Crypto::SignedBigInteger::from_base(10, string)));
@ -665,8 +670,8 @@ public:
// 11. Otherwise, if serialized.[[Type]] is "RegExp", then set value to a new RegExp object in targetRealm whose [[RegExpMatcher]] internal slot value is serialized.[[RegExpMatcher]],
// whose [[OriginalSource]] internal slot value is serialized.[[OriginalSource]], and whose [[OriginalFlags]] internal slot value is serialized.[[OriginalFlags]].
case ValueTag::RegExpObject: {
auto pattern = decode_string();
auto flags = decode_string();
auto pattern = decode_utf16_string();
auto flags = decode_utf16_string();
value = MUST(JS::regexp_create(m_vm, pattern, flags));
break;