LibJS: Port PrototypeObject::typed_this_object() to NonnullGCPtr
This commit is contained in:
parent
15360e50d3
commit
a23dd88f61
Notes:
sideshowbarker
2024-07-17 21:11:12 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/a23dd88f61 Pull-request: https://github.com/SerenityOS/serenity/pull/18346
36 changed files with 491 additions and 491 deletions
Userland/Libraries/LibJS/Runtime
AsyncFromSyncIteratorPrototype.cppDatePrototype.cppDisposableStackPrototype.cppFinalizationRegistryPrototype.cppGeneratorPrototype.cpp
Intl
CollatorPrototype.cppDateTimeFormatPrototype.cppDisplayNamesPrototype.cppDurationFormatPrototype.cppListFormatPrototype.cppLocalePrototype.cppNumberFormatPrototype.cppPluralRulesPrototype.cppRelativeTimeFormatPrototype.cppSegmentIteratorPrototype.cppSegmenterPrototype.cppSegmentsPrototype.cpp
MapPrototype.cppPromisePrototype.cppPrototypeObject.hRegExpPrototype.cppSetPrototype.cppShadowRealmPrototype.cppTemporal
CalendarPrototype.cppDurationPrototype.cppInstantPrototype.cppPlainDatePrototype.cppPlainDateTimePrototype.cppPlainMonthDayPrototype.cppPlainTimePrototype.cppPlainYearMonthPrototype.cppTimeZonePrototype.cppZonedDateTimePrototype.cpp
WeakMapPrototype.cppWeakRefPrototype.cppWeakSetPrototype.cpp
|
@ -74,7 +74,7 @@ JS_DEFINE_NATIVE_FUNCTION(AsyncFromSyncIteratorPrototype::next)
|
|||
|
||||
// 1. Let O be the this value.
|
||||
// 2. Assert: O is an Object that has a [[SyncIteratorRecord]] internal slot.
|
||||
auto* this_object = MUST(typed_this_object(vm));
|
||||
auto this_object = MUST(typed_this_object(vm));
|
||||
|
||||
// 3. Let promiseCapability be ! NewPromiseCapability(%Promise%).
|
||||
auto promise_capability = MUST(new_promise_capability(vm, realm.intrinsics().promise_constructor()));
|
||||
|
@ -102,7 +102,7 @@ JS_DEFINE_NATIVE_FUNCTION(AsyncFromSyncIteratorPrototype::return_)
|
|||
|
||||
// 1. Let O be the this value.
|
||||
// 2. Assert: O is an Object that has a [[SyncIteratorRecord]] internal slot.
|
||||
auto* this_object = MUST(typed_this_object(vm));
|
||||
auto this_object = MUST(typed_this_object(vm));
|
||||
|
||||
// 3. Let promiseCapability be ! NewPromiseCapability(%Promise%).
|
||||
auto promise_capability = MUST(new_promise_capability(vm, realm.intrinsics().promise_constructor()));
|
||||
|
@ -155,7 +155,7 @@ JS_DEFINE_NATIVE_FUNCTION(AsyncFromSyncIteratorPrototype::throw_)
|
|||
|
||||
// 1. Let O be the this value.
|
||||
// 2. Assert: O is an Object that has a [[SyncIteratorRecord]] internal slot.
|
||||
auto* this_object = MUST(typed_this_object(vm));
|
||||
auto this_object = MUST(typed_this_object(vm));
|
||||
|
||||
// 3. Let promiseCapability be ! NewPromiseCapability(%Promise%).
|
||||
auto promise_capability = MUST(new_promise_capability(vm, realm.intrinsics().promise_constructor()));
|
||||
|
|
|
@ -400,7 +400,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_date)
|
|||
new_date = time_clip(utc_time(new_date));
|
||||
|
||||
// 7. Set the [[DateValue]] internal slot of this Date object to u.
|
||||
auto* this_object = MUST(typed_this_object(vm));
|
||||
auto this_object = MUST(typed_this_object(vm));
|
||||
this_object->set_date_value(new_date);
|
||||
|
||||
// 8. Return u.
|
||||
|
@ -435,7 +435,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_full_year)
|
|||
new_date = time_clip(utc_time(new_date));
|
||||
|
||||
// 8. Set the [[DateValue]] internal slot of this Date object to u.
|
||||
auto* this_object = MUST(typed_this_object(vm));
|
||||
auto this_object = MUST(typed_this_object(vm));
|
||||
this_object->set_date_value(new_date);
|
||||
|
||||
// 9. Return u.
|
||||
|
@ -487,7 +487,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_hours)
|
|||
date = time_clip(utc_time(date));
|
||||
|
||||
// 13. Set the [[DateValue]] internal slot of this Date object to u.
|
||||
auto* this_object = MUST(typed_this_object(vm));
|
||||
auto this_object = MUST(typed_this_object(vm));
|
||||
this_object->set_date_value(date);
|
||||
|
||||
// 14. Return u.
|
||||
|
@ -522,7 +522,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_milliseconds)
|
|||
date = time_clip(utc_time(date));
|
||||
|
||||
// 7. Set the [[DateValue]] internal slot of this Date object to u.
|
||||
auto* this_object = MUST(typed_this_object(vm));
|
||||
auto this_object = MUST(typed_this_object(vm));
|
||||
this_object->set_date_value(date);
|
||||
|
||||
// 8. Return u.
|
||||
|
@ -569,7 +569,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_minutes)
|
|||
date = time_clip(utc_time(date));
|
||||
|
||||
// 11. Set the [[DateValue]] internal slot of this Date object to u.
|
||||
auto* this_object = MUST(typed_this_object(vm));
|
||||
auto this_object = MUST(typed_this_object(vm));
|
||||
this_object->set_date_value(date);
|
||||
|
||||
// 12. Return u.
|
||||
|
@ -609,7 +609,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_month)
|
|||
new_date = time_clip(utc_time(new_date));
|
||||
|
||||
// 9. Set the [[DateValue]] internal slot of this Date object to u.
|
||||
auto* this_object = MUST(typed_this_object(vm));
|
||||
auto this_object = MUST(typed_this_object(vm));
|
||||
this_object->set_date_value(new_date);
|
||||
|
||||
// 10. Return u.
|
||||
|
@ -650,7 +650,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_seconds)
|
|||
new_date = time_clip(utc_time(new_date));
|
||||
|
||||
// 9. Set the [[DateValue]] internal slot of this Date object to u.
|
||||
auto* this_object = MUST(typed_this_object(vm));
|
||||
auto this_object = MUST(typed_this_object(vm));
|
||||
this_object->set_date_value(new_date);
|
||||
|
||||
// 10. Return u.
|
||||
|
@ -670,7 +670,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_time)
|
|||
time = time_clip(time);
|
||||
|
||||
// 4. Set the [[DateValue]] internal slot of this Date object to v.
|
||||
auto* this_object = MUST(typed_this_object(vm));
|
||||
auto this_object = MUST(typed_this_object(vm));
|
||||
this_object->set_date_value(time);
|
||||
|
||||
// 5. Return v.
|
||||
|
@ -701,7 +701,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_utc_date)
|
|||
new_date = time_clip(new_date);
|
||||
|
||||
// 6. Set the [[DateValue]] internal slot of this Date object to v.
|
||||
auto* this_object = MUST(typed_this_object(vm));
|
||||
auto this_object = MUST(typed_this_object(vm));
|
||||
this_object->set_date_value(new_date);
|
||||
|
||||
// 7. Return v.
|
||||
|
@ -736,7 +736,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_utc_full_year)
|
|||
new_date = time_clip(new_date);
|
||||
|
||||
// 8. Set the [[DateValue]] internal slot of this Date object to v.
|
||||
auto* this_object = MUST(typed_this_object(vm));
|
||||
auto this_object = MUST(typed_this_object(vm));
|
||||
this_object->set_date_value(new_date);
|
||||
|
||||
// 9. Return v.
|
||||
|
@ -785,7 +785,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_utc_hours)
|
|||
date = time_clip(date);
|
||||
|
||||
// 12. Set the [[DateValue]] internal slot of this Date object to v.
|
||||
auto* this_object = MUST(typed_this_object(vm));
|
||||
auto this_object = MUST(typed_this_object(vm));
|
||||
this_object->set_date_value(date);
|
||||
|
||||
// 13. Return v.
|
||||
|
@ -817,7 +817,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_utc_milliseconds)
|
|||
date = time_clip(date);
|
||||
|
||||
// 6. Set the [[DateValue]] internal slot of this Date object to v.
|
||||
auto* this_object = MUST(typed_this_object(vm));
|
||||
auto this_object = MUST(typed_this_object(vm));
|
||||
this_object->set_date_value(date);
|
||||
|
||||
// 7. Return v.
|
||||
|
@ -861,7 +861,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_utc_minutes)
|
|||
date = time_clip(date);
|
||||
|
||||
// 10. Set the [[DateValue]] internal slot of this Date object to v.
|
||||
auto* this_object = MUST(typed_this_object(vm));
|
||||
auto this_object = MUST(typed_this_object(vm));
|
||||
this_object->set_date_value(date);
|
||||
|
||||
// 11. Return v.
|
||||
|
@ -898,7 +898,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_utc_month)
|
|||
new_date = time_clip(new_date);
|
||||
|
||||
// 8. Set the [[DateValue]] internal slot of this Date object to v.
|
||||
auto* this_object = MUST(typed_this_object(vm));
|
||||
auto this_object = MUST(typed_this_object(vm));
|
||||
this_object->set_date_value(new_date);
|
||||
|
||||
// 9. Return v.
|
||||
|
@ -936,7 +936,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_utc_seconds)
|
|||
new_date = time_clip(new_date);
|
||||
|
||||
// 8. Set the [[DateValue]] internal slot of this Date object to v.
|
||||
auto* this_object = MUST(typed_this_object(vm));
|
||||
auto this_object = MUST(typed_this_object(vm));
|
||||
this_object->set_date_value(new_date);
|
||||
|
||||
// 9. Return v.
|
||||
|
@ -962,7 +962,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_date_string)
|
|||
// 21.4.4.36 Date.prototype.toISOString ( ), https://tc39.es/ecma262/#sec-date.prototype.toisostring
|
||||
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_iso_string)
|
||||
{
|
||||
auto* this_object = TRY(typed_this_object(vm));
|
||||
auto this_object = TRY(typed_this_object(vm));
|
||||
|
||||
if (!Value(this_object->date_value()).is_finite_number())
|
||||
return vm.throw_completion<RangeError>(ErrorType::InvalidTimeValue);
|
||||
|
@ -1298,7 +1298,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_year)
|
|||
// 3. Let y be ? ToNumber(year).
|
||||
auto year = TRY(vm.argument(0).to_number(vm)).as_double();
|
||||
|
||||
auto* this_object = MUST(typed_this_object(vm));
|
||||
auto this_object = MUST(typed_this_object(vm));
|
||||
|
||||
// 4. If y is NaN, then
|
||||
if (isnan(year)) {
|
||||
|
|
|
@ -44,7 +44,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisposableStackPrototype::disposed_getter)
|
|||
{
|
||||
// 1. Let disposableStack be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(disposableStack, [[DisposableState]]).
|
||||
auto* disposable_stack = TRY(typed_this_object(vm));
|
||||
auto disposable_stack = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If disposableStack.[[DisposableState]] is disposed, return true.
|
||||
if (disposable_stack->disposable_state() == DisposableStack::DisposableState::Disposed)
|
||||
|
@ -59,7 +59,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisposableStackPrototype::dispose)
|
|||
{
|
||||
// 1. Let disposableStack be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(disposableStack, [[DisposableState]]).
|
||||
auto* disposable_stack = TRY(typed_this_object(vm));
|
||||
auto disposable_stack = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If disposableStack.[[DisposableState]] is disposed, return undefined.
|
||||
if (disposable_stack->disposable_state() == DisposableStack::DisposableState::Disposed)
|
||||
|
@ -79,7 +79,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisposableStackPrototype::use)
|
|||
|
||||
// 1. Let disposableStack be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(disposableStack, [[DisposableState]]).
|
||||
auto* disposable_stack = TRY(typed_this_object(vm));
|
||||
auto disposable_stack = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If disposableStack.[[DisposableState]] is disposed, throw a ReferenceError exception.
|
||||
if (disposable_stack->disposable_state() == DisposableStack::DisposableState::Disposed)
|
||||
|
@ -120,7 +120,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisposableStackPrototype::adopt)
|
|||
|
||||
// 1. Let disposableStack be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(disposableStack, [[DisposableState]]).
|
||||
auto* disposable_stack = TRY(typed_this_object(vm));
|
||||
auto disposable_stack = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If disposableStack.[[DisposableState]] is disposed, throw a ReferenceError exception.
|
||||
if (disposable_stack->disposable_state() == DisposableStack::DisposableState::Disposed)
|
||||
|
@ -161,7 +161,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisposableStackPrototype::defer)
|
|||
|
||||
// 1. Let disposableStack be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(disposableStack, [[DisposableState]]).
|
||||
auto* disposable_stack = TRY(typed_this_object(vm));
|
||||
auto disposable_stack = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If disposableStack.[[DisposableState]] is disposed, throw a ReferenceError exception.
|
||||
if (disposable_stack->disposable_state() == DisposableStack::DisposableState::Disposed)
|
||||
|
@ -183,7 +183,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisposableStackPrototype::move_)
|
|||
{
|
||||
// 1. Let disposableStack be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(disposableStack, [[DisposableState]]).
|
||||
auto* disposable_stack = TRY(typed_this_object(vm));
|
||||
auto disposable_stack = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If disposableStack.[[DisposableState]] is disposed, throw a ReferenceError exception.
|
||||
if (disposable_stack->disposable_state() == DisposableStack::DisposableState::Disposed)
|
||||
|
|
|
@ -38,7 +38,7 @@ JS_DEFINE_NATIVE_FUNCTION(FinalizationRegistryPrototype::cleanup_some)
|
|||
|
||||
// 1. Let finalizationRegistry be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(finalizationRegistry, [[Cells]]).
|
||||
auto* finalization_registry = TRY(typed_this_object(vm));
|
||||
auto finalization_registry = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If callback is present and IsCallable(callback) is false, throw a TypeError exception.
|
||||
if (vm.argument_count() > 0 && !callback.is_function())
|
||||
|
@ -62,7 +62,7 @@ JS_DEFINE_NATIVE_FUNCTION(FinalizationRegistryPrototype::register_)
|
|||
|
||||
// 1. Let finalizationRegistry be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(finalizationRegistry, [[Cells]]).
|
||||
auto* finalization_registry = TRY(typed_this_object(vm));
|
||||
auto finalization_registry = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If target is not an Object, throw a TypeError exception.
|
||||
if (!can_be_held_weakly(target))
|
||||
|
@ -93,7 +93,7 @@ JS_DEFINE_NATIVE_FUNCTION(FinalizationRegistryPrototype::unregister)
|
|||
|
||||
// 1. Let finalizationRegistry be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(finalizationRegistry, [[Cells]]).
|
||||
auto* finalization_registry = TRY(typed_this_object(vm));
|
||||
auto finalization_registry = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If unregisterToken is not an Object, throw a TypeError exception.
|
||||
if (!can_be_held_weakly(unregister_token))
|
||||
|
|
|
@ -33,7 +33,7 @@ ThrowCompletionOr<void> GeneratorPrototype::initialize(Realm& realm)
|
|||
JS_DEFINE_NATIVE_FUNCTION(GeneratorPrototype::next)
|
||||
{
|
||||
// 1. Return ? GeneratorResume(this value, value, empty).
|
||||
auto* generator_object = TRY(typed_this_object(vm));
|
||||
auto generator_object = TRY(typed_this_object(vm));
|
||||
return generator_object->resume(vm, vm.argument(0), {});
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ JS_DEFINE_NATIVE_FUNCTION(GeneratorPrototype::next)
|
|||
JS_DEFINE_NATIVE_FUNCTION(GeneratorPrototype::return_)
|
||||
{
|
||||
// 1. Let g be the this value.
|
||||
auto* generator_object = TRY(typed_this_object(vm));
|
||||
auto generator_object = TRY(typed_this_object(vm));
|
||||
|
||||
// 2. Let C be Completion Record { [[Type]]: return, [[Value]]: value, [[Target]]: empty }.
|
||||
auto completion = Completion(Completion::Type::Return, vm.argument(0), {});
|
||||
|
@ -54,7 +54,7 @@ JS_DEFINE_NATIVE_FUNCTION(GeneratorPrototype::return_)
|
|||
JS_DEFINE_NATIVE_FUNCTION(GeneratorPrototype::throw_)
|
||||
{
|
||||
// 1. Let g be the this value.
|
||||
auto* generator_object = TRY(typed_this_object(vm));
|
||||
auto generator_object = TRY(typed_this_object(vm));
|
||||
|
||||
// 2. Let C be ThrowCompletion(exception).
|
||||
auto completion = throw_completion(vm.argument(0));
|
||||
|
|
|
@ -40,13 +40,13 @@ JS_DEFINE_NATIVE_FUNCTION(CollatorPrototype::compare_getter)
|
|||
|
||||
// 1. Let collator be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(collator, [[InitializedCollator]]).
|
||||
auto* collator = TRY(typed_this_object(vm));
|
||||
auto collator = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If collator.[[BoundCompare]] is undefined, then
|
||||
if (!collator->bound_compare()) {
|
||||
// a. Let F be a new built-in function object as defined in 10.3.3.1.
|
||||
// b. Set F.[[Collator]] to collator.
|
||||
auto function = CollatorCompareFunction::create(realm, *collator);
|
||||
auto function = CollatorCompareFunction::create(realm, collator);
|
||||
|
||||
// c. Set collator.[[BoundCompare]] to F.
|
||||
collator->set_bound_compare(function);
|
||||
|
@ -63,7 +63,7 @@ JS_DEFINE_NATIVE_FUNCTION(CollatorPrototype::resolved_options)
|
|||
|
||||
// 1. Let collator be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(collator, [[InitializedCollator]]).
|
||||
auto* collator = TRY(typed_this_object(vm));
|
||||
auto collator = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let options be OrdinaryObjectCreate(%Object.prototype%).
|
||||
auto options = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
|
|
|
@ -48,13 +48,13 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatPrototype::format)
|
|||
// 2. If the implementation supports the normative optional constructor mode of 4.3 Note 1, then
|
||||
// a. Set dtf to ? UnwrapDateTimeFormat(dtf).
|
||||
// 3. Perform ? RequireInternalSlot(dtf, [[InitializedDateTimeFormat]]).
|
||||
auto* date_time_format = TRY(typed_this_object(vm));
|
||||
auto date_time_format = TRY(typed_this_object(vm));
|
||||
|
||||
// 4. If dtf.[[BoundFormat]] is undefined, then
|
||||
if (!date_time_format->bound_format()) {
|
||||
// a. Let F be a new built-in function object as defined in DateTime Format Functions (11.1.6).
|
||||
// b. Set F.[[DateTimeFormat]] to dtf.
|
||||
auto bound_format = DateTimeFormatFunction::create(realm, *date_time_format);
|
||||
auto bound_format = DateTimeFormatFunction::create(realm, date_time_format);
|
||||
|
||||
// c. Set dtf.[[BoundFormat]] to F.
|
||||
date_time_format->set_bound_format(bound_format);
|
||||
|
@ -73,7 +73,7 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatPrototype::format_to_parts)
|
|||
|
||||
// 1. Let dtf be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dtf, [[InitializedDateTimeFormat]]).
|
||||
auto* date_time_format = TRY(typed_this_object(vm));
|
||||
auto date_time_format = TRY(typed_this_object(vm));
|
||||
|
||||
double date_value;
|
||||
|
||||
|
@ -89,7 +89,7 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatPrototype::format_to_parts)
|
|||
}
|
||||
|
||||
// 5. Return ? FormatDateTimeToParts(dtf, x).
|
||||
return TRY(format_date_time_to_parts(vm, *date_time_format, date_value));
|
||||
return TRY(format_date_time_to_parts(vm, date_time_format, date_value));
|
||||
}
|
||||
|
||||
// 11.3.5 Intl.DateTimeFormat.prototype.formatRange ( startDate, endDate ), https://tc39.es/ecma402/#sec-intl.datetimeformat.prototype.formatRange
|
||||
|
@ -100,7 +100,7 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatPrototype::format_range)
|
|||
|
||||
// 1. Let dtf be this value.
|
||||
// 2. Perform ? RequireInternalSlot(dtf, [[InitializedDateTimeFormat]]).
|
||||
auto* date_time_format = TRY(typed_this_object(vm));
|
||||
auto date_time_format = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If startDate is undefined or endDate is undefined, throw a TypeError exception.
|
||||
if (start_date.is_undefined())
|
||||
|
@ -115,7 +115,7 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatPrototype::format_range)
|
|||
auto end_date_number = TRY(end_date.to_number(vm)).as_double();
|
||||
|
||||
// 6. Return ? FormatDateTimeRange(dtf, x, y).
|
||||
auto formatted = TRY(format_date_time_range(vm, *date_time_format, start_date_number, end_date_number));
|
||||
auto formatted = TRY(format_date_time_range(vm, date_time_format, start_date_number, end_date_number));
|
||||
return PrimitiveString::create(vm, move(formatted));
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatPrototype::format_range_to_parts)
|
|||
|
||||
// 1. Let dtf be this value.
|
||||
// 2. Perform ? RequireInternalSlot(dtf, [[InitializedDateTimeFormat]]).
|
||||
auto* date_time_format = TRY(typed_this_object(vm));
|
||||
auto date_time_format = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If startDate is undefined or endDate is undefined, throw a TypeError exception.
|
||||
if (start_date.is_undefined())
|
||||
|
@ -142,7 +142,7 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatPrototype::format_range_to_parts)
|
|||
auto end_date_number = TRY(end_date.to_number(vm)).as_double();
|
||||
|
||||
// 6. Return ? FormatDateTimeRangeToParts(dtf, x, y).
|
||||
return TRY(format_date_time_range_to_parts(vm, *date_time_format, start_date_number, end_date_number));
|
||||
return TRY(format_date_time_range_to_parts(vm, date_time_format, start_date_number, end_date_number));
|
||||
}
|
||||
|
||||
// 11.3.7 Intl.DateTimeFormat.prototype.resolvedOptions ( ), https://tc39.es/ecma402/#sec-intl.datetimeformat.prototype.resolvedoptions
|
||||
|
@ -154,7 +154,7 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatPrototype::resolved_options)
|
|||
// 2. If the implementation supports the normative optional constructor mode of 4.3 Note 1, then
|
||||
// a. Set dtf to ? UnwrapDateTimeFormat(dtf).
|
||||
// 3. Perform ? RequireInternalSlot(dtf, [[InitializedDateTimeFormat]]).
|
||||
auto* date_time_format = TRY(typed_this_object(vm));
|
||||
auto date_time_format = TRY(typed_this_object(vm));
|
||||
|
||||
// 4. Let options be OrdinaryObjectCreate(%Object.prototype%).
|
||||
auto options = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
|
@ -194,7 +194,7 @@ JS_DEFINE_NATIVE_FUNCTION(DateTimeFormatPrototype::resolved_options)
|
|||
}
|
||||
|
||||
if (!date_time_format->has_date_style() && !date_time_format->has_time_style()) {
|
||||
MUST(for_each_calendar_field(vm, *date_time_format, [&](auto& option, auto const& property, auto const&) -> ThrowCompletionOr<void> {
|
||||
MUST(for_each_calendar_field(vm, date_time_format, [&](auto& option, auto const& property, auto const&) -> ThrowCompletionOr<void> {
|
||||
using ValueType = typename RemoveReference<decltype(option)>::ValueType;
|
||||
|
||||
if (!option.has_value())
|
||||
|
|
|
@ -42,7 +42,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::of)
|
|||
|
||||
// 1. Let displayNames be this value.
|
||||
// 2. Perform ? RequireInternalSlot(displayNames, [[InitializedDisplayNames]]).
|
||||
auto* display_names = TRY(typed_this_object(vm));
|
||||
auto display_names = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let code be ? ToString(code).
|
||||
code = PrimitiveString::create(vm, TRY(code.to_string(vm)));
|
||||
|
@ -130,7 +130,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::resolved_options)
|
|||
|
||||
// 1. Let displayNames be this value.
|
||||
// 2. Perform ? RequireInternalSlot(displayNames, [[InitializedDisplayNames]]).
|
||||
auto* display_names = TRY(typed_this_object(vm));
|
||||
auto display_names = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let options be OrdinaryObjectCreate(%Object.prototype%).
|
||||
auto options = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
|
|
|
@ -40,13 +40,13 @@ JS_DEFINE_NATIVE_FUNCTION(DurationFormatPrototype::format)
|
|||
{
|
||||
// 1. Let df be this value.
|
||||
// 2. Perform ? RequireInternalSlot(df, [[InitializedDurationFormat]]).
|
||||
auto* duration_format = TRY(typed_this_object(vm));
|
||||
auto duration_format = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let record be ? ToDurationRecord(duration).
|
||||
auto record = TRY(to_duration_record(vm, vm.argument(0)));
|
||||
|
||||
// 4. Let parts be PartitionDurationFormatPattern(df, record).
|
||||
auto parts = MUST_OR_THROW_OOM(partition_duration_format_pattern(vm, *duration_format, record));
|
||||
auto parts = MUST_OR_THROW_OOM(partition_duration_format_pattern(vm, duration_format, record));
|
||||
|
||||
// 5. Let result be a new empty String.
|
||||
ThrowableStringBuilder result(vm);
|
||||
|
@ -68,13 +68,13 @@ JS_DEFINE_NATIVE_FUNCTION(DurationFormatPrototype::format_to_parts)
|
|||
|
||||
// 1. Let df be this value.
|
||||
// 2. Perform ? RequireInternalSlot(df, [[InitializedDurationFormat]]).
|
||||
auto* duration_format = TRY(typed_this_object(vm));
|
||||
auto duration_format = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let record be ? ToDurationRecord(duration).
|
||||
auto record = TRY(to_duration_record(vm, vm.argument(0)));
|
||||
|
||||
// 4. Let parts be PartitionDurationFormatPattern(df, record).
|
||||
auto parts = MUST_OR_THROW_OOM(partition_duration_format_pattern(vm, *duration_format, record));
|
||||
auto parts = MUST_OR_THROW_OOM(partition_duration_format_pattern(vm, duration_format, record));
|
||||
|
||||
// 5. Let result be ! ArrayCreate(0).
|
||||
auto result = MUST(Array::create(realm, 0));
|
||||
|
@ -110,7 +110,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationFormatPrototype::resolved_options)
|
|||
|
||||
// 1. Let df be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(df, [[InitializedDurationFormat]]).
|
||||
auto* duration_format = TRY(typed_this_object(vm));
|
||||
auto duration_format = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let options be OrdinaryObjectCreate(%Object.prototype%).
|
||||
auto options = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
|
|
|
@ -42,13 +42,13 @@ JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::format)
|
|||
|
||||
// 1. Let lf be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(lf, [[InitializedListFormat]]).
|
||||
auto* list_format = TRY(typed_this_object(vm));
|
||||
auto list_format = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let stringList be ? StringListFromIterable(list).
|
||||
auto string_list = TRY(string_list_from_iterable(vm, list));
|
||||
|
||||
// 4. Return ! FormatList(lf, stringList).
|
||||
auto formatted = MUST_OR_THROW_OOM(format_list(vm, *list_format, string_list));
|
||||
auto formatted = MUST_OR_THROW_OOM(format_list(vm, list_format, string_list));
|
||||
return PrimitiveString::create(vm, move(formatted));
|
||||
}
|
||||
|
||||
|
@ -59,13 +59,13 @@ JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::format_to_parts)
|
|||
|
||||
// 1. Let lf be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(lf, [[InitializedListFormat]]).
|
||||
auto* list_format = TRY(typed_this_object(vm));
|
||||
auto list_format = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let stringList be ? StringListFromIterable(list).
|
||||
auto string_list = TRY(string_list_from_iterable(vm, list));
|
||||
|
||||
// 4. Return ! FormatListToParts(lf, stringList).
|
||||
return MUST_OR_THROW_OOM(format_list_to_parts(vm, *list_format, string_list));
|
||||
return MUST_OR_THROW_OOM(format_list_to_parts(vm, list_format, string_list));
|
||||
}
|
||||
|
||||
// 13.3.5 Intl.ListFormat.prototype.resolvedOptions ( ), https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype.resolvedoptions
|
||||
|
@ -75,7 +75,7 @@ JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::resolved_options)
|
|||
|
||||
// 1. Let lf be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(lf, [[InitializedListFormat]]).
|
||||
auto* list_format = TRY(typed_this_object(vm));
|
||||
auto list_format = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let options be OrdinaryObjectCreate(%Object.prototype%).
|
||||
auto options = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
|
|
|
@ -61,7 +61,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::maximize)
|
|||
|
||||
// 1. Let loc be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
|
||||
auto* locale_object = TRY(typed_this_object(vm));
|
||||
auto locale_object = TRY(typed_this_object(vm));
|
||||
|
||||
auto locale = TRY_OR_THROW_OOM(vm, ::Locale::parse_unicode_locale_id(locale_object->locale()));
|
||||
VERIFY(locale.has_value());
|
||||
|
@ -81,7 +81,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::minimize)
|
|||
|
||||
// 1. Let loc be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
|
||||
auto* locale_object = TRY(typed_this_object(vm));
|
||||
auto locale_object = TRY(typed_this_object(vm));
|
||||
|
||||
auto locale = TRY_OR_THROW_OOM(vm, ::Locale::parse_unicode_locale_id(locale_object->locale()));
|
||||
VERIFY(locale.has_value());
|
||||
|
@ -99,7 +99,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::to_string)
|
|||
{
|
||||
// 1. Let loc be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
|
||||
auto* locale_object = TRY(typed_this_object(vm));
|
||||
auto locale_object = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return loc.[[Locale]].
|
||||
return PrimitiveString::create(vm, locale_object->locale());
|
||||
|
@ -110,7 +110,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::base_name)
|
|||
{
|
||||
// 1. Let loc be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
|
||||
auto* locale_object = TRY(typed_this_object(vm));
|
||||
auto locale_object = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let locale be loc.[[Locale]].
|
||||
auto locale = TRY_OR_THROW_OOM(vm, ::Locale::parse_unicode_locale_id(locale_object->locale()));
|
||||
|
@ -135,7 +135,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::base_name)
|
|||
#define __JS_ENUMERATE(keyword) \
|
||||
JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::keyword) \
|
||||
{ \
|
||||
auto* locale_object = TRY(typed_this_object(vm)); \
|
||||
auto locale_object = TRY(typed_this_object(vm)); \
|
||||
if (!locale_object->has_##keyword()) \
|
||||
return js_undefined(); \
|
||||
return PrimitiveString::create(vm, locale_object->keyword()); \
|
||||
|
@ -148,7 +148,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::numeric)
|
|||
{
|
||||
// 1. Let loc be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
|
||||
auto* locale_object = TRY(typed_this_object(vm));
|
||||
auto locale_object = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return loc.[[Numeric]].
|
||||
return Value(locale_object->numeric());
|
||||
|
@ -159,7 +159,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::language)
|
|||
{
|
||||
// 1. Let loc be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
|
||||
auto* locale_object = TRY(typed_this_object(vm));
|
||||
auto locale_object = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let locale be loc.[[Locale]].
|
||||
auto locale = TRY_OR_THROW_OOM(vm, ::Locale::parse_unicode_locale_id(locale_object->locale()));
|
||||
|
@ -176,7 +176,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::script)
|
|||
{
|
||||
// 1. Let loc be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
|
||||
auto* locale_object = TRY(typed_this_object(vm));
|
||||
auto locale_object = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let locale be loc.[[Locale]].
|
||||
auto locale = TRY_OR_THROW_OOM(vm, ::Locale::parse_unicode_locale_id(locale_object->locale()));
|
||||
|
@ -197,7 +197,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::region)
|
|||
{
|
||||
// 1. Let loc be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
|
||||
auto* locale_object = TRY(typed_this_object(vm));
|
||||
auto locale_object = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let locale be loc.[[Locale]].
|
||||
auto locale = TRY_OR_THROW_OOM(vm, ::Locale::parse_unicode_locale_id(locale_object->locale()));
|
||||
|
@ -223,11 +223,11 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::region)
|
|||
// 1.4.17 get Intl.Locale.prototype.collations, https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.collations
|
||||
// 1.4.18 get Intl.Locale.prototype.hourCycles, https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.hourCycles
|
||||
// 1.4.19 get Intl.Locale.prototype.numberingSystems, https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.numberingSystems
|
||||
#define __JS_ENUMERATE(keyword) \
|
||||
JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::keyword) \
|
||||
{ \
|
||||
auto* locale_object = TRY(typed_this_object(vm)); \
|
||||
return MUST_OR_THROW_OOM(keyword##_of_locale(vm, *locale_object)); \
|
||||
#define __JS_ENUMERATE(keyword) \
|
||||
JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::keyword) \
|
||||
{ \
|
||||
auto locale_object = TRY(typed_this_object(vm)); \
|
||||
return MUST_OR_THROW_OOM(keyword##_of_locale(vm, locale_object)); \
|
||||
}
|
||||
JS_ENUMERATE_LOCALE_INFO_PROPERTIES
|
||||
#undef __JS_ENUMERATE
|
||||
|
@ -237,7 +237,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::time_zones)
|
|||
{
|
||||
// 1. Let loc be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
|
||||
auto* locale_object = TRY(typed_this_object(vm));
|
||||
auto locale_object = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let locale be loc.[[Locale]].
|
||||
auto locale = TRY_OR_THROW_OOM(vm, ::Locale::parse_unicode_locale_id(locale_object->locale()));
|
||||
|
@ -257,13 +257,13 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::text_info)
|
|||
|
||||
// 1. Let loc be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
|
||||
auto* locale_object = TRY(typed_this_object(vm));
|
||||
auto locale_object = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let info be ! ObjectCreate(%Object.prototype%).
|
||||
auto info = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
|
||||
// 4. Let dir be ! CharacterDirectionOfLocale(loc).
|
||||
auto direction = MUST_OR_THROW_OOM(character_direction_of_locale(vm, *locale_object));
|
||||
auto direction = MUST_OR_THROW_OOM(character_direction_of_locale(vm, locale_object));
|
||||
|
||||
// 5. Perform ! CreateDataPropertyOrThrow(info, "direction", dir).
|
||||
MUST(info->create_data_property_or_throw(vm.names.direction, MUST_OR_THROW_OOM(PrimitiveString::create(vm, direction))));
|
||||
|
@ -279,13 +279,13 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::week_info)
|
|||
|
||||
// 1. Let loc be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
|
||||
[[maybe_unused]] auto* locale_object = TRY(typed_this_object(vm));
|
||||
auto locale_object = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let info be ! ObjectCreate(%Object.prototype%).
|
||||
auto info = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
|
||||
// 4. Let wi be ! WeekInfoOfLocale(loc).
|
||||
auto week_info = MUST_OR_THROW_OOM(week_info_of_locale(vm, *locale_object));
|
||||
auto week_info = MUST_OR_THROW_OOM(week_info_of_locale(vm, locale_object));
|
||||
|
||||
// 5. Let we be ! CreateArrayFromList( wi.[[Weekend]] ).
|
||||
auto weekend = Array::create_from<u8>(realm, week_info.weekend, [](auto day) { return Value(day); });
|
||||
|
|
|
@ -48,13 +48,13 @@ JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::format)
|
|||
// 2. If the implementation supports the normative optional constructor mode of 4.3 Note 1, then
|
||||
// a. Set nf to ? UnwrapNumberFormat(nf).
|
||||
// 3. Perform ? RequireInternalSlot(nf, [[InitializedNumberFormat]]).
|
||||
auto* number_format = TRY(typed_this_object(vm));
|
||||
auto number_format = TRY(typed_this_object(vm));
|
||||
|
||||
// 4. If nf.[[BoundFormat]] is undefined, then
|
||||
if (!number_format->bound_format()) {
|
||||
// a. Let F be a new built-in function object as defined in Number Format Functions (15.1.4).
|
||||
// b. Set F.[[NumberFormat]] to nf.
|
||||
auto bound_format = NumberFormatFunction::create(realm, *number_format);
|
||||
auto bound_format = NumberFormatFunction::create(realm, number_format);
|
||||
|
||||
// c. Set nf.[[BoundFormat]] to F.
|
||||
number_format->set_bound_format(bound_format);
|
||||
|
@ -71,13 +71,13 @@ JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::format_to_parts)
|
|||
|
||||
// 1. Let nf be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(nf, [[InitializedNumberFormat]]).
|
||||
auto* number_format = TRY(typed_this_object(vm));
|
||||
auto number_format = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let x be ? ToIntlMathematicalValue(value).
|
||||
auto mathematical_value = TRY(to_intl_mathematical_value(vm, value));
|
||||
|
||||
// 4. Return ? FormatNumericToParts(nf, x).
|
||||
return TRY(format_numeric_to_parts(vm, *number_format, move(mathematical_value)));
|
||||
return TRY(format_numeric_to_parts(vm, number_format, move(mathematical_value)));
|
||||
}
|
||||
|
||||
// 15.3.5 Intl.NumberFormat.prototype.formatRange ( start, end ), https://tc39.es/ecma402/#sec-intl.numberformat.prototype.formatrange
|
||||
|
@ -88,7 +88,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::format_range)
|
|||
|
||||
// 1. Let nf be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(nf, [[InitializedNumberFormat]]).
|
||||
auto* number_format = TRY(typed_this_object(vm));
|
||||
auto number_format = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If start is undefined or end is undefined, throw a TypeError exception.
|
||||
if (start.is_undefined())
|
||||
|
@ -103,7 +103,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::format_range)
|
|||
auto y = TRY(to_intl_mathematical_value(vm, end));
|
||||
|
||||
// 6. Return ? FormatNumericRange(nf, x, y).
|
||||
auto formatted = TRY(format_numeric_range(vm, *number_format, move(x), move(y)));
|
||||
auto formatted = TRY(format_numeric_range(vm, number_format, move(x), move(y)));
|
||||
return PrimitiveString::create(vm, move(formatted));
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::format_range_to_parts)
|
|||
|
||||
// 1. Let nf be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(nf, [[InitializedNumberFormat]]).
|
||||
auto* number_format = TRY(typed_this_object(vm));
|
||||
auto number_format = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If start is undefined or end is undefined, throw a TypeError exception.
|
||||
if (start.is_undefined())
|
||||
|
@ -130,7 +130,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::format_range_to_parts)
|
|||
auto y = TRY(to_intl_mathematical_value(vm, end));
|
||||
|
||||
// 6. Return ? FormatNumericRangeToParts(nf, x, y).
|
||||
return TRY(format_numeric_range_to_parts(vm, *number_format, move(x), move(y)));
|
||||
return TRY(format_numeric_range_to_parts(vm, number_format, move(x), move(y)));
|
||||
}
|
||||
|
||||
// 15.3.7 Intl.NumberFormat.prototype.resolvedOptions ( ), https://tc39.es/ecma402/#sec-intl.numberformat.prototype.resolvedoptions
|
||||
|
@ -142,7 +142,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::resolved_options)
|
|||
// 2. If the implementation supports the normative optional constructor mode of 4.3 Note 1, then
|
||||
// a. Set nf to ? UnwrapNumberFormat(nf).
|
||||
// 3. Perform ? RequireInternalSlot(nf, [[InitializedNumberFormat]]).
|
||||
auto* number_format = TRY(typed_this_object(vm));
|
||||
auto number_format = TRY(typed_this_object(vm));
|
||||
|
||||
// 4. Let options be OrdinaryObjectCreate(%Object.prototype%).
|
||||
auto options = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
|
|
|
@ -40,13 +40,13 @@ JS_DEFINE_NATIVE_FUNCTION(PluralRulesPrototype::select)
|
|||
{
|
||||
// 1. Let pr be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(pr, [[InitializedPluralRules]]).
|
||||
auto* plural_rules = TRY(typed_this_object(vm));
|
||||
auto plural_rules = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let n be ? ToNumber(value).
|
||||
auto number = TRY(vm.argument(0).to_number(vm));
|
||||
|
||||
// 4. Return ! ResolvePlural(pr, n).[[PluralCategory]].
|
||||
auto plurality = MUST_OR_THROW_OOM(resolve_plural(vm, *plural_rules, number));
|
||||
auto plurality = MUST_OR_THROW_OOM(resolve_plural(vm, plural_rules, number));
|
||||
return MUST_OR_THROW_OOM(PrimitiveString::create(vm, ::Locale::plural_category_to_string(plurality.plural_category)));
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ JS_DEFINE_NATIVE_FUNCTION(PluralRulesPrototype::select_range)
|
|||
|
||||
// 1. Let pr be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(pr, [[InitializedPluralRules]]).
|
||||
auto* plural_rules = TRY(typed_this_object(vm));
|
||||
auto plural_rules = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If start is undefined or end is undefined, throw a TypeError exception.
|
||||
if (start.is_undefined())
|
||||
|
@ -73,7 +73,7 @@ JS_DEFINE_NATIVE_FUNCTION(PluralRulesPrototype::select_range)
|
|||
auto y = TRY(end.to_number(vm));
|
||||
|
||||
// 6. Return ? ResolvePluralRange(pr, x, y).
|
||||
auto plurality = TRY(resolve_plural_range(vm, *plural_rules, x, y));
|
||||
auto plurality = TRY(resolve_plural_range(vm, plural_rules, x, y));
|
||||
return MUST_OR_THROW_OOM(PrimitiveString::create(vm, ::Locale::plural_category_to_string(plurality)));
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ JS_DEFINE_NATIVE_FUNCTION(PluralRulesPrototype::resolved_options)
|
|||
|
||||
// 1. Let pr be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(pr, [[InitializedPluralRules]]).
|
||||
auto* plural_rules = TRY(typed_this_object(vm));
|
||||
auto plural_rules = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let options be OrdinaryObjectCreate(%Object.prototype%).
|
||||
auto options = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
|
|
|
@ -38,7 +38,7 @@ JS_DEFINE_NATIVE_FUNCTION(RelativeTimeFormatPrototype::format)
|
|||
{
|
||||
// 1. Let relativeTimeFormat be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(relativeTimeFormat, [[InitializedRelativeTimeFormat]]).
|
||||
auto* relative_time_format = TRY(typed_this_object(vm));
|
||||
auto relative_time_format = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let value be ? ToNumber(value).
|
||||
auto value = TRY(vm.argument(0).to_number(vm));
|
||||
|
@ -47,7 +47,7 @@ JS_DEFINE_NATIVE_FUNCTION(RelativeTimeFormatPrototype::format)
|
|||
auto unit = TRY(vm.argument(1).to_string(vm));
|
||||
|
||||
// 5. Return ? FormatRelativeTime(relativeTimeFormat, value, unit).
|
||||
auto formatted = TRY(format_relative_time(vm, *relative_time_format, value.as_double(), unit.bytes_as_string_view()));
|
||||
auto formatted = TRY(format_relative_time(vm, relative_time_format, value.as_double(), unit.bytes_as_string_view()));
|
||||
return PrimitiveString::create(vm, move(formatted));
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ JS_DEFINE_NATIVE_FUNCTION(RelativeTimeFormatPrototype::format_to_parts)
|
|||
{
|
||||
// 1. Let relativeTimeFormat be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(relativeTimeFormat, [[InitializedRelativeTimeFormat]]).
|
||||
auto* relative_time_format = TRY(typed_this_object(vm));
|
||||
auto relative_time_format = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let value be ? ToNumber(value).
|
||||
auto value = TRY(vm.argument(0).to_number(vm));
|
||||
|
@ -65,7 +65,7 @@ JS_DEFINE_NATIVE_FUNCTION(RelativeTimeFormatPrototype::format_to_parts)
|
|||
auto unit = TRY(vm.argument(1).to_string(vm));
|
||||
|
||||
// 5. Return ? FormatRelativeTimeToParts(relativeTimeFormat, value, unit).
|
||||
return TRY(format_relative_time_to_parts(vm, *relative_time_format, value.as_double(), unit.bytes_as_string_view()));
|
||||
return TRY(format_relative_time_to_parts(vm, relative_time_format, value.as_double(), unit.bytes_as_string_view()));
|
||||
}
|
||||
|
||||
// 17.3.5 Intl.RelativeTimeFormat.prototype.resolvedOptions ( ), https://tc39.es/ecma402/#sec-intl.relativetimeformat.prototype.resolvedoptions
|
||||
|
@ -75,7 +75,7 @@ JS_DEFINE_NATIVE_FUNCTION(RelativeTimeFormatPrototype::resolved_options)
|
|||
|
||||
// 1. Let relativeTimeFormat be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(relativeTimeFormat, [[InitializedRelativeTimeFormat]]).
|
||||
auto* relative_time_format = TRY(typed_this_object(vm));
|
||||
auto relative_time_format = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let options be OrdinaryObjectCreate(%Object.prototype%).
|
||||
auto options = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
|
|
|
@ -38,7 +38,7 @@ JS_DEFINE_NATIVE_FUNCTION(SegmentIteratorPrototype::next)
|
|||
{
|
||||
// 1. Let iterator be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(iterator, [[IteratingSegmenter]]).
|
||||
auto* iterator = TRY(typed_this_object(vm));
|
||||
auto iterator = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let segmenter be iterator.[[IteratingSegmenter]].
|
||||
auto const& segmenter = iterator->iterating_segmenter();
|
||||
|
|
|
@ -40,7 +40,7 @@ JS_DEFINE_NATIVE_FUNCTION(SegmenterPrototype::resolved_options)
|
|||
|
||||
// 1. Let segmenter be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(segmenter, [[InitializedSegmenter]]).
|
||||
auto* segmenter = TRY(typed_this_object(vm));
|
||||
auto segmenter = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let options be OrdinaryObjectCreate(%Object.prototype%).
|
||||
auto options = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
|
@ -64,13 +64,13 @@ JS_DEFINE_NATIVE_FUNCTION(SegmenterPrototype::segment)
|
|||
|
||||
// 1. Let segmenter be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(segmenter, [[InitializedSegmenter]]).
|
||||
auto* segmenter = TRY(typed_this_object(vm));
|
||||
auto segmenter = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let string be ? ToString(string).
|
||||
auto string = TRY(vm.argument(0).to_utf16_string(vm));
|
||||
|
||||
// 4. Return ! CreateSegmentsObject(segmenter, string).
|
||||
return Segments::create(realm, *segmenter, move(string));
|
||||
return Segments::create(realm, segmenter, move(string));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ JS_DEFINE_NATIVE_FUNCTION(SegmentsPrototype::containing)
|
|||
{
|
||||
// 1. Let segments be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(segments, [[SegmentsSegmenter]]).
|
||||
auto* segments = TRY(typed_this_object(vm));
|
||||
auto segments = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let segmenter be segments.[[SegmentsSegmenter]].
|
||||
auto const& segmenter = segments->segments_segmenter();
|
||||
|
@ -70,7 +70,7 @@ JS_DEFINE_NATIVE_FUNCTION(SegmentsPrototype::symbol_iterator)
|
|||
|
||||
// 1. Let segments be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(segments, [[SegmentsSegmenter]]).
|
||||
auto* segments = TRY(typed_this_object(vm));
|
||||
auto segments = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let segmenter be segments.[[SegmentsSegmenter]].
|
||||
auto& segmenter = segments->segments_segmenter();
|
||||
|
@ -79,7 +79,7 @@ JS_DEFINE_NATIVE_FUNCTION(SegmentsPrototype::symbol_iterator)
|
|||
auto string = segments->segments_string();
|
||||
|
||||
// 5. Return ! CreateSegmentIterator(segmenter, string).
|
||||
return SegmentIterator::create(realm, segmenter, string, *segments);
|
||||
return SegmentIterator::create(realm, segmenter, string, segments);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ ThrowCompletionOr<void> MapPrototype::initialize(Realm& realm)
|
|||
// 24.1.3.1 Map.prototype.clear ( ), https://tc39.es/ecma262/#sec-map.prototype.clear
|
||||
JS_DEFINE_NATIVE_FUNCTION(MapPrototype::clear)
|
||||
{
|
||||
auto* map = TRY(typed_this_object(vm));
|
||||
auto map = TRY(typed_this_object(vm));
|
||||
map->map_clear();
|
||||
return js_undefined();
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ JS_DEFINE_NATIVE_FUNCTION(MapPrototype::clear)
|
|||
// 24.1.3.3 Map.prototype.delete ( key ), https://tc39.es/ecma262/#sec-map.prototype.delete
|
||||
JS_DEFINE_NATIVE_FUNCTION(MapPrototype::delete_)
|
||||
{
|
||||
auto* map = TRY(typed_this_object(vm));
|
||||
auto map = TRY(typed_this_object(vm));
|
||||
return Value(map->map_remove(vm.argument(0)));
|
||||
}
|
||||
|
||||
|
@ -61,15 +61,15 @@ JS_DEFINE_NATIVE_FUNCTION(MapPrototype::entries)
|
|||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
auto* map = TRY(typed_this_object(vm));
|
||||
auto map = TRY(typed_this_object(vm));
|
||||
|
||||
return MapIterator::create(realm, *map, Object::PropertyKind::KeyAndValue);
|
||||
return MapIterator::create(realm, map, Object::PropertyKind::KeyAndValue);
|
||||
}
|
||||
|
||||
// 24.1.3.5 Map.prototype.forEach ( callbackfn [ , thisArg ] ), https://tc39.es/ecma262/#sec-map.prototype.foreach
|
||||
JS_DEFINE_NATIVE_FUNCTION(MapPrototype::for_each)
|
||||
{
|
||||
auto* map = TRY(typed_this_object(vm));
|
||||
auto map = TRY(typed_this_object(vm));
|
||||
if (!vm.argument(0).is_function())
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAFunction, TRY_OR_THROW_OOM(vm, vm.argument(0).to_string_without_side_effects()));
|
||||
auto this_value = vm.this_value();
|
||||
|
@ -81,7 +81,7 @@ JS_DEFINE_NATIVE_FUNCTION(MapPrototype::for_each)
|
|||
// 24.1.3.6 Map.prototype.get ( key ), https://tc39.es/ecma262/#sec-map.prototype.get
|
||||
JS_DEFINE_NATIVE_FUNCTION(MapPrototype::get)
|
||||
{
|
||||
auto* map = TRY(typed_this_object(vm));
|
||||
auto map = TRY(typed_this_object(vm));
|
||||
auto result = map->map_get(vm.argument(0));
|
||||
if (!result.has_value())
|
||||
return js_undefined();
|
||||
|
@ -91,7 +91,7 @@ JS_DEFINE_NATIVE_FUNCTION(MapPrototype::get)
|
|||
// 24.1.3.7 Map.prototype.has ( key ), https://tc39.es/ecma262/#sec-map.prototype.has
|
||||
JS_DEFINE_NATIVE_FUNCTION(MapPrototype::has)
|
||||
{
|
||||
auto* map = TRY(typed_this_object(vm));
|
||||
auto map = TRY(typed_this_object(vm));
|
||||
return map->map_has(vm.argument(0));
|
||||
}
|
||||
|
||||
|
@ -100,15 +100,15 @@ JS_DEFINE_NATIVE_FUNCTION(MapPrototype::keys)
|
|||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
auto* map = TRY(typed_this_object(vm));
|
||||
auto map = TRY(typed_this_object(vm));
|
||||
|
||||
return MapIterator::create(realm, *map, Object::PropertyKind::Key);
|
||||
return MapIterator::create(realm, map, Object::PropertyKind::Key);
|
||||
}
|
||||
|
||||
// 24.1.3.9 Map.prototype.set ( key, value ), https://tc39.es/ecma262/#sec-map.prototype.set
|
||||
JS_DEFINE_NATIVE_FUNCTION(MapPrototype::set)
|
||||
{
|
||||
auto* map = TRY(typed_this_object(vm));
|
||||
auto map = TRY(typed_this_object(vm));
|
||||
auto key = vm.argument(0);
|
||||
if (key.is_negative_zero())
|
||||
key = Value(0);
|
||||
|
@ -121,15 +121,15 @@ JS_DEFINE_NATIVE_FUNCTION(MapPrototype::values)
|
|||
{
|
||||
auto& realm = *vm.current_realm();
|
||||
|
||||
auto* map = TRY(typed_this_object(vm));
|
||||
auto map = TRY(typed_this_object(vm));
|
||||
|
||||
return MapIterator::create(realm, *map, Object::PropertyKind::Value);
|
||||
return MapIterator::create(realm, map, Object::PropertyKind::Value);
|
||||
}
|
||||
|
||||
// 24.1.3.10 get Map.prototype.size, https://tc39.es/ecma262/#sec-get-map.prototype.size
|
||||
JS_DEFINE_NATIVE_FUNCTION(MapPrototype::size_getter)
|
||||
{
|
||||
auto* map = TRY(typed_this_object(vm));
|
||||
auto map = TRY(typed_this_object(vm));
|
||||
return Value(map->map_size());
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ JS_DEFINE_NATIVE_FUNCTION(PromisePrototype::then)
|
|||
auto promise = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let C be ? SpeciesConstructor(promise, %Promise%).
|
||||
auto* constructor = TRY(species_constructor(vm, *promise, realm.intrinsics().promise_constructor()));
|
||||
auto* constructor = TRY(species_constructor(vm, promise, realm.intrinsics().promise_constructor()));
|
||||
|
||||
// 4. Let resultCapability be ? NewPromiseCapability(C).
|
||||
auto result_capability = TRY(new_promise_capability(vm, constructor));
|
||||
|
|
|
@ -38,12 +38,12 @@ public:
|
|||
}
|
||||
|
||||
// Use typed_this_object() when the spec coerces |this| value to an object.
|
||||
static ThrowCompletionOr<ObjectType*> typed_this_object(VM& vm)
|
||||
static ThrowCompletionOr<NonnullGCPtr<ObjectType>> typed_this_object(VM& vm)
|
||||
{
|
||||
auto this_object = TRY(vm.this_value().to_object(vm));
|
||||
if (!is<ObjectType>(*this_object))
|
||||
return vm.throw_completion<TypeError>(ErrorType::NotAnObjectOfType, PrototypeType::display_name());
|
||||
return static_cast<ObjectType*>(this_object.ptr());
|
||||
return static_cast<ObjectType&>(*this_object);
|
||||
}
|
||||
|
||||
// Use typed_this_value() when the spec does not coerce |this| value to an object.
|
||||
|
|
|
@ -466,13 +466,13 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::exec)
|
|||
{
|
||||
// 1. Let R be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(R, [[RegExpMatcher]]).
|
||||
auto* regexp_object = TRY(typed_this_object(vm));
|
||||
auto regexp_object = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let S be ? ToString(string).
|
||||
auto string = TRY(vm.argument(0).to_utf16_string(vm));
|
||||
|
||||
// 4. Return ? RegExpBuiltinExec(R, S).
|
||||
return TRY(regexp_builtin_exec(vm, *regexp_object, move(string)));
|
||||
return TRY(regexp_builtin_exec(vm, regexp_object, move(string)));
|
||||
}
|
||||
|
||||
// 22.2.5.4 get RegExp.prototype.flags, https://tc39.es/ecma262/#sec-get-regexp.prototype.flags
|
||||
|
@ -1097,7 +1097,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::compile)
|
|||
|
||||
// 1. Let O be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(O, [[RegExpMatcher]]).
|
||||
auto* regexp_object = TRY(typed_this_object(vm));
|
||||
auto regexp_object = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let thisRealm be the current Realm Record.
|
||||
auto* this_realm = vm.current_realm();
|
||||
|
|
|
@ -59,7 +59,7 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::add)
|
|||
|
||||
// 1. Let S be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(S, [[SetData]]).
|
||||
auto* set = TRY(typed_this_object(vm));
|
||||
auto set = TRY(typed_this_object(vm));
|
||||
|
||||
// 4. If value is -0𝔽, set value to +0𝔽.
|
||||
if (value.is_negative_zero())
|
||||
|
@ -80,7 +80,7 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::clear)
|
|||
{
|
||||
// 1. Let S be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(S, [[SetData]]).
|
||||
auto* set = TRY(typed_this_object(vm));
|
||||
auto set = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. For each element e of S.[[SetData]], do
|
||||
// a. Replace the element of S.[[SetData]] whose value is e with an element whose value is empty.
|
||||
|
@ -97,7 +97,7 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::delete_)
|
|||
|
||||
// 1. Let S be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(S, [[SetData]]).
|
||||
auto* set = TRY(typed_this_object(vm));
|
||||
auto set = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. For each element e of S.[[SetData]], do
|
||||
// a. If e is not empty and SameValueZero(e, value) is true, then
|
||||
|
@ -113,10 +113,10 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::entries)
|
|||
auto& realm = *vm.current_realm();
|
||||
|
||||
// 1. Let S be the this value.
|
||||
auto* set = TRY(typed_this_object(vm));
|
||||
auto set = TRY(typed_this_object(vm));
|
||||
|
||||
// 2. Return ? CreateSetIterator(S, key+value).
|
||||
return SetIterator::create(realm, *set, Object::PropertyKind::KeyAndValue);
|
||||
return SetIterator::create(realm, set, Object::PropertyKind::KeyAndValue);
|
||||
}
|
||||
|
||||
// 24.2.3.6 Set.prototype.forEach ( callbackfn [ , thisArg ] ), https://tc39.es/ecma262/#sec-set.prototype.foreach
|
||||
|
@ -127,7 +127,7 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::for_each)
|
|||
|
||||
// 1. Let S be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(S, [[SetData]]).
|
||||
auto* set = TRY(typed_this_object(vm));
|
||||
auto set = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If IsCallable(callbackfn) is false, throw a TypeError exception.
|
||||
if (!callback_fn.is_function())
|
||||
|
@ -162,7 +162,7 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::has)
|
|||
|
||||
// 1. Let S be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(S, [[SetData]]).
|
||||
auto* set = TRY(typed_this_object(vm));
|
||||
auto set = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. For each element e of S.[[SetData]], do
|
||||
// a. If e is not empty and SameValueZero(e, value) is true, return true.
|
||||
|
@ -177,10 +177,10 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::values)
|
|||
|
||||
// 1. Let S be the this value.
|
||||
// NOTE: CreateSetIterator checks the presence of a [[SetData]] slot, so we can do this here.
|
||||
auto* set = TRY(typed_this_object(vm));
|
||||
auto set = TRY(typed_this_object(vm));
|
||||
|
||||
// 2. Return ? CreateSetIterator(S, value).
|
||||
return SetIterator::create(realm, *set, Object::PropertyKind::Value);
|
||||
return SetIterator::create(realm, set, Object::PropertyKind::Value);
|
||||
}
|
||||
|
||||
// 24.2.3.9 get Set.prototype.size, https://tc39.es/ecma262/#sec-get-set.prototype.size
|
||||
|
@ -188,7 +188,7 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::size_getter)
|
|||
{
|
||||
// 1. Let S be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(S, [[SetData]]).
|
||||
auto* set = TRY(typed_this_object(vm));
|
||||
auto set = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let count be 0.
|
||||
// 4. For each element e of S.[[SetData]], do
|
||||
|
@ -273,7 +273,7 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::union_)
|
|||
{
|
||||
// 1. Let O be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(O, [[SetData]]).
|
||||
auto* set = TRY(typed_this_object(vm));
|
||||
auto set = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let otherRec be ? GetSetRecord(other).
|
||||
auto other_record = TRY(get_set_record(vm, vm.argument(0)));
|
||||
|
@ -322,7 +322,7 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::intersection)
|
|||
|
||||
// 1. Let O be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(O, [[SetData]]).
|
||||
auto* set = TRY(typed_this_object(vm));
|
||||
auto set = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let otherRec be ? GetSetRecord(other).
|
||||
auto other_record = TRY(get_set_record(vm, vm.argument(0)));
|
||||
|
@ -400,7 +400,7 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::difference)
|
|||
{
|
||||
// 1. Let O be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(O, [[SetData]]).
|
||||
auto* set = TRY(typed_this_object(vm));
|
||||
auto set = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let otherRec be ? GetSetRecord(other).
|
||||
auto other_record = TRY(get_set_record(vm, vm.argument(0)));
|
||||
|
@ -469,7 +469,7 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::symmetric_difference)
|
|||
{
|
||||
// 1. Let O be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(O, [[SetData]]).
|
||||
auto* set = TRY(typed_this_object(vm));
|
||||
auto set = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let otherRec be ? GetSetRecord(other).
|
||||
auto other_record = TRY(get_set_record(vm, vm.argument(0)));
|
||||
|
@ -524,7 +524,7 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::is_subset_of)
|
|||
{
|
||||
// 1. Let O be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(O, [[SetData]]).
|
||||
auto* set = TRY(typed_this_object(vm));
|
||||
auto set = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let otherRec be ? GetSetRecord(other).
|
||||
auto other_record = TRY(get_set_record(vm, vm.argument(0)));
|
||||
|
@ -555,7 +555,7 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::is_superset_of)
|
|||
{
|
||||
// 1. Let O be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(O, [[SetData]]).
|
||||
auto* set = TRY(typed_this_object(vm));
|
||||
auto set = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let otherRec be ? GetSetRecord(other).
|
||||
auto other_record = TRY(get_set_record(vm, vm.argument(0)));
|
||||
|
@ -599,7 +599,7 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::is_disjoint_from)
|
|||
{
|
||||
// 1. Let O be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(O, [[SetData]]).
|
||||
auto* set = TRY(typed_this_object(vm));
|
||||
auto set = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let otherRec be ? GetSetRecord(other).
|
||||
auto other_record = TRY(get_set_record(vm, vm.argument(0)));
|
||||
|
|
|
@ -38,7 +38,7 @@ JS_DEFINE_NATIVE_FUNCTION(ShadowRealmPrototype::evaluate)
|
|||
|
||||
// 1. Let O be this value.
|
||||
// 2. Perform ? ValidateShadowRealmObject(O).
|
||||
auto* object = TRY(typed_this_object(vm));
|
||||
auto object = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If Type(sourceText) is not String, throw a TypeError exception.
|
||||
if (!source_text.is_string())
|
||||
|
@ -62,7 +62,7 @@ JS_DEFINE_NATIVE_FUNCTION(ShadowRealmPrototype::import_value)
|
|||
|
||||
// 1. Let O be this value.
|
||||
// 2. Perform ? ValidateShadowRealmObject(O).
|
||||
auto* object = TRY(typed_this_object(vm));
|
||||
auto object = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let specifierString be ? ToString(specifier).
|
||||
auto specifier_string = TRY(specifier.to_deprecated_string(vm));
|
||||
|
|
|
@ -74,7 +74,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::id_getter)
|
|||
{
|
||||
// 1. Let calendar be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
auto* calendar = TRY(typed_this_object(vm));
|
||||
auto calendar = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return calendar.[[Identifier]].
|
||||
return { PrimitiveString::create(vm, calendar->identifier()) };
|
||||
|
@ -86,7 +86,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::date_from_fields)
|
|||
{
|
||||
// 1. Let calendar be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
auto* calendar = TRY(typed_this_object(vm));
|
||||
auto calendar = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Assert: calendar.[[Identifier]] is "iso8601".
|
||||
VERIFY(calendar->identifier() == "iso8601"sv);
|
||||
|
@ -103,7 +103,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::date_from_fields)
|
|||
auto result = TRY(iso_date_from_fields(vm, fields.as_object(), *options));
|
||||
|
||||
// 7. Return ? CreateTemporalDate(result.[[Year]], result.[[Month]], result.[[Day]], calendar).
|
||||
return TRY(create_temporal_date(vm, result.year, result.month, result.day, *calendar));
|
||||
return TRY(create_temporal_date(vm, result.year, result.month, result.day, calendar));
|
||||
}
|
||||
|
||||
// 12.4.5 Temporal.Calendar.prototype.yearMonthFromFields ( fields [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.calendar.prototype.yearmonthfromfields
|
||||
|
@ -112,7 +112,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::year_month_from_fields)
|
|||
{
|
||||
// 1. Let calendar be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
auto* calendar = TRY(typed_this_object(vm));
|
||||
auto calendar = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Assert: calendar.[[Identifier]] is "iso8601".
|
||||
VERIFY(calendar->identifier() == "iso8601"sv);
|
||||
|
@ -129,7 +129,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::year_month_from_fields)
|
|||
auto result = TRY(iso_year_month_from_fields(vm, fields.as_object(), *options));
|
||||
|
||||
// 7. Return ? CreateTemporalYearMonth(result.[[Year]], result.[[Month]], calendar, result.[[ReferenceISODay]]).
|
||||
return TRY(create_temporal_year_month(vm, result.year, result.month, *calendar, result.reference_iso_day));
|
||||
return TRY(create_temporal_year_month(vm, result.year, result.month, calendar, result.reference_iso_day));
|
||||
}
|
||||
|
||||
// 12.4.6 Temporal.Calendar.prototype.monthDayFromFields ( fields [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.calendar.prototype.monthdayfromfields
|
||||
|
@ -138,7 +138,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::month_day_from_fields)
|
|||
{
|
||||
// 1. Let calendar be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
auto* calendar = TRY(typed_this_object(vm));
|
||||
auto calendar = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Assert: calendar.[[Identifier]] is "iso8601".
|
||||
VERIFY(calendar->identifier() == "iso8601"sv);
|
||||
|
@ -155,7 +155,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::month_day_from_fields)
|
|||
auto result = TRY(iso_month_day_from_fields(vm, fields.as_object(), *options));
|
||||
|
||||
// 7. Return ? CreateTemporalMonthDay(result.[[Month]], result.[[Day]], calendar, result.[[ReferenceISOYear]]).
|
||||
return TRY(create_temporal_month_day(vm, result.month, result.day, *calendar, result.reference_iso_year));
|
||||
return TRY(create_temporal_month_day(vm, result.month, result.day, calendar, result.reference_iso_year));
|
||||
}
|
||||
|
||||
// 12.4.7 Temporal.Calendar.prototype.dateAdd ( date, duration [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.calendar.prototype.dateadd
|
||||
|
@ -164,7 +164,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::date_add)
|
|||
{
|
||||
// 1. Let calendar be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
auto* calendar = TRY(typed_this_object(vm));
|
||||
auto calendar = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Assert: calendar.[[Identifier]] is "iso8601".
|
||||
VERIFY(calendar->identifier() == "iso8601"sv);
|
||||
|
@ -188,7 +188,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::date_add)
|
|||
auto result = TRY(add_iso_date(vm, date->iso_year(), date->iso_month(), date->iso_day(), duration->years(), duration->months(), duration->weeks(), balance_result.days, overflow));
|
||||
|
||||
// 10. Return ? CreateTemporalDate(result.[[Year]], result.[[Month]], result.[[Day]], calendar).
|
||||
return TRY(create_temporal_date(vm, result.year, result.month, result.day, *calendar));
|
||||
return TRY(create_temporal_date(vm, result.year, result.month, result.day, calendar));
|
||||
}
|
||||
|
||||
// 12.4.8 Temporal.Calendar.prototype.dateUntil ( one, two [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.calendar.prototype.dateuntil
|
||||
|
@ -197,7 +197,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::date_until)
|
|||
{
|
||||
// 1. Let calendar be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
auto* calendar = TRY(typed_this_object(vm));
|
||||
auto calendar = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Assert: calendar.[[Identifier]] is "iso8601".
|
||||
VERIFY(calendar->identifier() == "iso8601"sv);
|
||||
|
@ -231,7 +231,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::year)
|
|||
{
|
||||
// 1. Let calendar be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
auto* calendar = TRY(typed_this_object(vm));
|
||||
auto calendar = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Assert: calendar.[[Identifier]] is "iso8601".
|
||||
VERIFY(calendar->identifier() == "iso8601"sv);
|
||||
|
@ -256,7 +256,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::month)
|
|||
{
|
||||
// 1. Let calendar be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
auto* calendar = TRY(typed_this_object(vm));
|
||||
auto calendar = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Assert: calendar.[[Identifier]] is "iso8601".
|
||||
VERIFY(calendar->identifier() == "iso8601"sv);
|
||||
|
@ -287,7 +287,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::month_code)
|
|||
{
|
||||
// 1. Let calendar be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
auto* calendar = TRY(typed_this_object(vm));
|
||||
auto calendar = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Assert: calendar.[[Identifier]] is "iso8601".
|
||||
VERIFY(calendar->identifier() == "iso8601"sv);
|
||||
|
@ -312,7 +312,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::day)
|
|||
{
|
||||
// 1. Let calendar be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
auto* calendar = TRY(typed_this_object(vm));
|
||||
auto calendar = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Assert: calendar.[[Identifier]] is "iso8601".
|
||||
VERIFY(calendar->identifier() == "iso8601"sv);
|
||||
|
@ -336,7 +336,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::day_of_week)
|
|||
{
|
||||
// 1. Let calendar be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
auto* calendar = TRY(typed_this_object(vm));
|
||||
auto calendar = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Assert: calendar.[[Identifier]] is "iso8601".
|
||||
VERIFY(calendar->identifier() == "iso8601"sv);
|
||||
|
@ -354,7 +354,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::day_of_year)
|
|||
{
|
||||
// 1. Let calendar be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
auto* calendar = TRY(typed_this_object(vm));
|
||||
auto calendar = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Assert: calendar.[[Identifier]] is "iso8601".
|
||||
VERIFY(calendar->identifier() == "iso8601"sv);
|
||||
|
@ -372,7 +372,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::week_of_year)
|
|||
{
|
||||
// 1. Let calendar be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
auto* calendar = TRY(typed_this_object(vm));
|
||||
auto calendar = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Assert: calendar.[[Identifier]] is "iso8601".
|
||||
VERIFY(calendar->identifier() == "iso8601"sv);
|
||||
|
@ -393,7 +393,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::year_of_week)
|
|||
{
|
||||
// 1. Let calendar be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
auto* calendar = TRY(typed_this_object(vm));
|
||||
auto calendar = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Assert: calendar.[[Identifier]] is "iso8601".
|
||||
VERIFY(calendar->identifier() == "iso8601"sv);
|
||||
|
@ -414,7 +414,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::days_in_week)
|
|||
{
|
||||
// 1. Let calendar be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
auto* calendar = TRY(typed_this_object(vm));
|
||||
auto calendar = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Assert: calendar.[[Identifier]] is "iso8601".
|
||||
VERIFY(calendar->identifier() == "iso8601"sv);
|
||||
|
@ -432,7 +432,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::days_in_month)
|
|||
{
|
||||
// 1. Let calendar be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
auto* calendar = TRY(typed_this_object(vm));
|
||||
auto calendar = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Assert: calendar.[[Identifier]] is "iso8601".
|
||||
VERIFY(calendar->identifier() == "iso8601"sv);
|
||||
|
@ -454,7 +454,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::days_in_year)
|
|||
{
|
||||
// 1. Let calendar be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
auto* calendar = TRY(typed_this_object(vm));
|
||||
auto calendar = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Assert: calendar.[[Identifier]] is "iso8601".
|
||||
VERIFY(calendar->identifier() == "iso8601"sv);
|
||||
|
@ -476,7 +476,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::months_in_year)
|
|||
{
|
||||
// 1. Let calendar be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
auto* calendar = TRY(typed_this_object(vm));
|
||||
auto calendar = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Assert: calendar.[[Identifier]] is "iso8601".
|
||||
VERIFY(calendar->identifier() == "iso8601"sv);
|
||||
|
@ -498,7 +498,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::in_leap_year)
|
|||
{
|
||||
// 1. Let calendar be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
auto* calendar = TRY(typed_this_object(vm));
|
||||
auto calendar = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Assert: calendar.[[Identifier]] is "iso8601".
|
||||
VERIFY(calendar->identifier() == "iso8601"sv);
|
||||
|
@ -528,7 +528,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::fields)
|
|||
|
||||
// 1. Let calendar be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
auto* calendar = TRY(typed_this_object(vm));
|
||||
auto calendar = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Assert: calendar.[[Identifier]] is "iso8601".
|
||||
VERIFY(calendar->identifier() == "iso8601"sv);
|
||||
|
@ -595,7 +595,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::merge_fields)
|
|||
{
|
||||
// 1. Let calendar be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
auto* calendar = TRY(typed_this_object(vm));
|
||||
auto calendar = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Set fields to ? ToObject(fields).
|
||||
auto fields = TRY(vm.argument(0).to_object(vm));
|
||||
|
@ -615,7 +615,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::to_string)
|
|||
{
|
||||
// 1. Let calendar be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
auto* calendar = TRY(typed_this_object(vm));
|
||||
auto calendar = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return calendar.[[Identifier]].
|
||||
return PrimitiveString::create(vm, calendar->identifier());
|
||||
|
@ -626,7 +626,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::to_json)
|
|||
{
|
||||
// 1. Let calendar be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
auto* calendar = TRY(typed_this_object(vm));
|
||||
auto calendar = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? ToString(calendar).
|
||||
return PrimitiveString::create(vm, TRY(Value(calendar).to_string(vm)));
|
||||
|
@ -639,7 +639,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::era)
|
|||
|
||||
// 1. Let calendar be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
auto* calendar = TRY(typed_this_object(vm));
|
||||
auto calendar = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If Type(temporalDateLike) is not Object or temporalDateLike does not have an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], or [[InitializedTemporalYearMonth]] internal slot, then
|
||||
if (!temporal_date_like.is_object() || !(is<PlainDate>(temporal_date_like.as_object()) || is<PlainDateTime>(temporal_date_like.as_object()) || is<PlainYearMonth>(temporal_date_like.as_object()))) {
|
||||
|
@ -667,7 +667,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::era_year)
|
|||
|
||||
// 1. Let calendar be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
|
||||
auto* calendar = TRY(typed_this_object(vm));
|
||||
auto calendar = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If Type(temporalDateLike) is not Object or temporalDateLike does not have an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], or [[InitializedTemporalYearMonth]] internal slot, then
|
||||
if (!temporal_date_like.is_object() || !(is<PlainDate>(temporal_date_like.as_object()) || is<PlainDateTime>(temporal_date_like.as_object()) || is<PlainYearMonth>(temporal_date_like.as_object()))) {
|
||||
|
|
|
@ -63,7 +63,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::years_getter)
|
|||
{
|
||||
// 1. Let duration be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
|
||||
auto* duration = TRY(typed_this_object(vm));
|
||||
auto duration = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return 𝔽(duration.[[Years]]).
|
||||
return Value(duration->years());
|
||||
|
@ -74,7 +74,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::months_getter)
|
|||
{
|
||||
// 1. Let duration be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
|
||||
auto* duration = TRY(typed_this_object(vm));
|
||||
auto duration = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return 𝔽(duration.[[Months]]).
|
||||
return Value(duration->months());
|
||||
|
@ -85,7 +85,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::weeks_getter)
|
|||
{
|
||||
// 1. Let duration be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
|
||||
auto* duration = TRY(typed_this_object(vm));
|
||||
auto duration = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return 𝔽(duration.[[Weeks]]).
|
||||
return Value(duration->weeks());
|
||||
|
@ -96,7 +96,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::days_getter)
|
|||
{
|
||||
// 1. Let duration be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
|
||||
auto* duration = TRY(typed_this_object(vm));
|
||||
auto duration = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return 𝔽(duration.[[Days]]).
|
||||
return Value(duration->days());
|
||||
|
@ -107,7 +107,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::hours_getter)
|
|||
{
|
||||
// 1. Let duration be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
|
||||
auto* duration = TRY(typed_this_object(vm));
|
||||
auto duration = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return 𝔽(duration.[[Hours]]).
|
||||
return Value(duration->hours());
|
||||
|
@ -118,7 +118,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::minutes_getter)
|
|||
{
|
||||
// 1. Let duration be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
|
||||
auto* duration = TRY(typed_this_object(vm));
|
||||
auto duration = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return 𝔽(duration.[[Minutes]]).
|
||||
return Value(duration->minutes());
|
||||
|
@ -129,7 +129,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::seconds_getter)
|
|||
{
|
||||
// 1. Let duration be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
|
||||
auto* duration = TRY(typed_this_object(vm));
|
||||
auto duration = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return 𝔽(duration.[[Seconds]]).
|
||||
return Value(duration->seconds());
|
||||
|
@ -140,7 +140,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::milliseconds_getter)
|
|||
{
|
||||
// 1. Let duration be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
|
||||
auto* duration = TRY(typed_this_object(vm));
|
||||
auto duration = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return 𝔽(duration.[[Milliseconds]]).
|
||||
return Value(duration->milliseconds());
|
||||
|
@ -151,7 +151,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::microseconds_getter)
|
|||
{
|
||||
// 1. Let duration be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
|
||||
auto* duration = TRY(typed_this_object(vm));
|
||||
auto duration = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return 𝔽(duration.[[Microseconds]]).
|
||||
return Value(duration->microseconds());
|
||||
|
@ -162,7 +162,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::nanoseconds_getter)
|
|||
{
|
||||
// 1. Let duration be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
|
||||
auto* duration = TRY(typed_this_object(vm));
|
||||
auto duration = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return 𝔽(duration.[[Nanoseconds]]).
|
||||
return Value(duration->nanoseconds());
|
||||
|
@ -173,7 +173,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::sign_getter)
|
|||
{
|
||||
// 1. Let duration be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
|
||||
auto* duration = TRY(typed_this_object(vm));
|
||||
auto duration = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return 𝔽(! DurationSign(duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]])).
|
||||
return Value(duration_sign(duration->years(), duration->months(), duration->weeks(), duration->days(), duration->hours(), duration->minutes(), duration->seconds(), duration->milliseconds(), duration->microseconds(), duration->nanoseconds()));
|
||||
|
@ -184,7 +184,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::blank_getter)
|
|||
{
|
||||
// 1. Let duration be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
|
||||
auto* duration = TRY(typed_this_object(vm));
|
||||
auto duration = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let sign be ! DurationSign(duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]]).
|
||||
auto sign = duration_sign(duration->years(), duration->months(), duration->weeks(), duration->days(), duration->hours(), duration->minutes(), duration->seconds(), duration->milliseconds(), duration->microseconds(), duration->nanoseconds());
|
||||
|
@ -202,7 +202,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::with)
|
|||
{
|
||||
// 1. Let duration be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
|
||||
auto* duration = TRY(typed_this_object(vm));
|
||||
auto duration = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let temporalDurationLike be ? ToTemporalPartialDurationRecord(temporalDurationLike).
|
||||
auto temporal_duration_like = TRY(to_temporal_partial_duration_record(vm, vm.argument(0)));
|
||||
|
@ -276,10 +276,10 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::negated)
|
|||
{
|
||||
// 1. Let duration be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
|
||||
auto* duration = TRY(typed_this_object(vm));
|
||||
auto duration = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ! CreateNegatedTemporalDuration(duration).
|
||||
return create_negated_temporal_duration(vm, *duration);
|
||||
return create_negated_temporal_duration(vm, duration);
|
||||
}
|
||||
|
||||
// 7.3.17 Temporal.Duration.prototype.abs ( ), https://tc39.es/proposal-temporal/#sec-temporal.duration.prototype.abs
|
||||
|
@ -287,7 +287,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::abs)
|
|||
{
|
||||
// 1. Let duration be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
|
||||
auto* duration = TRY(typed_this_object(vm));
|
||||
auto duration = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ! CreateTemporalDuration(abs(duration.[[Years]]), abs(duration.[[Months]]), abs(duration.[[Weeks]]), abs(duration.[[Days]]), abs(duration.[[Hours]]), abs(duration.[[Minutes]]), abs(duration.[[Seconds]]), abs(duration.[[Milliseconds]]), abs(duration.[[Microseconds]]), abs(duration.[[Nanoseconds]])).
|
||||
return TRY(create_temporal_duration(vm, fabs(duration->years()), fabs(duration->months()), fabs(duration->weeks()), fabs(duration->days()), fabs(duration->hours()), fabs(duration->minutes()), fabs(duration->seconds()), fabs(duration->milliseconds()), fabs(duration->microseconds()), fabs(duration->nanoseconds())));
|
||||
|
@ -301,10 +301,10 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::add)
|
|||
|
||||
// 1. Let duration be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
|
||||
auto* duration = TRY(typed_this_object(vm));
|
||||
auto duration = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? AddDurationToOrSubtractDurationFromDuration(add, duration, other, options).
|
||||
return TRY(add_duration_to_or_subtract_duration_from_duration(vm, ArithmeticOperation::Add, *duration, other, options));
|
||||
return TRY(add_duration_to_or_subtract_duration_from_duration(vm, ArithmeticOperation::Add, duration, other, options));
|
||||
}
|
||||
|
||||
// 7.3.19 Temporal.Duration.prototype.subtract ( other [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.duration.prototype.subtract
|
||||
|
@ -315,10 +315,10 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::subtract)
|
|||
|
||||
// 1. Let duration be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
|
||||
auto* duration = TRY(typed_this_object(vm));
|
||||
auto duration = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? AddDurationToOrSubtractDurationFromDuration(subtract, duration, other, options).
|
||||
return TRY(add_duration_to_or_subtract_duration_from_duration(vm, ArithmeticOperation::Subtract, *duration, other, options));
|
||||
return TRY(add_duration_to_or_subtract_duration_from_duration(vm, ArithmeticOperation::Subtract, duration, other, options));
|
||||
}
|
||||
|
||||
// 7.3.20 Temporal.Duration.prototype.round ( roundTo ), https://tc39.es/proposal-temporal/#sec-temporal.duration.prototype.round
|
||||
|
@ -328,7 +328,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::round)
|
|||
|
||||
// 1. Let duration be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
|
||||
auto* duration = TRY(typed_this_object(vm));
|
||||
auto duration = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If roundTo is undefined, then
|
||||
if (vm.argument(0).is_undefined()) {
|
||||
|
@ -451,7 +451,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::total)
|
|||
|
||||
// 1. Let duration be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
|
||||
auto* duration = TRY(typed_this_object(vm));
|
||||
auto duration = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If totalOf is undefined, throw a TypeError exception.
|
||||
if (vm.argument(0).is_undefined())
|
||||
|
@ -569,7 +569,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::to_string)
|
|||
{
|
||||
// 1. Let duration be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
|
||||
auto* duration = TRY(typed_this_object(vm));
|
||||
auto duration = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Set options to ? GetOptionsObject(options).
|
||||
auto const* options = TRY(get_options_object(vm, vm.argument(0)));
|
||||
|
@ -596,7 +596,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::to_json)
|
|||
{
|
||||
// 1. Let duration be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
|
||||
auto* duration = TRY(typed_this_object(vm));
|
||||
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 PrimitiveString::create(vm, MUST_OR_THROW_OOM(temporal_duration_to_string(vm, duration->years(), duration->months(), duration->weeks(), duration->days(), duration->hours(), duration->minutes(), duration->seconds(), duration->milliseconds(), duration->microseconds(), duration->nanoseconds(), "auto"sv)));
|
||||
|
@ -608,7 +608,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::to_locale_string)
|
|||
{
|
||||
// 1. Let duration be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]).
|
||||
auto* duration = TRY(typed_this_object(vm));
|
||||
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 PrimitiveString::create(vm, MUST_OR_THROW_OOM(temporal_duration_to_string(vm, duration->years(), duration->months(), duration->weeks(), duration->days(), duration->hours(), duration->minutes(), duration->seconds(), duration->milliseconds(), duration->microseconds(), duration->nanoseconds(), "auto"sv)));
|
||||
|
|
|
@ -60,7 +60,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::epoch_seconds_getter)
|
|||
{
|
||||
// 1. Let instant be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]).
|
||||
auto* instant = TRY(typed_this_object(vm));
|
||||
auto instant = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let ns be instant.[[Nanoseconds]].
|
||||
auto& ns = instant->nanoseconds();
|
||||
|
@ -77,7 +77,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::epoch_milliseconds_getter)
|
|||
{
|
||||
// 1. Let instant be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]).
|
||||
auto* instant = TRY(typed_this_object(vm));
|
||||
auto instant = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let ns be instant.[[Nanoseconds]].
|
||||
auto& ns = instant->nanoseconds();
|
||||
|
@ -94,7 +94,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::epoch_microseconds_getter)
|
|||
{
|
||||
// 1. Let instant be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]).
|
||||
auto* instant = TRY(typed_this_object(vm));
|
||||
auto instant = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let ns be instant.[[Nanoseconds]].
|
||||
auto& ns = instant->nanoseconds();
|
||||
|
@ -111,7 +111,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::epoch_nanoseconds_getter)
|
|||
{
|
||||
// 1. Let instant be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]).
|
||||
auto* instant = TRY(typed_this_object(vm));
|
||||
auto instant = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let ns be instant.[[Nanoseconds]].
|
||||
auto& ns = instant->nanoseconds();
|
||||
|
@ -127,10 +127,10 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::add)
|
|||
|
||||
// 1. Let instant be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]).
|
||||
auto* instant = TRY(typed_this_object(vm));
|
||||
auto instant = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? AddDurationToOrSubtractDurationFromInstant(add, instant, temporalDurationLike).
|
||||
return TRY(add_duration_to_or_subtract_duration_from_instant(vm, ArithmeticOperation::Add, *instant, temporal_duration_like));
|
||||
return TRY(add_duration_to_or_subtract_duration_from_instant(vm, ArithmeticOperation::Add, instant, temporal_duration_like));
|
||||
}
|
||||
|
||||
// 8.3.8 Temporal.Instant.prototype.subtract ( temporalDurationLike ), https://tc39.es/proposal-temporal/#sec-temporal.instant.prototype.subtract
|
||||
|
@ -140,10 +140,10 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::subtract)
|
|||
|
||||
// 1. Let instant be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]).
|
||||
auto* instant = TRY(typed_this_object(vm));
|
||||
auto instant = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? AddDurationToOrSubtractDurationFromInstant(subtract, instant, temporalDurationLike).
|
||||
return TRY(add_duration_to_or_subtract_duration_from_instant(vm, ArithmeticOperation::Subtract, *instant, temporal_duration_like));
|
||||
return TRY(add_duration_to_or_subtract_duration_from_instant(vm, ArithmeticOperation::Subtract, instant, temporal_duration_like));
|
||||
}
|
||||
|
||||
// 8.3.9 Temporal.Instant.prototype.until ( other [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.instant.prototype.until
|
||||
|
@ -154,10 +154,10 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::until)
|
|||
|
||||
// 1. Let instant be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]).
|
||||
auto* instant = TRY(typed_this_object(vm));
|
||||
auto instant = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? DifferenceTemporalInstant(until, instant, other, options).
|
||||
return TRY(difference_temporal_instant(vm, DifferenceOperation::Until, *instant, other, options));
|
||||
return TRY(difference_temporal_instant(vm, DifferenceOperation::Until, instant, other, options));
|
||||
}
|
||||
|
||||
// 8.3.10 Temporal.Instant.prototype.since ( other [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.instant.prototype.since
|
||||
|
@ -168,10 +168,10 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::since)
|
|||
|
||||
// 1. Let instant be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]).
|
||||
auto* instant = TRY(typed_this_object(vm));
|
||||
auto instant = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? DifferenceTemporalInstant(since, instant, other, options).
|
||||
return TRY(difference_temporal_instant(vm, DifferenceOperation::Since, *instant, other, options));
|
||||
return TRY(difference_temporal_instant(vm, DifferenceOperation::Since, instant, other, options));
|
||||
}
|
||||
|
||||
// 8.3.11 Temporal.Instant.prototype.round ( roundTo ), https://tc39.es/proposal-temporal/#sec-temporal.instant.prototype.round
|
||||
|
@ -181,7 +181,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::round)
|
|||
|
||||
// 1. Let instant be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]).
|
||||
auto* instant = TRY(typed_this_object(vm));
|
||||
auto instant = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If roundTo is undefined, then
|
||||
if (vm.argument(0).is_undefined()) {
|
||||
|
@ -269,7 +269,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::equals)
|
|||
{
|
||||
// 1. Let instant be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]).
|
||||
auto* instant = TRY(typed_this_object(vm));
|
||||
auto instant = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Set other to ? ToTemporalInstant(other).
|
||||
auto other = TRY(to_temporal_instant(vm, vm.argument(0)));
|
||||
|
@ -287,7 +287,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::to_string)
|
|||
{
|
||||
// 1. Let instant be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]).
|
||||
auto* instant = TRY(typed_this_object(vm));
|
||||
auto instant = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Set options to ? GetOptionsObject(options).
|
||||
auto const* options = TRY(get_options_object(vm, vm.argument(0)));
|
||||
|
@ -323,10 +323,10 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::to_locale_string)
|
|||
{
|
||||
// 1. Let instant be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]).
|
||||
auto* instant = TRY(typed_this_object(vm));
|
||||
auto instant = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? TemporalInstantToString(instant, undefined, "auto").
|
||||
return PrimitiveString::create(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
|
||||
|
@ -334,10 +334,10 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::to_json)
|
|||
{
|
||||
// 1. Let instant be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]).
|
||||
auto* instant = TRY(typed_this_object(vm));
|
||||
auto instant = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? TemporalInstantToString(instant, undefined, "auto").
|
||||
return PrimitiveString::create(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
|
||||
|
@ -354,7 +354,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::to_zoned_date_time)
|
|||
|
||||
// 1. Let instant be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]).
|
||||
auto* instant = TRY(typed_this_object(vm));
|
||||
auto instant = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If Type(item) is not Object, then
|
||||
if (!item.is_object()) {
|
||||
|
@ -395,7 +395,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::to_zoned_date_time_iso)
|
|||
{
|
||||
// 1. Let instant be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]).
|
||||
auto* instant = TRY(typed_this_object(vm));
|
||||
auto instant = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Set timeZone to ? ToTemporalTimeZone(timeZone).
|
||||
auto* time_zone = TRY(to_temporal_time_zone(vm, vm.argument(0)));
|
||||
|
|
|
@ -77,7 +77,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::calendar_getter)
|
|||
{
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
|
||||
auto* temporal_date = TRY(typed_this_object(vm));
|
||||
auto temporal_date = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return temporalDate.[[Calendar]].
|
||||
return Value(&temporal_date->calendar());
|
||||
|
@ -88,13 +88,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::year_getter)
|
|||
{
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
|
||||
auto* temporal_date = TRY(typed_this_object(vm));
|
||||
auto temporal_date = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be temporalDate.[[Calendar]].
|
||||
auto& calendar = temporal_date->calendar();
|
||||
|
||||
// 4. Return 𝔽(? CalendarYear(calendar, temporalDate)).
|
||||
return TRY(calendar_year(vm, calendar, *temporal_date));
|
||||
return TRY(calendar_year(vm, calendar, temporal_date));
|
||||
}
|
||||
|
||||
// 3.3.5 get Temporal.PlainDate.prototype.month, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindate.prototype.month
|
||||
|
@ -102,13 +102,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::month_getter)
|
|||
{
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
|
||||
auto* temporal_date = TRY(typed_this_object(vm));
|
||||
auto temporal_date = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be temporalDate.[[Calendar]].
|
||||
auto& calendar = temporal_date->calendar();
|
||||
|
||||
// 4. Return 𝔽(? CalendarMonth(calendar, temporalDate)).
|
||||
return TRY(calendar_month(vm, calendar, *temporal_date));
|
||||
return TRY(calendar_month(vm, calendar, temporal_date));
|
||||
}
|
||||
|
||||
// 3.3.6 get Temporal.PlainDate.prototype.monthCode, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindate.prototype.monthCode
|
||||
|
@ -116,13 +116,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::month_code_getter)
|
|||
{
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
|
||||
auto* temporal_date = TRY(typed_this_object(vm));
|
||||
auto temporal_date = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be temporalDate.[[Calendar]].
|
||||
auto& calendar = temporal_date->calendar();
|
||||
|
||||
// 4. Return ? CalendarMonthCode(calendar, temporalDate).
|
||||
return PrimitiveString::create(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
|
||||
|
@ -130,13 +130,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::day_getter)
|
|||
{
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
|
||||
auto* temporal_date = TRY(typed_this_object(vm));
|
||||
auto temporal_date = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be temporalDate.[[Calendar]].
|
||||
auto& calendar = temporal_date->calendar();
|
||||
|
||||
// 4. Return 𝔽(? CalendarDay(calendar, temporalDate)).
|
||||
return TRY(calendar_day(vm, calendar, *temporal_date));
|
||||
return TRY(calendar_day(vm, calendar, temporal_date));
|
||||
}
|
||||
|
||||
// 3.3.8 get Temporal.PlainDate.prototype.dayOfWeek, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindate.prototype.dayofweek
|
||||
|
@ -144,13 +144,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::day_of_week_getter)
|
|||
{
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
|
||||
auto* temporal_date = TRY(typed_this_object(vm));
|
||||
auto temporal_date = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be temporalDate.[[Calendar]].
|
||||
auto& calendar = temporal_date->calendar();
|
||||
|
||||
// Return 𝔽(? CalendarDayOfWeek(calendar, temporalDate)).
|
||||
return TRY(calendar_day_of_week(vm, calendar, *temporal_date));
|
||||
return TRY(calendar_day_of_week(vm, calendar, temporal_date));
|
||||
}
|
||||
|
||||
// 3.3.9 get Temporal.PlainDate.prototype.dayOfYear, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindate.prototype.dayofyear
|
||||
|
@ -158,13 +158,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::day_of_year_getter)
|
|||
{
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
|
||||
auto* temporal_date = TRY(typed_this_object(vm));
|
||||
auto temporal_date = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be temporalDate.[[Calendar]].
|
||||
auto& calendar = temporal_date->calendar();
|
||||
|
||||
// 4. Return 𝔽(? CalendarDayOfYear(calendar, temporalDate)).
|
||||
return TRY(calendar_day_of_year(vm, calendar, *temporal_date));
|
||||
return TRY(calendar_day_of_year(vm, calendar, temporal_date));
|
||||
}
|
||||
|
||||
// 3.3.10 get Temporal.PlainDate.prototype.weekOfYear, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindate.prototype.weekofyear
|
||||
|
@ -172,13 +172,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::week_of_year_getter)
|
|||
{
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
|
||||
auto* temporal_date = TRY(typed_this_object(vm));
|
||||
auto temporal_date = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be temporalDate.[[Calendar]].
|
||||
auto& calendar = temporal_date->calendar();
|
||||
|
||||
// 4. Return 𝔽(? CalendarWeekOfYear(calendar, temporalDate)).
|
||||
return TRY(calendar_week_of_year(vm, calendar, *temporal_date));
|
||||
return TRY(calendar_week_of_year(vm, calendar, temporal_date));
|
||||
}
|
||||
|
||||
// 3.3.11 get Temporal.PlainDate.prototype.yearOfWeek, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindate.prototype.yearofweek
|
||||
|
@ -186,13 +186,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::year_of_week_getter)
|
|||
{
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
|
||||
auto* temporal_date = TRY(typed_this_object(vm));
|
||||
auto temporal_date = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be temporalDate.[[Calendar]].
|
||||
auto& calendar = temporal_date->calendar();
|
||||
|
||||
// 4. Return 𝔽(? CalendarYearOfWeek(calendar, temporalDate)).
|
||||
return TRY(calendar_year_of_week(vm, calendar, *temporal_date));
|
||||
return TRY(calendar_year_of_week(vm, calendar, temporal_date));
|
||||
}
|
||||
|
||||
// 3.3.12 get Temporal.PlainDate.prototype.daysInWeek, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindate.prototype.daysinweek
|
||||
|
@ -200,13 +200,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::days_in_week_getter)
|
|||
{
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
|
||||
auto* temporal_date = TRY(typed_this_object(vm));
|
||||
auto temporal_date = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be temporalDate.[[Calendar]].
|
||||
auto& calendar = temporal_date->calendar();
|
||||
|
||||
// 4. Return 𝔽(? CalendarDaysInWeek(calendar, temporalDate)).
|
||||
return TRY(calendar_days_in_week(vm, calendar, *temporal_date));
|
||||
return TRY(calendar_days_in_week(vm, calendar, temporal_date));
|
||||
}
|
||||
|
||||
// 3.3.13 get Temporal.PlainDate.prototype.daysInMonth, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindate.prototype.daysinmonth
|
||||
|
@ -214,13 +214,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::days_in_month_getter)
|
|||
{
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
|
||||
auto* temporal_date = TRY(typed_this_object(vm));
|
||||
auto temporal_date = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be temporalDate.[[Calendar]].
|
||||
auto& calendar = temporal_date->calendar();
|
||||
|
||||
// 4. Return 𝔽(? CalendarDaysInMonth(calendar, temporalDate)).
|
||||
return TRY(calendar_days_in_month(vm, calendar, *temporal_date));
|
||||
return TRY(calendar_days_in_month(vm, calendar, temporal_date));
|
||||
}
|
||||
|
||||
// 3.3.14 get Temporal.PlainDate.prototype.daysInYear, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindate.prototype.daysinyear
|
||||
|
@ -228,13 +228,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::days_in_year_getter)
|
|||
{
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
|
||||
auto* temporal_date = TRY(typed_this_object(vm));
|
||||
auto temporal_date = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be temporalDate.[[Calendar]].
|
||||
auto& calendar = temporal_date->calendar();
|
||||
|
||||
// 4. Return 𝔽(? CalendarDaysInYear(calendar, temporalDate)).
|
||||
return TRY(calendar_days_in_year(vm, calendar, *temporal_date));
|
||||
return TRY(calendar_days_in_year(vm, calendar, temporal_date));
|
||||
}
|
||||
|
||||
// 3.3.15 get Temporal.PlainDate.prototype.monthsInYear, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindate.prototype.monthsinyear
|
||||
|
@ -242,13 +242,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::months_in_year_getter)
|
|||
{
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
|
||||
auto* temporal_date = TRY(typed_this_object(vm));
|
||||
auto temporal_date = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be temporalDate.[[Calendar]].
|
||||
auto& calendar = temporal_date->calendar();
|
||||
|
||||
// 4. Return 𝔽(? CalendarMonthsInYear(calendar, temporalDate)).
|
||||
return TRY(calendar_months_in_year(vm, calendar, *temporal_date));
|
||||
return TRY(calendar_months_in_year(vm, calendar, temporal_date));
|
||||
}
|
||||
|
||||
// 3.3.16 get Temporal.PlainDate.prototype.inLeapYear, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindate.prototype.inleapyear
|
||||
|
@ -256,13 +256,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::in_leap_year_getter)
|
|||
{
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
|
||||
auto* temporal_date = TRY(typed_this_object(vm));
|
||||
auto temporal_date = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be temporalDate.[[Calendar]].
|
||||
auto& calendar = temporal_date->calendar();
|
||||
|
||||
// 4. Return ? CalendarInLeapYear(calendar, temporalDate).
|
||||
return Value(TRY(calendar_in_leap_year(vm, calendar, *temporal_date)));
|
||||
return Value(TRY(calendar_in_leap_year(vm, calendar, temporal_date)));
|
||||
}
|
||||
|
||||
// 15.6.5.2 get Temporal.PlainDate.prototype.era, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindate.prototype.era
|
||||
|
@ -270,13 +270,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::era_getter)
|
|||
{
|
||||
// 1. Let plainDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(plainDate, [[InitializedTemporalDate]]).
|
||||
auto* plain_date = TRY(typed_this_object(vm));
|
||||
auto plain_date = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be plainDate.[[Calendar]].
|
||||
auto& calendar = plain_date->calendar();
|
||||
|
||||
// 4. Return ? CalendarEra(calendar, plainDate).
|
||||
return TRY(calendar_era(vm, calendar, *plain_date));
|
||||
return TRY(calendar_era(vm, calendar, plain_date));
|
||||
}
|
||||
|
||||
// 15.6.5.3 get Temporal.PlainDate.prototype.eraYear, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindate.prototype.erayear
|
||||
|
@ -284,13 +284,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::era_year_getter)
|
|||
{
|
||||
// 1. Let plainDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(plainDate, [[InitializedTemporalDate]]).
|
||||
auto* plain_date = TRY(typed_this_object(vm));
|
||||
auto plain_date = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be plainDate.[[Calendar]].
|
||||
auto& calendar = plain_date->calendar();
|
||||
|
||||
// 4. Return ? CalendarEraYear(calendar, plainDate).
|
||||
return TRY(calendar_era_year(vm, calendar, *plain_date));
|
||||
return TRY(calendar_era_year(vm, calendar, plain_date));
|
||||
}
|
||||
|
||||
// 3.3.17 Temporal.PlainDate.prototype.toPlainYearMonth ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype.toplainyearmonth
|
||||
|
@ -298,7 +298,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::to_plain_year_month)
|
|||
{
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
|
||||
auto* temporal_date = TRY(typed_this_object(vm));
|
||||
auto temporal_date = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be temporalDate.[[Calendar]].
|
||||
auto& calendar = temporal_date->calendar();
|
||||
|
@ -307,7 +307,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::to_plain_year_month)
|
|||
auto field_names = TRY(calendar_fields(vm, calendar, { "monthCode"sv, "year"sv }));
|
||||
|
||||
// 5. Let fields be ? PrepareTemporalFields(temporalDate, fieldNames, «»).
|
||||
auto* fields = TRY(prepare_temporal_fields(vm, *temporal_date, field_names, Vector<StringView> {}));
|
||||
auto* fields = TRY(prepare_temporal_fields(vm, temporal_date, field_names, Vector<StringView> {}));
|
||||
|
||||
// 6. Return ? CalendarYearMonthFromFields(calendar, fields).
|
||||
return TRY(calendar_year_month_from_fields(vm, calendar, *fields));
|
||||
|
@ -318,7 +318,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::to_plain_month_day)
|
|||
{
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
|
||||
auto* temporal_date = TRY(typed_this_object(vm));
|
||||
auto temporal_date = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be temporalDate.[[Calendar]].
|
||||
auto& calendar = temporal_date->calendar();
|
||||
|
@ -327,7 +327,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::to_plain_month_day)
|
|||
auto field_names = TRY(calendar_fields(vm, calendar, { "day"sv, "monthCode"sv }));
|
||||
|
||||
// 5. Let fields be ? PrepareTemporalFields(temporalDate, fieldNames, «»).
|
||||
auto* fields = TRY(prepare_temporal_fields(vm, *temporal_date, field_names, Vector<StringView> {}));
|
||||
auto* fields = TRY(prepare_temporal_fields(vm, temporal_date, field_names, Vector<StringView> {}));
|
||||
|
||||
// 6. Return ? CalendarMonthDayFromFields(calendar, fields).
|
||||
return TRY(calendar_month_day_from_fields(vm, calendar, *fields));
|
||||
|
@ -340,7 +340,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::get_iso_fields)
|
|||
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
|
||||
auto* temporal_date = TRY(typed_this_object(vm));
|
||||
auto temporal_date = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let fields be OrdinaryObjectCreate(%Object.prototype%).
|
||||
auto fields = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
|
@ -366,7 +366,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::add)
|
|||
{
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
|
||||
auto* temporal_date = TRY(typed_this_object(vm));
|
||||
auto temporal_date = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let duration be ? ToTemporalDuration(temporalDurationLike).
|
||||
auto* duration = TRY(to_temporal_duration(vm, vm.argument(0)));
|
||||
|
@ -383,7 +383,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::subtract)
|
|||
{
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
|
||||
auto* temporal_date = TRY(typed_this_object(vm));
|
||||
auto temporal_date = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let duration be ? ToTemporalDuration(temporalDurationLike).
|
||||
auto* duration = TRY(to_temporal_duration(vm, vm.argument(0)));
|
||||
|
@ -405,7 +405,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::with)
|
|||
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
|
||||
auto* temporal_date = TRY(typed_this_object(vm));
|
||||
auto temporal_date = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If Type(temporalDateLike) is not Object, then
|
||||
if (!temporal_date_like.is_object()) {
|
||||
|
@ -429,7 +429,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::with)
|
|||
auto const* options = TRY(get_options_object(vm, vm.argument(1)));
|
||||
|
||||
// 9. Let fields be ? PrepareTemporalFields(temporalDate, fieldNames, «»).
|
||||
auto* fields = TRY(prepare_temporal_fields(vm, *temporal_date, field_names, Vector<StringView> {}));
|
||||
auto* fields = TRY(prepare_temporal_fields(vm, temporal_date, field_names, Vector<StringView> {}));
|
||||
|
||||
// 10. Set fields to ? CalendarMergeFields(calendar, fields, partialDate).
|
||||
fields = TRY(calendar_merge_fields(vm, calendar, *fields, *partial_date));
|
||||
|
@ -448,7 +448,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::with_calendar)
|
|||
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
|
||||
auto* temporal_date = TRY(typed_this_object(vm));
|
||||
auto temporal_date = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be ? ToTemporalCalendar(calendarLike).
|
||||
auto* calendar = TRY(to_temporal_calendar(vm, calendar_like));
|
||||
|
@ -465,10 +465,10 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::until)
|
|||
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
|
||||
auto* temporal_date = TRY(typed_this_object(vm));
|
||||
auto temporal_date = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? DifferenceTemporalPlainDate(until, temporalDate, other, options).
|
||||
return TRY(difference_temporal_plain_date(vm, DifferenceOperation::Until, *temporal_date, other, options));
|
||||
return TRY(difference_temporal_plain_date(vm, DifferenceOperation::Until, temporal_date, other, options));
|
||||
}
|
||||
|
||||
// 3.3.25 Temporal.PlainDate.prototype.since ( other [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype.since
|
||||
|
@ -479,10 +479,10 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::since)
|
|||
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
|
||||
auto* temporal_date = TRY(typed_this_object(vm));
|
||||
auto temporal_date = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? DifferenceTemporalPlainDate(since, temporalDate, other, options).
|
||||
return TRY(difference_temporal_plain_date(vm, DifferenceOperation::Since, *temporal_date, other, options));
|
||||
return TRY(difference_temporal_plain_date(vm, DifferenceOperation::Since, temporal_date, other, options));
|
||||
}
|
||||
|
||||
// 3.3.26 Temporal.PlainDate.prototype.equals ( other ), https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype.equals
|
||||
|
@ -490,7 +490,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::equals)
|
|||
{
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
|
||||
auto* temporal_date = TRY(typed_this_object(vm));
|
||||
auto temporal_date = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Set other to ? ToTemporalDate(other).
|
||||
auto* other = TRY(to_temporal_date(vm, vm.argument(0)));
|
||||
|
@ -513,7 +513,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::to_plain_date_time)
|
|||
{
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
|
||||
auto* temporal_date = TRY(typed_this_object(vm));
|
||||
auto temporal_date = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If temporalTime is undefined, then
|
||||
if (vm.argument(0).is_undefined()) {
|
||||
|
@ -535,7 +535,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::to_zoned_date_time)
|
|||
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
|
||||
auto* temporal_date = TRY(typed_this_object(vm));
|
||||
auto temporal_date = TRY(typed_this_object(vm));
|
||||
|
||||
auto temporal_time_value = js_undefined();
|
||||
Object* time_zone;
|
||||
|
@ -607,7 +607,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::to_string)
|
|||
{
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
|
||||
auto* temporal_date = TRY(typed_this_object(vm));
|
||||
auto temporal_date = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Set options to ? GetOptionsObject(options).
|
||||
auto* options = TRY(get_options_object(vm, vm.argument(0)));
|
||||
|
@ -616,7 +616,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::to_string)
|
|||
auto show_calendar = TRY(to_calendar_name_option(vm, *options));
|
||||
|
||||
// 5. Return ? TemporalDateToString(temporalDate, showCalendar).
|
||||
return PrimitiveString::create(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.30 Temporal.PlainDate.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype.tolocalestring
|
||||
|
@ -625,10 +625,10 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::to_locale_string)
|
|||
{
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
|
||||
auto* temporal_date = TRY(typed_this_object(vm));
|
||||
auto temporal_date = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? TemporalDateToString(temporalDate, "auto").
|
||||
return PrimitiveString::create(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.toJSON ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype.tojson
|
||||
|
@ -636,10 +636,10 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::to_json)
|
|||
{
|
||||
// 1. Let temporalDate be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]).
|
||||
auto* temporal_date = TRY(typed_this_object(vm));
|
||||
auto temporal_date = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? TemporalDateToString(temporalDate, "auto").
|
||||
return PrimitiveString::create(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.32 Temporal.PlainDate.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaindate.prototype.valueof
|
||||
|
|
|
@ -88,7 +88,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::calendar_getter)
|
|||
{
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return dateTime.[[Calendar]].
|
||||
return Value(&date_time->calendar());
|
||||
|
@ -99,13 +99,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::year_getter)
|
|||
{
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be dateTime.[[Calendar]].
|
||||
auto& calendar = date_time->calendar();
|
||||
|
||||
// 4. Return 𝔽(? CalendarYear(calendar, dateTime)).
|
||||
return TRY(calendar_year(vm, calendar, *date_time));
|
||||
return TRY(calendar_year(vm, calendar, date_time));
|
||||
}
|
||||
|
||||
// 5.3.5 get Temporal.PlainDateTime.prototype.month, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindatetime.prototype.month
|
||||
|
@ -113,13 +113,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::month_getter)
|
|||
{
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be dateTime.[[Calendar]].
|
||||
auto& calendar = date_time->calendar();
|
||||
|
||||
// 4. Return 𝔽(? CalendarMonth(calendar, dateTime)).
|
||||
return TRY(calendar_month(vm, calendar, *date_time));
|
||||
return TRY(calendar_month(vm, calendar, date_time));
|
||||
}
|
||||
|
||||
// 5.3.6 get Temporal.PlainDateTime.prototype.monthCode, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindatetime.prototype.monthcode
|
||||
|
@ -127,13 +127,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::month_code_getter)
|
|||
{
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be dateTime.[[Calendar]].
|
||||
auto& calendar = date_time->calendar();
|
||||
|
||||
// 4. Return ? CalendarMonthCode(calendar, dateTime).
|
||||
return PrimitiveString::create(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
|
||||
|
@ -141,13 +141,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::day_getter)
|
|||
{
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be dateTime.[[Calendar]].
|
||||
auto& calendar = date_time->calendar();
|
||||
|
||||
// 4. Return 𝔽(? CalendarDay(calendar, dateTime)).
|
||||
return TRY(calendar_day(vm, calendar, *date_time));
|
||||
return TRY(calendar_day(vm, calendar, date_time));
|
||||
}
|
||||
|
||||
// 5.3.8 get Temporal.PlainDateTime.prototype.hour, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindatetime.prototype.hour
|
||||
|
@ -155,7 +155,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::hour_getter)
|
|||
{
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return 𝔽(dateTime.[[ISOHour]]).
|
||||
return Value(date_time->iso_hour());
|
||||
|
@ -166,7 +166,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::minute_getter)
|
|||
{
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return 𝔽(dateTime.[[ISOMinute]]).
|
||||
return Value(date_time->iso_minute());
|
||||
|
@ -177,7 +177,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::second_getter)
|
|||
{
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return 𝔽(dateTime.[[ISOSecond]]).
|
||||
return Value(date_time->iso_second());
|
||||
|
@ -188,7 +188,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::millisecond_getter)
|
|||
{
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return 𝔽(dateTime.[[ISOMillisecond]]).
|
||||
return Value(date_time->iso_millisecond());
|
||||
|
@ -199,7 +199,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::microsecond_getter)
|
|||
{
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return 𝔽(dateTime.[[ISOMicrosecond]]).
|
||||
return Value(date_time->iso_microsecond());
|
||||
|
@ -210,7 +210,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::nanosecond_getter)
|
|||
{
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return 𝔽(dateTime.[[ISONanosecond]]).
|
||||
return Value(date_time->iso_nanosecond());
|
||||
|
@ -221,13 +221,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::day_of_week_getter)
|
|||
{
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be dateTime.[[Calendar]].
|
||||
auto& calendar = date_time->calendar();
|
||||
|
||||
// 4. Return 𝔽(? CalendarDayOfWeek(calendar, dateTime)).
|
||||
return TRY(calendar_day_of_week(vm, calendar, *date_time));
|
||||
return TRY(calendar_day_of_week(vm, calendar, date_time));
|
||||
}
|
||||
|
||||
// 5.3.15 get Temporal.PlainDateTime.prototype.dayOfYear, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindatetime.prototype.dayofyear
|
||||
|
@ -235,13 +235,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::day_of_year_getter)
|
|||
{
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be dateTime.[[Calendar]].
|
||||
auto& calendar = date_time->calendar();
|
||||
|
||||
// 4. Return 𝔽(? CalendarDayOfYear(calendar, dateTime)).
|
||||
return TRY(calendar_day_of_year(vm, calendar, *date_time));
|
||||
return TRY(calendar_day_of_year(vm, calendar, date_time));
|
||||
}
|
||||
|
||||
// 5.3.16 get Temporal.PlainDateTime.prototype.weekOfYear, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindatetime.prototype.weekofyear
|
||||
|
@ -249,13 +249,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::week_of_year_getter)
|
|||
{
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be dateTime.[[Calendar]].
|
||||
auto& calendar = date_time->calendar();
|
||||
|
||||
// 4. Return 𝔽(? CalendarWeekOfYear(calendar, dateTime)).
|
||||
return TRY(calendar_week_of_year(vm, calendar, *date_time));
|
||||
return TRY(calendar_week_of_year(vm, calendar, date_time));
|
||||
}
|
||||
|
||||
// 5.3.17 get Temporal.PlainDateTime.prototype.yearOfWeek, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindatetime.prototype.yearofweek
|
||||
|
@ -263,13 +263,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::year_of_week_getter)
|
|||
{
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be dateTime.[[Calendar]].
|
||||
auto& calendar = date_time->calendar();
|
||||
|
||||
// 4. Return 𝔽(? CalendarYearOfWeek(calendar, dateTime)).
|
||||
return TRY(calendar_year_of_week(vm, calendar, *date_time));
|
||||
return TRY(calendar_year_of_week(vm, calendar, date_time));
|
||||
}
|
||||
|
||||
// 5.3.18 get Temporal.PlainDateTime.prototype.daysInWeek, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindatetime.prototype.daysinweek
|
||||
|
@ -277,13 +277,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::days_in_week_getter)
|
|||
{
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be dateTime.[[Calendar]].
|
||||
auto& calendar = date_time->calendar();
|
||||
|
||||
// 4. Return 𝔽(? CalendarDaysInWeek(calendar, dateTime)).
|
||||
return TRY(calendar_days_in_week(vm, calendar, *date_time));
|
||||
return TRY(calendar_days_in_week(vm, calendar, date_time));
|
||||
}
|
||||
|
||||
// 5.3.19 get Temporal.PlainDateTime.prototype.daysInMonth, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindatetime.prototype.daysinmonth
|
||||
|
@ -291,13 +291,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::days_in_month_getter)
|
|||
{
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be dateTime.[[Calendar]].
|
||||
auto& calendar = date_time->calendar();
|
||||
|
||||
// 4. Return 𝔽(? CalendarDaysInMonth(calendar, dateTime)).
|
||||
return TRY(calendar_days_in_month(vm, calendar, *date_time));
|
||||
return TRY(calendar_days_in_month(vm, calendar, date_time));
|
||||
}
|
||||
|
||||
// 5.3.20 get Temporal.PlainDateTime.prototype.daysInYear, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindatetime.prototype.daysinyear
|
||||
|
@ -305,13 +305,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::days_in_year_getter)
|
|||
{
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be dateTime.[[Calendar]].
|
||||
auto& calendar = date_time->calendar();
|
||||
|
||||
// 4. Return 𝔽(? CalendarDaysInYear(calendar, dateTime)).
|
||||
return TRY(calendar_days_in_year(vm, calendar, *date_time));
|
||||
return TRY(calendar_days_in_year(vm, calendar, date_time));
|
||||
}
|
||||
|
||||
// 5.3.21 get Temporal.PlainDateTime.prototype.monthsInYear, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindatetime.prototype.monthsinyear
|
||||
|
@ -319,13 +319,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::months_in_year_getter)
|
|||
{
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be dateTime.[[Calendar]].
|
||||
auto& calendar = date_time->calendar();
|
||||
|
||||
// 4. Return 𝔽(? CalendarMonthsInYear(calendar, dateTime)).
|
||||
return TRY(calendar_months_in_year(vm, calendar, *date_time));
|
||||
return TRY(calendar_months_in_year(vm, calendar, date_time));
|
||||
}
|
||||
|
||||
// 5.3.22 get Temporal.PlainDateTime.prototype.inLeapYear, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindatetime.prototype.inleapyear
|
||||
|
@ -333,13 +333,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::in_leap_year_getter)
|
|||
{
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be dateTime.[[Calendar]].
|
||||
auto& calendar = date_time->calendar();
|
||||
|
||||
// 4. Return ? CalendarInLeapYear(calendar, dateTime).
|
||||
return TRY(calendar_in_leap_year(vm, calendar, *date_time));
|
||||
return TRY(calendar_in_leap_year(vm, calendar, date_time));
|
||||
}
|
||||
|
||||
// 15.6.6.2 get Temporal.PlainDateTime.prototype.era, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindatetime.prototype.era
|
||||
|
@ -347,13 +347,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::era_getter)
|
|||
{
|
||||
// 1. Let plainDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(plainDateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* plain_date_time = TRY(typed_this_object(vm));
|
||||
auto plain_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be plainDateTime.[[Calendar]].
|
||||
auto& calendar = plain_date_time->calendar();
|
||||
|
||||
// 4. Return ? CalendarEra(calendar, plainDateTime).
|
||||
return TRY(calendar_era(vm, calendar, *plain_date_time));
|
||||
return TRY(calendar_era(vm, calendar, plain_date_time));
|
||||
}
|
||||
|
||||
// 15.6.6.3 get Temporal.PlainDateTime.prototype.eraYear, https://tc39.es/proposal-temporal/#sec-get-temporal.plaindatetime.prototype.erayear
|
||||
|
@ -361,13 +361,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::era_year_getter)
|
|||
{
|
||||
// 1. Let plainDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(plainDateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* plain_date_time = TRY(typed_this_object(vm));
|
||||
auto plain_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be plainDateTime.[[Calendar]].
|
||||
auto& calendar = plain_date_time->calendar();
|
||||
|
||||
// 4. Return ? CalendarEraYear(calendar, plainDateTime).
|
||||
return TRY(calendar_era_year(vm, calendar, *plain_date_time));
|
||||
return TRY(calendar_era_year(vm, calendar, plain_date_time));
|
||||
}
|
||||
|
||||
// 5.3.23 Temporal.PlainDateTime.prototype.with ( temporalDateTimeLike [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype.with
|
||||
|
@ -377,7 +377,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::with)
|
|||
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If Type(temporalDateTimeLike) is not Object, then
|
||||
if (!temporal_date_time_like.is_object()) {
|
||||
|
@ -401,7 +401,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::with)
|
|||
auto* options = TRY(get_options_object(vm, vm.argument(1)));
|
||||
|
||||
// 9. Let fields be ? PrepareTemporalFields(dateTime, fieldNames, «»).
|
||||
auto* fields = TRY(prepare_temporal_fields(vm, *date_time, field_names, Vector<StringView> {}));
|
||||
auto* fields = TRY(prepare_temporal_fields(vm, date_time, field_names, Vector<StringView> {}));
|
||||
|
||||
// 10. Set fields to ? CalendarMergeFields(calendar, fields, partialDateTime).
|
||||
fields = TRY(calendar_merge_fields(vm, calendar, *fields, *partial_date_time));
|
||||
|
@ -427,7 +427,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::with_plain_time)
|
|||
{
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If plainTimeLike is undefined, then
|
||||
if (vm.argument(0).is_undefined()) {
|
||||
|
@ -447,7 +447,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::with_plain_date)
|
|||
{
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let plainDate be ? ToTemporalDate(plainDateLike).
|
||||
auto* plain_date = TRY(to_temporal_date(vm, vm.argument(0)));
|
||||
|
@ -466,7 +466,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::with_calendar)
|
|||
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be ? ToTemporalCalendar(calendarLike).
|
||||
auto* calendar = TRY(to_temporal_calendar(vm, calendar_like));
|
||||
|
@ -483,10 +483,10 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::add)
|
|||
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? AddDurationToOrSubtractDurationFromPlainDateTime(add, dateTime, temporalDurationLike, options).
|
||||
return TRY(add_duration_to_or_subtract_duration_from_plain_date_time(vm, ArithmeticOperation::Add, *date_time, temporal_duration_like, options));
|
||||
return TRY(add_duration_to_or_subtract_duration_from_plain_date_time(vm, ArithmeticOperation::Add, date_time, temporal_duration_like, options));
|
||||
}
|
||||
|
||||
// 5.3.28 Temporal.PlainDateTime.prototype.subtract ( temporalDurationLike [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype.subtract
|
||||
|
@ -497,10 +497,10 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::subtract)
|
|||
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? AddDurationToOrSubtractDurationFromPlainDateTime(subtract, dateTime, temporalDurationLike, options).
|
||||
return TRY(add_duration_to_or_subtract_duration_from_plain_date_time(vm, ArithmeticOperation::Subtract, *date_time, temporal_duration_like, options));
|
||||
return TRY(add_duration_to_or_subtract_duration_from_plain_date_time(vm, ArithmeticOperation::Subtract, date_time, temporal_duration_like, options));
|
||||
}
|
||||
|
||||
// 5.3.29 Temporal.PlainDateTime.prototype.until ( other [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.since
|
||||
|
@ -511,10 +511,10 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::until)
|
|||
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? DifferenceTemporalPlainDateTime(until, dateTime, other, options).
|
||||
return TRY(difference_temporal_plain_date_time(vm, DifferenceOperation::Until, *date_time, other, options));
|
||||
return TRY(difference_temporal_plain_date_time(vm, DifferenceOperation::Until, date_time, other, options));
|
||||
}
|
||||
|
||||
// 5.3.30 Temporal.PlainDateTime.prototype.since ( other [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype.since
|
||||
|
@ -525,10 +525,10 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::since)
|
|||
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? DifferenceTemporalPlainDateTime(since, dateTime, other, options).
|
||||
return TRY(difference_temporal_plain_date_time(vm, DifferenceOperation::Since, *date_time, other, options));
|
||||
return TRY(difference_temporal_plain_date_time(vm, DifferenceOperation::Since, date_time, other, options));
|
||||
}
|
||||
|
||||
// 5.3.31 Temporal.PlainDateTime.prototype.round ( roundTo ), https://tc39.es/proposal-temporal/#sec-temporal.plaindatetime.prototype.round
|
||||
|
@ -538,7 +538,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::round)
|
|||
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If roundTo is undefined, then
|
||||
if (vm.argument(0).is_undefined()) {
|
||||
|
@ -585,7 +585,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::equals)
|
|||
{
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Set other to ? ToTemporalDateTime(other).
|
||||
auto* other = TRY(to_temporal_date_time(vm, vm.argument(0)));
|
||||
|
@ -606,7 +606,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::to_string)
|
|||
{
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Set options to ? GetOptionsObject(options).
|
||||
auto* options = TRY(get_options_object(vm, vm.argument(0)));
|
||||
|
@ -633,7 +633,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::to_locale_string)
|
|||
{
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
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 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)));
|
||||
|
@ -644,7 +644,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::to_json)
|
|||
{
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
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 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)));
|
||||
|
@ -662,7 +662,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::to_zoned_date_time)
|
|||
{
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let timeZone be ? ToTemporalTimeZone(temporalTimeZoneLike).
|
||||
auto* time_zone = TRY(to_temporal_time_zone(vm, vm.argument(0)));
|
||||
|
@ -674,7 +674,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::to_zoned_date_time)
|
|||
auto disambiguation = TRY(to_temporal_disambiguation(vm, options));
|
||||
|
||||
// 6. Let instant be ? BuiltinTimeZoneGetInstantFor(timeZone, dateTime, disambiguation).
|
||||
auto* instant = TRY(builtin_time_zone_get_instant_for(vm, time_zone, *date_time, disambiguation));
|
||||
auto* instant = TRY(builtin_time_zone_get_instant_for(vm, time_zone, date_time, disambiguation));
|
||||
|
||||
// 7. Return ! CreateTemporalZonedDateTime(instant.[[Nanoseconds]], timeZone, dateTime.[[Calendar]]).
|
||||
return MUST(create_temporal_zoned_date_time(vm, instant->nanoseconds(), *time_zone, date_time->calendar()));
|
||||
|
@ -685,7 +685,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::to_plain_date)
|
|||
{
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ! CreateTemporalDate(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[Calendar]]).
|
||||
return MUST(create_temporal_date(vm, date_time->iso_year(), date_time->iso_month(), date_time->iso_day(), date_time->calendar()));
|
||||
|
@ -696,7 +696,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::to_plain_year_month)
|
|||
{
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be dateTime.[[Calendar]].
|
||||
auto& calendar = date_time->calendar();
|
||||
|
@ -705,7 +705,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::to_plain_year_month)
|
|||
auto field_names = TRY(calendar_fields(vm, calendar, { "monthCode"sv, "year"sv }));
|
||||
|
||||
// 5. Let fields be ? PrepareTemporalFields(dateTime, fieldNames, «»).
|
||||
auto* fields = TRY(prepare_temporal_fields(vm, *date_time, field_names, Vector<StringView> {}));
|
||||
auto* fields = TRY(prepare_temporal_fields(vm, date_time, field_names, Vector<StringView> {}));
|
||||
|
||||
// 6. Return ? CalendarYearMonthFromFields(calendar, fields).
|
||||
return TRY(calendar_year_month_from_fields(vm, calendar, *fields));
|
||||
|
@ -716,7 +716,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::to_plain_month_day)
|
|||
{
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be dateTime.[[Calendar]].
|
||||
auto& calendar = date_time->calendar();
|
||||
|
@ -725,7 +725,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::to_plain_month_day)
|
|||
auto field_names = TRY(calendar_fields(vm, calendar, { "day"sv, "monthCode"sv }));
|
||||
|
||||
// 5. Let fields be ? PrepareTemporalFields(dateTime, fieldNames, «»).
|
||||
auto* fields = TRY(prepare_temporal_fields(vm, *date_time, field_names, Vector<StringView> {}));
|
||||
auto* fields = TRY(prepare_temporal_fields(vm, date_time, field_names, Vector<StringView> {}));
|
||||
|
||||
// 6. Return ? CalendarMonthDayFromFields(calendar, fields).
|
||||
return TRY(calendar_month_day_from_fields(vm, calendar, *fields));
|
||||
|
@ -736,7 +736,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::to_plain_time)
|
|||
{
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ! CreateTemporalTime(dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]]).
|
||||
return MUST(create_temporal_time(vm, date_time->iso_hour(), date_time->iso_minute(), date_time->iso_second(), date_time->iso_millisecond(), date_time->iso_microsecond(), date_time->iso_nanosecond()));
|
||||
|
@ -749,7 +749,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::get_iso_fields)
|
|||
|
||||
// 1. Let dateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]).
|
||||
auto* date_time = TRY(typed_this_object(vm));
|
||||
auto date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let fields be OrdinaryObjectCreate(%Object.prototype%).
|
||||
auto fields = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
|
|
|
@ -51,7 +51,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::calendar_getter)
|
|||
{
|
||||
// 1. Let monthDay be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]).
|
||||
auto* month_day = TRY(typed_this_object(vm));
|
||||
auto month_day = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return monthDay.[[Calendar]].
|
||||
return Value(&month_day->calendar());
|
||||
|
@ -62,13 +62,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::month_code_getter)
|
|||
{
|
||||
// 1. Let monthDay be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]).
|
||||
auto* month_day = TRY(typed_this_object(vm));
|
||||
auto month_day = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be monthDay.[[Calendar]].
|
||||
auto& calendar = month_day->calendar();
|
||||
|
||||
// 4. Return ? CalendarMonthCode(calendar, monthDay).
|
||||
return PrimitiveString::create(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
|
||||
|
@ -76,13 +76,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::day_getter)
|
|||
{
|
||||
// 1. Let monthDay be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]).
|
||||
auto* month_day = TRY(typed_this_object(vm));
|
||||
auto month_day = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be monthDay.[[Calendar]].
|
||||
auto& calendar = month_day->calendar();
|
||||
|
||||
// 4. Return 𝔽(? CalendarDay(calendar, monthDay)).
|
||||
return Value(TRY(calendar_day(vm, calendar, *month_day)));
|
||||
return Value(TRY(calendar_day(vm, calendar, month_day)));
|
||||
}
|
||||
|
||||
// 10.3.6 Temporal.PlainMonthDay.prototype.with ( temporalMonthDayLike [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainmonthday.prototype.with
|
||||
|
@ -92,7 +92,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::with)
|
|||
|
||||
// 1. Let monthDay be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]).
|
||||
auto* month_day = TRY(typed_this_object(vm));
|
||||
auto month_day = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If Type(temporalMonthDayLike) is not Object, then
|
||||
if (!temporal_month_day_like.is_object()) {
|
||||
|
@ -116,7 +116,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::with)
|
|||
auto* options = TRY(get_options_object(vm, vm.argument(1)));
|
||||
|
||||
// 9. Let fields be ? PrepareTemporalFields(monthDay, fieldNames, «»).
|
||||
auto* fields = TRY(prepare_temporal_fields(vm, *month_day, field_names, Vector<StringView> {}));
|
||||
auto* fields = TRY(prepare_temporal_fields(vm, month_day, field_names, Vector<StringView> {}));
|
||||
|
||||
// 10. Set fields to ? CalendarMergeFields(calendar, fields, partialMonthDay).
|
||||
fields = TRY(calendar_merge_fields(vm, calendar, *fields, *partial_month_day));
|
||||
|
@ -133,7 +133,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::equals)
|
|||
{
|
||||
// 1. Let monthDay be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]).
|
||||
auto* month_day = TRY(typed_this_object(vm));
|
||||
auto month_day = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Set other to ? ToTemporalMonthDay(other).
|
||||
auto* other = TRY(to_temporal_month_day(vm, vm.argument(0)));
|
||||
|
@ -159,7 +159,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::to_string)
|
|||
{
|
||||
// 1. Let monthDay be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]).
|
||||
auto* month_day = TRY(typed_this_object(vm));
|
||||
auto month_day = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Set options to ? GetOptionsObject(options).
|
||||
auto* options = TRY(get_options_object(vm, vm.argument(0)));
|
||||
|
@ -168,7 +168,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::to_string)
|
|||
auto show_calendar = TRY(to_calendar_name_option(vm, *options));
|
||||
|
||||
// 5. Return ? TemporalMonthDayToString(monthDay, showCalendar).
|
||||
return PrimitiveString::create(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
|
||||
|
@ -177,10 +177,10 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::to_locale_string)
|
|||
{
|
||||
// 1. Let monthDay be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]).
|
||||
auto* month_day = TRY(typed_this_object(vm));
|
||||
auto month_day = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? TemporalMonthDayToString(monthDay, "auto").
|
||||
return PrimitiveString::create(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
|
||||
|
@ -188,10 +188,10 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::to_json)
|
|||
{
|
||||
// 1. Let monthDay be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]).
|
||||
auto* month_day = TRY(typed_this_object(vm));
|
||||
auto month_day = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? TemporalMonthDayToString(monthDay, "auto").
|
||||
return PrimitiveString::create(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
|
||||
|
@ -210,7 +210,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::to_plain_date)
|
|||
|
||||
// 1. Let monthDay be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]).
|
||||
auto* month_day = TRY(typed_this_object(vm));
|
||||
auto month_day = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If Type(item) is not Object, then
|
||||
if (!item.is_object()) {
|
||||
|
@ -225,7 +225,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::to_plain_date)
|
|||
auto receiver_field_names = TRY(calendar_fields(vm, calendar, { "day"sv, "monthCode"sv }));
|
||||
|
||||
// 6. Let fields be ? PrepareTemporalFields(monthDay, receiverFieldNames, «»).
|
||||
auto* fields = TRY(prepare_temporal_fields(vm, *month_day, receiver_field_names, Vector<StringView> {}));
|
||||
auto* fields = TRY(prepare_temporal_fields(vm, month_day, receiver_field_names, Vector<StringView> {}));
|
||||
|
||||
// 7. Let inputFieldNames be ? CalendarFields(calendar, « "year" »).
|
||||
auto input_field_names = TRY(calendar_fields(vm, calendar, { "year"sv }));
|
||||
|
@ -259,7 +259,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::get_iso_fields)
|
|||
|
||||
// 1. Let monthDay be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]).
|
||||
auto* month_day = TRY(typed_this_object(vm));
|
||||
auto month_day = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let fields be OrdinaryObjectCreate(%Object.prototype%).
|
||||
auto fields = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
|
|
|
@ -66,7 +66,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::calendar_getter)
|
|||
{
|
||||
// 1. Let temporalTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
||||
auto* temporal_time = TRY(typed_this_object(vm));
|
||||
auto temporal_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return temporalTime.[[Calendar]].
|
||||
return Value(&temporal_time->calendar());
|
||||
|
@ -77,7 +77,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::hour_getter)
|
|||
{
|
||||
// 1. Let temporalTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
||||
auto* temporal_time = TRY(typed_this_object(vm));
|
||||
auto temporal_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return 𝔽(temporalTime.[[ISOHour]]).
|
||||
return Value(temporal_time->iso_hour());
|
||||
|
@ -88,7 +88,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::minute_getter)
|
|||
{
|
||||
// 1. Let temporalTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
||||
auto* temporal_time = TRY(typed_this_object(vm));
|
||||
auto temporal_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return 𝔽(temporalTime.[[ISOMinute]]).
|
||||
return Value(temporal_time->iso_minute());
|
||||
|
@ -99,7 +99,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::second_getter)
|
|||
{
|
||||
// 1. Let temporalTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
||||
auto* temporal_time = TRY(typed_this_object(vm));
|
||||
auto temporal_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return 𝔽(temporalTime.[[ISOSecond]]).
|
||||
return Value(temporal_time->iso_second());
|
||||
|
@ -110,7 +110,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::millisecond_getter)
|
|||
{
|
||||
// 1. Let temporalTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
||||
auto* temporal_time = TRY(typed_this_object(vm));
|
||||
auto temporal_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return 𝔽(temporalTime.[[ISOMillisecond]]).
|
||||
return Value(temporal_time->iso_millisecond());
|
||||
|
@ -121,7 +121,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::microsecond_getter)
|
|||
{
|
||||
// 1. Let temporalTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
||||
auto* temporal_time = TRY(typed_this_object(vm));
|
||||
auto temporal_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return 𝔽(temporalTime.[[ISOMicrosecond]]).
|
||||
return Value(temporal_time->iso_microsecond());
|
||||
|
@ -132,7 +132,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::nanosecond_getter)
|
|||
{
|
||||
// 1. Let temporalTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
||||
auto* temporal_time = TRY(typed_this_object(vm));
|
||||
auto temporal_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return 𝔽(temporalTime.[[ISONanosecond]]).
|
||||
return Value(temporal_time->iso_nanosecond());
|
||||
|
@ -145,10 +145,10 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::add)
|
|||
|
||||
// 1. Let temporalTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
||||
auto* temporal_time = TRY(typed_this_object(vm));
|
||||
auto temporal_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? AddDurationToOrSubtractDurationFromPlainTime(add, temporalTime, temporalDurationLike).
|
||||
return TRY(add_duration_to_or_subtract_duration_from_plain_time(vm, ArithmeticOperation::Add, *temporal_time, temporal_duration_like));
|
||||
return TRY(add_duration_to_or_subtract_duration_from_plain_time(vm, ArithmeticOperation::Add, temporal_time, temporal_duration_like));
|
||||
}
|
||||
|
||||
// 4.3.11 Temporal.PlainTime.prototype.subtract ( temporalDurationLike ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.subtract
|
||||
|
@ -158,10 +158,10 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::subtract)
|
|||
|
||||
// 1. Let temporalTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
||||
auto* temporal_time = TRY(typed_this_object(vm));
|
||||
auto temporal_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? AddDurationToOrSubtractDurationFromPlainTime(subtract, temporalTime, temporalDurationLike).
|
||||
return TRY(add_duration_to_or_subtract_duration_from_plain_time(vm, ArithmeticOperation::Subtract, *temporal_time, temporal_duration_like));
|
||||
return TRY(add_duration_to_or_subtract_duration_from_plain_time(vm, ArithmeticOperation::Subtract, temporal_time, temporal_duration_like));
|
||||
}
|
||||
|
||||
// 4.3.12 Temporal.PlainTime.prototype.with ( temporalTimeLike [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.with
|
||||
|
@ -169,7 +169,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::with)
|
|||
{
|
||||
// 1. Let temporalTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
||||
auto* temporal_time = TRY(typed_this_object(vm));
|
||||
auto temporal_time = TRY(typed_this_object(vm));
|
||||
|
||||
auto temporal_time_like_argument = vm.argument(0);
|
||||
|
||||
|
@ -244,10 +244,10 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::until)
|
|||
|
||||
// 1. Let temporalTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
||||
auto* temporal_time = TRY(typed_this_object(vm));
|
||||
auto temporal_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? DifferenceTemporalPlainTime(until, temporalTime, other, options).
|
||||
return TRY(difference_temporal_plain_time(vm, DifferenceOperation::Until, *temporal_time, other, options));
|
||||
return TRY(difference_temporal_plain_time(vm, DifferenceOperation::Until, temporal_time, other, options));
|
||||
}
|
||||
|
||||
// 4.3.14 Temporal.PlainTime.prototype.since ( other [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.since
|
||||
|
@ -258,10 +258,10 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::since)
|
|||
|
||||
// 1. Let temporalTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
||||
auto* temporal_time = TRY(typed_this_object(vm));
|
||||
auto temporal_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? DifferenceTemporalPlainTime(since, temporalTime, other, options).
|
||||
return TRY(difference_temporal_plain_time(vm, DifferenceOperation::Since, *temporal_time, other, options));
|
||||
return TRY(difference_temporal_plain_time(vm, DifferenceOperation::Since, temporal_time, other, options));
|
||||
}
|
||||
|
||||
// 4.3.15 Temporal.PlainTime.prototype.round ( roundTo ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.round
|
||||
|
@ -271,7 +271,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::round)
|
|||
|
||||
// 1. Let temporalTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
||||
auto* temporal_time = TRY(typed_this_object(vm));
|
||||
auto temporal_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If roundTo is undefined, then
|
||||
if (vm.argument(0).is_undefined()) {
|
||||
|
@ -321,7 +321,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::equals)
|
|||
{
|
||||
// 1. Let temporalTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
||||
auto* temporal_time = TRY(typed_this_object(vm));
|
||||
auto temporal_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Set other to ? ToTemporalTime(other).
|
||||
auto* other = TRY(to_temporal_time(vm, vm.argument(0)));
|
||||
|
@ -359,7 +359,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::to_plain_date_time)
|
|||
{
|
||||
// 1. Let temporalTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
||||
auto* temporal_time = TRY(typed_this_object(vm));
|
||||
auto temporal_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Set temporalDate to ? ToTemporalDate(temporalDate).
|
||||
auto* temporal_date = TRY(to_temporal_date(vm, vm.argument(0)));
|
||||
|
@ -375,7 +375,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::to_zoned_date_time)
|
|||
|
||||
// 1. Let temporalTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
||||
auto* temporal_time = TRY(typed_this_object(vm));
|
||||
auto temporal_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If Type(item) is not Object, then
|
||||
if (!item.is_object()) {
|
||||
|
@ -424,7 +424,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::get_iso_fields)
|
|||
|
||||
// 1. Let temporalTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
||||
auto* temporal_time = TRY(typed_this_object(vm));
|
||||
auto temporal_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let fields be OrdinaryObjectCreate(%Object.prototype%).
|
||||
auto fields = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
|
@ -459,7 +459,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::to_string)
|
|||
{
|
||||
// 1. Let temporalTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
||||
auto* temporal_time = TRY(typed_this_object(vm));
|
||||
auto temporal_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Set options to ? GetOptionsObject(options).
|
||||
auto* options = TRY(get_options_object(vm, vm.argument(0)));
|
||||
|
@ -483,7 +483,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::to_locale_string)
|
|||
{
|
||||
// 1. Let temporalTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
||||
auto* temporal_time = TRY(typed_this_object(vm));
|
||||
auto temporal_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ! TemporalTimeToString(temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], "auto").
|
||||
auto string = MUST_OR_THROW_OOM(temporal_time_to_string(vm, 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));
|
||||
|
@ -495,7 +495,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::to_json)
|
|||
{
|
||||
// 1. Let temporalTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]).
|
||||
auto* temporal_time = TRY(typed_this_object(vm));
|
||||
auto temporal_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ! TemporalTimeToString(temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], "auto").
|
||||
auto string = MUST_OR_THROW_OOM(temporal_time_to_string(vm, 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));
|
||||
|
|
|
@ -64,7 +64,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::calendar_getter)
|
|||
{
|
||||
// 1. Let yearMonth be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
|
||||
auto* year_month = TRY(typed_this_object(vm));
|
||||
auto year_month = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return yearMonth.[[Calendar]].
|
||||
return Value(&year_month->calendar());
|
||||
|
@ -75,13 +75,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::year_getter)
|
|||
{
|
||||
// 1. Let yearMonth be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
|
||||
auto* year_month = TRY(typed_this_object(vm));
|
||||
auto year_month = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be yearMonth.[[Calendar]].
|
||||
auto& calendar = year_month->calendar();
|
||||
|
||||
// 4. Return 𝔽(? CalendarYear(calendar, yearMonth)).
|
||||
return Value(TRY(calendar_year(vm, calendar, *year_month)));
|
||||
return Value(TRY(calendar_year(vm, calendar, year_month)));
|
||||
}
|
||||
|
||||
// 9.3.5 get Temporal.PlainYearMonth.prototype.month, https://tc39.es/proposal-temporal/#sec-get-temporal.plainyearmonth.prototype.month
|
||||
|
@ -89,13 +89,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::month_getter)
|
|||
{
|
||||
// 1. Let yearMonth be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
|
||||
auto* year_month = TRY(typed_this_object(vm));
|
||||
auto year_month = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be yearMonth.[[Calendar]].
|
||||
auto& calendar = year_month->calendar();
|
||||
|
||||
// 4. Return 𝔽(? CalendarMonth(calendar, yearMonth)).
|
||||
return Value(TRY(calendar_month(vm, calendar, *year_month)));
|
||||
return Value(TRY(calendar_month(vm, calendar, year_month)));
|
||||
}
|
||||
|
||||
// 9.3.6 get Temporal.PlainYearMonth.prototype.monthCode, https://tc39.es/proposal-temporal/#sec-get-temporal.plainyearmonth.prototype.monthCode
|
||||
|
@ -103,13 +103,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::month_code_getter)
|
|||
{
|
||||
// 1. Let yearMonth be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
|
||||
auto* year_month = TRY(typed_this_object(vm));
|
||||
auto year_month = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be yearMonth.[[Calendar]].
|
||||
auto& calendar = year_month->calendar();
|
||||
|
||||
// 4. Return ? CalendarMonthCode(calendar, yearMonth).
|
||||
return PrimitiveString::create(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
|
||||
|
@ -117,13 +117,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::days_in_year_getter)
|
|||
{
|
||||
// 1. Let yearMonth be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
|
||||
auto* year_month = TRY(typed_this_object(vm));
|
||||
auto year_month = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be yearMonth.[[Calendar]].
|
||||
auto& calendar = year_month->calendar();
|
||||
|
||||
// 4. Return 𝔽(? CalendarDaysInYear(calendar, yearMonth)).
|
||||
return TRY(calendar_days_in_year(vm, calendar, *year_month));
|
||||
return TRY(calendar_days_in_year(vm, calendar, year_month));
|
||||
}
|
||||
|
||||
// 9.3.8 get Temporal.PlainYearMonth.prototype.daysInMonth, https://tc39.es/proposal-temporal/#sec-get-temporal.plainyearmonth.prototype.daysinmonth
|
||||
|
@ -131,13 +131,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::days_in_month_getter)
|
|||
{
|
||||
// 1. Let yearMonth be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
|
||||
auto* year_month = TRY(typed_this_object(vm));
|
||||
auto year_month = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be yearMonth.[[Calendar]].
|
||||
auto& calendar = year_month->calendar();
|
||||
|
||||
// 4. Return 𝔽(? CalendarDaysInMonth(calendar, yearMonth)).
|
||||
return TRY(calendar_days_in_month(vm, calendar, *year_month));
|
||||
return TRY(calendar_days_in_month(vm, calendar, year_month));
|
||||
}
|
||||
|
||||
// 9.3.9 get Temporal.PlainYearMonth.prototype.monthsInYear, https://tc39.es/proposal-temporal/#sec-get-temporal.plainyearmonth.prototype.monthsinyear
|
||||
|
@ -145,13 +145,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::months_in_year_getter)
|
|||
{
|
||||
// 1. Let yearMonth be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
|
||||
auto* year_month = TRY(typed_this_object(vm));
|
||||
auto year_month = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be yearMonth.[[Calendar]].
|
||||
auto& calendar = year_month->calendar();
|
||||
|
||||
// 4. Return 𝔽(? CalendarMonthsInYear(calendar, yearMonth)).
|
||||
return TRY(calendar_months_in_year(vm, calendar, *year_month));
|
||||
return TRY(calendar_months_in_year(vm, calendar, year_month));
|
||||
}
|
||||
|
||||
// 9.3.10 get Temporal.PlainYearMonth.prototype.inLeapYear, https://tc39.es/proposal-temporal/#sec-get-temporal.plainyearmonth.prototype.inleapyear
|
||||
|
@ -159,13 +159,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::in_leap_year_getter)
|
|||
{
|
||||
// 1. Let yearMonth be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
|
||||
auto* year_month = TRY(typed_this_object(vm));
|
||||
auto year_month = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be yearMonth.[[Calendar]].
|
||||
auto& calendar = year_month->calendar();
|
||||
|
||||
// 4. Return ? CalendarInLeapYear(calendar, yearMonth).
|
||||
return Value(TRY(calendar_in_leap_year(vm, calendar, *year_month)));
|
||||
return Value(TRY(calendar_in_leap_year(vm, calendar, year_month)));
|
||||
}
|
||||
|
||||
// 15.6.9.2 get Temporal.PlainYearMonth.prototype.era, https://tc39.es/proposal-temporal/#sec-get-temporal.plainyearmonth.prototype.era
|
||||
|
@ -173,13 +173,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::era_getter)
|
|||
{
|
||||
// 1. Let plainYearMonth be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(plainYearMonth, [[InitializedTemporalYearMonth]]).
|
||||
auto* plain_year_month = TRY(typed_this_object(vm));
|
||||
auto plain_year_month = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be plainYearMonth.[[Calendar]].
|
||||
auto& calendar = plain_year_month->calendar();
|
||||
|
||||
// 4. Return ? CalendarEra(calendar, plainYearMonth).
|
||||
return TRY(calendar_era(vm, calendar, *plain_year_month));
|
||||
return TRY(calendar_era(vm, calendar, plain_year_month));
|
||||
}
|
||||
|
||||
// 15.6.9.3 get Temporal.PlainYearMonth.prototype.eraYear, https://tc39.es/proposal-temporal/#sec-get-temporal.plainyearmonth.prototype.erayear
|
||||
|
@ -187,13 +187,13 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::era_year_getter)
|
|||
{
|
||||
// 1. Let plainYearMonth be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(plainYearMonth, [[InitializedTemporalYearMonth]]).
|
||||
auto* plain_year_month = TRY(typed_this_object(vm));
|
||||
auto plain_year_month = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be plainYearMonth.[[Calendar]].
|
||||
auto& calendar = plain_year_month->calendar();
|
||||
|
||||
// 4. Return ? CalendarEraYear(calendar, plainYearMonth).
|
||||
return TRY(calendar_era_year(vm, calendar, *plain_year_month));
|
||||
return TRY(calendar_era_year(vm, calendar, plain_year_month));
|
||||
}
|
||||
|
||||
// 9.3.11 Temporal.PlainYearMonth.prototype.with ( temporalYearMonthLike [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.prototype.with
|
||||
|
@ -203,7 +203,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::with)
|
|||
|
||||
// 1. Let yearMonth be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
|
||||
auto* year_month = TRY(typed_this_object(vm));
|
||||
auto year_month = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If Type(temporalYearMonthLike) is not Object, then
|
||||
if (!temporal_year_month_like.is_object()) {
|
||||
|
@ -227,7 +227,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::with)
|
|||
auto* options = TRY(get_options_object(vm, vm.argument(1)));
|
||||
|
||||
// 9. Let fields be ? PrepareTemporalFields(yearMonth, fieldNames, «»).
|
||||
auto* fields = TRY(prepare_temporal_fields(vm, *year_month, field_names, Vector<StringView> {}));
|
||||
auto* fields = TRY(prepare_temporal_fields(vm, year_month, field_names, Vector<StringView> {}));
|
||||
|
||||
// 10. Set fields to ? CalendarMergeFields(calendar, fields, partialYearMonth).
|
||||
fields = TRY(calendar_merge_fields(vm, calendar, *fields, *partial_year_month));
|
||||
|
@ -247,10 +247,10 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::add)
|
|||
|
||||
// 1. Let yearMonth be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
|
||||
auto* year_month = TRY(typed_this_object(vm));
|
||||
auto year_month = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? AddDurationToOrSubtractDurationFromPlainYearMonth(add, yearMonth, temporalDurationLike, options).
|
||||
return TRY(add_duration_to_or_subtract_duration_from_plain_year_month(vm, ArithmeticOperation::Add, *year_month, temporal_duration_like, options));
|
||||
return TRY(add_duration_to_or_subtract_duration_from_plain_year_month(vm, ArithmeticOperation::Add, year_month, temporal_duration_like, options));
|
||||
}
|
||||
|
||||
// 9.3.13 Temporal.PlainYearMonth.prototype.subtract ( temporalDurationLike [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.prototype.subtract
|
||||
|
@ -261,10 +261,10 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::subtract)
|
|||
|
||||
// 1. Let yearMonth be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
|
||||
auto* year_month = TRY(typed_this_object(vm));
|
||||
auto year_month = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? AddDurationToOrSubtractDurationFromPlainYearMonth(add, yearMonth, temporalDurationLike, options).
|
||||
return TRY(add_duration_to_or_subtract_duration_from_plain_year_month(vm, ArithmeticOperation::Subtract, *year_month, temporal_duration_like, options));
|
||||
return TRY(add_duration_to_or_subtract_duration_from_plain_year_month(vm, ArithmeticOperation::Subtract, year_month, temporal_duration_like, options));
|
||||
}
|
||||
|
||||
// 9.3.14 Temporal.PlainYearMonth.prototype.until ( other [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.prototype.until
|
||||
|
@ -275,10 +275,10 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::until)
|
|||
|
||||
// 1. Let yearMonth be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
|
||||
auto* year_month = TRY(typed_this_object(vm));
|
||||
auto year_month = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? DifferenceTemporalPlainYearMonth(until, yearMonth, other, options).
|
||||
return TRY(difference_temporal_plain_year_month(vm, DifferenceOperation::Until, *year_month, other, options));
|
||||
return TRY(difference_temporal_plain_year_month(vm, DifferenceOperation::Until, year_month, other, options));
|
||||
}
|
||||
|
||||
// 9.3.15 Temporal.PlainYearMonth.prototype.since ( other [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.prototype.since
|
||||
|
@ -289,10 +289,10 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::since)
|
|||
|
||||
// 1. Let yearMonth be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
|
||||
auto* year_month = TRY(typed_this_object(vm));
|
||||
auto year_month = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? DifferenceTemporalPlainYearMonth(since, yearMonth, other, options).
|
||||
return TRY(difference_temporal_plain_year_month(vm, DifferenceOperation::Since, *year_month, other, options));
|
||||
return TRY(difference_temporal_plain_year_month(vm, DifferenceOperation::Since, year_month, other, options));
|
||||
}
|
||||
|
||||
// 9.3.16 Temporal.PlainYearMonth.prototype.equals ( other ), https://tc39.es/proposal-temporal/#sec-temporal.plainyearmonth.prototype.equals
|
||||
|
@ -300,7 +300,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::equals)
|
|||
{
|
||||
// 1. Let yearMonth be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
|
||||
auto* year_month = TRY(typed_this_object(vm));
|
||||
auto year_month = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Set other to ? ToTemporalYearMonth(other).
|
||||
auto* other = TRY(to_temporal_year_month(vm, vm.argument(0)));
|
||||
|
@ -326,7 +326,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::to_string)
|
|||
{
|
||||
// 1. Let yearMonth be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
|
||||
auto* year_month = TRY(typed_this_object(vm));
|
||||
auto year_month = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Set options to ? GetOptionsObject(options).
|
||||
auto* options = TRY(get_options_object(vm, vm.argument(0)));
|
||||
|
@ -335,7 +335,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::to_string)
|
|||
auto show_calendar = TRY(to_calendar_name_option(vm, *options));
|
||||
|
||||
// 5. Return ? TemporalYearMonthToString(yearMonth, showCalendar).
|
||||
return PrimitiveString::create(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
|
||||
|
@ -344,10 +344,10 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::to_locale_string)
|
|||
{
|
||||
// 1. Let yearMonth be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
|
||||
auto* year_month = TRY(typed_this_object(vm));
|
||||
auto year_month = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? TemporalYearMonthToString(yearMonth, "auto").
|
||||
return PrimitiveString::create(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
|
||||
|
@ -355,10 +355,10 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::to_json)
|
|||
{
|
||||
// 1. Let yearMonth be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
|
||||
auto* year_month = TRY(typed_this_object(vm));
|
||||
auto year_month = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? TemporalYearMonthToString(yearMonth, "auto").
|
||||
return PrimitiveString::create(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
|
||||
|
@ -377,7 +377,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::to_plain_date)
|
|||
|
||||
// 1. Let yearMonth be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
|
||||
auto* year_month = TRY(typed_this_object(vm));
|
||||
auto year_month = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If Type(item) is not Object, then
|
||||
if (!item.is_object()) {
|
||||
|
@ -392,7 +392,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::to_plain_date)
|
|||
auto receiver_field_names = TRY(calendar_fields(vm, calendar, { "monthCode"sv, "year"sv }));
|
||||
|
||||
// 6. Let fields be ? PrepareTemporalFields(yearMonth, receiverFieldNames, «»).
|
||||
auto* fields = TRY(prepare_temporal_fields(vm, *year_month, receiver_field_names, Vector<StringView> {}));
|
||||
auto* fields = TRY(prepare_temporal_fields(vm, year_month, receiver_field_names, Vector<StringView> {}));
|
||||
|
||||
// 7. Let inputFieldNames be ? CalendarFields(calendar, « "day" »).
|
||||
auto input_field_names = TRY(calendar_fields(vm, calendar, { "day"sv }));
|
||||
|
@ -426,7 +426,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::get_iso_fields)
|
|||
|
||||
// 1. Let yearMonth be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]).
|
||||
auto* year_month = TRY(typed_this_object(vm));
|
||||
auto year_month = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let fields be OrdinaryObjectCreate(%Object.prototype%).
|
||||
auto fields = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
|
|
|
@ -52,7 +52,7 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::id_getter)
|
|||
{
|
||||
// 1. Let timeZone be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(timeZone, [[InitializedTemporalTimeZone]]).
|
||||
auto* time_zone = TRY(typed_this_object(vm));
|
||||
auto time_zone = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return timeZone.[[Identifier]].
|
||||
return PrimitiveString::create(vm, time_zone->identifier());
|
||||
|
@ -63,7 +63,7 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::get_offset_nanoseconds_for)
|
|||
{
|
||||
// 1. Let timeZone be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(timeZone, [[InitializedTemporalTimeZone]]).
|
||||
auto* time_zone = TRY(typed_this_object(vm));
|
||||
auto time_zone = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Set instant to ? ToTemporalInstant(instant).
|
||||
auto* instant = TRY(to_temporal_instant(vm, vm.argument(0)));
|
||||
|
@ -81,7 +81,7 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::get_offset_string_for)
|
|||
{
|
||||
// 1. Let timeZone be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(timeZone, [[InitializedTemporalTimeZone]]).
|
||||
auto* time_zone = TRY(typed_this_object(vm));
|
||||
auto time_zone = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Set instant to ? ToTemporalInstant(instant).
|
||||
auto* instant = TRY(to_temporal_instant(vm, vm.argument(0)));
|
||||
|
@ -96,7 +96,7 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::get_plain_date_time_for)
|
|||
{
|
||||
// 1. Let timeZone be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(timeZone, [[InitializedTemporalTimeZone]]).
|
||||
auto* time_zone = TRY(typed_this_object(vm));
|
||||
auto time_zone = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Set instant to ? ToTemporalInstant(instant).
|
||||
auto* instant = TRY(to_temporal_instant(vm, vm.argument(0)));
|
||||
|
@ -113,7 +113,7 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::get_instant_for)
|
|||
{
|
||||
// 1. Let timeZone be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(timeZone, [[InitializedTemporalTimeZone]]).
|
||||
auto* time_zone = TRY(typed_this_object(vm));
|
||||
auto time_zone = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Set dateTime to ? ToTemporalDateTime(dateTime).
|
||||
auto* date_time = TRY(to_temporal_date_time(vm, vm.argument(0)));
|
||||
|
@ -135,7 +135,7 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::get_possible_instants_for)
|
|||
|
||||
// 1. Let timeZone be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(timeZone, [[InitializedTemporalTimezone]]).
|
||||
auto* time_zone = TRY(typed_this_object(vm));
|
||||
auto time_zone = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Set dateTime to ? ToTemporalDateTime(dateTime).
|
||||
auto* date_time = TRY(to_temporal_date_time(vm, vm.argument(0)));
|
||||
|
@ -182,7 +182,7 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::get_next_transition)
|
|||
{
|
||||
// 1. Let timeZone be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(timeZone, [[InitializedTemporalTimeZone]]).
|
||||
auto* time_zone = TRY(typed_this_object(vm));
|
||||
auto time_zone = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Set startingPoint to ? ToTemporalInstant(startingPoint).
|
||||
auto* starting_point = TRY(to_temporal_instant(vm, vm.argument(0)));
|
||||
|
@ -207,7 +207,7 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::get_previous_transition)
|
|||
{
|
||||
// 1. Let timeZone be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(timeZone, [[InitializedTemporalTimeZone]]).
|
||||
auto* time_zone = TRY(typed_this_object(vm));
|
||||
auto time_zone = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Set startingPoint to ? ToTemporalInstant(startingPoint).
|
||||
auto* starting_point = TRY(to_temporal_instant(vm, vm.argument(0)));
|
||||
|
@ -232,7 +232,7 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::to_string)
|
|||
{
|
||||
// 1. Let timeZone be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(timeZone, [[InitializedTemporalTimeZone]]).
|
||||
auto* time_zone = TRY(typed_this_object(vm));
|
||||
auto time_zone = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return timeZone.[[Identifier]].
|
||||
return PrimitiveString::create(vm, time_zone->identifier());
|
||||
|
@ -243,7 +243,7 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::to_json)
|
|||
{
|
||||
// 1. Let timeZone be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(timeZone, [[InitializedTemporalTimeZone]]).
|
||||
auto* time_zone = TRY(typed_this_object(vm));
|
||||
auto time_zone = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? ToString(timeZone).
|
||||
return PrimitiveString::create(vm, TRY(Value(time_zone).to_string(vm)));
|
||||
|
|
|
@ -99,7 +99,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::calendar_getter)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return zonedDateTime.[[Calendar]].
|
||||
return Value(&zoned_date_time->calendar());
|
||||
|
@ -110,7 +110,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::time_zone_getter)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return zonedDateTime.[[TimeZone]].
|
||||
return Value(&zoned_date_time->time_zone());
|
||||
|
@ -121,7 +121,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::year_getter)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let timeZone be zonedDateTime.[[TimeZone]].
|
||||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
@ -144,7 +144,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::month_getter)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let timeZone be zonedDateTime.[[TimeZone]].
|
||||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
@ -167,7 +167,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::month_code_getter)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let timeZone be zonedDateTime.[[TimeZone]].
|
||||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
@ -190,7 +190,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::day_getter)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let timeZone be zonedDateTime.[[TimeZone]].
|
||||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
@ -213,7 +213,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::hour_getter)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let timeZone be zonedDateTime.[[TimeZone]].
|
||||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
@ -236,7 +236,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::minute_getter)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let timeZone be zonedDateTime.[[TimeZone]].
|
||||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
@ -259,7 +259,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::second_getter)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let timeZone be zonedDateTime.[[TimeZone]].
|
||||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
@ -282,7 +282,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::millisecond_getter)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let timeZone be zonedDateTime.[[TimeZone]].
|
||||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
@ -305,7 +305,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::microsecond_getter)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let timeZone be zonedDateTime.[[TimeZone]].
|
||||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
@ -328,7 +328,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::nanosecond_getter)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let timeZone be zonedDateTime.[[TimeZone]].
|
||||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
@ -351,7 +351,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::epoch_seconds_getter)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let ns be zonedDateTime.[[Nanoseconds]].
|
||||
auto& ns = zoned_date_time->nanoseconds();
|
||||
|
@ -368,7 +368,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::epoch_milliseconds_getter)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let ns be zonedDateTime.[[Nanoseconds]].
|
||||
auto& ns = zoned_date_time->nanoseconds();
|
||||
|
@ -385,7 +385,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::epoch_microseconds_getter)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let ns be zonedDateTime.[[Nanoseconds]].
|
||||
auto& ns = zoned_date_time->nanoseconds();
|
||||
|
@ -402,7 +402,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::epoch_nanoseconds_getter)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return zonedDateTime.[[Nanoseconds]].
|
||||
return &zoned_date_time->nanoseconds();
|
||||
|
@ -413,7 +413,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::day_of_week_getter)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let timeZone be zonedDateTime.[[TimeZone]].
|
||||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
@ -436,7 +436,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::day_of_year_getter)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let timeZone be zonedDateTime.[[TimeZone]].
|
||||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
@ -459,7 +459,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::week_of_year_getter)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let timeZone be zonedDateTime.[[TimeZone]].
|
||||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
@ -482,7 +482,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::year_of_week_getter)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let timeZone be zonedDateTime.[[TimeZone]].
|
||||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
@ -505,7 +505,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::hours_in_day_getter)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let timeZone be zonedDateTime.[[TimeZone]].
|
||||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
@ -556,7 +556,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::days_in_week_getter)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let timeZone be zonedDateTime.[[TimeZone]].
|
||||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
@ -579,7 +579,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::days_in_month_getter)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let timeZone be zonedDateTime.[[TimeZone]].
|
||||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
@ -602,7 +602,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::days_in_year_getter)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let timeZone be zonedDateTime.[[TimeZone]].
|
||||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
@ -625,7 +625,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::months_in_year_getter)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let timeZone be zonedDateTime.[[TimeZone]].
|
||||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
@ -648,7 +648,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::in_leap_year_getter)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let timeZone be zonedDateTime.[[TimeZone]].
|
||||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
@ -671,7 +671,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::offset_nanoseconds_getter)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let timeZone be zonedDateTime.[[TimeZone]].
|
||||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
@ -688,7 +688,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::offset_getter)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
||||
auto* instant = MUST(create_temporal_instant(vm, zoned_date_time->nanoseconds()));
|
||||
|
@ -703,7 +703,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::era_getter)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let timeZone be zonedDateTime.[[TimeZone]].
|
||||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
@ -726,7 +726,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::era_year_getter)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let timeZone be zonedDateTime.[[TimeZone]].
|
||||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
@ -751,7 +751,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::with)
|
|||
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If Type(temporalZonedDateTimeLike) is not Object, then
|
||||
if (!temporal_zoned_date_time_like.is_object()) {
|
||||
|
@ -790,7 +790,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::with)
|
|||
field_names.append(TRY_OR_THROW_OOM(vm, "timeZone"_string));
|
||||
|
||||
// 14. Let fields be ? PrepareTemporalFields(zonedDateTime, fieldNames, « "timeZone", "offset" »).
|
||||
auto* fields = TRY(prepare_temporal_fields(vm, *zoned_date_time, field_names, Vector<StringView> { "timeZone"sv, "offset"sv }));
|
||||
auto* fields = TRY(prepare_temporal_fields(vm, zoned_date_time, field_names, Vector<StringView> { "timeZone"sv, "offset"sv }));
|
||||
|
||||
// 15. Set fields to ? CalendarMergeFields(calendar, fields, partialZonedDateTime).
|
||||
fields = TRY(calendar_merge_fields(vm, calendar, *fields, *partial_zoned_date_time));
|
||||
|
@ -827,7 +827,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::with_plain_time)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
PlainTime* plain_time = nullptr;
|
||||
|
||||
|
@ -869,7 +869,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::with_plain_date)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let plainDate be ? ToTemporalDate(plainDateLike).
|
||||
auto* plain_date = TRY(to_temporal_date(vm, vm.argument(0)));
|
||||
|
@ -901,7 +901,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::with_time_zone)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let timeZone be ? ToTemporalTimeZone(timeZoneLike).
|
||||
auto* time_zone = TRY(to_temporal_time_zone(vm, vm.argument(0)));
|
||||
|
@ -915,7 +915,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::with_calendar)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let calendar be ? ToTemporalCalendar(calendarLike).
|
||||
auto* calendar = TRY(to_temporal_calendar(vm, vm.argument(0)));
|
||||
|
@ -932,10 +932,10 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::add)
|
|||
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? AddDurationToOrSubtractDurationFromZonedDateTime(add, zonedDateTime, temporalDurationLike, options).
|
||||
return TRY(add_duration_to_or_subtract_duration_from_zoned_date_time(vm, ArithmeticOperation::Add, *zoned_date_time, temporal_duration_like, options));
|
||||
return TRY(add_duration_to_or_subtract_duration_from_zoned_date_time(vm, ArithmeticOperation::Add, zoned_date_time, temporal_duration_like, options));
|
||||
}
|
||||
|
||||
// 6.3.37 Temporal.ZonedDateTime.prototype.subtract ( temporalDurationLike [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.subtract
|
||||
|
@ -946,10 +946,10 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::subtract)
|
|||
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? AddDurationToOrSubtractDurationFromZonedDateTime(subtract, zonedDateTime, temporalDurationLike, options).
|
||||
return TRY(add_duration_to_or_subtract_duration_from_zoned_date_time(vm, ArithmeticOperation::Subtract, *zoned_date_time, temporal_duration_like, options));
|
||||
return TRY(add_duration_to_or_subtract_duration_from_zoned_date_time(vm, ArithmeticOperation::Subtract, zoned_date_time, temporal_duration_like, options));
|
||||
}
|
||||
|
||||
// 6.3.38 Temporal.ZonedDateTime.prototype.until ( other [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.until
|
||||
|
@ -960,10 +960,10 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::until)
|
|||
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? DifferenceTemporalZonedDateTime(until, zonedDateTime, other, options).
|
||||
return TRY(difference_temporal_zoned_date_time(vm, DifferenceOperation::Until, *zoned_date_time, other, options));
|
||||
return TRY(difference_temporal_zoned_date_time(vm, DifferenceOperation::Until, zoned_date_time, other, options));
|
||||
}
|
||||
|
||||
// 6.3.39 Temporal.ZonedDateTime.prototype.since ( other [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.since
|
||||
|
@ -974,10 +974,10 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::since)
|
|||
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? DifferenceTemporalZonedDateTime(since, zonedDateTime, other, options).
|
||||
return TRY(difference_temporal_zoned_date_time(vm, DifferenceOperation::Since, *zoned_date_time, other, options));
|
||||
return TRY(difference_temporal_zoned_date_time(vm, DifferenceOperation::Since, zoned_date_time, other, options));
|
||||
}
|
||||
|
||||
// 6.3.40 Temporal.ZonedDateTime.prototype.round ( roundTo ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.round
|
||||
|
@ -987,7 +987,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::round)
|
|||
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If roundTo is undefined, then
|
||||
if (vm.argument(0).is_undefined()) {
|
||||
|
@ -1076,7 +1076,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::equals)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Set other to ? ToTemporalZonedDateTime(other).
|
||||
auto* other = TRY(to_temporal_zoned_date_time(vm, vm.argument(0)));
|
||||
|
@ -1098,7 +1098,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_string)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Set options to ? GetOptionsObject(options).
|
||||
auto* options = TRY(get_options_object(vm, vm.argument(0)));
|
||||
|
@ -1119,7 +1119,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 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)));
|
||||
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.43 Temporal.ZonedDateTime.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.tolocalestring
|
||||
|
@ -1128,10 +1128,10 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_locale_string)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? TemporalZonedDateTimeToString(zonedDateTime, "auto", "auto", "auto", "auto").
|
||||
return PrimitiveString::create(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.toJSON ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.tojson
|
||||
|
@ -1139,10 +1139,10 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_json)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ? TemporalZonedDateTimeToString(zonedDateTime, "auto", "auto", "auto", "auto").
|
||||
return PrimitiveString::create(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.45 Temporal.ZonedDateTime.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.zoneddatetime.prototype.valueof
|
||||
|
@ -1157,7 +1157,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::start_of_day)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let timeZone be zonedDateTime.[[TimeZone]].
|
||||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
@ -1186,7 +1186,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_instant)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]).
|
||||
return MUST(create_temporal_instant(vm, zoned_date_time->nanoseconds()));
|
||||
|
@ -1197,7 +1197,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_plain_date)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let timeZone be zonedDateTime.[[TimeZone]].
|
||||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
@ -1220,7 +1220,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_plain_time)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let timeZone be zonedDateTime.[[TimeZone]].
|
||||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
@ -1243,7 +1243,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_plain_date_time)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let timeZone be zonedDateTime.[[TimeZone]].
|
||||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
@ -1260,7 +1260,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_plain_year_month)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let timeZone be zonedDateTime.[[TimeZone]].
|
||||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
@ -1289,7 +1289,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_plain_month_day)
|
|||
{
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let timeZone be zonedDateTime.[[TimeZone]].
|
||||
auto& time_zone = zoned_date_time->time_zone();
|
||||
|
@ -1320,7 +1320,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::get_iso_fields)
|
|||
|
||||
// 1. Let zonedDateTime be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]).
|
||||
auto* zoned_date_time = TRY(typed_this_object(vm));
|
||||
auto zoned_date_time = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Let fields be OrdinaryObjectCreate(%Object.prototype%).
|
||||
auto fields = Object::create(realm, realm.intrinsics().object_prototype());
|
||||
|
|
|
@ -40,7 +40,7 @@ JS_DEFINE_NATIVE_FUNCTION(WeakMapPrototype::delete_)
|
|||
|
||||
// 1. Let M be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(M, [[WeakMapData]]).
|
||||
auto* weak_map = TRY(typed_this_object(vm));
|
||||
auto weak_map = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If CanBeHeldWeakly(key) is false, return false.
|
||||
if (!can_be_held_weakly(key))
|
||||
|
@ -62,7 +62,7 @@ JS_DEFINE_NATIVE_FUNCTION(WeakMapPrototype::get)
|
|||
|
||||
// 1. Let M be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(M, [[WeakMapData]]).
|
||||
auto* weak_map = TRY(typed_this_object(vm));
|
||||
auto weak_map = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If CanBeHeldWeakly(key) is false, return undefined.
|
||||
if (!can_be_held_weakly(key))
|
||||
|
@ -86,7 +86,7 @@ JS_DEFINE_NATIVE_FUNCTION(WeakMapPrototype::has)
|
|||
|
||||
// 1. Let M be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(M, [[WeakMapData]]).
|
||||
auto* weak_map = TRY(typed_this_object(vm));
|
||||
auto weak_map = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If CanBeHeldWeakly(key) is false, return false.
|
||||
if (!can_be_held_weakly(key))
|
||||
|
@ -111,7 +111,7 @@ JS_DEFINE_NATIVE_FUNCTION(WeakMapPrototype::set)
|
|||
|
||||
// 1. Let M be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(M, [[WeakMapData]]).
|
||||
auto* weak_map = TRY(typed_this_object(vm));
|
||||
auto weak_map = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If CanBeHeldWeakly(key) is false, throw a TypeError exception.
|
||||
if (!can_be_held_weakly(key))
|
||||
|
|
|
@ -31,7 +31,7 @@ JS_DEFINE_NATIVE_FUNCTION(WeakRefPrototype::deref)
|
|||
{
|
||||
// 1. Let weakRef be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(weakRef, [[WeakRefTarget]]).
|
||||
auto* weak_ref = TRY(typed_this_object(vm));
|
||||
auto weak_ref = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. Return WeakRefDeref(weakRef).
|
||||
weak_ref->update_execution_generation();
|
||||
|
|
|
@ -39,7 +39,7 @@ JS_DEFINE_NATIVE_FUNCTION(WeakSetPrototype::add)
|
|||
|
||||
// 1. Let S be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(S, [[WeakSetData]]).
|
||||
auto* weak_set = TRY(typed_this_object(vm));
|
||||
auto weak_set = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If CanBeHeldWeakly(value) is false, throw a TypeError exception.
|
||||
if (!can_be_held_weakly(value))
|
||||
|
@ -62,7 +62,7 @@ JS_DEFINE_NATIVE_FUNCTION(WeakSetPrototype::delete_)
|
|||
|
||||
// 1. Let S be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(S, [[WeakSetData]]).
|
||||
auto* weak_set = TRY(typed_this_object(vm));
|
||||
auto weak_set = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If CanBeHeldWeakly(value) is false, return false.
|
||||
if (!can_be_held_weakly(value))
|
||||
|
@ -83,7 +83,7 @@ JS_DEFINE_NATIVE_FUNCTION(WeakSetPrototype::has)
|
|||
|
||||
// 1. Let S be the this value.
|
||||
// 2. Perform ? RequireInternalSlot(S, [[WeakSetData]]).
|
||||
auto* weak_set = TRY(typed_this_object(vm));
|
||||
auto weak_set = TRY(typed_this_object(vm));
|
||||
|
||||
// 3. If CanBeHeldWeakly(value) is false, return false.
|
||||
if (!can_be_held_weakly(value))
|
||||
|
|
Loading…
Add table
Reference in a new issue