From 1822b2938e9edffa7337aa2af8c7ecd9d662fd8e Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Thu, 16 Sep 2021 00:59:40 +0300 Subject: LibJS: Convert ZonedDateTime AOs to ThrowCompletionOr --- Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp | 4 ++-- Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp | 2 +- Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp | 4 ++-- Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.h | 2 +- .../Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'Userland') diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp index 7289e78dc2..ed96c10be9 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/InstantPrototype.cpp @@ -553,7 +553,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::to_zoned_date_time) return {}; // 10. Return ? CreateTemporalZonedDateTime(instant.[[Nanoseconds]], timeZone, calendar). - return create_temporal_zoned_date_time(global_object, instant->nanoseconds(), *time_zone, *calendar); + return TRY_OR_DISCARD(create_temporal_zoned_date_time(global_object, instant->nanoseconds(), *time_zone, *calendar)); } // 8.3.18 Temporal.Instant.prototype.toZonedDateTimeISO ( item ), https://tc39.es/proposal-temporal/#sec-temporal.instant.prototype.tozoneddatetimeiso @@ -590,7 +590,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantPrototype::to_zoned_date_time_iso) auto* calendar = get_iso8601_calendar(global_object); // 6. Return ? CreateTemporalZonedDateTime(instant.[[Nanoseconds]], timeZone, calendar). - return create_temporal_zoned_date_time(global_object, instant->nanoseconds(), *time_zone, *calendar); + return TRY_OR_DISCARD(create_temporal_zoned_date_time(global_object, instant->nanoseconds(), *time_zone, *calendar)); } } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp index 664710dab0..3a732631a5 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Now.cpp @@ -254,7 +254,7 @@ ZonedDateTime* system_zoned_date_time(GlobalObject& global_object, Value tempora auto* ns = system_utc_epoch_nanoseconds(global_object); // 5. Return ? CreateTemporalZonedDateTime(ns, timeZone, calendar). - return create_temporal_zoned_date_time(global_object, *ns, *time_zone, *calendar); + return TRY_OR_DISCARD(create_temporal_zoned_date_time(global_object, *ns, *time_zone, *calendar)); } } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp index fed3f02d5d..8714bbf099 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.cpp @@ -31,7 +31,7 @@ void ZonedDateTime::visit_edges(Cell::Visitor& visitor) } // 6.5.3 CreateTemporalZonedDateTime ( epochNanoseconds, timeZone, calendar [ , newTarget ] ), https://tc39.es/proposal-temporal/#sec-temporal-createtemporalzoneddatetime -ZonedDateTime* create_temporal_zoned_date_time(GlobalObject& global_object, BigInt const& epoch_nanoseconds, Object& time_zone, Object& calendar, FunctionObject const* new_target) +ThrowCompletionOr create_temporal_zoned_date_time(GlobalObject& global_object, BigInt const& epoch_nanoseconds, Object& time_zone, Object& calendar, FunctionObject const* new_target) { // 1. Assert: Type(epochNanoseconds) is BigInt. // 3. Assert: Type(timeZone) is Object. @@ -48,7 +48,7 @@ ZonedDateTime* create_temporal_zoned_date_time(GlobalObject& global_object, BigI // 7. Set object.[[Nanoseconds]] to epochNanoseconds. // 8. Set object.[[TimeZone]] to timeZone. // 9. Set object.[[Calendar]] to calendar. - auto* object = TRY_OR_DISCARD(ordinary_create_from_constructor(global_object, *new_target, &GlobalObject::temporal_time_zone_prototype, epoch_nanoseconds, time_zone, calendar)); + auto* object = TRY(ordinary_create_from_constructor(global_object, *new_target, &GlobalObject::temporal_time_zone_prototype, epoch_nanoseconds, time_zone, calendar)); // 10. Return object. return object; diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.h b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.h index 42bcd15a2d..8bd512ad9f 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTime.h @@ -33,6 +33,6 @@ private: Object& m_calendar; // [[Calendar]] }; -ZonedDateTime* create_temporal_zoned_date_time(GlobalObject&, BigInt const& epoch_nanoseconds, Object& time_zone, Object& calendar, FunctionObject const* new_target = nullptr); +ThrowCompletionOr create_temporal_zoned_date_time(GlobalObject&, BigInt const& epoch_nanoseconds, Object& time_zone, Object& calendar, FunctionObject const* new_target = nullptr); } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp index a895d26f00..d9ca18db8a 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/ZonedDateTimeConstructor.cpp @@ -70,7 +70,7 @@ Value ZonedDateTimeConstructor::construct(FunctionObject& new_target) return {}; // 6. Return ? CreateTemporalZonedDateTime(epochNanoseconds, timeZone, calendar, NewTarget). - return create_temporal_zoned_date_time(global_object, *epoch_nanoseconds, *time_zone, *calendar, &new_target); + return TRY_OR_DISCARD(create_temporal_zoned_date_time(global_object, *epoch_nanoseconds, *time_zone, *calendar, &new_target)); } } -- cgit v1.2.3