1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 05:07:35 +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

@ -117,7 +117,7 @@ ThrowCompletionOr<Value> get_option(VM& vm, Object const& options, PropertyKey c
[](Empty) { return js_undefined(); },
[](bool b) { return Value(b); },
[](double d) { return Value(d); },
[&vm](StringView s) { return Value(js_string(vm, s)); });
[&vm](StringView s) { return Value(PrimitiveString::create(vm, s)); });
}
// 5. If type is "boolean", then
@ -603,7 +603,7 @@ ThrowCompletionOr<Value> to_relative_temporal_object(VM& vm, Object const& optio
auto* date_options = Object::create(realm, nullptr);
// g. Perform ! CreateDataPropertyOrThrow(dateOptions, "overflow", "constrain").
MUST(date_options->create_data_property_or_throw(vm.names.overflow, js_string(vm, "constrain"sv)));
MUST(date_options->create_data_property_or_throw(vm.names.overflow, PrimitiveString::create(vm, "constrain"sv)));
// h. Let result be ? InterpretTemporalDateTimeFields(calendar, fields, dateOptions).
result = TRY(interpret_temporal_date_time_fields(vm, *calendar, *fields, *date_options));
@ -635,10 +635,10 @@ ThrowCompletionOr<Value> to_relative_temporal_object(VM& vm, Object const& optio
result = TRY(parse_temporal_relative_to_string(vm, string));
// c. Let calendar be ? ToTemporalCalendarWithISODefault(result.[[Calendar]]).
calendar = TRY(to_temporal_calendar_with_iso_default(vm, result.calendar.has_value() ? js_string(vm, *result.calendar) : js_undefined()));
calendar = TRY(to_temporal_calendar_with_iso_default(vm, result.calendar.has_value() ? PrimitiveString::create(vm, *result.calendar) : js_undefined()));
// d. Let offsetString be result.[[TimeZone]].[[OffsetString]].
offset_string = result.time_zone.offset_string.has_value() ? js_string(vm, *result.time_zone.offset_string) : js_undefined();
offset_string = result.time_zone.offset_string.has_value() ? PrimitiveString::create(vm, *result.time_zone.offset_string) : js_undefined();
// e. Let timeZoneName be result.[[TimeZone]].[[Name]].
auto time_zone_name = result.time_zone.name;
@ -757,7 +757,7 @@ ThrowCompletionOr<Object*> merge_largest_unit_option(VM& vm, Object const& optio
}
// 4. Perform ! CreateDataPropertyOrThrow(merged, "largestUnit", largestUnit).
MUST(merged->create_data_property_or_throw(vm.names.largestUnit, js_string(vm, move(largest_unit))));
MUST(merged->create_data_property_or_throw(vm.names.largestUnit, PrimitiveString::create(vm, move(largest_unit))));
// 5. Return merged.
return merged;

View file

@ -119,7 +119,7 @@ ThrowCompletionOr<Vector<DeprecatedString>> calendar_fields(VM& vm, Object& cale
}
// 3. Let fieldsArray be ? Call(fields, calendar, « CreateArrayFromList(fieldNames) »).
auto fields_array = TRY(call(vm, *fields, &calendar, Array::create_from<StringView>(realm, field_names, [&](auto value) { return js_string(vm, value); })));
auto fields_array = TRY(call(vm, *fields, &calendar, Array::create_from<StringView>(realm, field_names, [&](auto value) { return PrimitiveString::create(vm, value); })));
// 4. Return ? IterableToListOfType(fieldsArray, « String »).
auto list = TRY(iterable_to_list_of_type(vm, fields_array, { OptionType::String }));
@ -397,7 +397,7 @@ ThrowCompletionOr<Value> calendar_era(VM& vm, Object& calendar, Object& date_lik
// 3. If result is not undefined, set result to ? ToString(result).
if (!result.is_undefined())
result = js_string(vm, TRY(result.to_string(vm)));
result = PrimitiveString::create(vm, TRY(result.to_string(vm)));
// 4. Return result.
return result;
@ -811,7 +811,7 @@ ThrowCompletionOr<double> resolve_iso_month(VM& vm, Object const& fields)
return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidMonthCode);
// 11. Let monthCodeNumber be ! ToIntegerOrInfinity(monthCodeDigits).
auto month_code_number = MUST(Value(js_string(vm, move(month_code_digits))).to_integer_or_infinity(vm));
auto month_code_number = MUST(Value(PrimitiveString::create(vm, move(month_code_digits))).to_integer_or_infinity(vm));
// 12. Assert: SameValue(monthCode, ISOMonthCode(monthCodeNumber)) is true.
VERIFY(month_code_string == iso_month_code(month_code_number));

View file

@ -36,7 +36,7 @@ void CalendarPrototype::initialize(Realm& realm)
auto& vm = this->vm();
// 12.4.2 Temporal.Calendar.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.calendar.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal.Calendar"), Attribute::Configurable);
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.Calendar"), Attribute::Configurable);
define_native_accessor(realm, vm.names.id, id_getter, {}, Attribute::Configurable);
@ -74,7 +74,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::id_getter)
auto* calendar = TRY(typed_this_object(vm));
// 3. Return calendar.[[Identifier]].
return { js_string(vm, calendar->identifier()) };
return { PrimitiveString::create(vm, calendar->identifier()) };
}
// 12.4.4 Temporal.Calendar.prototype.dateFromFields ( fields [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.calendar.prototype.datefromfields
@ -300,7 +300,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::month_code)
// NOTE: The assertion happens in iso_month() call.
// 6. Return ISOMonthCode(temporalDateLike.[[ISOMonth]]).
return js_string(vm, iso_month_code(iso_month(temporal_date_like.as_object())));
return PrimitiveString::create(vm, iso_month_code(iso_month(temporal_date_like.as_object())));
}
// 12.4.12 Temporal.Calendar.prototype.day ( temporalDateLike ), https://tc39.es/proposal-temporal/#sec-temporal.calendar.prototype.day
@ -589,7 +589,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::to_string)
auto* calendar = TRY(typed_this_object(vm));
// 3. Return calendar.[[Identifier]].
return js_string(vm, calendar->identifier());
return PrimitiveString::create(vm, calendar->identifier());
}
// 12.4.24 Temporal.Calendar.prototype.toJSON ( ), https://tc39.es/proposal-temporal/#sec-temporal.calendar.prototype.tojson
@ -600,7 +600,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::to_json)
auto* calendar = TRY(typed_this_object(vm));
// 3. Return ? ToString(calendar).
return js_string(vm, TRY(Value(calendar).to_string(vm)));
return PrimitiveString::create(vm, TRY(Value(calendar).to_string(vm)));
}
// 15.6.2.6 Temporal.Calendar.prototype.era ( temporalDateLike ), https://tc39.es/proposal-temporal/#sec-temporal.calendar.prototype.era

