diff options
4 files changed, 89 insertions, 93 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp index 2323b8473b..ee346afc32 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.cpp @@ -28,8 +28,8 @@ void PlainTimeConstructor::initialize(GlobalObject& global_object) define_direct_property(vm.names.prototype, global_object.temporal_plain_time_prototype(), 0); u8 attr = Attribute::Writable | Attribute::Configurable; - define_old_native_function(vm.names.from, from, 1, attr); - define_old_native_function(vm.names.compare, compare, 2, attr); + define_native_function(vm.names.from, from, 1, attr); + define_native_function(vm.names.compare, compare, 2, attr); define_direct_property(vm.names.length, Value(0), Attribute::Configurable); } @@ -79,13 +79,13 @@ ThrowCompletionOr<Object*> PlainTimeConstructor::construct(FunctionObject& new_t } // 4.2.2 Temporal.PlainTime.from ( item [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.from -JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimeConstructor::from) +JS_DEFINE_NATIVE_FUNCTION(PlainTimeConstructor::from) { // 1. Set options to ? GetOptionsObject(options). - auto* options = TRY_OR_DISCARD(get_options_object(global_object, vm.argument(1))); + auto* options = TRY(get_options_object(global_object, vm.argument(1))); // 2. Let overflow be ? ToTemporalOverflow(options). - auto overflow = TRY_OR_DISCARD(to_temporal_overflow(global_object, *options)); + auto overflow = TRY(to_temporal_overflow(global_object, *options)); auto item = vm.argument(0); @@ -93,21 +93,21 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimeConstructor::from) if (item.is_object() && is<PlainTime>(item.as_object())) { auto& plain_time = static_cast<PlainTime&>(item.as_object()); // a. Return ? CreateTemporalTime(item.[[ISOHour]], item.[[ISOMinute]], item.[[ISOSecond]], item.[[ISOMillisecond]], item.[[ISOMicrosecond]], item.[[ISONanosecond]]). - return TRY_OR_DISCARD(create_temporal_time(global_object, plain_time.iso_hour(), plain_time.iso_minute(), plain_time.iso_second(), plain_time.iso_millisecond(), plain_time.iso_microsecond(), plain_time.iso_nanosecond())); + return TRY(create_temporal_time(global_object, plain_time.iso_hour(), plain_time.iso_minute(), plain_time.iso_second(), plain_time.iso_millisecond(), plain_time.iso_microsecond(), plain_time.iso_nanosecond())); } // 4. Return ? ToTemporalTime(item, overflow). - return TRY_OR_DISCARD(to_temporal_time(global_object, item, overflow)); + return TRY(to_temporal_time(global_object, item, overflow)); } // 4.2.3 Temporal.PlainTime.compare ( one, two ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.compare -JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimeConstructor::compare) +JS_DEFINE_NATIVE_FUNCTION(PlainTimeConstructor::compare) { // 1. Set one to ? ToTemporalTime(one). - auto* one = TRY_OR_DISCARD(to_temporal_time(global_object, vm.argument(0))); + auto* one = TRY(to_temporal_time(global_object, vm.argument(0))); // 2. Set two to ? ToTemporalTime(two). - auto* two = TRY_OR_DISCARD(to_temporal_time(global_object, vm.argument(1))); + auto* two = TRY(to_temporal_time(global_object, vm.argument(1))); // 3. Return 𝔽(! CompareTemporalTime(one.[[ISOHour]], one.[[ISOMinute]], one.[[ISOSecond]], one.[[ISOMillisecond]], one.[[ISOMicrosecond]], one.[[ISONanosecond]], two.[[ISOHour]], two.[[ISOMinute]], two.[[ISOSecond]], two.[[ISOMillisecond]], two.[[ISOMicrosecond]], two.[[ISONanosecond]])). return Value(compare_temporal_time(one->iso_hour(), one->iso_minute(), one->iso_second(), one->iso_millisecond(), one->iso_microsecond(), one->iso_nanosecond(), two->iso_hour(), two->iso_minute(), two->iso_second(), two->iso_millisecond(), two->iso_microsecond(), two->iso_nanosecond())); diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.h index ea92684a50..d3b13730e4 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimeConstructor.h @@ -24,8 +24,8 @@ public: private: virtual bool has_constructor() const override { return true; } - JS_DECLARE_OLD_NATIVE_FUNCTION(from); - JS_DECLARE_OLD_NATIVE_FUNCTION(compare); + JS_DECLARE_NATIVE_FUNCTION(from); + JS_DECLARE_NATIVE_FUNCTION(compare); }; } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp index 2ee828e917..cdb96ff86b 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.cpp @@ -29,151 +29,148 @@ void PlainTimePrototype::initialize(GlobalObject& global_object) // 4.3.2 Temporal.PlainTime.prototype[ @@toStringTag ], https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype-@@tostringtag define_direct_property(*vm.well_known_symbol_to_string_tag(), js_string(vm, "Temporal.PlainTime"), Attribute::Configurable); - define_old_native_accessor(vm.names.calendar, calendar_getter, {}, Attribute::Configurable); - define_old_native_accessor(vm.names.hour, hour_getter, {}, Attribute::Configurable); - define_old_native_accessor(vm.names.minute, minute_getter, {}, Attribute::Configurable); - define_old_native_accessor(vm.names.second, second_getter, {}, Attribute::Configurable); - define_old_native_accessor(vm.names.millisecond, millisecond_getter, {}, Attribute::Configurable); - define_old_native_accessor(vm.names.microsecond, microsecond_getter, {}, Attribute::Configurable); - define_old_native_accessor(vm.names.nanosecond, nanosecond_getter, {}, Attribute::Configurable); + define_native_accessor(vm.names.calendar, calendar_getter, {}, Attribute::Configurable); + define_native_accessor(vm.names.hour, hour_getter, {}, Attribute::Configurable); + define_native_accessor(vm.names.minute, minute_getter, {}, Attribute::Configurable); + define_native_accessor(vm.names.second, second_getter, {}, Attribute::Configurable); + define_native_accessor(vm.names.millisecond, millisecond_getter, {}, Attribute::Configurable); + define_native_accessor(vm.names.microsecond, microsecond_getter, {}, Attribute::Configurable); + define_native_accessor(vm.names.nanosecond, nanosecond_getter, {}, Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; - define_old_native_function(vm.names.with, with, 1, attr); - define_old_native_function(vm.names.equals, equals, 1, attr); - define_old_native_function(vm.names.toPlainDateTime, to_plain_date_time, 1, attr); - define_old_native_function(vm.names.getISOFields, get_iso_fields, 0, attr); - define_old_native_function(vm.names.toString, to_string, 0, attr); - define_old_native_function(vm.names.toLocaleString, to_locale_string, 0, attr); - define_old_native_function(vm.names.toJSON, to_json, 0, attr); - define_old_native_function(vm.names.valueOf, value_of, 0, attr); + define_native_function(vm.names.with, with, 1, attr); + define_native_function(vm.names.equals, equals, 1, attr); + define_native_function(vm.names.toPlainDateTime, to_plain_date_time, 1, attr); + define_native_function(vm.names.getISOFields, get_iso_fields, 0, attr); + define_native_function(vm.names.toString, to_string, 0, attr); + define_native_function(vm.names.toLocaleString, to_locale_string, 0, attr); + define_native_function(vm.names.toJSON, to_json, 0, attr); + define_native_function(vm.names.valueOf, value_of, 0, attr); } // 4.3.3 get Temporal.PlainTime.prototype.calendar, https://tc39.es/proposal-temporal/#sec-get-temporal.plaintime.prototype.calendar -JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::calendar_getter) +JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::calendar_getter) { // 1. Let temporalTime be the this value. // 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]). - auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object)); + auto* temporal_time = TRY(typed_this_object(global_object)); // 3. Return temporalTime.[[Calendar]]. return Value(&temporal_time->calendar()); } // 4.3.4 get Temporal.PlainTime.prototype.hour, https://tc39.es/proposal-temporal/#sec-get-temporal.plaintime.prototype.hour -JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::hour_getter) +JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::hour_getter) { // 1. Let temporalTime be the this value. // 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]). - auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object)); + auto* temporal_time = TRY(typed_this_object(global_object)); // 3. Return 𝔽(temporalTime.[[ISOHour]]). return Value(temporal_time->iso_hour()); } // 4.3.5 get Temporal.PlainTime.prototype.minute, https://tc39.es/proposal-temporal/#sec-get-temporal.plaintime.prototype.minute -JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::minute_getter) +JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::minute_getter) { // 1. Let temporalTime be the this value. // 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]). - auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object)); + auto* temporal_time = TRY(typed_this_object(global_object)); // 3. Return 𝔽(temporalTime.[[ISOMinute]]). return Value(temporal_time->iso_minute()); } // 4.3.6 get Temporal.PlainTime.prototype.second, https://tc39.es/proposal-temporal/#sec-get-temporal.plaintime.prototype.second -JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::second_getter) +JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::second_getter) { // 1. Let temporalTime be the this value. // 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]). - auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object)); + auto* temporal_time = TRY(typed_this_object(global_object)); // 3. Return 𝔽(temporalTime.[[ISOSecond]]). return Value(temporal_time->iso_second()); } // 4.3.7 get Temporal.PlainTime.prototype.millisecond, https://tc39.es/proposal-temporal/#sec-get-temporal.plaintime.prototype.millisecond -JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::millisecond_getter) +JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::millisecond_getter) { // 1. Let temporalTime be the this value. // 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]). - auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object)); + auto* temporal_time = TRY(typed_this_object(global_object)); // 3. Return 𝔽(temporalTime.[[ISOMillisecond]]). return Value(temporal_time->iso_millisecond()); } // 4.3.8 get Temporal.PlainTime.prototype.microsecond, https://tc39.es/proposal-temporal/#sec-get-temporal.plaintime.prototype.microsecond -JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::microsecond_getter) +JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::microsecond_getter) { // 1. Let temporalTime be the this value. // 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]). - auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object)); + auto* temporal_time = TRY(typed_this_object(global_object)); // 3. Return 𝔽(temporalTime.[[ISOMicrosecond]]). return Value(temporal_time->iso_microsecond()); } // 4.3.9 get Temporal.PlainTime.prototype.nanosecond, https://tc39.es/proposal-temporal/#sec-get-temporal.plaintime.prototype.nanosecond -JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::nanosecond_getter) +JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::nanosecond_getter) { // 1. Let temporalTime be the this value. // 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]). - auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object)); + auto* temporal_time = TRY(typed_this_object(global_object)); // 3. Return 𝔽(temporalTime.[[ISONanosecond]]). return Value(temporal_time->iso_nanosecond()); } // 4.3.12 Temporal.PlainTime.prototype.with ( temporalTimeLike [ , options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.with -JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::with) +JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::with) { // 1. Let temporalTime be the this value. // 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]). - auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object)); + auto* temporal_time = TRY(typed_this_object(global_object)); auto temporal_time_like_argument = vm.argument(0); // 3. If Type(temporalTimeLike) is not Object, then if (!temporal_time_like_argument.is_object()) { // a. Throw a TypeError exception. - vm.throw_exception<TypeError>(global_object, ErrorType::NotAnObject, temporal_time_like_argument.to_string_without_side_effects()); - return {}; + return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObject, temporal_time_like_argument.to_string_without_side_effects()); } auto& temporal_time_like = temporal_time_like_argument.as_object(); // 4. Perform ? RejectTemporalCalendarType(temporalTimeLike). - TRY_OR_DISCARD(reject_temporal_calendar_type(global_object, temporal_time_like)); + TRY(reject_temporal_calendar_type(global_object, temporal_time_like)); // 5. Let calendarProperty be ? Get(temporalTimeLike, "calendar"). - auto calendar_property = TRY_OR_DISCARD(temporal_time_like.get(vm.names.calendar)); + auto calendar_property = TRY(temporal_time_like.get(vm.names.calendar)); // 6. If calendarProperty is not undefined, then if (!calendar_property.is_undefined()) { // a. Throw a TypeError exception. - vm.throw_exception<TypeError>(global_object, ErrorType::TemporalPlainTimeWithArgumentMustNotHave, "calendar"); - return {}; + return vm.throw_completion<TypeError>(global_object, ErrorType::TemporalPlainTimeWithArgumentMustNotHave, "calendar"); } // 7. Let timeZoneProperty be ? Get(temporalTimeLike, "timeZone"). - auto time_zone_property = TRY_OR_DISCARD(temporal_time_like.get(vm.names.timeZone)); + auto time_zone_property = TRY(temporal_time_like.get(vm.names.timeZone)); // 8. If timeZoneProperty is not undefined, then if (!time_zone_property.is_undefined()) { // a. Throw a TypeError exception. - vm.throw_exception<TypeError>(global_object, ErrorType::TemporalPlainTimeWithArgumentMustNotHave, "timeZone"); - return {}; + return vm.throw_completion<TypeError>(global_object, ErrorType::TemporalPlainTimeWithArgumentMustNotHave, "timeZone"); } // 9. Let partialTime be ? ToPartialTime(temporalTimeLike). - auto partial_time = TRY_OR_DISCARD(to_partial_time(global_object, temporal_time_like)); + auto partial_time = TRY(to_partial_time(global_object, temporal_time_like)); // 10. Set options to ? GetOptionsObject(options). - auto* options = TRY_OR_DISCARD(get_options_object(global_object, vm.argument(1))); + auto* options = TRY(get_options_object(global_object, vm.argument(1))); // 11. Let overflow be ? ToTemporalOverflow(options). - auto overflow = TRY_OR_DISCARD(to_temporal_overflow(global_object, *options)); + auto overflow = TRY(to_temporal_overflow(global_object, *options)); // 12. If partialTime.[[Hour]] is not undefined, then // a. Let hour be partialTime.[[Hour]]. @@ -212,21 +209,21 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::with) auto nanosecond = partial_time.nanosecond.value_or(temporal_time->iso_nanosecond()); // 24. Let result be ? RegulateTime(hour, minute, second, millisecond, microsecond, nanosecond, overflow). - auto result = TRY_OR_DISCARD(regulate_time(global_object, hour, minute, second, millisecond, microsecond, nanosecond, overflow)); + auto result = TRY(regulate_time(global_object, hour, minute, second, millisecond, microsecond, nanosecond, overflow)); // 25. Return ? CreateTemporalTime(result.[[Hour]], result.[[Minute]], result.[[Second]], result.[[Millisecond]], result.[[Microsecond]], result.[[Nanosecond]]). - return TRY_OR_DISCARD(create_temporal_time(global_object, result.hour, result.minute, result.second, result.millisecond, result.microsecond, result.nanosecond)); + return TRY(create_temporal_time(global_object, result.hour, result.minute, result.second, result.millisecond, result.microsecond, result.nanosecond)); } // 4.3.16 Temporal.PlainTime.prototype.equals ( other ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.equals -JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::equals) +JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::equals) { // 1. Let temporalTime be the this value. // 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]). - auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object)); + auto* temporal_time = TRY(typed_this_object(global_object)); // 3. Set other to ? ToTemporalTime(other). - auto* other = TRY_OR_DISCARD(to_temporal_time(global_object, vm.argument(0))); + auto* other = TRY(to_temporal_time(global_object, vm.argument(0))); // 4. If temporalTime.[[ISOHour]] ≠ other.[[ISOHour]], return false. if (temporal_time->iso_hour() != other->iso_hour()) @@ -257,25 +254,25 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::equals) } // 4.3.17 Temporal.PlainTime.prototype.toPlainDateTime ( temporalDate ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.toplaindatetime -JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::to_plain_date_time) +JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::to_plain_date_time) { // 1. Let temporalTime be the this value. // 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]). - auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object)); + auto* temporal_time = TRY(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))); + auto* temporal_date = TRY(to_temporal_date(global_object, vm.argument(0))); // 4. Return ? CreateTemporalDateTime(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]], temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], temporalDate.[[Calendar]]). - return TRY_OR_DISCARD(create_temporal_date_time(global_object, temporal_date->iso_year(), temporal_date->iso_month(), temporal_date->iso_day(), temporal_time->iso_hour(), temporal_time->iso_minute(), temporal_time->iso_second(), temporal_time->iso_millisecond(), temporal_time->iso_microsecond(), temporal_time->iso_nanosecond(), temporal_date->calendar())); + return TRY(create_temporal_date_time(global_object, temporal_date->iso_year(), temporal_date->iso_month(), temporal_date->iso_day(), temporal_time->iso_hour(), temporal_time->iso_minute(), temporal_time->iso_second(), temporal_time->iso_millisecond(), temporal_time->iso_microsecond(), temporal_time->iso_nanosecond(), temporal_date->calendar())); } // 4.3.19 Temporal.PlainTime.prototype.getISOFields ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.getisofields -JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::get_iso_fields) +JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::get_iso_fields) { // 1. Let temporalTime be the this value. // 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]). - auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object)); + auto* temporal_time = TRY(typed_this_object(global_object)); // 3. Let fields be ! OrdinaryObjectCreate(%Object.prototype%). auto* fields = Object::create(global_object, global_object.object_prototype()); @@ -306,20 +303,20 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::get_iso_fields) } // 4.3.20 Temporal.PlainTime.prototype.toString ( [ options ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.tostring -JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::to_string) +JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::to_string) { // 1. Let temporalTime be the this value. // 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]). - auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object)); + auto* temporal_time = TRY(typed_this_object(global_object)); // 3. Set options to ? GetOptionsObject(options). - auto* options = TRY_OR_DISCARD(get_options_object(global_object, vm.argument(0))); + auto* options = TRY(get_options_object(global_object, vm.argument(0))); // 4. Let precision be ? ToSecondsStringPrecision(options). - auto precision = TRY_OR_DISCARD(to_seconds_string_precision(global_object, *options)); + auto precision = TRY(to_seconds_string_precision(global_object, *options)); // 5. Let roundingMode be ? ToTemporalRoundingMode(options, "trunc"). - auto rounding_mode = TRY_OR_DISCARD(to_temporal_rounding_mode(global_object, *options, "trunc"sv)); + auto rounding_mode = TRY(to_temporal_rounding_mode(global_object, *options, "trunc"sv)); // 6. Let roundResult be ! RoundTime(temporalTime.[[ISOHour]], temporalTime.[[ISOMinute]], temporalTime.[[ISOSecond]], temporalTime.[[ISOMillisecond]], temporalTime.[[ISOMicrosecond]], temporalTime.[[ISONanosecond]], precision.[[Increment]], precision.[[Unit]], roundingMode). auto round_result = round_time(temporal_time->iso_hour(), temporal_time->iso_minute(), temporal_time->iso_second(), temporal_time->iso_millisecond(), temporal_time->iso_microsecond(), temporal_time->iso_nanosecond(), precision.increment, precision.unit, rounding_mode); @@ -330,11 +327,11 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::to_string) } // 4.3.21 Temporal.PlainTime.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.tolocalestring -JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::to_locale_string) +JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::to_locale_string) { // 1. Let temporalTime be the this value. // 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]). - auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object)); + auto* temporal_time = TRY(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); @@ -342,11 +339,11 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::to_locale_string) } // 4.3.22 Temporal.PlainTime.prototype.toJSON ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.tojson -JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::to_json) +JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::to_json) { // 1. Let temporalTime be the this value. // 2. Perform ? RequireInternalSlot(temporalTime, [[InitializedTemporalTime]]). - auto* temporal_time = TRY_OR_DISCARD(typed_this_object(global_object)); + auto* temporal_time = TRY(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); @@ -354,11 +351,10 @@ JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::to_json) } // 4.3.23 Temporal.PlainTime.prototype.valueOf ( ), https://tc39.es/proposal-temporal/#sec-temporal.plaintime.prototype.valueof -JS_DEFINE_OLD_NATIVE_FUNCTION(PlainTimePrototype::value_of) +JS_DEFINE_NATIVE_FUNCTION(PlainTimePrototype::value_of) { // 1. Throw a TypeError exception. - vm.throw_exception<TypeError>(global_object, ErrorType::Convert, "Temporal.PlainTime", "a primitive value"); - return {}; + return vm.throw_completion<TypeError>(global_object, ErrorType::Convert, "Temporal.PlainTime", "a primitive value"); } } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.h b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.h index 60a5e7e377..b732aff2e0 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainTimePrototype.h @@ -20,21 +20,21 @@ public: virtual ~PlainTimePrototype() override = default; private: - JS_DECLARE_OLD_NATIVE_FUNCTION(calendar_getter); - JS_DECLARE_OLD_NATIVE_FUNCTION(hour_getter); - JS_DECLARE_OLD_NATIVE_FUNCTION(minute_getter); - JS_DECLARE_OLD_NATIVE_FUNCTION(second_getter); - JS_DECLARE_OLD_NATIVE_FUNCTION(millisecond_getter); - JS_DECLARE_OLD_NATIVE_FUNCTION(microsecond_getter); - JS_DECLARE_OLD_NATIVE_FUNCTION(nanosecond_getter); - JS_DECLARE_OLD_NATIVE_FUNCTION(with); - JS_DECLARE_OLD_NATIVE_FUNCTION(equals); - JS_DECLARE_OLD_NATIVE_FUNCTION(to_plain_date_time); - JS_DECLARE_OLD_NATIVE_FUNCTION(get_iso_fields); - JS_DECLARE_OLD_NATIVE_FUNCTION(to_string); - JS_DECLARE_OLD_NATIVE_FUNCTION(to_locale_string); - JS_DECLARE_OLD_NATIVE_FUNCTION(to_json); - JS_DECLARE_OLD_NATIVE_FUNCTION(value_of); + JS_DECLARE_NATIVE_FUNCTION(calendar_getter); + JS_DECLARE_NATIVE_FUNCTION(hour_getter); + JS_DECLARE_NATIVE_FUNCTION(minute_getter); + JS_DECLARE_NATIVE_FUNCTION(second_getter); + JS_DECLARE_NATIVE_FUNCTION(millisecond_getter); + JS_DECLARE_NATIVE_FUNCTION(microsecond_getter); + JS_DECLARE_NATIVE_FUNCTION(nanosecond_getter); + JS_DECLARE_NATIVE_FUNCTION(with); + JS_DECLARE_NATIVE_FUNCTION(equals); + JS_DECLARE_NATIVE_FUNCTION(to_plain_date_time); + JS_DECLARE_NATIVE_FUNCTION(get_iso_fields); + JS_DECLARE_NATIVE_FUNCTION(to_string); + JS_DECLARE_NATIVE_FUNCTION(to_locale_string); + JS_DECLARE_NATIVE_FUNCTION(to_json); + JS_DECLARE_NATIVE_FUNCTION(value_of); }; } |