diff options
author | Linus Groh <mail@linusgroh.de> | 2021-10-18 20:03:21 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-10-18 21:24:30 +0100 |
commit | 4b7c1f703e810a8011cc6ddc791d1d374139c87f (patch) | |
tree | 9105a7316736310089bf01934b9228fc802c0ccb /Userland/Libraries/LibJS/Runtime/Temporal | |
parent | 7c29979e30831140271a3a96d92f7e463e56ddf2 (diff) | |
download | serenity-4b7c1f703e810a8011cc6ddc791d1d374139c87f.zip |
LibJS: Convert PrototypeObject::typed_this_object() to ThrowCompletionOr
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/Temporal')
10 files changed, 183 insertions, 549 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp index 8e96c7ce79..41796a7189 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/CalendarPrototype.cpp @@ -78,9 +78,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::date_from_fields) { // 1. Let calendar be the this value. // 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - auto* calendar = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* calendar = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Assert: calendar.[[Identifier]] is "iso8601". VERIFY(calendar->identifier() == "iso8601"sv); @@ -108,9 +106,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::year_month_from_fields) { // 1. Let calendar be the this value. // 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - auto* calendar = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* calendar = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Assert: calendar.[[Identifier]] is "iso8601". VERIFY(calendar->identifier() == "iso8601"sv); @@ -138,9 +134,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::month_day_from_fields) { // 1. Let calendar be the this value. // 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - auto* calendar = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* calendar = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Assert: calendar.[[Identifier]] is "iso8601". VERIFY(calendar->identifier() == "iso8601"sv); @@ -168,9 +162,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::date_add) { // 1. Let calendar be the this value. // 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - auto* calendar = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* calendar = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Assert: calendar.[[Identifier]] is "iso8601". VERIFY(calendar->identifier() == "iso8601"sv); @@ -206,9 +198,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::date_until) { // 1. Let calendar be the this value. // 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - auto* calendar = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* calendar = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Assert: calendar.[[Identifier]] is "iso8601". VERIFY(calendar->identifier() == "iso8601"sv); @@ -238,9 +228,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::year) { // 1. Let calendar be the this value. // 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - auto* calendar = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* calendar = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Assert: calendar.[[Identifier]] is "iso8601". VERIFY(calendar->identifier() == "iso8601"sv); @@ -262,9 +250,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::month) { // 1. Let calendar be the this value. // 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - auto* calendar = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* calendar = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Assert: calendar.[[Identifier]] is "iso8601". VERIFY(calendar->identifier() == "iso8601"sv); @@ -294,9 +280,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::month_code) { // 1. Let calendar be the this value. // 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - auto* calendar = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* calendar = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Assert: calendar.[[Identifier]] is "iso8601". VERIFY(calendar->identifier() == "iso8601"sv); @@ -318,9 +302,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::day) { // 1. Let calendar be the this value. // 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - auto* calendar = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* calendar = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Assert: calendar.[[Identifier]] is "iso8601". VERIFY(calendar->identifier() == "iso8601"sv); @@ -342,9 +324,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::day_of_week) { // 1. Let calendar be the this value. // 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - auto* calendar = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* calendar = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Assert: calendar.[[Identifier]] is "iso8601". VERIFY(calendar->identifier() == "iso8601"sv); @@ -362,9 +342,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::day_of_year) { // 1. Let calendar be the this value. // 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - auto* calendar = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* calendar = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Assert: calendar.[[Identifier]] is "iso8601". VERIFY(calendar->identifier() == "iso8601"sv); @@ -382,9 +360,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::week_of_year) { // 1. Let calendar be the this value. // 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - auto* calendar = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* calendar = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Assert: calendar.[[Identifier]] is "iso8601". VERIFY(calendar->identifier() == "iso8601"sv); @@ -402,9 +378,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::days_in_week) { // 1. Let calendar be the this value. // 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - auto* calendar = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* calendar = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Assert: calendar.[[Identifier]] is "iso8601". VERIFY(calendar->identifier() == "iso8601"sv); @@ -422,9 +396,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::days_in_month) { // 1. Let calendar be the this value. // 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - auto* calendar = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* calendar = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Assert: calendar.[[Identifier]] is "iso8601". VERIFY(calendar->identifier() == "iso8601"sv); @@ -446,9 +418,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::days_in_year) { // 1. Let calendar be the this value. // 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - auto* calendar = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* calendar = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Assert: calendar.[[Identifier]] is "iso8601". VERIFY(calendar->identifier() == "iso8601"sv); @@ -470,9 +440,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::months_in_year) { // 1. Let calendar be the this value. // 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - auto* calendar = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* calendar = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Assert: calendar.[[Identifier]] is "iso8601". VERIFY(calendar->identifier() == "iso8601"sv); @@ -494,9 +462,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::in_leap_year) { // 1. Let calendar be the this value. // 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - auto* calendar = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* calendar = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Assert: calendar.[[Identifier]] is "iso8601". VERIFY(calendar->identifier() == "iso8601"sv); @@ -520,9 +486,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::fields) // 1. Let calendar be the this value. // 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - auto* calendar = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* calendar = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Assert: calendar.[[Identifier]] is "iso8601". VERIFY(calendar->identifier() == "iso8601"sv); @@ -596,9 +560,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::merge_fields) { // 1. Let calendar be the this value. // 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - auto* calendar = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* calendar = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Assert: calendar.[[Identifier]] is "iso8601". VERIFY(calendar->identifier() == "iso8601"sv); @@ -618,9 +580,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::to_string) { // 1. Let calendar be the this value. // 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - auto* calendar = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* calendar = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return calendar.[[Identifier]]. return js_string(vm, calendar->identifier()); @@ -643,9 +603,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::era) // 1. Let calendar be the this value. // 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - auto* calendar = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* calendar = TRY_OR_DISCARD(typed_this_object(global_object)); // 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()))) { @@ -673,9 +631,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::era_year) // 1. Let calendar be the this value. // 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - auto* calendar = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* calendar = TRY_OR_DISCARD(typed_this_object(global_object)); // 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()))) { diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp index 9568c0f73b..1f80984a62 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/DurationPrototype.cpp @@ -52,9 +52,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::years_getter) { // 1. Let duration be the this value. // 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]). - auto* duration = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* duration = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return duration.[[Years]]. return Value(duration->years()); @@ -65,9 +63,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::months_getter) { // 1. Let duration be the this value. // 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]). - auto* duration = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* duration = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return duration.[[Months]]. return Value(duration->months()); @@ -78,9 +74,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::weeks_getter) { // 1. Let duration be the this value. // 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]). - auto* duration = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* duration = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return duration.[[Weeks]]. return Value(duration->weeks()); @@ -91,9 +85,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::days_getter) { // 1. Let duration be the this value. // 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]). - auto* duration = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* duration = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return duration.[[Days]]. return Value(duration->days()); @@ -104,9 +96,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::hours_getter) { // 1. Let duration be the this value. // 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]). - auto* duration = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* duration = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return duration.[[Hours]]. return Value(duration->hours()); @@ -117,9 +107,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::minutes_getter) { // 1. Let duration be the this value. // 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]). - auto* duration = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* duration = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return duration.[[Minutes]]. return Value(duration->minutes()); @@ -130,9 +118,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::seconds_getter) { // 1. Let duration be the this value. // 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]). - auto* duration = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* duration = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return duration.[[Seconds]]. return Value(duration->seconds()); @@ -143,9 +129,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::milliseconds_getter) { // 1. Let duration be the this value. // 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]). - auto* duration = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* duration = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return duration.[[Milliseconds]]. return Value(duration->milliseconds()); @@ -156,9 +140,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::microseconds_getter) { // 1. Let duration be the this value. // 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]). - auto* duration = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* duration = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return duration.[[Microseconds]]. return Value(duration->microseconds()); @@ -169,9 +151,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::nanoseconds_getter) { // 1. Let duration be the this value. // 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]). - auto* duration = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* duration = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return duration.[[Nanoseconds]]. return Value(duration->nanoseconds()); @@ -182,9 +162,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::sign_getter) { // 1. Let duration be the this value. // 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]). - auto* duration = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* duration = TRY_OR_DISCARD(typed_this_object(global_object)); // 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())); @@ -195,9 +173,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::blank_getter) { // 1. Let duration be the this value. // 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]). - auto* duration = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* duration = TRY_OR_DISCARD(typed_this_object(global_object)); // 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()); @@ -215,9 +191,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::with) { // 1. Let duration be the this value. // 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]). - auto* duration = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* duration = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let temporalDurationLike be ? ToPartialDuration(temporalDurationLike). auto temporal_duration_like = TRY_OR_DISCARD(to_partial_duration(global_object, vm.argument(0))); @@ -291,9 +265,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::negated) { // 1. Let duration be the this value. // 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]). - auto* duration = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* duration = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return ! CreateNegatedTemporalDuration(duration). return create_negated_temporal_duration(global_object, *duration); @@ -304,9 +276,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationPrototype::abs) { // 1. Let duration be the this value. // 2. Perform ? RequireInternalSlot(duration, [[InitializedTemporalDuration]]). - auto* duration = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* duration = TRY_OR_DISCARD(typed_this_object(global_object)); // 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_OR_DISCARD(create_temporal_duration(global_object, 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()))); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp index 01b9ad223c..dbac4e2e42 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp @@ -57,9 +57,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::epoch_seconds_getter) { // 1. Let instant be the this value. // 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]). - auto* instant = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* instant = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let ns be instant.[[Nanoseconds]]. auto& ns = instant->nanoseconds(); @@ -76,9 +74,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::epoch_milliseconds_getter) { // 1. Let instant be the this value. // 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]). - auto* instant = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* instant = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let ns be instant.[[Nanoseconds]]. auto& ns = instant->nanoseconds(); @@ -95,9 +91,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::epoch_microseconds_getter) { // 1. Let instant be the this value. // 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]). - auto* instant = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* instant = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let ns be instant.[[Nanoseconds]]. auto& ns = instant->nanoseconds(); @@ -114,9 +108,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::epoch_nanoseconds_getter) { // 1. Let instant be the this value. // 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]). - auto* instant = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* instant = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let ns be instant.[[Nanoseconds]]. auto& ns = instant->nanoseconds(); @@ -132,9 +124,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::add) // 1. Let instant be the this value. // 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]). - auto* instant = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* instant = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let duration be ? ToLimitedTemporalDuration(temporalDurationLike, ยซ "years", "months", "weeks", "days" ยป). auto duration = TRY_OR_DISCARD(to_limited_temporal_duration(global_object, temporal_duration_like, { "years"sv, "months"sv, "weeks"sv, "days"sv })); @@ -153,9 +143,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::subtract) // 1. Let instant be the this value. // 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]). - auto* instant = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* instant = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let duration be ? ToLimitedTemporalDuration(temporalDurationLike, ยซ "years", "months", "weeks", "days" ยป). auto duration = TRY_OR_DISCARD(to_limited_temporal_duration(global_object, temporal_duration_like, { "years"sv, "months"sv, "weeks"sv, "days"sv })); @@ -172,9 +160,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::until) { // 1. Let instant be the this value. // 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]). - auto* instant = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* instant = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Set other to ? ToTemporalInstant(other). auto* other = TRY_OR_DISCARD(to_temporal_instant(global_object, vm.argument(0))); @@ -218,9 +204,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::since) { // 1. Let instant be the this value. // 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]). - auto* instant = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* instant = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Set other to ? ToTemporalInstant(other). auto* other = TRY_OR_DISCARD(to_temporal_instant(global_object, vm.argument(0))); @@ -264,9 +248,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::round) { // 1. Let instant be the this value. // 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]). - auto* instant = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* instant = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. If options is undefined, then if (vm.argument(0).is_undefined()) { @@ -343,9 +325,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::equals) { // 1. Let instant be the this value. // 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]). - auto* instant = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* instant = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Set other to ? ToTemporalInstant(other). auto other = TRY_OR_DISCARD(to_temporal_instant(global_object, vm.argument(0))); @@ -363,9 +343,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::to_string) { // 1. Let instant be the this value. // 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]). - auto* instant = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* instant = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Set options to ? GetOptionsObject(options). auto* options = TRY_OR_DISCARD(get_options_object(global_object, vm.argument(0))); @@ -403,9 +381,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::to_locale_string) { // 1. Let instant be the this value. // 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]). - auto* instant = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* instant = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return ? TemporalInstantToString(instant, undefined, "auto"). return js_string(vm, TRY_OR_DISCARD(temporal_instant_to_string(global_object, *instant, js_undefined(), "auto"sv))); @@ -416,9 +392,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::to_json) { // 1. Let instant be the this value. // 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]). - auto* instant = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* instant = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return ? TemporalInstantToString(instant, undefined, "auto"). return js_string(vm, TRY_OR_DISCARD(temporal_instant_to_string(global_object, *instant, js_undefined(), "auto"sv))); @@ -439,9 +413,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::to_zoned_date_time) // 1. Let instant be the this value. // 2. Perform ? RequireInternalSlot(instant, [[InitializedTemporalInstant]]). - auto* instant = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* instant = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. If Type(item) is not Object, then if (!item.is_object()) { @@ -487,9 +459,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 = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* instant = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. If Type(item) is Object, then if (item.is_object()) { diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp index c39b3abc09..d2623baf21 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDatePrototype.cpp @@ -67,9 +67,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::calendar_getter) { // 1. Let temporalDate be the this value. // 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]). - auto* temporal_date = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_date = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return temporalDate.[[Calendar]]. return Value(&temporal_date->calendar()); @@ -80,9 +78,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::year_getter) { // 1. Let temporalDate be the this value. // 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]). - auto* temporal_date = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_date = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be temporalDate.[[Calendar]]. auto& calendar = temporal_date->calendar(); @@ -96,9 +92,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::month_getter) { // 1. Let temporalDate be the this value. // 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]). - auto* temporal_date = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_date = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be temporalDate.[[Calendar]]. auto& calendar = temporal_date->calendar(); @@ -112,9 +106,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::month_code_getter) { // 1. Let temporalDate be the this value. // 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]). - auto* temporal_date = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_date = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be temporalDate.[[Calendar]]. auto& calendar = temporal_date->calendar(); @@ -128,9 +120,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::day_getter) { // 1. Let temporalDate be the this value. // 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]). - auto* temporal_date = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_date = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be temporalDate.[[Calendar]]. auto& calendar = temporal_date->calendar(); @@ -144,9 +134,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::day_of_week_getter) { // 1. Let temporalDate be the this value. // 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]). - auto* temporal_date = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_date = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be temporalDate.[[Calendar]]. auto& calendar = temporal_date->calendar(); @@ -160,9 +148,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::day_of_year_getter) { // 1. Let temporalDate be the this value. // 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]). - auto* temporal_date = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_date = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be temporalDate.[[Calendar]]. auto& calendar = temporal_date->calendar(); @@ -176,9 +162,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::week_of_year_getter) { // 1. Let temporalDate be the this value. // 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]). - auto* temporal_date = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_date = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be temporalDate.[[Calendar]]. auto& calendar = temporal_date->calendar(); @@ -192,9 +176,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::days_in_week_getter) { // 1. Let temporalDate be the this value. // 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]). - auto* temporal_date = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_date = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be temporalDate.[[Calendar]]. auto& calendar = temporal_date->calendar(); @@ -208,9 +190,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::days_in_month_getter) { // 1. Let temporalDate be the this value. // 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]). - auto* temporal_date = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_date = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be temporalDate.[[Calendar]]. auto& calendar = temporal_date->calendar(); @@ -224,9 +204,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::days_in_year_getter) { // 1. Let temporalDate be the this value. // 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]). - auto* temporal_date = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_date = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be temporalDate.[[Calendar]]. auto& calendar = temporal_date->calendar(); @@ -240,9 +218,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::months_in_year_getter) { // 1. Let temporalDate be the this value. // 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]). - auto* temporal_date = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_date = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be temporalDate.[[Calendar]]. auto& calendar = temporal_date->calendar(); @@ -256,9 +232,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::in_leap_year_getter) { // 1. Let temporalDate be the this value. // 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]). - auto* temporal_date = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_date = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be temporalDate.[[Calendar]]. auto& calendar = temporal_date->calendar(); @@ -272,9 +246,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::era_getter) { // 1. Let plainDate be the this value. // 2. Perform ? RequireInternalSlot(plainDate, [[InitializedTemporalDate]]). - auto* plain_date = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* plain_date = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be plainDate.[[Calendar]]. auto& calendar = plain_date->calendar(); @@ -288,9 +260,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::era_year_getter) { // 1. Let plainDate be the this value. // 2. Perform ? RequireInternalSlot(plainDate, [[InitializedTemporalDate]]). - auto* plain_date = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* plain_date = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be plainDate.[[Calendar]]. auto& calendar = plain_date->calendar(); @@ -304,9 +274,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 = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_date = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be temporalDate.[[Calendar]]. auto& calendar = temporal_date->calendar(); @@ -326,9 +294,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 = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_date = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be temporalDate.[[Calendar]]. auto& calendar = temporal_date->calendar(); @@ -348,9 +314,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::get_iso_fields) { // 1. Let temporalDate be the this value. // 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]). - auto* temporal_date = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_date = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let fields be ! OrdinaryObjectCreate(%Object.prototype%). auto* fields = Object::create(global_object, global_object.object_prototype()); @@ -376,9 +340,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::with_calendar) { // 1. Let temporalDate be the this value. // 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]). - auto* temporal_date = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_date = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be ? ToTemporalCalendar(calendar). auto* calendar = TRY_OR_DISCARD(to_temporal_calendar(global_object, vm.argument(0))); @@ -392,9 +354,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::equals) { // 1. Let temporalDate be the this value. // 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]). - auto* temporal_date = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_date = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Set other to ? ToTemporalDate(other). auto* other = TRY_OR_DISCARD(to_temporal_date(global_object, vm.argument(0))); @@ -417,9 +377,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 = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_date = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. If temporalTime is undefined, then if (vm.argument(0).is_undefined()) { @@ -439,9 +397,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::to_string) { // 1. Let temporalDate be the this value. // 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]). - auto* temporal_date = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_date = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Set options to ? GetOptionsObject(options). auto* options = TRY_OR_DISCARD(get_options_object(global_object, vm.argument(0))); @@ -459,9 +415,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::to_locale_string) { // 1. Let temporalDate be the this value. // 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]). - auto* temporal_date = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_date = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return ? TemporalDateToString(temporalDate, "auto"). return js_string(vm, TRY_OR_DISCARD(temporal_date_to_string(global_object, *temporal_date, "auto"sv))); @@ -472,9 +426,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDatePrototype::to_json) { // 1. Let temporalDate be the this value. // 2. Perform ? RequireInternalSlot(temporalDate, [[InitializedTemporalDate]]). - auto* temporal_date = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_date = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return ? TemporalDateToString(temporalDate, "auto"). return js_string(vm, TRY_OR_DISCARD(temporal_date_to_string(global_object, *temporal_date, "auto"sv))); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp index e73a884726..ad13b848b4 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainDateTimePrototype.cpp @@ -70,9 +70,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::calendar_getter) { // 1. Let dateTime be the this value. // 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]). - auto* date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return dateTime.[[Calendar]]. return Value(&date_time->calendar()); @@ -83,9 +81,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::year_getter) { // 1. Let dateTime be the this value. // 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]). - auto* date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be dateTime.[[Calendar]]. auto& calendar = date_time->calendar(); @@ -99,9 +95,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::month_getter) { // 1. Let dateTime be the this value. // 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]). - auto* date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be dateTime.[[Calendar]]. auto& calendar = date_time->calendar(); @@ -115,9 +109,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::month_code_getter) { // 1. Let dateTime be the this value. // 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]). - auto* date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be dateTime.[[Calendar]]. auto& calendar = date_time->calendar(); @@ -131,9 +123,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::day_getter) { // 1. Let dateTime be the this value. // 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]). - auto* date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be dateTime.[[Calendar]]. auto& calendar = date_time->calendar(); @@ -147,9 +137,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::hour_getter) { // 1. Let dateTime be the this value. // 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]). - auto* date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return ๐ฝ(dateTime.[[ISOHour]]). return Value(date_time->iso_hour()); @@ -160,9 +148,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::minute_getter) { // 1. Let dateTime be the this value. // 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]). - auto* date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return ๐ฝ(dateTime.[[ISOMinute]]). return Value(date_time->iso_minute()); @@ -173,9 +159,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::second_getter) { // 1. Let dateTime be the this value. // 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]). - auto* date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return ๐ฝ(dateTime.[[ISOSecond]]). return Value(date_time->iso_second()); @@ -186,9 +170,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::millisecond_getter) { // 1. Let dateTime be the this value. // 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]). - auto* date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return ๐ฝ(dateTime.[[ISOMillisecond]]). return Value(date_time->iso_millisecond()); @@ -199,9 +181,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::microsecond_getter) { // 1. Let dateTime be the this value. // 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]). - auto* date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return ๐ฝ(dateTime.[[ISOMicrosecond]]). return Value(date_time->iso_microsecond()); @@ -212,9 +192,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::nanosecond_getter) { // 1. Let dateTime be the this value. // 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]). - auto* date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return ๐ฝ(dateTime.[[ISONanosecond]]). return Value(date_time->iso_nanosecond()); @@ -225,9 +203,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::day_of_week_getter) { // 1. Let dateTime be the this value. // 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]). - auto* date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be dateTime.[[Calendar]]. auto& calendar = date_time->calendar(); @@ -241,9 +217,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::day_of_year_getter) { // 1. Let dateTime be the this value. // 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]). - auto* date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be dateTime.[[Calendar]]. auto& calendar = date_time->calendar(); @@ -257,9 +231,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::week_of_year_getter) { // 1. Let dateTime be the this value. // 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]). - auto* date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be dateTime.[[Calendar]]. auto& calendar = date_time->calendar(); @@ -273,9 +245,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::days_in_week_getter) { // 1. Let dateTime be the this value. // 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]). - auto* date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be dateTime.[[Calendar]]. auto& calendar = date_time->calendar(); @@ -289,9 +259,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::days_in_month_getter) { // 1. Let dateTime be the this value. // 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]). - auto* date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be dateTime.[[Calendar]]. auto& calendar = date_time->calendar(); @@ -305,9 +273,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::days_in_year_getter) { // 1. Let dateTime be the this value. // 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]). - auto* date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be dateTime.[[Calendar]]. auto& calendar = date_time->calendar(); @@ -321,9 +287,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::months_in_year_getter) { // 1. Let dateTime be the this value. // 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]). - auto* date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be dateTime.[[Calendar]]. auto& calendar = date_time->calendar(); @@ -337,9 +301,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::in_leap_year_getter) { // 1. Let dateTime be the this value. // 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]). - auto* date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be dateTime.[[Calendar]]. auto& calendar = date_time->calendar(); @@ -353,9 +315,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::era_getter) { // 1. Let plainDateTime be the this value. // 2. Perform ? RequireInternalSlot(plainDateTime, [[InitializedTemporalDateTime]]). - auto* plain_date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* plain_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be plainDateTime.[[Calendar]]. auto& calendar = plain_date_time->calendar(); @@ -369,9 +329,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::era_year_getter) { // 1. Let plainDateTime be the this value. // 2. Perform ? RequireInternalSlot(plainDateTime, [[InitializedTemporalDateTime]]). - auto* plain_date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* plain_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be plainDateTime.[[Calendar]]. auto& calendar = plain_date_time->calendar(); @@ -385,9 +343,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::with_plain_time) { // 1. Let dateTime be the this value. // 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]). - auto* date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. If plainTimeLike is undefined, then if (vm.argument(0).is_undefined()) { @@ -407,9 +363,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::with_plain_date) { // 1. Let dateTime be the this value. // 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]). - auto* date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let plainDate be ? ToTemporalDate(plainDateLike). auto* plain_date = TRY_OR_DISCARD(to_temporal_date(global_object, vm.argument(0))); @@ -426,9 +380,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::with_calendar) { // 1. Let dateTime be the this value. // 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]). - auto* date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be ? ToTemporalCalendar(calendar). auto* calendar = TRY_OR_DISCARD(to_temporal_calendar(global_object, vm.argument(0))); @@ -442,9 +394,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::equals) { // 1. Let dateTime be the this value. // 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]). - auto* date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Set other to ? ToTemporalDateTime(other). auto* other = TRY_OR_DISCARD(to_temporal_date_time(global_object, vm.argument(0))); @@ -473,9 +423,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::to_plain_date) { // 1. Let dateTime be the this value. // 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]). - auto* date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return ? CreateTemporalDate(dateTime.[[ISOYear]], dateTime.[[ISOMonth]], dateTime.[[ISODay]], dateTime.[[Calendar]]). return TRY_OR_DISCARD(create_temporal_date(global_object, date_time->iso_year(), date_time->iso_month(), date_time->iso_day(), date_time->calendar())); @@ -486,9 +434,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 = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be dateTime.[[Calendar]]. auto& calendar = date_time->calendar(); @@ -508,9 +454,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 = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be dateTime.[[Calendar]]. auto& calendar = date_time->calendar(); @@ -530,9 +474,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::to_plain_time) { // 1. Let dateTime be the this value. // 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]). - auto* date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return ? CreateTemporalTime(dateTime.[[ISOHour]], dateTime.[[ISOMinute]], dateTime.[[ISOSecond]], dateTime.[[ISOMillisecond]], dateTime.[[ISOMicrosecond]], dateTime.[[ISONanosecond]]). return TRY_OR_DISCARD(create_temporal_time(global_object, date_time->iso_hour(), date_time->iso_minute(), date_time->iso_second(), date_time->iso_millisecond(), date_time->iso_microsecond(), date_time->iso_nanosecond())); @@ -543,9 +485,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainDateTimePrototype::get_iso_fields) { // 1. Let dateTime be the this value. // 2. Perform ? RequireInternalSlot(dateTime, [[InitializedTemporalDateTime]]). - auto* date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let fields be ! OrdinaryObjectCreate(%Object.prototype%). auto* fields = Object::create(global_object, global_object.object_prototype()); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp index d1252015d6..35a2b26d17 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp @@ -47,9 +47,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::calendar_getter) { // 1. Let monthDay be the this value. // 2. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]). - auto* month_day = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* month_day = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return monthDay.[[Calendar]]. return Value(&month_day->calendar()); @@ -60,9 +58,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::month_code_getter) { // 1. Let monthDay be the this value. // 2. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]). - auto* month_day = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* month_day = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be monthDay.[[Calendar]]. auto& calendar = month_day->calendar(); @@ -76,9 +72,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::day_getter) { // 1. Let monthDay be the this value. // 2. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]). - auto* month_day = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* month_day = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be monthDay.[[Calendar]]. auto& calendar = month_day->calendar(); @@ -92,9 +86,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::equals) { // 1. Let monthDay be the this value. // 2. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]). - auto* month_day = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* month_day = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Set other to ? ToTemporalMonthDay(other). auto* other = TRY_OR_DISCARD(to_temporal_month_day(global_object, vm.argument(0))); @@ -120,9 +112,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::to_string) { // 1. Let monthDay be the this value. // 2. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]). - auto* month_day = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* month_day = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Set options to ? GetOptionsObject(options). auto* options = TRY_OR_DISCARD(get_options_object(global_object, vm.argument(0))); @@ -140,9 +130,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::to_locale_string) { // 1. Let monthDay be the this value. // 2. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]). - auto* month_day = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* month_day = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return ? TemporalMonthDayToString(monthDay, "auto"). return js_string(vm, TRY_OR_DISCARD(temporal_month_day_to_string(global_object, *month_day, "auto"sv))); @@ -153,9 +141,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::to_json) { // 1. Let monthDay be the this value. // 2. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]). - auto* month_day = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* month_day = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return ? TemporalMonthDayToString(monthDay, "auto"). return js_string(vm, TRY_OR_DISCARD(temporal_month_day_to_string(global_object, *month_day, "auto"sv))); @@ -176,9 +162,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::to_plain_date) // 1. Let monthDay be the this value. // 2. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]). - auto* month_day = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* month_day = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. If Type(item) is not Object, then if (!item.is_object()) { @@ -234,9 +218,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::get_iso_fields) { // 1. Let monthDay be the this value. // 2. Perform ? RequireInternalSlot(monthDay, [[InitializedTemporalMonthDay]]). - auto* month_day = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* month_day = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let fields be ! OrdinaryObjectCreate(%Object.prototype%). auto* fields = Object::create(global_object, global_object.object_prototype()); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp index 37577389c7..6f35442513 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp @@ -53,9 +53,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::calendar_getter) { // 1. Let temporalTime be the this value. // 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]). - auto* temporal_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return temporalTime.[[Calendar]]. return Value(&temporal_time->calendar()); @@ -66,9 +64,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::hour_getter) { // 1. Let temporalTime be the this value. // 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]). - auto* temporal_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return ๐ฝ(temporalTime.[[ISOHour]]). return Value(temporal_time->iso_hour()); @@ -79,9 +75,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::minute_getter) { // 1. Let temporalTime be the this value. // 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]). - auto* temporal_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return ๐ฝ(temporalTime.[[ISOMinute]]). return Value(temporal_time->iso_minute()); @@ -92,9 +86,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::second_getter) { // 1. Let temporalTime be the this value. // 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]). - auto* temporal_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return ๐ฝ(temporalTime.[[ISOSecond]]). return Value(temporal_time->iso_second()); @@ -105,9 +97,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::millisecond_getter) { // 1. Let temporalTime be the this value. // 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]). - auto* temporal_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return ๐ฝ(temporalTime.[[ISOMillisecond]]). return Value(temporal_time->iso_millisecond()); @@ -118,9 +108,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::microsecond_getter) { // 1. Let temporalTime be the this value. // 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]). - auto* temporal_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return ๐ฝ(temporalTime.[[ISOMicrosecond]]). return Value(temporal_time->iso_microsecond()); @@ -131,9 +119,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::nanosecond_getter) { // 1. Let temporalTime be the this value. // 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]). - auto* temporal_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return ๐ฝ(temporalTime.[[ISONanosecond]]). return Value(temporal_time->iso_nanosecond()); @@ -144,9 +130,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::with) { // 1. Let temporalTime be the this value. // 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]). - auto* temporal_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object)); auto temporal_time_like_argument = vm.argument(0); @@ -239,9 +223,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::equals) { // 1. Let temporalTime be the this value. // 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]). - auto* temporal_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Set other to ? ToTemporalTime(other). auto* other = TRY_OR_DISCARD(to_temporal_time(global_object, vm.argument(0))); @@ -279,9 +261,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 = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Set temporalDate to ? ToTemporalDate(temporalDate). auto* temporal_date = TRY_OR_DISCARD(to_temporal_date(global_object, vm.argument(0))); @@ -295,9 +275,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::get_iso_fields) { // 1. Let temporalTime be the this value. // 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]). - auto* temporal_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let fields be ! OrdinaryObjectCreate(%Object.prototype%). auto* fields = Object::create(global_object, global_object.object_prototype()); @@ -332,9 +310,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::to_string) { // 1. Let temporalTime be the this value. // 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]). - auto* temporal_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Set options to ? GetOptionsObject(options). auto* options = TRY_OR_DISCARD(get_options_object(global_object, vm.argument(0))); @@ -358,9 +334,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::to_locale_string) { // 1. Let temporalTime be the this value. // 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]). - auto* temporal_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return ! TemporalTimeToString(temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], "auto"). auto string = temporal_time_to_string(temporal_time->iso_hour(), temporal_time->iso_minute(), temporal_time->iso_second(), temporal_time->iso_millisecond(), temporal_time->iso_microsecond(), temporal_time->iso_nanosecond(), "auto"sv); @@ -372,9 +346,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::to_json) { // 1. Let temporalTime be the this value. // 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]). - auto* temporal_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return ! TemporalTimeToString(temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], "auto"). auto string = temporal_time_to_string(temporal_time->iso_hour(), temporal_time->iso_minute(), temporal_time->iso_second(), temporal_time->iso_millisecond(), temporal_time->iso_microsecond(), temporal_time->iso_nanosecond(), "auto"sv); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp index 251f59482e..0290aca1b1 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp @@ -54,9 +54,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::calendar_getter) { // 1. Let yearMonth be the this value. // 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]). - auto* year_month = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* year_month = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return yearMonth.[[Calendar]]. return Value(&year_month->calendar()); @@ -67,9 +65,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::year_getter) { // 1. Let yearMonth be the this value. // 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]). - auto* year_month = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* year_month = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be yearMonth.[[Calendar]]. auto& calendar = year_month->calendar(); @@ -83,9 +79,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::month_getter) { // 1. Let yearMonth be the this value. // 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]). - auto* year_month = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* year_month = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be yearMonth.[[Calendar]]. auto& calendar = year_month->calendar(); @@ -99,9 +93,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::month_code_getter) { // 1. Let yearMonth be the this value. // 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]). - auto* year_month = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* year_month = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be yearMonth.[[Calendar]]. auto& calendar = year_month->calendar(); @@ -115,9 +107,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::days_in_year_getter) { // 1. Let yearMonth be the this value. // 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]). - auto* year_month = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* year_month = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be yearMonth.[[Calendar]]. auto& calendar = year_month->calendar(); @@ -131,9 +121,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::days_in_month_getter) { // 1. Let yearMonth be the this value. // 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]). - auto* year_month = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* year_month = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be yearMonth.[[Calendar]]. auto& calendar = year_month->calendar(); @@ -147,9 +135,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::months_in_year_getter) { // 1. Let yearMonth be the this value. // 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]). - auto* year_month = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* year_month = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be yearMonth.[[Calendar]]. auto& calendar = year_month->calendar(); @@ -163,9 +149,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::in_leap_year_getter) { // 1. Let yearMonth be the this value. // 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]). - auto* year_month = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* year_month = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be yearMonth.[[Calendar]]. auto& calendar = year_month->calendar(); @@ -179,9 +163,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::era_getter) { // 1. Let plainYearMonth be the this value. // 2. Perform ? RequireInternalSlot(plainYearMonth, [[InitializedTemporalYearMonth]]). - auto* plain_year_month = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* plain_year_month = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be plainYearMonth.[[Calendar]]. auto& calendar = plain_year_month->calendar(); @@ -195,9 +177,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::era_year_getter) { // 1. Let plainYearMonth be the this value. // 2. Perform ? RequireInternalSlot(plainYearMonth, [[InitializedTemporalYearMonth]]). - auto* plain_year_month = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* plain_year_month = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let calendar be plainYearMonth.[[Calendar]]. auto& calendar = plain_year_month->calendar(); @@ -211,9 +191,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::equals) { // 1. Let yearMonth be the this value. // 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]). - auto* year_month = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* year_month = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Set other to ? ToTemporalYearMonth(other). auto* other = TRY_OR_DISCARD(to_temporal_year_month(global_object, vm.argument(0))); @@ -239,9 +217,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::to_string) { // 1. Let yearMonth be the this value. // 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]). - auto* year_month = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* year_month = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Set options to ? GetOptionsObject(options). auto* options = TRY_OR_DISCARD(get_options_object(global_object, vm.argument(0))); @@ -259,9 +235,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::to_locale_string) { // 1. Let yearMonth be the this value. // 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]). - auto* year_month = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* year_month = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return ? TemporalYearMonthToString(yearMonth, "auto"). return js_string(vm, TRY_OR_DISCARD(temporal_year_month_to_string(global_object, *year_month, "auto"sv))); @@ -272,9 +246,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::to_json) { // 1. Let yearMonth be the this value. // 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]). - auto* year_month = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* year_month = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return ? TemporalYearMonthToString(yearMonth, "auto"). return js_string(vm, TRY_OR_DISCARD(temporal_year_month_to_string(global_object, *year_month, "auto"sv))); @@ -295,9 +267,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::to_plain_date) // 1. Let yearMonth be the this value. // 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]). - auto* year_month = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* year_month = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. If Type(item) is not Object, then if (!item.is_object()) { @@ -353,9 +323,7 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::get_iso_fields) { // 1. Let yearMonth be the this value. // 2. Perform ? RequireInternalSlot(yearMonth, [[InitializedTemporalYearMonth]]). - auto* year_month = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* year_month = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let fields be ! OrdinaryObjectCreate(%Object.prototype%). auto* fields = Object::create(global_object, global_object.object_prototype()); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp index c298ecbe06..c3742afb81 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/TimeZonePrototype.cpp @@ -53,9 +53,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 = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* time_zone = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Set instant to ? ToTemporalInstant(instant). auto* instant = TRY_OR_DISCARD(to_temporal_instant(global_object, vm.argument(0))); @@ -73,9 +71,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 = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* time_zone = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Set instant to ? ToTemporalInstant(instant). auto* instant = TRY_OR_DISCARD(to_temporal_instant(global_object, vm.argument(0))); @@ -106,9 +102,7 @@ JS_DEFINE_NATIVE_FUNCTION(TimeZonePrototype::to_string) { // 1. Let timeZone be the this value. // 2. Perform ? RequireInternalSlot(timeZone, [[InitializedTemporalTimeZone]]). - auto* time_zone = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* time_zone = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return timeZone.[[Identifier]]. return js_string(vm, time_zone->identifier()); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp index d613456109..ca3cd23818 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimePrototype.cpp @@ -78,9 +78,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::calendar_getter) { // 1. Let zonedDateTime be the this value. // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). - auto* zoned_date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return zonedDateTime.[[Calendar]]. return Value(&zoned_date_time->calendar()); @@ -91,9 +89,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 = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return zonedDateTime.[[TimeZone]]. return Value(&zoned_date_time->time_zone()); @@ -104,9 +100,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::year_getter) { // 1. Let zonedDateTime be the this value. // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). - auto* zoned_date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let timeZone be zonedDateTime.[[TimeZone]]. auto& time_zone = zoned_date_time->time_zone(); @@ -129,9 +123,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::month_getter) { // 1. Let zonedDateTime be the this value. // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). - auto* zoned_date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let timeZone be zonedDateTime.[[TimeZone]]. auto& time_zone = zoned_date_time->time_zone(); @@ -154,9 +146,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 = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let timeZone be zonedDateTime.[[TimeZone]]. auto& time_zone = zoned_date_time->time_zone(); @@ -179,9 +169,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::day_getter) { // 1. Let zonedDateTime be the this value. // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). - auto* zoned_date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let timeZone be zonedDateTime.[[TimeZone]]. auto& time_zone = zoned_date_time->time_zone(); @@ -204,9 +192,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::hour_getter) { // 1. Let zonedDateTime be the this value. // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). - auto* zoned_date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let timeZone be zonedDateTime.[[TimeZone]]. auto& time_zone = zoned_date_time->time_zone(); @@ -229,9 +215,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::minute_getter) { // 1. Let zonedDateTime be the this value. // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). - auto* zoned_date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let timeZone be zonedDateTime.[[TimeZone]]. auto& time_zone = zoned_date_time->time_zone(); @@ -254,9 +238,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::second_getter) { // 1. Let zonedDateTime be the this value. // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). - auto* zoned_date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let timeZone be zonedDateTime.[[TimeZone]]. auto& time_zone = zoned_date_time->time_zone(); @@ -279,9 +261,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::millisecond_getter) { // 1. Let zonedDateTime be the this value. // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). - auto* zoned_date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let timeZone be zonedDateTime.[[TimeZone]]. auto& time_zone = zoned_date_time->time_zone(); @@ -304,9 +284,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::microsecond_getter) { // 1. Let zonedDateTime be the this value. // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). - auto* zoned_date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let timeZone be zonedDateTime.[[TimeZone]]. auto& time_zone = zoned_date_time->time_zone(); @@ -329,9 +307,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::nanosecond_getter) { // 1. Let zonedDateTime be the this value. // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). - auto* zoned_date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let timeZone be zonedDateTime.[[TimeZone]]. auto& time_zone = zoned_date_time->time_zone(); @@ -354,9 +330,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 = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let ns be zonedDateTime.[[Nanoseconds]]. auto& ns = zoned_date_time->nanoseconds(); @@ -373,9 +347,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 = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let ns be zonedDateTime.[[Nanoseconds]]. auto& ns = zoned_date_time->nanoseconds(); @@ -392,9 +364,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 = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let ns be zonedDateTime.[[Nanoseconds]]. auto& ns = zoned_date_time->nanoseconds(); @@ -411,9 +381,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 = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return zonedDateTime.[[Nanoseconds]]. return &zoned_date_time->nanoseconds(); @@ -424,9 +392,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 = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let timeZone be zonedDateTime.[[TimeZone]]. auto& time_zone = zoned_date_time->time_zone(); @@ -449,9 +415,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 = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let timeZone be zonedDateTime.[[TimeZone]]. auto& time_zone = zoned_date_time->time_zone(); @@ -474,9 +438,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 = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let timeZone be zonedDateTime.[[TimeZone]]. auto& time_zone = zoned_date_time->time_zone(); @@ -499,9 +461,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 = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let timeZone be zonedDateTime.[[TimeZone]]. auto& time_zone = zoned_date_time->time_zone(); @@ -524,9 +484,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 = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let timeZone be zonedDateTime.[[TimeZone]]. auto& time_zone = zoned_date_time->time_zone(); @@ -549,9 +507,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 = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let timeZone be zonedDateTime.[[TimeZone]]. auto& time_zone = zoned_date_time->time_zone(); @@ -574,9 +530,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 = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let timeZone be zonedDateTime.[[TimeZone]]. auto& time_zone = zoned_date_time->time_zone(); @@ -599,9 +553,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 = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let timeZone be zonedDateTime.[[TimeZone]]. auto& time_zone = zoned_date_time->time_zone(); @@ -624,9 +576,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 = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let timeZone be zonedDateTime.[[TimeZone]]. auto& time_zone = zoned_date_time->time_zone(); @@ -643,9 +593,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::offset_getter) { // 1. Let zonedDateTime be the this value. // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). - auto* zoned_date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let instant be ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]). auto* instant = MUST(create_temporal_instant(global_object, zoned_date_time->nanoseconds())); @@ -660,9 +608,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::era_getter) { // 1. Let zonedDateTime be the this value. // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). - auto* zoned_date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let timeZone be zonedDateTime.[[TimeZone]]. auto& time_zone = zoned_date_time->time_zone(); @@ -685,9 +631,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 = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let timeZone be zonedDateTime.[[TimeZone]]. auto& time_zone = zoned_date_time->time_zone(); @@ -718,9 +662,7 @@ JS_DEFINE_NATIVE_FUNCTION(ZonedDateTimePrototype::to_instant) { // 1. Let zonedDateTime be the this value. // 2. Perform ? RequireInternalSlot(zonedDateTime, [[InitializedTemporalZonedDateTime]]). - auto* zoned_date_time = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Return ! CreateTemporalInstant(zonedDateTime.[[Nanoseconds]]). return MUST(create_temporal_instant(global_object, zoned_date_time->nanoseconds())); @@ -731,9 +673,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 = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let timeZone be zonedDateTime.[[TimeZone]]. auto& time_zone = zoned_date_time->time_zone(); @@ -756,9 +696,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 = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let timeZone be zonedDateTime.[[TimeZone]]. auto& time_zone = zoned_date_time->time_zone(); @@ -781,9 +719,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 = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let timeZone be zonedDateTime.[[TimeZone]]. auto& time_zone = zoned_date_time->time_zone(); @@ -800,9 +736,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 = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let timeZone be zonedDateTime.[[TimeZone]]. auto& time_zone = zoned_date_time->time_zone(); @@ -831,9 +765,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 = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let timeZone be zonedDateTime.[[TimeZone]]. auto& time_zone = zoned_date_time->time_zone(); @@ -862,9 +794,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 = typed_this_object(global_object); - if (vm.exception()) - return {}; + auto* zoned_date_time = TRY_OR_DISCARD(typed_this_object(global_object)); // 3. Let fields be ! OrdinaryObjectCreate(%Object.prototype%). auto* fields = Object::create(global_object, global_object.object_prototype()); |