View file

@ -692,7 +692,7 @@ ThrowCompletionOr<DateDurationRecord> unbalance_duration_relative(VM& vm, double
auto* until_options = Object::create(realm, nullptr);
// iii. Perform ! CreateDataPropertyOrThrow(untilOptions, "largestUnit", "month").
MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, js_string(vm, "month"sv)));
MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, PrimitiveString::create(vm, "month"sv)));
// iv. Let untilResult be ? CalendarDateUntil(calendar, relativeTo, newRelativeTo, untilOptions, dateUntil).
auto* until_result = TRY(calendar_date_until(vm, *calendar, relative_to, new_relative_to, *until_options, date_until));
@ -928,7 +928,7 @@ ThrowCompletionOr<DateDurationRecord> balance_duration_relative(VM& vm, double y
auto* until_options = Object::create(realm, nullptr);
// m. Perform ! CreateDataPropertyOrThrow(untilOptions, "largestUnit", "month").
MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, js_string(vm, "month"sv)));
MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, PrimitiveString::create(vm, "month"sv)));
// n. Let untilResult be ? CalendarDateUntil(calendar, relativeTo, newRelativeTo, untilOptions, dateUntil).
auto* until_result = TRY(calendar_date_until(vm, calendar, relative_to, new_relative_to, *until_options, date_until));
@ -954,7 +954,7 @@ ThrowCompletionOr<DateDurationRecord> balance_duration_relative(VM& vm, double y
until_options = Object::create(realm, nullptr);
// vi. Perform ! CreateDataPropertyOrThrow(untilOptions, "largestUnit", "month").
MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, js_string(vm, "month"sv)));
MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, PrimitiveString::create(vm, "month"sv)));
// vii. Set untilResult to ? CalendarDateUntil(calendar, relativeTo, newRelativeTo, untilOptions, dateUntil).
until_result = TRY(calendar_date_until(vm, calendar, relative_to, new_relative_to, *until_options, date_until));
@ -1109,7 +1109,7 @@ ThrowCompletionOr<DurationRecord> add_duration(VM& vm, double years1, double mon
auto* difference_options = Object::create(realm, nullptr);
// i. Perform ! CreateDataPropertyOrThrow(differenceOptions, "largestUnit", dateLargestUnit).
MUST(difference_options->create_data_property_or_throw(vm.names.largestUnit, js_string(vm, date_largest_unit)));
MUST(difference_options->create_data_property_or_throw(vm.names.largestUnit, PrimitiveString::create(vm, date_largest_unit)));
// j. Let dateDifference be ? CalendarDateUntil(calendar, relativeTo, end, differenceOptions).
auto* date_difference = TRY(calendar_date_until(vm, calendar, &relative_to, end, *difference_options));
@ -1312,7 +1312,7 @@ ThrowCompletionOr<RoundedDuration> round_duration(VM& vm, double years, double m
auto* until_options = Object::create(realm, nullptr);
// l. Perform ! CreateDataPropertyOrThrow(untilOptions, "largestUnit", "year").
MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, js_string(vm, "year"sv)));
MUST(until_options->create_data_property_or_throw(vm.names.largestUnit, PrimitiveString::create(vm, "year"sv)));
// m. Let timePassed be ? CalendarDateUntil(calendar, relativeTo, daysLater, untilOptions).
auto* time_passed = TRY(calendar_date_until(vm, *calendar, relative_to, days_later, *until_options));

View file

@ -27,7 +27,7 @@ void DurationPrototype::initialize(Realm& realm)
auto& vm = this->vm();
// 7.3.2 Temporal.Duration.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.duration.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal.Duration"), Attribute::Configurable);
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.Duration"), Attribute::Configurable);
define_native_accessor(realm, vm.names.years, years_getter, {}, Attribute::Configurable);
define_native_accessor(realm, vm.names.months, months_getter, {}, Attribute::Configurable);
@ -586,7 +586,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::to_string)
auto result = TRY(round_duration(vm, duration->years(), duration->months(), duration->weeks(), duration->days(), duration->hours(), duration->minutes(), duration->seconds(), duration->milliseconds(), duration->microseconds(), duration->nanoseconds(), precision.increment, precision.unit, rounding_mode)).duration_record;
// 8. Return ! TemporalDurationToString(result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], result.[[Hours]], result.[[Minutes]], result.[[Seconds]], result.[[Milliseconds]], result.[[Microseconds]], result.[[Nanoseconds]], precision.[[Precision]]).
return js_string(vm, temporal_duration_to_string(result.years, result.months, result.weeks, result.days, result.hours, result.minutes, result.seconds, result.milliseconds, result.microseconds, result.nanoseconds, precision.precision));
return PrimitiveString::create(vm, temporal_duration_to_string(result.years, result.months, result.weeks, result.days, result.hours, result.minutes, result.seconds, result.milliseconds, result.microseconds, result.nanoseconds, precision.precision));
}
// 7.3.23 Temporal.Duration.prototype.toJSON ( ), https://tc39.es/proposal-temporal/#sec-temporal.duration.prototype.tojson
@ -597,7 +597,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::to_json)
auto* duration = TRY(typed_this_object(vm));
// 3. Return ! TemporalDurationToString(duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]], "auto").
return js_string(vm, temporal_duration_to_string(duration->years(), duration->months(), duration->weeks(), duration->days(), duration->hours(), duration->minutes(), duration->seconds(), duration->milliseconds(), duration->microseconds(), duration->nanoseconds(), "auto"sv));
return PrimitiveString::create(vm, temporal_duration_to_string(duration->years(), duration->months(), duration->weeks(), duration->days(), duration->hours(), duration->minutes(), duration->seconds(), duration->milliseconds(), duration->microseconds(), duration->nanoseconds(), "auto"sv));
}
// 7.3.24 Temporal.Duration.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.duration.prototype.tolocalestring
@ -609,7 +609,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::to_locale_string)
auto* duration = TRY(typed_this_object(vm));
// 3. Return ! TemporalDurationToString(duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]], "auto").
return js_string(vm, temporal_duration_to_string(duration->years(), duration->months(), duration->weeks(), duration->days(), duration->hours(), duration->minutes(), duration->seconds(), duration->milliseconds(), duration->microseconds(), duration->nanoseconds(), "auto"sv));
return PrimitiveString::create(vm, temporal_duration_to_string(duration->years(), duration->months(), duration->weeks(), duration->days(), duration->hours(), duration->minutes(), duration->seconds(), duration->milliseconds(), duration->microseconds(), duration->nanoseconds(), "auto"sv));
}
// 7.3.25 Temporal.Duration.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.duration.prototype.valueof

View file

@ -31,7 +31,7 @@ void InstantPrototype::initialize(Realm& realm)
auto& vm = this->vm();
// 8.3.2 Temporal.Instant.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.instant.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal.Instant"), Attribute::Configurable);
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.Instant"), Attribute::Configurable);
define_native_accessor(realm, vm.names.epochSeconds, epoch_seconds_getter, {}, Attribute::Configurable);
define_native_accessor(realm, vm.names.epochMilliseconds, epoch_milliseconds_getter, {}, Attribute::Configurable);
@ -312,7 +312,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::to_string)
auto* rounded_instant = MUST(create_temporal_instant(vm, *rounded_ns));
// 10. Return ? TemporalInstantToString(roundedInstant, timeZone, precision.[[Precision]]).
return js_string(vm, TRY(temporal_instant_to_string(vm, *rounded_instant, time_zone, precision.precision)));
return PrimitiveString::create(vm, TRY(temporal_instant_to_string(vm, *rounded_instant, time_zone, precision.precision)));
}
// 8.3.14 Temporal.Instant.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.instant.prototype.tolocalestring
@ -324,7 +324,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::to_locale_string)
auto* instant = TRY(typed_this_object(vm));
// 3. Return ? TemporalInstantToString(instant, undefined, "auto").
return js_string(vm, TRY(temporal_instant_to_string(vm, *instant, js_undefined(), "auto"sv)));
return PrimitiveString::create(vm, TRY(temporal_instant_to_string(vm, *instant, js_undefined(), "auto"sv)));
}
// 8.3.15 Temporal.Instant.prototype.toJSON ( ), https://tc39.es/proposal-temporal/#sec-temporal.instant.prototype.tojson
@ -335,7 +335,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::to_json)
auto* instant = TRY(typed_this_object(vm));
// 3. Return ? TemporalInstantToString(instant, undefined, "auto").
return js_string(vm, TRY(temporal_instant_to_string(vm, *instant, js_undefined(), "auto"sv)));
return PrimitiveString::create(vm, TRY(temporal_instant_to_string(vm, *instant, js_undefined(), "auto"sv)));
}
// 8.3.16 Temporal.Instant.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.instant.prototype.valueof

View file

@ -33,7 +33,7 @@ void Now::initialize(Realm& realm)
auto& vm = this->vm();
// 2.1.1 Temporal.Now [ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal-now-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal.Now"), Attribute::Configurable);
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.Now"), Attribute::Configurable);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_native_function(realm, vm.names.timeZone, time_zone, 0, attr);

View file

@ -149,7 +149,7 @@ ThrowCompletionOr<PlainDate*> to_temporal_date(VM& vm, Value item, Object const*
VERIFY(is_valid_iso_date(result.year, result.month, result.day));
// 8. Let calendar be ? ToTemporalCalendarWithISODefault(result.[[Calendar]]).
auto* calendar = TRY(to_temporal_calendar_with_iso_default(vm, result.calendar.has_value() ? js_string(vm, *result.calendar) : js_undefined()));
auto* calendar = TRY(to_temporal_calendar_with_iso_default(vm, result.calendar.has_value() ? PrimitiveString::create(vm, *result.calendar) : js_undefined()));
// 9. Return ? CreateTemporalDate(result.[[Year]], result.[[Month]], result.[[Day]], calendar).
return create_temporal_date(vm, result.year, result.month, result.day, *calendar);

View file

@ -32,7 +32,7 @@ void PlainDatePrototype::initialize(Realm& realm)
auto& vm = this->vm();
// 3.3.2 Temporal.PlainDate.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal.PlainDate"), Attribute::Configurable);
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.PlainDate"), Attribute::Configurable);
define_native_accessor(realm, vm.names.calendar, calendar_getter, {}, Attribute::Configurable);
define_native_accessor(realm, vm.names.year, year_getter, {}, Attribute::Configurable);
@ -119,7 +119,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::month_code_getter)
auto& calendar = temporal_date->calendar();
// 4. Return ? CalendarMonthCode(calendar, temporalDate).
return js_string(vm, TRY(calendar_month_code(vm, calendar, *temporal_date)));
return PrimitiveString::create(vm, TRY(calendar_month_code(vm, calendar, *temporal_date)));
}
// 3.3.7 get Temporal.PlainDate.prototype.day, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindate.prototype.day
@ -599,7 +599,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::to_string)
auto show_calendar = TRY(to_calendar_name_option(vm, *options));
// 5. Return ? TemporalDateToString(temporalDate, showCalendar).
return js_string(vm, TRY(temporal_date_to_string(vm, *temporal_date, show_calendar)));
return PrimitiveString::create(vm, TRY(temporal_date_to_string(vm, *temporal_date, show_calendar)));
}
// 3.3.29 Temporal.PlainDate.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype.tolocalestring
@ -611,7 +611,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::to_locale_string)
auto* temporal_date = TRY(typed_this_object(vm));
// 3. Return ? TemporalDateToString(temporalDate, "auto").
return js_string(vm, TRY(temporal_date_to_string(vm, *temporal_date, "auto"sv)));
return PrimitiveString::create(vm, TRY(temporal_date_to_string(vm, *temporal_date, "auto"sv)));
}
// 3.3.30 Temporal.PlainDate.prototype.toJSON ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype.tojson
@ -622,7 +622,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::to_json)
auto* temporal_date = TRY(typed_this_object(vm));
// 3. Return ? TemporalDateToString(temporalDate, "auto").
return js_string(vm, TRY(temporal_date_to_string(vm, *temporal_date, "auto"sv)));
return PrimitiveString::create(vm, TRY(temporal_date_to_string(vm, *temporal_date, "auto"sv)));
}
// 3.3.31 Temporal.PlainDate.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype.valueof

View file

@ -177,7 +177,7 @@ ThrowCompletionOr<PlainDateTime*> to_temporal_date_time(VM& vm, Value item, Obje
VERIFY(is_valid_time(result.hour, result.minute, result.second, result.millisecond, result.microsecond, result.nanosecond));
// f. Let calendar be ? ToTemporalCalendarWithISODefault(result.[[Calendar]]).
calendar = TRY(to_temporal_calendar_with_iso_default(vm, result.calendar.has_value() ? js_string(vm, *result.calendar) : js_undefined()));
calendar = TRY(to_temporal_calendar_with_iso_default(vm, result.calendar.has_value() ? PrimitiveString::create(vm, *result.calendar) : js_undefined()));
}
// 5. Return ? CreateTemporalDateTime(result.[[Year]], result.[[Month]], result.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]], calendar).

View file

