mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 16:37:47 +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:
parent
5db38d7ba1
commit
525f22d018
144 changed files with 656 additions and 672 deletions
|
@ -589,7 +589,7 @@ ThrowCompletionOr<Array*> supported_locales(VM& vm, Vector<DeprecatedString> con
|
|||
}
|
||||
|
||||
// 5. Return CreateArrayFromList(supportedLocales).
|
||||
return Array::create_from<DeprecatedString>(realm, supported_locales, [&vm](auto& locale) { return js_string(vm, locale); });
|
||||
return Array::create_from<DeprecatedString>(realm, supported_locales, [&vm](auto& locale) { return PrimitiveString::create(vm, locale); });
|
||||
}
|
||||
|
||||
// 9.2.12 CoerceOptionsToObject ( options ), https://tc39.es/ecma402/#sec-coerceoptionstoobject
|
||||
|
|
|
@ -26,7 +26,7 @@ void CollatorCompareFunction::initialize(Realm&)
|
|||
{
|
||||
auto& vm = this->vm();
|
||||
define_direct_property(vm.names.length, Value(2), Attribute::Configurable);
|
||||
define_direct_property(vm.names.name, js_string(vm, DeprecatedString::empty()), Attribute::Configurable);
|
||||
define_direct_property(vm.names.name, PrimitiveString::create(vm, DeprecatedString::empty()), Attribute::Configurable);
|
||||
}
|
||||
|
||||
// 10.3.3.2 CompareStrings ( collator, x, y ), https://tc39.es/ecma402/#sec-collator-comparestrings
|
||||
|
|
|
@ -88,7 +88,7 @@ static ThrowCompletionOr<Collator*> initialize_collator(VM& vm, Collator& collat
|
|||
// 24. If relevantExtensionKeys contains "kn", then
|
||||
if (relevant_extension_keys.span().contains_slow("kn"sv) && result.kn.has_value()) {
|
||||
// a. Set collator.[[Numeric]] to SameValue(r.[[kn]], "true").
|
||||
collator.set_numeric(same_value(js_string(vm, result.kn.release_value()), js_string(vm, "true"sv)));
|
||||
collator.set_numeric(same_value(PrimitiveString::create(vm, result.kn.release_value()), PrimitiveString::create(vm, "true"sv)));
|
||||
}
|
||||
|
||||
// 25. If relevantExtensionKeys contains "kf", then
|
||||
|
@ -105,14 +105,14 @@ static ThrowCompletionOr<Collator*> initialize_collator(VM& vm, Collator& collat
|
|||
// a. If usage is "sort", then
|
||||
if (collator.usage() == Collator::Usage::Sort) {
|
||||
// i. Let sensitivity be "variant".
|
||||
sensitivity = js_string(vm, "variant"sv);
|
||||
sensitivity = PrimitiveString::create(vm, "variant"sv);
|
||||
}
|
||||
// b. Else,
|
||||
else {
|
||||
// i. Let dataLocale be r.[[dataLocale]].
|
||||
// ii. Let dataLocaleData be localeData.[[<dataLocale>]].
|
||||
// iii. Let sensitivity be dataLocaleData.[[sensitivity]].
|
||||
sensitivity = js_string(vm, "base"sv);
|
||||
sensitivity = PrimitiveString::create(vm, "base"sv);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ void CollatorPrototype::initialize(Realm& realm)
|
|||
auto& vm = this->vm();
|
||||
|
||||
// 10.3.2 Intl.Collator.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-intl.collator.prototype-@@tostringtag
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.Collator"), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.Collator"), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_accessor(realm, vm.names.compare, compare_getter, {}, attr);
|
||||
|
@ -75,13 +75,13 @@ JS_DEFINE_NATIVE_FUNCTION(CollatorPrototype::resolved_options)
|
|||
// 1. Let v be undefined.
|
||||
// d. If v is not undefined, then
|
||||
// i. Perform ! CreateDataPropertyOrThrow(options, p, v).
|
||||
MUST(options->create_data_property_or_throw(vm.names.locale, js_string(vm, collator->locale())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.usage, js_string(vm, collator->usage_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.sensitivity, js_string(vm, collator->sensitivity_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.locale, PrimitiveString::create(vm, collator->locale())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.usage, PrimitiveString::create(vm, collator->usage_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.sensitivity, PrimitiveString::create(vm, collator->sensitivity_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.ignorePunctuation, Value(collator->ignore_punctuation())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.collation, js_string(vm, collator->collation())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.collation, PrimitiveString::create(vm, collator->collation())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.numeric, Value(collator->numeric())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.caseFirst, js_string(vm, collator->case_first_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.caseFirst, PrimitiveString::create(vm, collator->case_first_string())));
|
||||
|
||||
// 5. Return options.
|
||||
return options;
|
||||
|
|
|
@ -135,7 +135,7 @@ ThrowCompletionOr<Object*> to_date_time_options(VM& vm, Value options_value, Opt
|
|||
// a. For each property name prop of « "year", "month", "day" », do
|
||||
for (auto const& property : AK::Array { vm.names.year, vm.names.month, vm.names.day }) {
|
||||
// i. Perform ? CreateDataPropertyOrThrow(options, prop, "numeric").
|
||||
TRY(options->create_data_property_or_throw(property, js_string(vm, "numeric"sv)));
|
||||
TRY(options->create_data_property_or_throw(property, PrimitiveString::create(vm, "numeric"sv)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ ThrowCompletionOr<Object*> to_date_time_options(VM& vm, Value options_value, Opt
|
|||
// a. For each property name prop of « "hour", "minute", "second" », do
|
||||
for (auto const& property : AK::Array { vm.names.hour, vm.names.minute, vm.names.second }) {
|
||||
// i. Perform ? CreateDataPropertyOrThrow(options, prop, "numeric").
|
||||
TRY(options->create_data_property_or_throw(property, js_string(vm, "numeric"sv)));
|
||||
TRY(options->create_data_property_or_throw(property, PrimitiveString::create(vm, "numeric"sv)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -548,7 +548,7 @@ ThrowCompletionOr<Vector<PatternPartition>> format_date_time_pattern(VM& vm, Dat
|
|||
auto const& data_locale = date_time_format.data_locale();
|
||||
|
||||
auto construct_number_format = [&](auto* options) -> ThrowCompletionOr<NumberFormat*> {
|
||||
auto* number_format = TRY(construct(vm, *realm.intrinsics().intl_number_format_constructor(), js_string(vm, locale), options));
|
||||
auto* number_format = TRY(construct(vm, *realm.intrinsics().intl_number_format_constructor(), PrimitiveString::create(vm, locale), options));
|
||||
return static_cast<NumberFormat*>(number_format);
|
||||
};
|
||||
|
||||
|
@ -868,10 +868,10 @@ ThrowCompletionOr<Array*> format_date_time_to_parts(VM& vm, DateTimeFormat& date
|
|||
auto* object = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
|
||||
// b. Perform ! CreateDataPropertyOrThrow(O, "type", part.[[Type]]).
|
||||
MUST(object->create_data_property_or_throw(vm.names.type, js_string(vm, part.type)));
|
||||
MUST(object->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, part.type)));
|
||||
|
||||
// c. Perform ! CreateDataPropertyOrThrow(O, "value", part.[[Value]]).
|
||||
MUST(object->create_data_property_or_throw(vm.names.value, js_string(vm, move(part.value))));
|
||||
MUST(object->create_data_property_or_throw(vm.names.value, PrimitiveString::create(vm, move(part.value))));
|
||||
|
||||
// d. Perform ! CreateDataProperty(result, ! ToString(n), O).
|
||||
MUST(result->create_data_property_or_throw(n, object));
|
||||
|
@ -1184,13 +1184,13 @@ ThrowCompletionOr<Array*> format_date_time_range_to_parts(VM& vm, DateTimeFormat
|
|||
auto* object = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
|
||||
// b. Perform ! CreateDataPropertyOrThrow(O, "type", part.[[Type]]).
|
||||
MUST(object->create_data_property_or_throw(vm.names.type, js_string(vm, part.type)));
|
||||
MUST(object->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, part.type)));
|
||||
|
||||
// c. Perform ! CreateDataPropertyOrThrow(O, "value", part.[[Value]]).
|
||||
MUST(object->create_data_property_or_throw(vm.names.value, js_string(vm, move(part.value))));
|
||||
MUST(object->create_data_property_or_throw(vm.names.value, PrimitiveString::create(vm, move(part.value))));
|
||||
|
||||
// d. Perform ! CreateDataPropertyOrThrow(O, "source", part.[[Source]]).
|
||||
MUST(object->create_data_property_or_throw(vm.names.source, js_string(vm, part.source)));
|
||||
MUST(object->create_data_property_or_throw(vm.names.source, PrimitiveString::create(vm, part.source)));
|
||||
|
||||
// e. Perform ! CreateDataProperty(result, ! ToString(n), O).
|
||||
MUST(result->create_data_property_or_throw(n, object));
|
||||
|
|
|
@ -31,7 +31,7 @@ void DateTimeFormatFunction::initialize(Realm& realm)
|
|||
|
||||
Base::initialize(realm);
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
define_direct_property(vm.names.name, js_string(vm, DeprecatedString::empty()), Attribute::Configurable);
|
||||
define_direct_property(vm.names.name, PrimitiveString::create(vm, DeprecatedString::empty()), Attribute::Configurable);
|
||||
}
|
||||
|
||||
ThrowCompletionOr<Value> DateTimeFormatFunction::call()
|
||||
|
@ -59,7 +59,7 @@ ThrowCompletionOr<Value> DateTimeFormatFunction::call()
|
|||
|
||||
// 5. Return ? FormatDateTime(dtf, x).
|
||||
auto formatted = TRY(format_date_time(vm, m_date_time_format, date_value));
|
||||
return js_string(vm, move(formatted));
|
||||
return PrimitiveString::create(vm, move(formatted));
|
||||
}
|
||||
|
||||
void DateTimeFormatFunction::visit_edges(Cell::Visitor& visitor)
|
||||
|
|
|
@ -26,7 +26,7 @@ void DateTimeFormatPrototype::initialize(Realm& realm)
|
|||
auto& vm = this->vm();
|
||||
|
||||
// 11.3.2 Intl.DateTimeFormat.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-intl.datetimeformat.prototype-@@tostringtag
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.DateTimeFormat"), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.DateTimeFormat"), Attribute::Configurable);
|
||||
|
||||
define_native_accessor(realm, vm.names.format, format, nullptr, Attribute::Configurable);
|
||||
|
||||
|
@ -114,7 +114,7 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatPrototype::format_range)
|
|||
|
||||
// 6. Return ? FormatDateTimeRange(dtf, x, y).
|
||||
auto formatted = TRY(format_date_time_range(vm, *date_time_format, start_date_number, end_date_number));
|
||||
return js_string(vm, move(formatted));
|
||||
return PrimitiveString::create(vm, move(formatted));
|
||||
}
|
||||
|
||||
// 11.3.6 Intl.DateTimeFormat.prototype.formatRangeToParts ( startDate, endDate ), https://tc39.es/ecma402/#sec-Intl.DateTimeFormat.prototype.formatRangeToParts
|
||||
|
@ -171,13 +171,13 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatPrototype::resolved_options)
|
|||
// 1. Let v be undefined.
|
||||
// e. If v is not undefined, then
|
||||
// i. Perform ! CreateDataPropertyOrThrow(options, p, v).
|
||||
MUST(options->create_data_property_or_throw(vm.names.locale, js_string(vm, date_time_format->locale())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.calendar, js_string(vm, date_time_format->calendar())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.numberingSystem, js_string(vm, date_time_format->numbering_system())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.timeZone, js_string(vm, date_time_format->time_zone())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.locale, PrimitiveString::create(vm, date_time_format->locale())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.calendar, PrimitiveString::create(vm, date_time_format->calendar())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.numberingSystem, PrimitiveString::create(vm, date_time_format->numbering_system())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.timeZone, PrimitiveString::create(vm, date_time_format->time_zone())));
|
||||
|
||||
if (date_time_format->has_hour_cycle()) {
|
||||
MUST(options->create_data_property_or_throw(vm.names.hourCycle, js_string(vm, date_time_format->hour_cycle_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.hourCycle, PrimitiveString::create(vm, date_time_format->hour_cycle_string())));
|
||||
|
||||
switch (date_time_format->hour_cycle()) {
|
||||
case ::Locale::HourCycle::H11:
|
||||
|
@ -202,7 +202,7 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatPrototype::resolved_options)
|
|||
TRY(options->create_data_property_or_throw(property, Value(*option)));
|
||||
} else {
|
||||
auto name = ::Locale::calendar_pattern_style_to_string(*option);
|
||||
TRY(options->create_data_property_or_throw(property, js_string(vm, name)));
|
||||
TRY(options->create_data_property_or_throw(property, PrimitiveString::create(vm, name)));
|
||||
}
|
||||
|
||||
return {};
|
||||
|
@ -210,9 +210,9 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatPrototype::resolved_options)
|
|||
}
|
||||
|
||||
if (date_time_format->has_date_style())
|
||||
MUST(options->create_data_property_or_throw(vm.names.dateStyle, js_string(vm, date_time_format->date_style_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.dateStyle, PrimitiveString::create(vm, date_time_format->date_style_string())));
|
||||
if (date_time_format->has_time_style())
|
||||
MUST(options->create_data_property_or_throw(vm.names.timeStyle, js_string(vm, date_time_format->time_style_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.timeStyle, PrimitiveString::create(vm, date_time_format->time_style_string())));
|
||||
|
||||
// 6. Return options.
|
||||
return options;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -26,7 +26,7 @@ void DisplayNamesPrototype::initialize(Realm& realm)
|
|||
auto& vm = this->vm();
|
||||
|
||||
// 12.3.2 Intl.DisplayNames.prototype[ @@toStringTag ], https://tc39.es/ecma402/#sec-Intl.DisplayNames.prototype-@@tostringtag
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.DisplayNames"), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.DisplayNames"), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(realm, vm.names.of, of, 1, attr);
|
||||
|
@ -44,7 +44,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::of)
|
|||
|
||||
// 3. Let code be ? ToString(code).
|
||||
auto code_string = TRY(code.to_string(vm));
|
||||
code = js_string(vm, move(code_string));
|
||||
code = PrimitiveString::create(vm, move(code_string));
|
||||
|
||||
// 4. Let code be ? CanonicalCodeForDisplayNames(displayNames.[[Type]], code).
|
||||
code = TRY(canonical_code_for_display_names(vm, display_names->type(), code.as_string().deprecated_string()));
|
||||
|
@ -109,9 +109,9 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::of)
|
|||
}
|
||||
|
||||
if (result.has_value())
|
||||
return js_string(vm, result.release_value());
|
||||
return PrimitiveString::create(vm, result.release_value());
|
||||
if (formatted_result.has_value())
|
||||
return js_string(vm, formatted_result.release_value());
|
||||
return PrimitiveString::create(vm, formatted_result.release_value());
|
||||
|
||||
// 7. If displayNames.[[Fallback]] is "code", return code.
|
||||
if (display_names->fallback() == DisplayNames::Fallback::Code)
|
||||
|
@ -138,14 +138,14 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::resolved_options)
|
|||
// b. Let v be the value of displayNames's internal slot whose name is the Internal Slot value of the current row.
|
||||
// c. Assert: v is not undefined.
|
||||
// d. Perform ! CreateDataPropertyOrThrow(options, p, v).
|
||||
MUST(options->create_data_property_or_throw(vm.names.locale, js_string(vm, display_names->locale())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.style, js_string(vm, display_names->style_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.type, js_string(vm, display_names->type_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.fallback, js_string(vm, display_names->fallback_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.locale, PrimitiveString::create(vm, display_names->locale())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.style, PrimitiveString::create(vm, display_names->style_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, display_names->type_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.fallback, PrimitiveString::create(vm, display_names->fallback_string())));
|
||||
|
||||
// NOTE: Step 4c indicates languageDisplay must not be undefined, but it is only set when the type option is language.
|
||||
if (display_names->has_language_display())
|
||||
MUST(options->create_data_property_or_throw(vm.names.languageDisplay, js_string(vm, display_names->language_display_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.languageDisplay, PrimitiveString::create(vm, display_names->language_display_string())));
|
||||
|
||||
// 5. Return options.
|
||||
return options;
|
||||
|
|
|
@ -401,7 +401,7 @@ Vector<PatternPartition> partition_duration_format_pattern(VM& vm, DurationForma
|
|||
// i. If style is "2-digit" or "numeric", then
|
||||
if (style == DurationFormat::ValueStyle::TwoDigit || style == DurationFormat::ValueStyle::Numeric) {
|
||||
// 1. Let nf be ! Construct(%NumberFormat%, « durationFormat.[[Locale]], nfOpts »).
|
||||
auto* number_format = static_cast<NumberFormat*>(MUST(construct(vm, *realm.intrinsics().intl_number_format_constructor(), js_string(vm, duration_format.locale()), number_format_options)));
|
||||
auto* number_format = static_cast<NumberFormat*>(MUST(construct(vm, *realm.intrinsics().intl_number_format_constructor(), PrimitiveString::create(vm, duration_format.locale()), number_format_options)));
|
||||
|
||||
// 2. Let dataLocale be durationFormat.[[DataLocale]].
|
||||
auto const& data_locale = duration_format.data_locale();
|
||||
|
@ -455,17 +455,17 @@ Vector<PatternPartition> partition_duration_format_pattern(VM& vm, DurationForma
|
|||
// ii. Else,
|
||||
else {
|
||||
// 1. Perform ! CreateDataPropertyOrThrow(nfOpts, "style", "unit").
|
||||
MUST(number_format_options->create_data_property_or_throw(vm.names.style, js_string(vm, "unit"sv)));
|
||||
MUST(number_format_options->create_data_property_or_throw(vm.names.style, PrimitiveString::create(vm, "unit"sv)));
|
||||
|
||||
// 2. Perform ! CreateDataPropertyOrThrow(nfOpts, "unit", numberFormatUnit).
|
||||
MUST(number_format_options->create_data_property_or_throw(vm.names.unit, js_string(vm, number_format_unit)));
|
||||
MUST(number_format_options->create_data_property_or_throw(vm.names.unit, PrimitiveString::create(vm, number_format_unit)));
|
||||
|
||||
// 3. Perform ! CreateDataPropertyOrThrow(nfOpts, "unitDisplay", style).
|
||||
auto unicode_style = ::Locale::style_to_string(static_cast<::Locale::Style>(style));
|
||||
MUST(number_format_options->create_data_property_or_throw(vm.names.unitDisplay, js_string(vm, unicode_style)));
|
||||
MUST(number_format_options->create_data_property_or_throw(vm.names.unitDisplay, PrimitiveString::create(vm, unicode_style)));
|
||||
|
||||
// 4. Let nf be ! Construct(%NumberFormat%, « durationFormat.[[Locale]], nfOpts »).
|
||||
auto* number_format = static_cast<NumberFormat*>(MUST(construct(vm, *realm.intrinsics().intl_number_format_constructor(), js_string(vm, duration_format.locale()), number_format_options)));
|
||||
auto* number_format = static_cast<NumberFormat*>(MUST(construct(vm, *realm.intrinsics().intl_number_format_constructor(), PrimitiveString::create(vm, duration_format.locale()), number_format_options)));
|
||||
|
||||
// 5. Let parts be ! PartitionNumberPattern(nf, 𝔽(value)).
|
||||
auto parts = partition_number_pattern(vm, *number_format, MathematicalValue(value));
|
||||
|
@ -489,7 +489,7 @@ Vector<PatternPartition> partition_duration_format_pattern(VM& vm, DurationForma
|
|||
auto* list_format_options = Object::create(realm, nullptr);
|
||||
|
||||
// 5. Perform ! CreateDataPropertyOrThrow(lfOpts, "type", "unit").
|
||||
MUST(list_format_options->create_data_property_or_throw(vm.names.type, js_string(vm, "unit"sv)));
|
||||
MUST(list_format_options->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, "unit"sv)));
|
||||
|
||||
// 6. Let listStyle be durationFormat.[[Style]].
|
||||
auto list_style = duration_format.style();
|
||||
|
@ -503,10 +503,10 @@ Vector<PatternPartition> partition_duration_format_pattern(VM& vm, DurationForma
|
|||
auto unicode_list_style = ::Locale::style_to_string(static_cast<::Locale::Style>(list_style));
|
||||
|
||||
// 8. Perform ! CreateDataPropertyOrThrow(lfOpts, "style", listStyle).
|
||||
MUST(list_format_options->create_data_property_or_throw(vm.names.style, js_string(vm, unicode_list_style)));
|
||||
MUST(list_format_options->create_data_property_or_throw(vm.names.style, PrimitiveString::create(vm, unicode_list_style)));
|
||||
|
||||
// 9. Let lf be ! Construct(%ListFormat%, « durationFormat.[[Locale]], lfOpts »).
|
||||
auto* list_format = static_cast<ListFormat*>(MUST(construct(vm, *realm.intrinsics().intl_list_format_constructor(), js_string(vm, duration_format.locale()), list_format_options)));
|
||||
auto* list_format = static_cast<ListFormat*>(MUST(construct(vm, *realm.intrinsics().intl_list_format_constructor(), PrimitiveString::create(vm, duration_format.locale()), list_format_options)));
|
||||
|
||||
// FIXME: CreatePartsFromList expects a list of strings and creates a list of Pattern Partition records, but we already created a list of Pattern Partition records
|
||||
// so we try to hack something together from it that looks mostly right
|
||||
|
|
|
@ -24,7 +24,7 @@ void DurationFormatPrototype::initialize(Realm& realm)
|
|||
auto& vm = this->vm();
|
||||
|
||||
// 1.4.2 Intl.DurationFormat.prototype [ @@toStringTag ], https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat.prototype-@@tostringtag
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.DurationFormat"), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.DurationFormat"), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(realm, vm.names.format, format, 1, attr);
|
||||
|
@ -59,7 +59,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationFormatPrototype::format)
|
|||
}
|
||||
|
||||
// 8. Return result.
|
||||
return js_string(vm, result.build());
|
||||
return PrimitiveString::create(vm, result.build());
|
||||
}
|
||||
|
||||
// 1.4.4 Intl.DurationFormat.prototype.formatToParts ( duration ), https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat.prototype.formatToParts
|
||||
|
@ -93,10 +93,10 @@ JS_DEFINE_NATIVE_FUNCTION(DurationFormatPrototype::format_to_parts)
|
|||
auto* object = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
|
||||
// b. Perform ! CreateDataPropertyOrThrow(obj, "type", part.[[Type]]).
|
||||
MUST(object->create_data_property_or_throw(vm.names.type, js_string(vm, part.type)));
|
||||
MUST(object->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, part.type)));
|
||||
|
||||
// c. Perform ! CreateDataPropertyOrThrow(obj, "value", part.[[Value]]).
|
||||
MUST(object->create_data_property_or_throw(vm.names.value, js_string(vm, part.value)));
|
||||
MUST(object->create_data_property_or_throw(vm.names.value, PrimitiveString::create(vm, part.value)));
|
||||
|
||||
// d. Perform ! CreateDataPropertyOrThrow(result, ! ToString(n), obj).
|
||||
MUST(result->create_data_property_or_throw(n, object));
|
||||
|
@ -125,30 +125,30 @@ JS_DEFINE_NATIVE_FUNCTION(DurationFormatPrototype::resolved_options)
|
|||
// b. Let v be the value of df's internal slot whose name is the Internal Slot value of the current row.
|
||||
// c. Assert: v is not undefined.
|
||||
// d. Perform ! CreateDataPropertyOrThrow(options, p, v).
|
||||
MUST(options->create_data_property_or_throw(vm.names.locale, js_string(vm, duration_format->locale())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.style, js_string(vm, duration_format->style_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.years, js_string(vm, duration_format->years_style_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.yearsDisplay, js_string(vm, duration_format->years_display_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.months, js_string(vm, duration_format->months_style_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.monthsDisplay, js_string(vm, duration_format->months_display_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.weeks, js_string(vm, duration_format->weeks_style_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.weeksDisplay, js_string(vm, duration_format->weeks_display_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.days, js_string(vm, duration_format->days_style_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.daysDisplay, js_string(vm, duration_format->days_display_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.hours, js_string(vm, duration_format->hours_style_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.hoursDisplay, js_string(vm, duration_format->hours_display_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.minutes, js_string(vm, duration_format->minutes_style_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.minutesDisplay, js_string(vm, duration_format->minutes_display_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.seconds, js_string(vm, duration_format->seconds_style_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.secondsDisplay, js_string(vm, duration_format->seconds_display_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.milliseconds, js_string(vm, duration_format->milliseconds_style_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.millisecondsDisplay, js_string(vm, duration_format->milliseconds_display_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.microseconds, js_string(vm, duration_format->microseconds_style_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.microsecondsDisplay, js_string(vm, duration_format->microseconds_display_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.nanoseconds, js_string(vm, duration_format->nanoseconds_style_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.nanosecondsDisplay, js_string(vm, duration_format->nanoseconds_display_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.locale, PrimitiveString::create(vm, duration_format->locale())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.style, PrimitiveString::create(vm, duration_format->style_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.years, PrimitiveString::create(vm, duration_format->years_style_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.yearsDisplay, PrimitiveString::create(vm, duration_format->years_display_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.months, PrimitiveString::create(vm, duration_format->months_style_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.monthsDisplay, PrimitiveString::create(vm, duration_format->months_display_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.weeks, PrimitiveString::create(vm, duration_format->weeks_style_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.weeksDisplay, PrimitiveString::create(vm, duration_format->weeks_display_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.days, PrimitiveString::create(vm, duration_format->days_style_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.daysDisplay, PrimitiveString::create(vm, duration_format->days_display_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.hours, PrimitiveString::create(vm, duration_format->hours_style_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.hoursDisplay, PrimitiveString::create(vm, duration_format->hours_display_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.minutes, PrimitiveString::create(vm, duration_format->minutes_style_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.minutesDisplay, PrimitiveString::create(vm, duration_format->minutes_display_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.seconds, PrimitiveString::create(vm, duration_format->seconds_style_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.secondsDisplay, PrimitiveString::create(vm, duration_format->seconds_display_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.milliseconds, PrimitiveString::create(vm, duration_format->milliseconds_style_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.millisecondsDisplay, PrimitiveString::create(vm, duration_format->milliseconds_display_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.microseconds, PrimitiveString::create(vm, duration_format->microseconds_style_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.microsecondsDisplay, PrimitiveString::create(vm, duration_format->microseconds_display_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.nanoseconds, PrimitiveString::create(vm, duration_format->nanoseconds_style_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.nanosecondsDisplay, PrimitiveString::create(vm, duration_format->nanoseconds_display_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.fractionalDigits, duration_format->has_fractional_digits() ? Value(duration_format->fractional_digits()) : js_undefined()));
|
||||
MUST(options->create_data_property_or_throw(vm.names.numberingSystem, js_string(vm, duration_format->numbering_system())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.numberingSystem, PrimitiveString::create(vm, duration_format->numbering_system())));
|
||||
|
||||
// 5. Return options.
|
||||
return options;
|
||||
|
|
|
@ -39,7 +39,7 @@ void Intl::initialize(Realm& realm)
|
|||
auto& vm = this->vm();
|
||||
|
||||
// 8.1.1 Intl[ @@toStringTag ], https://tc39.es/ecma402/#sec-Intl-toStringTag
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl"), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl"), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_intrinsic_accessor(vm.names.Collator, attr, [](auto& realm) -> Value { return realm.intrinsics().intl_collator_constructor(); });
|
||||
|
@ -70,7 +70,7 @@ JS_DEFINE_NATIVE_FUNCTION(Intl::get_canonical_locales)
|
|||
MarkedVector<Value> marked_locale_list { vm.heap() };
|
||||
marked_locale_list.ensure_capacity(locale_list.size());
|
||||
for (auto& locale : locale_list)
|
||||
marked_locale_list.append(js_string(vm, move(locale)));
|
||||
marked_locale_list.append(PrimitiveString::create(vm, move(locale)));
|
||||
|
||||
// 2. Return CreateArrayFromList(ll).
|
||||
return Array::create_from(realm, marked_locale_list);
|
||||
|
@ -154,7 +154,7 @@ JS_DEFINE_NATIVE_FUNCTION(Intl::supported_values_of)
|
|||
}
|
||||
|
||||
// 9. Return CreateArrayFromList( list ).
|
||||
return Array::create_from<StringView>(realm, list, [&](auto value) { return js_string(vm, value); });
|
||||
return Array::create_from<StringView>(realm, list, [&](auto value) { return PrimitiveString::create(vm, value); });
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -220,10 +220,10 @@ Array* format_list_to_parts(VM& vm, ListFormat const& list_format, Vector<Deprec
|
|||
auto* object = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
|
||||
// b. Perform ! CreateDataPropertyOrThrow(O, "type", part.[[Type]]).
|
||||
MUST(object->create_data_property_or_throw(vm.names.type, js_string(vm, part.type)));
|
||||
MUST(object->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, part.type)));
|
||||
|
||||
// c. Perform ! CreateDataPropertyOrThrow(O, "value", part.[[Value]]).
|
||||
MUST(object->create_data_property_or_throw(vm.names.value, js_string(vm, move(part.value))));
|
||||
MUST(object->create_data_property_or_throw(vm.names.value, PrimitiveString::create(vm, move(part.value))));
|
||||
|
||||
// d. Perform ! CreateDataPropertyOrThrow(result, ! ToString(n), O).
|
||||
MUST(result->create_data_property_or_throw(n, object));
|
||||
|
|
|
@ -25,7 +25,7 @@ void ListFormatPrototype::initialize(Realm& realm)
|
|||
auto& vm = this->vm();
|
||||
|
||||
// 13.3.2 Intl.ListFormat.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype-toStringTag
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.ListFormat"), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.ListFormat"), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(realm, vm.names.format, format, 1, attr);
|
||||
|
@ -47,7 +47,7 @@ JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::format)
|
|||
|
||||
// 4. Return ! FormatList(lf, stringList).
|
||||
auto formatted = format_list(*list_format, string_list);
|
||||
return js_string(vm, move(formatted));
|
||||
return PrimitiveString::create(vm, move(formatted));
|
||||
}
|
||||
|
||||
// 13.3.4 Intl.ListFormat.prototype.formatToParts ( list ), https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype.formatToParts
|
||||
|
@ -83,9 +83,9 @@ JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::resolved_options)
|
|||
// b. Let v be the value of lf's internal slot whose name is the Internal Slot value of the current row.
|
||||
// c. Assert: v is not undefined.
|
||||
// d. Perform ! CreateDataPropertyOrThrow(options, p, v).
|
||||
MUST(options->create_data_property_or_throw(vm.names.locale, js_string(vm, list_format->locale())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.type, js_string(vm, list_format->type_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.style, js_string(vm, list_format->style_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.locale, PrimitiveString::create(vm, list_format->locale())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, list_format->type_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.style, PrimitiveString::create(vm, list_format->style_string())));
|
||||
|
||||
// 5. Return options.
|
||||
return options;
|
||||
|
|
|
@ -67,7 +67,7 @@ static Array* create_array_from_list_or_restricted(VM& vm, Vector<StringView> li
|
|||
|
||||
// 2. Return ! CreateArrayFromList( list ).
|
||||
return Array::create_from<StringView>(realm, list, [&vm](auto value) {
|
||||
return js_string(vm, value);
|
||||
return PrimitiveString::create(vm, value);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,7 @@ Array* time_zones_of_locale(VM& vm, StringView region)
|
|||
|
||||
// 5. Return ! CreateArrayFromList( list ).
|
||||
return Array::create_from<StringView>(realm, list, [&vm](auto value) {
|
||||
return js_string(vm, value);
|
||||
return PrimitiveString::create(vm, value);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -346,7 +346,7 @@ ThrowCompletionOr<Object*> LocaleConstructor::construct(FunctionObject& new_targ
|
|||
// 35. If relevantExtensionKeys contains "kn", then
|
||||
if (relevant_extension_keys.span().contains_slow("kn"sv)) {
|
||||
// a. If SameValue(r.[[kn]], "true") is true or r.[[kn]] is the empty String, then
|
||||
if (result.kn.has_value() && (same_value(js_string(vm, *result.kn), js_string(vm, "true")) || result.kn->is_empty())) {
|
||||
if (result.kn.has_value() && (same_value(PrimitiveString::create(vm, *result.kn), PrimitiveString::create(vm, "true")) || result.kn->is_empty())) {
|
||||
// i. Set locale.[[Numeric]] to true.
|
||||
locale->set_numeric(true);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ void LocalePrototype::initialize(Realm& realm)
|
|||
define_native_function(realm, vm.names.toString, to_string, 0, attr);
|
||||
|
||||
// 14.3.2 Intl.Locale.prototype[ @@toStringTag ], https://tc39.es/ecma402/#sec-Intl.Locale.prototype-@@tostringtag
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.Locale"), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.Locale"), Attribute::Configurable);
|
||||
|
||||
define_native_accessor(realm, vm.names.baseName, base_name, {}, Attribute::Configurable);
|
||||
define_native_accessor(realm, vm.names.calendar, calendar, {}, Attribute::Configurable);
|
||||
|
@ -100,7 +100,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::to_string)
|
|||
auto* locale_object = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return loc.[[Locale]].
|
||||
return js_string(vm, locale_object->locale());
|
||||
return PrimitiveString::create(vm, locale_object->locale());
|
||||
}
|
||||
|
||||
// 14.3.6 get Intl.Locale.prototype.baseName, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.baseName
|
||||
|
@ -115,7 +115,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::base_name)
|
|||
VERIFY(locale.has_value());
|
||||
|
||||
// 4. Return the substring of locale corresponding to the unicode_language_id production.
|
||||
return js_string(vm, locale->language_id.to_deprecated_string());
|
||||
return PrimitiveString::create(vm, locale->language_id.to_deprecated_string());
|
||||
}
|
||||
|
||||
#define JS_ENUMERATE_LOCALE_KEYWORD_PROPERTIES \
|
||||
|
@ -130,13 +130,13 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::base_name)
|
|||
// 14.3.9 get Intl.Locale.prototype.collation, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.collation
|
||||
// 14.3.10 get Intl.Locale.prototype.hourCycle, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.hourCycle
|
||||
// 14.3.12 get Intl.Locale.prototype.numberingSystem, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.numberingSystem
|
||||
#define __JS_ENUMERATE(keyword) \
|
||||
JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::keyword) \
|
||||
{ \
|
||||
auto* locale_object = TRY(typed_this_object(vm)); \
|
||||
if (!locale_object->has_##keyword()) \
|
||||
return js_undefined(); \
|
||||
return js_string(vm, locale_object->keyword()); \
|
||||
#define __JS_ENUMERATE(keyword) \
|
||||
JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::keyword) \
|
||||
{ \
|
||||
auto* locale_object = TRY(typed_this_object(vm)); \
|
||||
if (!locale_object->has_##keyword()) \
|
||||
return js_undefined(); \
|
||||
return PrimitiveString::create(vm, locale_object->keyword()); \
|
||||
}
|
||||
JS_ENUMERATE_LOCALE_KEYWORD_PROPERTIES
|
||||
#undef __JS_ENUMERATE
|
||||
|
@ -166,7 +166,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::language)
|
|||
VERIFY(locale.has_value());
|
||||
|
||||
// 5. Return the substring of locale corresponding to the unicode_language_subtag production of the unicode_language_id.
|
||||
return js_string(vm, *locale->language_id.language);
|
||||
return PrimitiveString::create(vm, *locale->language_id.language);
|
||||
}
|
||||
|
||||
// 14.3.14 get Intl.Locale.prototype.script, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.script
|
||||
|
@ -187,7 +187,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::script)
|
|||
return js_undefined();
|
||||
|
||||
// 6. Return the substring of locale corresponding to the unicode_script_subtag production of the unicode_language_id.
|
||||
return js_string(vm, *locale->language_id.script);
|
||||
return PrimitiveString::create(vm, *locale->language_id.script);
|
||||
}
|
||||
|
||||
// 14.3.15 get Intl.Locale.prototype.region, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.region
|
||||
|
@ -208,7 +208,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::region)
|
|||
return js_undefined();
|
||||
|
||||
// 6. Return the substring of locale corresponding to the unicode_region_subtag production of the unicode_language_id.
|
||||
return js_string(vm, *locale->language_id.region);
|
||||
return PrimitiveString::create(vm, *locale->language_id.region);
|
||||
}
|
||||
|
||||
#define JS_ENUMERATE_LOCALE_INFO_PROPERTIES \
|
||||
|
@ -264,7 +264,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::text_info)
|
|||
auto direction = character_direction_of_locale(*locale_object);
|
||||
|
||||
// 5. Perform ! CreateDataPropertyOrThrow(info, "direction", dir).
|
||||
MUST(info->create_data_property_or_throw(vm.names.direction, js_string(vm, direction)));
|
||||
MUST(info->create_data_property_or_throw(vm.names.direction, PrimitiveString::create(vm, direction)));
|
||||
|
||||
// 6. Return info.
|
||||
return info;
|
||||
|
|
|
@ -246,11 +246,11 @@ Value NumberFormat::use_grouping_to_value(VM& vm) const
|
|||
{
|
||||
switch (m_use_grouping) {
|
||||
case UseGrouping::Always:
|
||||
return js_string(vm, "always"sv);
|
||||
return PrimitiveString::create(vm, "always"sv);
|
||||
case UseGrouping::Auto:
|
||||
return js_string(vm, "auto"sv);
|
||||
return PrimitiveString::create(vm, "auto"sv);
|
||||
case UseGrouping::Min2:
|
||||
return js_string(vm, "min2"sv);
|
||||
return PrimitiveString::create(vm, "min2"sv);
|
||||
case UseGrouping::False:
|
||||
return Value(false);
|
||||
default:
|
||||
|
@ -925,10 +925,10 @@ Array* format_numeric_to_parts(VM& vm, NumberFormat& number_format, Mathematical
|
|||
auto* object = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
|
||||
// b. Perform ! CreateDataPropertyOrThrow(O, "type", part.[[Type]]).
|
||||
MUST(object->create_data_property_or_throw(vm.names.type, js_string(vm, part.type)));
|
||||
MUST(object->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, part.type)));
|
||||
|
||||
// c. Perform ! CreateDataPropertyOrThrow(O, "value", part.[[Value]]).
|
||||
MUST(object->create_data_property_or_throw(vm.names.value, js_string(vm, move(part.value))));
|
||||
MUST(object->create_data_property_or_throw(vm.names.value, PrimitiveString::create(vm, move(part.value))));
|
||||
|
||||
// d. Perform ! CreateDataPropertyOrThrow(result, ! ToString(n), O).
|
||||
MUST(result->create_data_property_or_throw(n, object));
|
||||
|
@ -1835,13 +1835,13 @@ ThrowCompletionOr<Array*> format_numeric_range_to_parts(VM& vm, NumberFormat& nu
|
|||
auto* object = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
|
||||
// b. Perform ! CreateDataPropertyOrThrow(O, "type", part.[[Type]]).
|
||||
MUST(object->create_data_property_or_throw(vm.names.type, js_string(vm, part.type)));
|
||||
MUST(object->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, part.type)));
|
||||
|
||||
// c. Perform ! CreateDataPropertyOrThrow(O, "value", part.[[Value]]).
|
||||
MUST(object->create_data_property_or_throw(vm.names.value, js_string(vm, move(part.value))));
|
||||
MUST(object->create_data_property_or_throw(vm.names.value, PrimitiveString::create(vm, move(part.value))));
|
||||
|
||||
// d. Perform ! CreateDataPropertyOrThrow(O, "source", part.[[Source]]).
|
||||
MUST(object->create_data_property_or_throw(vm.names.source, js_string(vm, part.source)));
|
||||
MUST(object->create_data_property_or_throw(vm.names.source, PrimitiveString::create(vm, part.source)));
|
||||
|
||||
// e. Perform ! CreateDataPropertyOrThrow(result, ! ToString(n), O).
|
||||
MUST(result->create_data_property_or_throw(n, object));
|
||||
|
|
|
@ -29,7 +29,7 @@ void NumberFormatFunction::initialize(Realm& realm)
|
|||
|
||||
Base::initialize(realm);
|
||||
define_direct_property(vm.names.length, Value(1), Attribute::Configurable);
|
||||
define_direct_property(vm.names.name, js_string(vm, DeprecatedString::empty()), Attribute::Configurable);
|
||||
define_direct_property(vm.names.name, PrimitiveString::create(vm, DeprecatedString::empty()), Attribute::Configurable);
|
||||
}
|
||||
|
||||
ThrowCompletionOr<Value> NumberFormatFunction::call()
|
||||
|
@ -47,7 +47,7 @@ ThrowCompletionOr<Value> NumberFormatFunction::call()
|
|||
// 5. Return ? FormatNumeric(nf, x).
|
||||
// Note: Our implementation of FormatNumeric does not throw.
|
||||
auto formatted = format_numeric(vm, m_number_format, move(mathematical_value));
|
||||
return js_string(vm, move(formatted));
|
||||
return PrimitiveString::create(vm, move(formatted));
|
||||
}
|
||||
|
||||
void NumberFormatFunction::visit_edges(Cell::Visitor& visitor)
|
||||
|
|
|
@ -26,7 +26,7 @@ void NumberFormatPrototype::initialize(Realm& realm)
|
|||
auto& vm = this->vm();
|
||||
|
||||
// 15.3.2 Intl.NumberFormat.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-intl.numberformat.prototype-@@tostringtag
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.NumberFormat"), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.NumberFormat"), Attribute::Configurable);
|
||||
|
||||
define_native_accessor(realm, vm.names.format, format, nullptr, Attribute::Configurable);
|
||||
|
||||
|
@ -104,7 +104,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::format_range)
|
|||
|
||||
// 6. Return ? FormatNumericRange(nf, x, y).
|
||||
auto formatted = TRY(format_numeric_range(vm, *number_format, move(x), move(y)));
|
||||
return js_string(vm, move(formatted));
|
||||
return PrimitiveString::create(vm, move(formatted));
|
||||
}
|
||||
|
||||
// 1.4.6 Intl.NumberFormat.prototype.formatRangeToParts ( start, end ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-intl.numberformat.prototype.formatrangetoparts
|
||||
|
@ -152,19 +152,19 @@ JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::resolved_options)
|
|||
// b. Let v be the value of nf's internal slot whose name is the Internal Slot value of the current row.
|
||||
// c. If v is not undefined, then
|
||||
// i. Perform ! CreateDataPropertyOrThrow(options, p, v).
|
||||
MUST(options->create_data_property_or_throw(vm.names.locale, js_string(vm, number_format->locale())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.numberingSystem, js_string(vm, number_format->numbering_system())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.style, js_string(vm, number_format->style_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.locale, PrimitiveString::create(vm, number_format->locale())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.numberingSystem, PrimitiveString::create(vm, number_format->numbering_system())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.style, PrimitiveString::create(vm, number_format->style_string())));
|
||||
if (number_format->has_currency())
|
||||
MUST(options->create_data_property_or_throw(vm.names.currency, js_string(vm, number_format->currency())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.currency, PrimitiveString::create(vm, number_format->currency())));
|
||||
if (number_format->has_currency_display())
|
||||
MUST(options->create_data_property_or_throw(vm.names.currencyDisplay, js_string(vm, number_format->currency_display_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.currencyDisplay, PrimitiveString::create(vm, number_format->currency_display_string())));
|
||||
if (number_format->has_currency_sign())
|
||||
MUST(options->create_data_property_or_throw(vm.names.currencySign, js_string(vm, number_format->currency_sign_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.currencySign, PrimitiveString::create(vm, number_format->currency_sign_string())));
|
||||
if (number_format->has_unit())
|
||||
MUST(options->create_data_property_or_throw(vm.names.unit, js_string(vm, number_format->unit())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.unit, PrimitiveString::create(vm, number_format->unit())));
|
||||
if (number_format->has_unit_display())
|
||||
MUST(options->create_data_property_or_throw(vm.names.unitDisplay, js_string(vm, number_format->unit_display_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.unitDisplay, PrimitiveString::create(vm, number_format->unit_display_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.minimumIntegerDigits, Value(number_format->min_integer_digits())));
|
||||
if (number_format->has_min_fraction_digits())
|
||||
MUST(options->create_data_property_or_throw(vm.names.minimumFractionDigits, Value(number_format->min_fraction_digits())));
|
||||
|
@ -175,29 +175,29 @@ JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::resolved_options)
|
|||
if (number_format->has_max_significant_digits())
|
||||
MUST(options->create_data_property_or_throw(vm.names.maximumSignificantDigits, Value(number_format->max_significant_digits())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.useGrouping, number_format->use_grouping_to_value(vm)));
|
||||
MUST(options->create_data_property_or_throw(vm.names.notation, js_string(vm, number_format->notation_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.notation, PrimitiveString::create(vm, number_format->notation_string())));
|
||||
if (number_format->has_compact_display())
|
||||
MUST(options->create_data_property_or_throw(vm.names.compactDisplay, js_string(vm, number_format->compact_display_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.signDisplay, js_string(vm, number_format->sign_display_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.roundingMode, js_string(vm, number_format->rounding_mode_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.compactDisplay, PrimitiveString::create(vm, number_format->compact_display_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.signDisplay, PrimitiveString::create(vm, number_format->sign_display_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.roundingMode, PrimitiveString::create(vm, number_format->rounding_mode_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.roundingIncrement, Value(number_format->rounding_increment())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.trailingZeroDisplay, js_string(vm, number_format->trailing_zero_display_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.trailingZeroDisplay, PrimitiveString::create(vm, number_format->trailing_zero_display_string())));
|
||||
|
||||
switch (number_format->rounding_type()) {
|
||||
// 6. If nf.[[RoundingType]] is morePrecision, then
|
||||
case NumberFormatBase::RoundingType::MorePrecision:
|
||||
// a. Perform ! CreateDataPropertyOrThrow(options, "roundingPriority", "morePrecision").
|
||||
MUST(options->create_data_property_or_throw(vm.names.roundingPriority, js_string(vm, "morePrecision"sv)));
|
||||
MUST(options->create_data_property_or_throw(vm.names.roundingPriority, PrimitiveString::create(vm, "morePrecision"sv)));
|
||||
break;
|
||||
// 7. Else if nf.[[RoundingType]] is lessPrecision, then
|
||||
case NumberFormatBase::RoundingType::LessPrecision:
|
||||
// a. Perform ! CreateDataPropertyOrThrow(options, "roundingPriority", "lessPrecision").
|
||||
MUST(options->create_data_property_or_throw(vm.names.roundingPriority, js_string(vm, "lessPrecision"sv)));
|
||||
MUST(options->create_data_property_or_throw(vm.names.roundingPriority, PrimitiveString::create(vm, "lessPrecision"sv)));
|
||||
break;
|
||||
// 8. Else,
|
||||
default:
|
||||
// a. Perform ! CreateDataPropertyOrThrow(options, "roundingPriority", "auto").
|
||||
MUST(options->create_data_property_or_throw(vm.names.roundingPriority, js_string(vm, "auto"sv)));
|
||||
MUST(options->create_data_property_or_throw(vm.names.roundingPriority, PrimitiveString::create(vm, "auto"sv)));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ void PluralRulesPrototype::initialize(Realm& realm)
|
|||
auto& vm = this->vm();
|
||||
|
||||
// 16.3.2 Intl.PluralRules.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-intl.pluralrules.prototype-tostringtag
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.PluralRules"sv), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.PluralRules"sv), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(realm, vm.names.select, select, 1, attr);
|
||||
|
@ -45,7 +45,7 @@ JS_DEFINE_NATIVE_FUNCTION(PluralRulesPrototype::select)
|
|||
|
||||
// 4. Return ! ResolvePlural(pr, n).
|
||||
auto plurality = resolve_plural(*plural_rules, number);
|
||||
return js_string(vm, ::Locale::plural_category_to_string(plurality));
|
||||
return PrimitiveString::create(vm, ::Locale::plural_category_to_string(plurality));
|
||||
}
|
||||
|
||||
// 1.4.4 Intl.PluralRules.prototype.selectRange ( start, end ), https://tc39.es/proposal-intl-numberformat-v3/out/pluralrules/proposed.html#sec-intl.pluralrules.prototype.selectrange
|
||||
|
@ -72,7 +72,7 @@ JS_DEFINE_NATIVE_FUNCTION(PluralRulesPrototype::select_range)
|
|||
|
||||
// 6. Return ? ResolvePluralRange(pr, x, y).
|
||||
auto plurality = TRY(resolve_plural_range(vm, *plural_rules, x, y));
|
||||
return js_string(vm, ::Locale::plural_category_to_string(plurality));
|
||||
return PrimitiveString::create(vm, ::Locale::plural_category_to_string(plurality));
|
||||
}
|
||||
|
||||
// 16.3.4 Intl.PluralRules.prototype.resolvedOptions ( ), https://tc39.es/ecma402/#sec-intl.pluralrules.prototype.resolvedoptions
|
||||
|
@ -93,8 +93,8 @@ JS_DEFINE_NATIVE_FUNCTION(PluralRulesPrototype::resolved_options)
|
|||
// b. Let v be the value of pr's internal slot whose name is the Internal Slot value of the current row.
|
||||
// c. If v is not undefined, then
|
||||
// i. Perform ! CreateDataPropertyOrThrow(options, p, v).
|
||||
MUST(options->create_data_property_or_throw(vm.names.locale, js_string(vm, plural_rules->locale())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.type, js_string(vm, plural_rules->type_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.locale, PrimitiveString::create(vm, plural_rules->locale())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, plural_rules->type_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.minimumIntegerDigits, Value(plural_rules->min_integer_digits())));
|
||||
if (plural_rules->has_min_fraction_digits())
|
||||
MUST(options->create_data_property_or_throw(vm.names.minimumFractionDigits, Value(plural_rules->min_fraction_digits())));
|
||||
|
@ -109,7 +109,7 @@ JS_DEFINE_NATIVE_FUNCTION(PluralRulesPrototype::resolved_options)
|
|||
auto available_categories = ::Locale::available_plural_categories(plural_rules->locale(), plural_rules->type());
|
||||
|
||||
auto* plural_categories = Array::create_from<::Locale::PluralCategory>(realm, available_categories, [&](auto category) {
|
||||
return js_string(vm, ::Locale::plural_category_to_string(category));
|
||||
return PrimitiveString::create(vm, ::Locale::plural_category_to_string(category));
|
||||
});
|
||||
|
||||
// 6. Perform ! CreateDataProperty(options, "pluralCategories", CreateArrayFromList(pluralCategories)).
|
||||
|
@ -119,17 +119,17 @@ JS_DEFINE_NATIVE_FUNCTION(PluralRulesPrototype::resolved_options)
|
|||
// 7. If pr.[[RoundingType]] is morePrecision, then
|
||||
case NumberFormatBase::RoundingType::MorePrecision:
|
||||
// a. Perform ! CreateDataPropertyOrThrow(options, "roundingPriority", "morePrecision").
|
||||
MUST(options->create_data_property_or_throw(vm.names.roundingPriority, js_string(vm, "morePrecision"sv)));
|
||||
MUST(options->create_data_property_or_throw(vm.names.roundingPriority, PrimitiveString::create(vm, "morePrecision"sv)));
|
||||
break;
|
||||
// 8. Else if pr.[[RoundingType]] is lessPrecision, then
|
||||
case NumberFormatBase::RoundingType::LessPrecision:
|
||||
// a. Perform ! CreateDataPropertyOrThrow(options, "roundingPriority", "lessPrecision").
|
||||
MUST(options->create_data_property_or_throw(vm.names.roundingPriority, js_string(vm, "lessPrecision"sv)));
|
||||
MUST(options->create_data_property_or_throw(vm.names.roundingPriority, PrimitiveString::create(vm, "lessPrecision"sv)));
|
||||
break;
|
||||
// 9. Else,
|
||||
default:
|
||||
// a. Perform ! CreateDataPropertyOrThrow(options, "roundingPriority", "auto").
|
||||
MUST(options->create_data_property_or_throw(vm.names.roundingPriority, js_string(vm, "auto"sv)));
|
||||
MUST(options->create_data_property_or_throw(vm.names.roundingPriority, PrimitiveString::create(vm, "auto"sv)));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -260,15 +260,15 @@ ThrowCompletionOr<Array*> format_relative_time_to_parts(VM& vm, RelativeTimeForm
|
|||
auto* object = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
|
||||
// b. Perform ! CreateDataPropertyOrThrow(O, "type", part.[[Type]]).
|
||||
MUST(object->create_data_property_or_throw(vm.names.type, js_string(vm, part.type)));
|
||||
MUST(object->create_data_property_or_throw(vm.names.type, PrimitiveString::create(vm, part.type)));
|
||||
|
||||
// c. Perform ! CreateDataPropertyOrThrow(O, "value", part.[[Value]]).
|
||||
MUST(object->create_data_property_or_throw(vm.names.value, js_string(vm, move(part.value))));
|
||||
MUST(object->create_data_property_or_throw(vm.names.value, PrimitiveString::create(vm, move(part.value))));
|
||||
|
||||
// d. If part.[[Unit]] is not empty, then
|
||||
if (!part.unit.is_empty()) {
|
||||
// i. Perform ! CreateDataPropertyOrThrow(O, "unit", part.[[Unit]]).
|
||||
MUST(object->create_data_property_or_throw(vm.names.unit, js_string(vm, part.unit)));
|
||||
MUST(object->create_data_property_or_throw(vm.names.unit, PrimitiveString::create(vm, part.unit)));
|
||||
}
|
||||
|
||||
// e. Perform ! CreateDataPropertyOrThrow(result, ! ToString(n), O).
|
||||
|
|
|
@ -138,11 +138,11 @@ ThrowCompletionOr<RelativeTimeFormat*> initialize_relative_time_format(VM& vm, R
|
|||
relative_time_format.set_numeric(numeric.as_string().deprecated_string());
|
||||
|
||||
// 19. Let relativeTimeFormat.[[NumberFormat]] be ! Construct(%NumberFormat%, « locale »).
|
||||
auto* number_format = MUST(construct(vm, *realm.intrinsics().intl_number_format_constructor(), js_string(vm, locale)));
|
||||
auto* number_format = MUST(construct(vm, *realm.intrinsics().intl_number_format_constructor(), PrimitiveString::create(vm, locale)));
|
||||
relative_time_format.set_number_format(static_cast<NumberFormat*>(number_format));
|
||||
|
||||
// 20. Let relativeTimeFormat.[[PluralRules]] be ! Construct(%PluralRules%, « locale »).
|
||||
auto* plural_rules = MUST(construct(vm, *realm.intrinsics().intl_plural_rules_constructor(), js_string(vm, locale)));
|
||||
auto* plural_rules = MUST(construct(vm, *realm.intrinsics().intl_plural_rules_constructor(), PrimitiveString::create(vm, locale)));
|
||||
relative_time_format.set_plural_rules(static_cast<PluralRules*>(plural_rules));
|
||||
|
||||
// 21. Return relativeTimeFormat.
|
||||
|
|
|
@ -23,7 +23,7 @@ void RelativeTimeFormatPrototype::initialize(Realm& realm)
|
|||
auto& vm = this->vm();
|
||||
|
||||
// 17.3.2 Intl.RelativeTimeFormat.prototype[ @@toStringTag ], https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.prototype-toStringTag
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.RelativeTimeFormat"sv), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.RelativeTimeFormat"sv), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(realm, vm.names.format, format, 2, attr);
|
||||
|
@ -46,7 +46,7 @@ JS_DEFINE_NATIVE_FUNCTION(RelativeTimeFormatPrototype::format)
|
|||
|
||||
// 5. Return ? FormatRelativeTime(relativeTimeFormat, value, unit).
|
||||
auto formatted = TRY(format_relative_time(vm, *relative_time_format, value.as_double(), unit));
|
||||
return js_string(vm, move(formatted));
|
||||
return PrimitiveString::create(vm, move(formatted));
|
||||
}
|
||||
|
||||
// 17.3.4 Intl.RelativeTimeFormat.prototype.formatToParts ( value, unit ), https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.prototype.formatToParts
|
||||
|
@ -83,10 +83,10 @@ JS_DEFINE_NATIVE_FUNCTION(RelativeTimeFormatPrototype::resolved_options)
|
|||
// b. Let v be the value of relativeTimeFormat's internal slot whose name is the Internal Slot value of the current row.
|
||||
// c. Assert: v is not undefined.
|
||||
// d. Perform ! CreateDataPropertyOrThrow(options, p, v).
|
||||
MUST(options->create_data_property_or_throw(vm.names.locale, js_string(vm, relative_time_format->locale())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.style, js_string(vm, relative_time_format->style_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.numeric, js_string(vm, relative_time_format->numeric_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.numberingSystem, js_string(vm, relative_time_format->numbering_system())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.locale, PrimitiveString::create(vm, relative_time_format->locale())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.style, PrimitiveString::create(vm, relative_time_format->style_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.numeric, PrimitiveString::create(vm, relative_time_format->numeric_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.numberingSystem, PrimitiveString::create(vm, relative_time_format->numbering_system())));
|
||||
|
||||
// 5. Return options.
|
||||
return options;
|
||||
|
|
|
@ -25,7 +25,7 @@ void SegmentIteratorPrototype::initialize(Realm& realm)
|
|||
auto& vm = this->vm();
|
||||
|
||||
// 18.6.2.2 %SegmentIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma402/#sec-%segmentiteratorprototype%.@@tostringtag
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Segmenter String Iterator"), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Segmenter String Iterator"), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(realm, vm.names.next, next, 0, attr);
|
||||
|
|
|
@ -68,13 +68,13 @@ Object* create_segment_data_object(VM& vm, Segmenter const& segmenter, Utf16View
|
|||
auto segment = string.substring_view(start_index, end_index - start_index);
|
||||
|
||||
// 7. Perform ! CreateDataPropertyOrThrow(result, "segment", segment).
|
||||
MUST(result->create_data_property_or_throw(vm.names.segment, js_string(vm, segment)));
|
||||
MUST(result->create_data_property_or_throw(vm.names.segment, PrimitiveString::create(vm, segment)));
|
||||
|
||||
// 8. Perform ! CreateDataPropertyOrThrow(result, "index", 𝔽(startIndex)).
|
||||
MUST(result->create_data_property_or_throw(vm.names.index, Value(start_index)));
|
||||
|
||||
// 9. Perform ! CreateDataPropertyOrThrow(result, "input", string).
|
||||
MUST(result->create_data_property_or_throw(vm.names.input, js_string(vm, string)));
|
||||
MUST(result->create_data_property_or_throw(vm.names.input, PrimitiveString::create(vm, string)));
|
||||
|
||||
// 10. Let granularity be segmenter.[[SegmenterGranularity]].
|
||||
auto granularity = segmenter.segmenter_granularity();
|
||||
|
|
|
@ -24,7 +24,7 @@ void SegmenterPrototype::initialize(Realm& realm)
|
|||
auto& vm = this->vm();
|
||||
|
||||
// 18.3.2 Intl.Segmenter.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-intl.segmenter.prototype-@@tostringtag
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Intl.Segmenter"), Attribute::Configurable);
|
||||
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.Segmenter"), Attribute::Configurable);
|
||||
|
||||
u8 attr = Attribute::Writable | Attribute::Configurable;
|
||||
define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr);
|
||||
|
@ -48,8 +48,8 @@ JS_DEFINE_NATIVE_FUNCTION(SegmenterPrototype::resolved_options)
|
|||
// b. Let v be the value of segmenter's internal slot whose name is the Internal Slot value of the current row.
|
||||
// c. Assert: v is not undefined.
|
||||
// d. Perform ! CreateDataPropertyOrThrow(options, p, v).
|
||||
MUST(options->create_data_property_or_throw(vm.names.locale, js_string(vm, segmenter->locale())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.granularity, js_string(vm, segmenter->segmenter_granularity_string())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.locale, PrimitiveString::create(vm, segmenter->locale())));
|
||||
MUST(options->create_data_property_or_throw(vm.names.granularity, PrimitiveString::create(vm, segmenter->segmenter_granularity_string())));
|
||||
|
||||
// 5. Return options.
|
||||
return options;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue