1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:47:45 +00:00

LibJS: Replace standalone js_string() with PrimitiveString::create()

Note that js_rope_string() has been folded into this, the old name was
misleading - it would not always create a rope string, only if both
sides are not empty strings. Use a three-argument create() overload
instead.
This commit is contained in:
Linus Groh 2022-12-06 22:17:27 +00:00
parent 5db38d7ba1
commit 525f22d018
144 changed files with 656 additions and 672 deletions

View file

@ -116,7 +116,7 @@ ThrowCompletionOr<Value> canonical_code_for_display_names(VM& vm, DisplayNames::
// c. Return ! CanonicalizeUnicodeLocaleId(code).
auto canonicalized_tag = JS::Intl::canonicalize_unicode_locale_id(*locale_id);
return js_string(vm, move(canonicalized_tag));
return PrimitiveString::create(vm, move(canonicalized_tag));
}
// 2. If type is "region", then
@ -126,7 +126,7 @@ ThrowCompletionOr<Value> canonical_code_for_display_names(VM& vm, DisplayNames::
return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, code, "region"sv);
// b. Return the ASCII-uppercase of code.
return js_string(vm, code.to_uppercase_string());
return PrimitiveString::create(vm, code.to_uppercase_string());
}
// 3. If type is "script", then
@ -142,7 +142,7 @@ ThrowCompletionOr<Value> canonical_code_for_display_names(VM& vm, DisplayNames::
// c. Let first be the ASCII-uppercase of the substring of code from 0 to 1.
// d. Let rest be the ASCII-lowercase of the substring of code from 1.
// e. Return the string-concatenation of first and rest.
return js_string(vm, code.to_titlecase_string());
return PrimitiveString::create(vm, code.to_titlecase_string());
}
// 4. If type is "calendar", then
@ -156,7 +156,7 @@ ThrowCompletionOr<Value> canonical_code_for_display_names(VM& vm, DisplayNames::
return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, code, "calendar"sv);
// c. Return the ASCII-lowercase of code.
return js_string(vm, code.to_lowercase_string());
return PrimitiveString::create(vm, code.to_lowercase_string());
}
// 5. If type is "dateTimeField", then
@ -166,7 +166,7 @@ ThrowCompletionOr<Value> canonical_code_for_display_names(VM& vm, DisplayNames::
return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, code, "dateTimeField"sv);
// b. Return code.
return js_string(vm, code);
return PrimitiveString::create(vm, code);
}
// 6. Assert: type is "currency".
@ -177,7 +177,7 @@ ThrowCompletionOr<Value> canonical_code_for_display_names(VM& vm, DisplayNames::
return vm.throw_completion<RangeError>(ErrorType::OptionIsNotValidValue, code, "currency"sv);
// 8. Return the ASCII-uppercase of code.
return js_string(vm, code.to_uppercase_string());
return PrimitiveString::create(vm, code.to_uppercase_string());
}
// 12.5.2 IsValidDateTimeFieldCode ( field ), https://tc39.es/ecma402/#sec-isvaliddatetimefieldcode