@ -33,7 +33,7 @@ void PlainDateTimePrototype::initialize(Realm& realm)
auto& vm = this->vm();
// 5.3.2 Temporal.PlainDateTime.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal.PlainDateTime"), Attribute::Configurable);
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.PlainDateTime"), Attribute::Configurable);
define_native_accessor(realm, vm.names.calendar, calendar_getter, {}, Attribute::Configurable);
define_native_accessor(realm, vm.names.year, year_getter, {}, Attribute::Configurable);
@ -130,7 +130,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::month_code_getter)
auto& calendar = date_time->calendar();
// 4. Return ? CalendarMonthCode(calendar, dateTime).
return js_string(vm, TRY(calendar_month_code(vm, calendar, *date_time)));
return PrimitiveString::create(vm, TRY(calendar_month_code(vm, calendar, *date_time)));
}
// 5.3.7 get Temporal.PlainDateTime.prototype.day, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindatetime.prototype.day
@ -607,7 +607,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::to_string)
auto result = round_iso_date_time(date_time->iso_year(), date_time->iso_month(), date_time->iso_day(), date_time->iso_hour(), date_time->iso_minute(), date_time->iso_second(), date_time->iso_millisecond(), date_time->iso_microsecond(), date_time->iso_nanosecond(), precision.increment, precision.unit, rounding_mode);
// 8. Return ? TemporalDateTimeToString(result.[[Year]], result.[[Month]], result.[[Day]], result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]], dateTime.[[Calendar]], precision.[[Precision]], showCalendar).
return js_string(vm, TRY(temporal_date_time_to_string(vm, result.year, result.month, result.day, result.hour, result.minute, result.second, result.millisecond, result.microsecond, result.nanosecond, &date_time->calendar(), precision.precision, show_calendar)));
return PrimitiveString::create(vm, TRY(temporal_date_time_to_string(vm, result.year, result.month, result.day, result.hour, result.minute, result.second, result.millisecond, result.microsecond, result.nanosecond, &date_time->calendar(), precision.precision, show_calendar)));
}
// 5.3.33 Temporal.PlainDateTime.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype.tolocalestring
@ -619,7 +619,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::to_locale_string)
auto* date_time = TRY(typed_this_object(vm));
// 3. Return ? TemporalDateTimeToString(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]], dateTime.[[Calendar]], "auto", "auto").
return js_string(vm, TRY(temporal_date_time_to_string(vm, date_time->iso_year(), date_time->iso_month(), date_time->iso_day(), date_time->iso_hour(), date_time->iso_minute(), date_time->iso_second(), date_time->iso_millisecond(), date_time->iso_microsecond(), date_time->iso_nanosecond(), &date_time->calendar(), "auto"sv, "auto"sv)));
return PrimitiveString::create(vm, TRY(temporal_date_time_to_string(vm, date_time->iso_year(), date_time->iso_month(), date_time->iso_day(), date_time->iso_hour(), date_time->iso_minute(), date_time->iso_second(), date_time->iso_millisecond(), date_time->iso_microsecond(), date_time->iso_nanosecond(), &date_time->calendar(), "auto"sv, "auto"sv)));
}
// 5.3.34 Temporal.PlainDateTime.prototype.toJSON ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype.tojson
@ -630,7 +630,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::to_json)
auto* date_time = TRY(typed_this_object(vm));
// 3. Return ? TemporalDateTimeToString(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]], dateTime.[[Calendar]], "auto", "auto").
return js_string(vm, TRY(temporal_date_time_to_string(vm, date_time->iso_year(), date_time->iso_month(), date_time->iso_day(), date_time->iso_hour(), date_time->iso_minute(), date_time->iso_second(), date_time->iso_millisecond(), date_time->iso_microsecond(), date_time->iso_nanosecond(), &date_time->calendar(), "auto"sv, "auto"sv)));
return PrimitiveString::create(vm, TRY(temporal_date_time_to_string(vm, date_time->iso_year(), date_time->iso_month(), date_time->iso_day(), date_time->iso_hour(), date_time->iso_minute(), date_time->iso_second(), date_time->iso_millisecond(), date_time->iso_microsecond(), date_time->iso_nanosecond(), &date_time->calendar(), "auto"sv, "auto"sv)));
}
// 5.3.35 Temporal.PlainDateTime.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype.valueof

View file

@ -126,7 +126,7 @@ ThrowCompletionOr<PlainMonthDay*> to_temporal_month_day(VM& vm, Value item, Obje
auto result = TRY(parse_temporal_month_day_string(vm, string));
// 8. Let calendar be ? ToTemporalCalendarWithISODefault(result.[[Calendar]]).
auto* calendar = TRY(to_temporal_calendar_with_iso_default(vm, result.calendar.has_value() ? js_string(vm, move(*result.calendar)) : js_undefined()));
auto* calendar = TRY(to_temporal_calendar_with_iso_default(vm, result.calendar.has_value() ? PrimitiveString::create(vm, move(*result.calendar)) : js_undefined()));
// 9. If result.[[Year]] is undefined, then
if (!result.year.has_value()) {

View file

@ -27,7 +27,7 @@ void PlainMonthDayPrototype::initialize(Realm& realm)
auto& vm = this->vm();
// 10.3.2 Temporal.PlainMonthDay.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal.PlainMonthDay"), Attribute::Configurable);
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.PlainMonthDay"), Attribute::Configurable);
define_native_accessor(realm, vm.names.calendar, calendar_getter, {}, Attribute::Configurable);
define_native_accessor(realm, vm.names.monthCode, month_code_getter, {}, Attribute::Configurable);
@ -66,7 +66,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::month_code_getter)
auto& calendar = month_day->calendar();
// 4. Return ? CalendarMonthCode(calendar, monthDay).
return js_string(vm, TRY(calendar_month_code(vm, calendar, *month_day)));
return PrimitiveString::create(vm, TRY(calendar_month_code(vm, calendar, *month_day)));
}
// 10.3.5 get Temporal.PlainMonthDay.prototype.day, https://tc39.es/proposal-temporal/#sec-get-temporal.plainmonthday.prototype.day
@ -166,7 +166,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::to_string)
auto show_calendar = TRY(to_calendar_name_option(vm, *options));
// 5. Return ? TemporalMonthDayToString(monthDay, showCalendar).
return js_string(vm, TRY(temporal_month_day_to_string(vm, *month_day, show_calendar)));
return PrimitiveString::create(vm, TRY(temporal_month_day_to_string(vm, *month_day, show_calendar)));
}
// 10.3.9 Temporal.PlainMonthDay.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday.prototype.tolocalestring
@ -178,7 +178,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::to_locale_string)
auto* month_day = TRY(typed_this_object(vm));
// 3. Return ? TemporalMonthDayToString(monthDay, "auto").
return js_string(vm, TRY(temporal_month_day_to_string(vm, *month_day, "auto"sv)));
return PrimitiveString::create(vm, TRY(temporal_month_day_to_string(vm, *month_day, "auto"sv)));
}
// 10.3.10 Temporal.PlainMonthDay.prototype.toJSON ( ), https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday.prototype.tojson
@ -189,7 +189,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::to_json)
auto* month_day = TRY(typed_this_object(vm));
// 3. Return ? TemporalMonthDayToString(monthDay, "auto").
return js_string(vm, TRY(temporal_month_day_to_string(vm, *month_day, "auto"sv)));
return PrimitiveString::create(vm, TRY(temporal_month_day_to_string(vm, *month_day, "auto"sv)));
}
// 10.3.11 Temporal.PlainMonthDay.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday.prototype.valueof
@ -244,7 +244,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::to_plain_date)
auto* options = Object::create(realm, nullptr);
// 13. Perform ! CreateDataPropertyOrThrow(options, "overflow", "reject").
MUST(options->create_data_property_or_throw(vm.names.overflow, js_string(vm, vm.names.reject.as_string())));
MUST(options->create_data_property_or_throw(vm.names.overflow, PrimitiveString::create(vm, vm.names.reject.as_string())));
// 14. Return ? CalendarDateFromFields(calendar, mergedFields, options).
return TRY(calendar_date_from_fields(vm, calendar, *merged_fields, options));

View file

@ -32,7 +32,7 @@ void PlainTimePrototype::initialize(Realm& realm)
auto& vm = this->vm();
// 4.3.2 Temporal.PlainTime.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal.PlainTime"), Attribute::Configurable);
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.PlainTime"), Attribute::Configurable);
define_native_accessor(realm, vm.names.calendar, calendar_getter, {}, Attribute::Configurable);
define_native_accessor(realm, vm.names.hour, hour_getter, {}, Attribute::Configurable);
@ -473,7 +473,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::to_string)
// 7. Return ! TemporalTimeToString(roundResult.[[Hour]], roundResult.[[Minute]], roundResult.[[Second]], roundResult.[[Millisecond]], roundResult.[[Microsecond]], roundResult.[[Nanosecond]], precision.[[Precision]]).
auto string = temporal_time_to_string(round_result.hour, round_result.minute, round_result.second, round_result.millisecond, round_result.microsecond, round_result.nanosecond, precision.precision);
return js_string(vm, move(string));
return PrimitiveString::create(vm, move(string));
}
// 4.3.21 Temporal.PlainTime.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.tolocalestring
@ -485,7 +485,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::to_locale_string)
// 3. Return ! TemporalTimeToString(temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], "auto").
auto string = temporal_time_to_string(temporal_time->iso_hour(), temporal_time->iso_minute(), temporal_time->iso_second(), temporal_time->iso_millisecond(), temporal_time->iso_microsecond(), temporal_time->iso_nanosecond(), "auto"sv);
return js_string(vm, move(string));
return PrimitiveString::create(vm, move(string));
}
// 4.3.22 Temporal.PlainTime.prototype.toJSON ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.tojson
@ -497,7 +497,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::to_json)
// 3. Return ! TemporalTimeToString(temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], "auto").
auto string = temporal_time_to_string(temporal_time->iso_hour(), temporal_time->iso_minute(), temporal_time->iso_second(), temporal_time->iso_millisecond(), temporal_time->iso_microsecond(), temporal_time->iso_nanosecond(), "auto"sv);
return js_string(vm, move(string));
return PrimitiveString::create(vm, move(string));
}
// 4.3.23 Temporal.PlainTime.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.valueof

View file

@ -72,7 +72,7 @@ ThrowCompletionOr<PlainYearMonth*> to_temporal_year_month(VM& vm, Value item, Ob
auto result = TRY(parse_temporal_year_month_string(vm, string));
// 7. Let calendar be ? ToTemporalCalendarWithISODefault(result.[[Calendar]]).
auto* calendar = TRY(to_temporal_calendar_with_iso_default(vm, result.calendar.has_value() ? js_string(vm, *result.calendar) : js_undefined()));
auto* calendar = TRY(to_temporal_calendar_with_iso_default(vm, result.calendar.has_value() ? PrimitiveString::create(vm, *result.calendar) : js_undefined()));
// 8. Set result to ? CreateTemporalYearMonth(result.[[Year]], result.[[Month]], calendar, result.[[Day]]).
auto* creation_result = TRY(create_temporal_year_month(vm, result.year, result.month, *calendar, result.day));

View file

@ -29,7 +29,7 @@ void PlainYearMonthPrototype::initialize(Realm& realm)
auto& vm = this->vm();
// 9.3.2 Temporal.PlainYearMonth.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal.PlainYearMonth"), Attribute::Configurable);
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.PlainYearMonth"), Attribute::Configurable);
define_native_accessor(realm, vm.names.calendar, calendar_getter, {}, Attribute::Configurable);
define_native_accessor(realm, vm.names.year, year_getter, {}, Attribute::Configurable);
@ -107,7 +107,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::month_code_getter)
auto& calendar = year_month->calendar();
// 4. Return ? CalendarMonthCode(calendar, yearMonth).
return js_string(vm, TRY(calendar_month_code(vm, calendar, *year_month)));
return PrimitiveString::create(vm, TRY(calendar_month_code(vm, calendar, *year_month)));
}
// 9.3.7 get Temporal.PlainYearMonth.prototype.daysInYear, https://tc39.es/proposal-temporal/#sec-get-temporal.plainyearmonth.prototype.daysinyear
@ -333,7 +333,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::to_string)
auto show_calendar = TRY(to_calendar_name_option(vm, *options));
// 5. Return ? TemporalYearMonthToString(yearMonth, showCalendar).
return js_string(vm, TRY(temporal_year_month_to_string(vm, *year_month, show_calendar)));
return PrimitiveString::create(vm, TRY(temporal_year_month_to_string(vm, *year_month, show_calendar)));
}
// 9.3.18 Temporal.PlainYearMonth.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.prototype.tolocalestring
@ -345,7 +345,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::to_locale_string)
auto* year_month = TRY(typed_this_object(vm));
// 3. Return ? TemporalYearMonthToString(yearMonth, "auto").
return js_string(vm, TRY(temporal_year_month_to_string(vm, *year_month, "auto"sv)));
return PrimitiveString::create(vm, TRY(temporal_year_month_to_string(vm, *year_month, "auto"sv)));
}
// 9.3.19 Temporal.PlainYearMonth.prototype.toJSON ( ), https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.prototype.tojson
@ -356,7 +356,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::to_json)
auto* year_month = TRY(typed_this_object(vm));
// 3. Return ? TemporalYearMonthToString(yearMonth, "auto").
return js_string(vm, TRY(temporal_year_month_to_string(vm, *year_month, "auto"sv)));
return PrimitiveString::create(vm, TRY(temporal_year_month_to_string(vm, *year_month, "auto"sv)));
}
// 9.3.20 Temporal.PlainYearMonth.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.prototype.valueof
@ -411,7 +411,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::to_plain_date)
auto* options = Object::create(realm, nullptr);
// 13. Perform ! CreateDataPropertyOrThrow(options, "overflow", "reject").
MUST(options->create_data_property_or_throw(vm.names.overflow, js_string(vm, vm.names.reject.as_string())));
MUST(options->create_data_property_or_throw(vm.names.overflow, PrimitiveString::create(vm, vm.names.reject.as_string())));
// 14. Return ? CalendarDateFromFields(calendar, mergedFields, options).
return TRY(calendar_date_from_fields(vm, calendar, *merged_fields, options));

View file

@ -33,7 +33,7 @@ void Temporal::initialize(Realm& realm)
auto& vm = this->vm();
// 1.1.1 Temporal [ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal"), Attribute::Configurable);
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal"), Attribute::Configurable);
u8 attr = Attribute::Writable | Attribute::Configurable;
define_direct_property(vm.names.Now, heap().allocate<Now>(realm, realm), attr);

View file

@ -42,7 +42,7 @@ void TimeZonePrototype::initialize(Realm& realm)
define_native_function(realm, vm.names.toJSON, to_json, 0, attr);
// 11.4.2 Temporal.TimeZone.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.timezone.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal.TimeZone"), Attribute::Configurable);
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.TimeZone"), Attribute::Configurable);
}
// 11.4.3 get Temporal.TimeZone.prototype.id, https://tc39.es/proposal-temporal/#sec-get-temporal.timezone.prototype.id
@ -53,7 +53,7 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::id_getter)
auto* time_zone = TRY(typed_this_object(vm));
// 3. Return timeZone.[[Identifier]].
return js_string(vm, time_zone->identifier());
return PrimitiveString::create(vm, time_zone->identifier());
}
// 11.4.4 Temporal.TimeZone.prototype.getOffsetNanosecondsFor ( instant ), https://tc39.es/proposal-temporal/#sec-temporal.timezone.prototype.getoffsetnanosecondsfor
@ -86,7 +86,7 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::get_offset_string_for)
// 4. Return ? BuiltinTimeZoneGetOffsetStringFor(timeZone, instant).
auto offset_string = TRY(builtin_time_zone_get_offset_string_for(vm, time_zone, *instant));
return js_string(vm, move(offset_string));
return PrimitiveString::create(vm, move(offset_string));
}
// 11.4.6 Temporal.TimeZone.prototype.getPlainDateTimeFor ( instant [ , calendarLike ] ), https://tc39.es/proposal-temporal/#sec-temporal.timezone.prototype.getplaindatetimefor
@ -233,7 +233,7 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::to_string)
auto* time_zone = TRY(typed_this_object(vm));
// 3. Return timeZone.[[Identifier]].
return js_string(vm, time_zone->identifier());
return PrimitiveString::create(vm, time_zone->identifier());
}
// 11.4.12 Temporal.TimeZone.prototype.toJSON ( ), https://tc39.es/proposal-temporal/#sec-temporal.timezone.prototype.tojson
@ -244,7 +244,7 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::to_json)
auto* time_zone = TRY(typed_this_object(vm));
// 3. Return ? ToString(timeZone).
return js_string(vm, TRY(Value(time_zone).to_string(vm)));
return PrimitiveString::create(vm, TRY(Value(time_zone).to_string(vm)));
}
}

View file

@ -227,7 +227,7 @@ ThrowCompletionOr<ZonedDateTime*> to_temporal_zoned_date_time(VM& vm, Value item
// k. Let calendar be ? ToTemporalCalendarWithISODefault(result.[[Calendar]]).
auto temporal_calendar_like = result.calendar.has_value()
? js_string(vm, result.calendar.value())
? PrimitiveString::create(vm, result.calendar.value())
: js_undefined();
calendar = TRY(to_temporal_calendar_with_iso_default(vm, temporal_calendar_like));

View file

@ -33,7 +33,7 @@ void ZonedDateTimePrototype::initialize(Realm& realm)
auto& vm = this->vm();
// 6.3.2 Temporal.ZonedDateTime.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype-@@tostringtag
define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal.ZonedDateTime"), Attribute::Configurable);
define_direct_property(*vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Temporal.ZonedDateTime"), Attribute::Configurable);
define_native_accessor(realm, vm.names.calendar, calendar_getter, {}, Attribute::Configurable);
define_native_accessor(realm, vm.names.timeZone, time_zone_getter, {}, Attribute::Configurable);
@ -179,7 +179,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::month_code_getter)
auto* temporal_date_time = TRY(builtin_time_zone_get_plain_date_time_for(vm, &time_zone, *instant, calendar));
// 7. Return ? CalendarMonthCode(calendar, temporalDateTime).
return js_string(vm, TRY(calendar_month_code(vm, calendar, *temporal_date_time)));
return PrimitiveString::create(vm, TRY(calendar_month_code(vm, calendar, *temporal_date_time)));
}
// 6.3.8 get Temporal.ZonedDateTime.prototype.day, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.day
@ -669,7 +669,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::offset_getter)
// 4. Return ? BuiltinTimeZoneGetOffsetStringFor(zonedDateTime.[[TimeZone]], instant).
auto offset_string = TRY(builtin_time_zone_get_offset_string_for(vm, &zoned_date_time->time_zone(), *instant));
return js_string(vm, move(offset_string));
return PrimitiveString::create(vm, move(offset_string));
}
// 15.6.10.2 get Temporal.ZonedDateTime.prototype.era, https://tc39.es/proposal-temporal/#sec-get-temporal.zoneddatetime.prototype.era
@ -1093,7 +1093,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_string)
auto show_offset = TRY(to_show_offset_option(vm, *options));
// 9. Return ? TemporalZonedDateTimeToString(zonedDateTime, precision.[[Precision]], showCalendar, showTimeZone, showOffset, precision.[[Increment]], precision.[[Unit]], roundingMode).
return js_string(vm, TRY(temporal_zoned_date_time_to_string(vm, *zoned_date_time, precision.precision, show_calendar, show_time_zone, show_offset, precision.increment, precision.unit, rounding_mode)));
return PrimitiveString::create(vm, TRY(temporal_zoned_date_time_to_string(vm, *zoned_date_time, precision.precision, show_calendar, show_time_zone, show_offset, precision.increment, precision.unit, rounding_mode)));
}
// 6.3.42 Temporal.ZonedDateTime.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.tolocalestring
@ -1105,7 +1105,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_locale_string)
auto* zoned_date_time = TRY(typed_this_object(vm));
// 3. Return ? TemporalZonedDateTimeToString(zonedDateTime, "auto", "auto", "auto", "auto").
return js_string(vm, TRY(temporal_zoned_date_time_to_string(vm, *zoned_date_time, "auto"sv, "auto"sv, "auto"sv, "auto"sv)));
return PrimitiveString::create(vm, TRY(temporal_zoned_date_time_to_string(vm, *zoned_date_time, "auto"sv, "auto"sv, "auto"sv, "auto"sv)));
}
// 6.3.43 Temporal.ZonedDateTime.prototype.toJSON ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.tojson
@ -1116,7 +1116,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_json)
auto* zoned_date_time = TRY(typed_this_object(vm));
// 3. Return ? TemporalZonedDateTimeToString(zonedDateTime, "auto", "auto", "auto", "auto").
return js_string(vm, TRY(temporal_zoned_date_time_to_string(vm, *zoned_date_time, "auto"sv, "auto"sv, "auto"sv, "auto"sv)));
return PrimitiveString::create(vm, TRY(temporal_zoned_date_time_to_string(vm, *zoned_date_time, "auto"sv, "auto"sv, "auto"sv, "auto"sv)));
}
// 6.3.44 Temporal.ZonedDateTime.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.valueof
@ -1345,7 +1345,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::get_iso_fields)
MUST(fields->create_data_property_or_throw(vm.names.isoYear, Value(date_time->iso_year())));
// 19. Perform ! CreateDataPropertyOrThrow(fields, "offset", offset).
MUST(fields->create_data_property_or_throw(vm.names.offset, js_string(vm, offset)));
MUST(fields->create_data_property_or_throw(vm.names.offset, PrimitiveString::create(vm, offset)));
// 20. Perform ! CreateDataPropertyOrThrow(fields, "timeZone", timeZone).
MUST(fields->create_data_property_or_throw(vm.names.timeZone, Value(&time_zone)));