LibJS: Convert PrototypeObject::typed_this_object() to ThrowCompletionOr

This commit is contained in:
Linus Groh 2021-10-18 20:03:21 +01:00
parent 7c29979e30
commit 4b7c1f703e
Notes: sideshowbarker 2024-07-18 02:10:49 +09:00
26 changed files with 282 additions and 831 deletions

View file

@ -95,9 +95,7 @@ DatePrototype::~DatePrototype()
// 21.4.4.2 Date.prototype.getDate ( ), https://tc39.es/ecma262/#sec-date.prototype.getdate
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_date)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
if (this_object->is_invalid())
return js_nan();
@ -108,9 +106,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_date)
// 21.4.4.20 Date.prototype.setDate ( date ), https://tc39.es/ecma262/#sec-date.prototype.setdate
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_date)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
auto& datetime = this_object->datetime();
@ -134,9 +130,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_date)
// 21.4.4.3 Date.prototype.getDay ( ), https://tc39.es/ecma262/#sec-date.prototype.getday
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_day)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
if (this_object->is_invalid())
return js_nan();
@ -147,9 +141,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_day)
// 21.4.4.4 Date.prototype.getFullYear ( ), https://tc39.es/ecma262/#sec-date.prototype.getfullyear
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_full_year)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
if (this_object->is_invalid())
return js_nan();
@ -160,9 +152,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_full_year)
// 21.4.4.21 Date.prototype.setFullYear ( year [ , month [ , date ] ] ), https://tc39.es/ecma262/#sec-date.prototype.setfullyear
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_full_year)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
auto& datetime = this_object->datetime();
@ -205,9 +195,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_full_year)
// B.2.4.1 Date.prototype.getYear ( ), https://tc39.es/ecma262/#sec-date.prototype.getyear
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_year)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
if (this_object->is_invalid())
return js_nan();
@ -218,9 +206,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_year)
// B.2.4.2 Date.prototype.setYear ( year ), https://tc39.es/ecma262/#sec-date.prototype.setyear
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_year)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
auto& datetime = this_object->datetime();
@ -247,9 +233,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_year)
// 21.4.4.5 Date.prototype.getHours ( ), https://tc39.es/ecma262/#sec-date.prototype.gethours
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_hours)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
if (this_object->is_invalid())
return js_nan();
@ -260,9 +244,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_hours)
// 21.4.4.22 Date.prototype.setHours ( hour [ , min [ , sec [ , ms ] ] ] ), https://tc39.es/ecma262/#sec-date.prototype.sethours
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_hours)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
auto arg_or = [&vm, &global_object](size_t i, i32 fallback) -> ThrowCompletionOr<Value> {
return vm.argument_count() > i ? vm.argument(i).to_number(global_object) : Value(fallback);
@ -314,9 +296,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_hours)
// 21.4.4.23 Date.prototype.setMilliseconds ( ms ), https://tc39.es/ecma262/#sec-date.prototype.setmilliseconds
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_milliseconds)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
if (this_object->is_invalid())
return js_nan();
@ -327,9 +307,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_milliseconds)
// 21.4.4.23 Date.prototype.setMilliseconds ( ms ), https://tc39.es/ecma262/#sec-date.prototype.setmilliseconds
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_milliseconds)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
auto new_milliseconds_value = TRY_OR_DISCARD(vm.argument(0).to_number(global_object));
@ -361,9 +339,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_milliseconds)
// 21.4.4.7 Date.prototype.getMinutes ( ), https://tc39.es/ecma262/#sec-date.prototype.getminutes
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_minutes)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
if (this_object->is_invalid())
return js_nan();
@ -374,9 +350,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_minutes)
// 21.4.4.24 Date.prototype.setMinutes ( min [ , sec [ , ms ] ] ), https://tc39.es/ecma262/#sec-date.prototype.setminutes
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_minutes)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
auto arg_or = [&vm, &global_object](size_t i, i32 fallback) -> ThrowCompletionOr<Value> {
return vm.argument_count() > i ? vm.argument(i).to_number(global_object) : Value(fallback);
@ -421,9 +395,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_minutes)
// 21.4.4.8 Date.prototype.getMonth ( ), https://tc39.es/ecma262/#sec-date.prototype.getmonth
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_month)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
if (this_object->is_invalid())
return js_nan();
@ -434,9 +406,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_month)
// 21.4.4.25 Date.prototype.setMonth ( month [ , date ] ), https://tc39.es/ecma262/#sec-date.prototype.setmonth
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_month)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
auto arg_or = [&vm, &global_object](size_t i, i32 fallback) -> ThrowCompletionOr<Value> {
return vm.argument_count() > i ? vm.argument(i).to_number(global_object) : Value(fallback);
@ -471,9 +441,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_month)
// 21.4.4.9 Date.prototype.getSeconds ( ), https://tc39.es/ecma262/#sec-date.prototype.getseconds
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_seconds)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
if (this_object->is_invalid())
return js_nan();
@ -484,9 +452,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_seconds)
// 21.4.4.26 Date.prototype.setSeconds ( sec [ , ms ] ), https://tc39.es/ecma262/#sec-date.prototype.setseconds
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_seconds)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
auto arg_or = [&vm, &global_object](size_t i, i32 fallback) -> ThrowCompletionOr<Value> {
return vm.argument_count() > i ? vm.argument(i).to_number(global_object) : Value(fallback);
@ -524,9 +490,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_seconds)
// 21.4.4.10 Date.prototype.getTime ( ), https://tc39.es/ecma262/#sec-date.prototype.gettime
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_time)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
if (this_object->is_invalid())
return js_nan();
@ -537,9 +501,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_time)
// 21.4.4.27 Date.prototype.setTime ( time ), https://tc39.es/ecma262/#sec-date.prototype.settime
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_time)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
auto new_time_value = TRY_OR_DISCARD(vm.argument(0).to_number(global_object));
if (!new_time_value.is_finite_number()) {
@ -564,9 +526,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::set_time)
// 21.4.4.11 Date.prototype.getTimezoneOffset ( ), https://tc39.es/ecma262/#sec-date.prototype.gettimezoneoffset
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_timezone_offset)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
if (this_object->is_invalid())
return js_nan();
@ -578,9 +538,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_timezone_offset)
// 21.4.4.12 Date.prototype.getUTCDate ( ), https://tc39.es/ecma262/#sec-date.prototype.getutcdate
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_utc_date)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
if (this_object->is_invalid())
return js_nan();
@ -591,9 +549,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_utc_date)
// 21.4.4.13 Date.prototype.getUTCDay ( ), https://tc39.es/ecma262/#sec-date.prototype.getutcday
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_utc_day)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
if (this_object->is_invalid())
return js_nan();
@ -604,9 +560,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_utc_day)
// 21.4.4.14 Date.prototype.getUTCFullYear ( ), https://tc39.es/ecma262/#sec-date.prototype.getutcfullyear
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_utc_full_year)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
if (this_object->is_invalid())
return js_nan();
@ -617,9 +571,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_utc_full_year)
// 21.4.4.15 Date.prototype.getUTCHours ( ), https://tc39.es/ecma262/#sec-date.prototype.getutchours
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_utc_hours)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
if (this_object->is_invalid())
return js_nan();
@ -630,9 +582,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_utc_hours)
// 21.4.4.16 Date.prototype.getUTCMilliseconds ( ), https://tc39.es/ecma262/#sec-date.prototype.getutcmilliseconds
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_utc_milliseconds)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
if (this_object->is_invalid())
return js_nan();
@ -643,9 +593,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_utc_milliseconds)
// 21.4.4.18 Date.prototype.getUTCMonth ( ), https://tc39.es/ecma262/#sec-date.prototype.getutcmonth
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_utc_month)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
if (this_object->is_invalid())
return js_nan();
@ -656,9 +604,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_utc_month)
// 21.4.4.17 Date.prototype.getUTCMinutes ( ), https://tc39.es/ecma262/#sec-date.prototype.getutcminutes
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_utc_minutes)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
if (this_object->is_invalid())
return js_nan();
@ -669,9 +615,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_utc_minutes)
// 21.4.4.19 Date.prototype.getUTCSeconds ( ), https://tc39.es/ecma262/#sec-date.prototype.getutcseconds
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_utc_seconds)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
if (this_object->is_invalid())
return js_nan();
@ -682,9 +626,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::get_utc_seconds)
// 21.4.4.35 Date.prototype.toDateString ( ), https://tc39.es/ecma262/#sec-date.prototype.todatestring
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_date_string)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
if (this_object->is_invalid())
return js_string(vm, "Invalid Date");
@ -703,9 +645,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_gmt_string)
// 21.4.4.43 Date.prototype.toUTCString ( ), https://tc39.es/ecma262/#sec-date.prototype.toutcstring
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_utc_string)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
if (this_object->is_invalid())
return js_string(vm, "Invalid Date");
@ -718,9 +658,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_utc_string)
// 21.4.4.36 Date.prototype.toISOString ( ), https://tc39.es/ecma262/#sec-date.prototype.toisostring
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_iso_string)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
if (this_object->is_invalid()) {
vm.throw_exception<RangeError>(global_object, ErrorType::InvalidTimeValue);
@ -734,9 +672,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_iso_string)
// 21.4.4.38 Date.prototype.toLocaleDateString ( [ reserved1 [ , reserved2 ] ] ), https://tc39.es/ecma262/#sec-date.prototype.tolocaledatestring
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_locale_date_string)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
if (this_object->is_invalid())
return js_string(vm, "Invalid Date");
@ -749,9 +685,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_locale_date_string)
// 21.4.4.39 Date.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ), https://tc39.es/ecma262/#sec-date.prototype.tolocalestring
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_locale_string)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
if (this_object->is_invalid())
return js_string(vm, "Invalid Date");
@ -764,9 +698,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_locale_string)
// 21.4.4.40 Date.prototype.toLocaleTimeString ( [ reserved1 [ , reserved2 ] ] ), https://tc39.es/ecma262/#sec-date.prototype.tolocaletimestring
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_locale_time_string)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
if (this_object->is_invalid())
return js_string(vm, "Invalid Date");
@ -779,9 +711,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_locale_time_string)
// 21.4.4.42 Date.prototype.toTimeString ( ), https://tc39.es/ecma262/#sec-date.prototype.totimestring
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_time_string)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
if (this_object->is_invalid())
return js_string(vm, "Invalid Date");
@ -793,9 +723,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_time_string)
// 21.4.4.41 Date.prototype.toString ( ), https://tc39.es/ecma262/#sec-date.prototype.tostring
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_string)
{
auto* this_object = typed_this_object(global_object);
if (!this_object)
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
if (this_object->is_invalid())
return js_string(vm, "Invalid Date");
@ -821,9 +749,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_json)
JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_temporal_instant)
{
// 1. Let t be ? thisTimeValue(this value).
auto* this_object = typed_this_object(global_object);
if (vm.exception())
return {};
auto* this_object = TRY_OR_DISCARD(typed_this_object(global_object));
auto t = this_object->value_of();
// 2. Let ns be ? NumberToBigInt(t) × 10^6.

View file

@ -35,9 +35,7 @@ FinalizationRegistryPrototype::~FinalizationRegistryPrototype()
// @STAGE 2@ FinalizationRegistry.prototype.cleanupSome ( [ callback ] ), https://github.com/tc39/proposal-cleanup-some/blob/master/spec/finalization-registry.html
JS_DEFINE_NATIVE_FUNCTION(FinalizationRegistryPrototype::cleanup_some)
{
auto* finalization_registry = typed_this_object(global_object);
if (!finalization_registry)
return {};
auto* finalization_registry = TRY_OR_DISCARD(typed_this_object(global_object));
auto callback = vm.argument(0);
if (vm.argument_count() > 0 && !callback.is_function()) {
@ -53,9 +51,7 @@ JS_DEFINE_NATIVE_FUNCTION(FinalizationRegistryPrototype::cleanup_some)
// 26.2.3.2 FinalizationRegistry.prototype.register ( target, heldValue [ , unregisterToken ] ), https://tc39.es/ecma262/#sec-finalization-registry.prototype.register
JS_DEFINE_NATIVE_FUNCTION(FinalizationRegistryPrototype::register_)
{
auto* finalization_registry = typed_this_object(global_object);
if (!finalization_registry)
return {};
auto* finalization_registry = TRY_OR_DISCARD(typed_this_object(global_object));
auto target = vm.argument(0);
if (!target.is_object()) {
@ -83,9 +79,7 @@ JS_DEFINE_NATIVE_FUNCTION(FinalizationRegistryPrototype::register_)
// 26.2.3.3 FinalizationRegistry.prototype.unregister ( unregisterToken ), https://tc39.es/ecma262/#sec-finalization-registry.prototype.unregister
JS_DEFINE_NATIVE_FUNCTION(FinalizationRegistryPrototype::unregister)
{
auto* finalization_registry = typed_this_object(global_object);
if (!finalization_registry)
return {};
auto* finalization_registry = TRY_OR_DISCARD(typed_this_object(global_object));
auto unregister_token = vm.argument(0);
if (!unregister_token.is_object()) {

View file

@ -35,18 +35,14 @@ GeneratorObjectPrototype::~GeneratorObjectPrototype()
// 27.5.1.2 Generator.prototype.next ( value ), https://tc39.es/ecma262/#sec-generator.prototype.next
JS_DEFINE_NATIVE_FUNCTION(GeneratorObjectPrototype::next)
{
auto generator_object = typed_this_object(global_object);
if (!generator_object)
return {};
auto* generator_object = TRY_OR_DISCARD(typed_this_object(global_object));
return generator_object->next_impl(vm, global_object, {});
}
// 27.5.1.3 Generator.prototype.next ( value ), https://tc39.es/ecma262/#sec-generator.prototype.return
JS_DEFINE_NATIVE_FUNCTION(GeneratorObjectPrototype::return_)
{
auto generator_object = typed_this_object(global_object);
if (!generator_object)
return {};
auto* generator_object = TRY_OR_DISCARD(typed_this_object(global_object));
generator_object->set_done();
return generator_object->next_impl(vm, global_object, {});
}
@ -54,9 +50,7 @@ JS_DEFINE_NATIVE_FUNCTION(GeneratorObjectPrototype::return_)
// 27.5.1.4 Generator.prototype.next ( value ), https://tc39.es/ecma262/#sec-generator.prototype.throw
JS_DEFINE_NATIVE_FUNCTION(GeneratorObjectPrototype::throw_)
{
auto generator_object = typed_this_object(global_object);
if (!generator_object)
return {};
auto* generator_object = TRY_OR_DISCARD(typed_this_object(global_object));
return generator_object->next_impl(vm, global_object, vm.argument(0));
}

View file

@ -39,9 +39,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::of)
// 1. Let displayNames be this value.
// 2. Perform ? RequireInternalSlot(displayNames, [[InitializedDisplayNames]]).
auto* display_names = typed_this_object(global_object);
if (!display_names)
return {};
auto* display_names = TRY_OR_DISCARD(typed_this_object(global_object));
// 3. Let code be ? ToString(code).
auto code_string = TRY_OR_DISCARD(code.to_string(global_object));
@ -87,9 +85,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::resolved_options)
{
// 1. Let displayNames be this value.
// 2. Perform ? RequireInternalSlot(displayNames, [[InitializedDisplayNames]]).
auto* display_names = typed_this_object(global_object);
if (!display_names)
return {};
auto* display_names = TRY_OR_DISCARD(typed_this_object(global_object));
// 3. Let options be ! OrdinaryObjectCreate(%Object.prototype%).
auto* options = Object::create(global_object, global_object.object_prototype());

View file

@ -40,9 +40,7 @@ JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::format)
// 1. Let lf be the this value.
// 2. Perform ? RequireInternalSlot(lf, [[InitializedListFormat]]).
auto* list_format = typed_this_object(global_object);
if (vm.exception())
return {};
auto* list_format = TRY_OR_DISCARD(typed_this_object(global_object));
// 3. Let stringList be ? StringListFromIterable(list).
auto string_list = TRY_OR_DISCARD(string_list_from_iterable(global_object, list));
@ -59,9 +57,7 @@ JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::format_to_parts)
// 1. Let lf be the this value.
// 2. Perform ? RequireInternalSlot(lf, [[InitializedListFormat]]).
auto* list_format = typed_this_object(global_object);
if (vm.exception())
return {};
auto* list_format = TRY_OR_DISCARD(typed_this_object(global_object));
// 3. Let stringList be ? StringListFromIterable(list).
auto string_list = TRY_OR_DISCARD(string_list_from_iterable(global_object, list));
@ -75,9 +71,7 @@ JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::resolved_options)
{
// 1. Let lf be the this value.
// 2. Perform ? RequireInternalSlot(lf, [[InitializedListFormat]]).
auto* list_format = typed_this_object(global_object);
if (vm.exception())
return {};
auto* list_format = TRY_OR_DISCARD(typed_this_object(global_object));
// 3. Let options be ! OrdinaryObjectCreate(%Object.prototype%).
auto* options = Object::create(global_object, global_object.object_prototype());

View file

@ -49,9 +49,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::maximize)
{
// 1. Let loc be the this value.
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
auto* locale_object = typed_this_object(global_object);
if (!locale_object)
return {};
auto* locale_object = TRY_OR_DISCARD(typed_this_object(global_object));
auto locale = Unicode::parse_unicode_locale_id(locale_object->locale());
VERIFY(locale.has_value());
@ -69,9 +67,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::minimize)
{
// 1. Let loc be the this value.
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
auto* locale_object = typed_this_object(global_object);
if (!locale_object)
return {};
auto* locale_object = TRY_OR_DISCARD(typed_this_object(global_object));
auto locale = Unicode::parse_unicode_locale_id(locale_object->locale());
VERIFY(locale.has_value());
@ -89,9 +85,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::to_string)
{
// 1. Let loc be the this value.
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
auto* locale_object = typed_this_object(global_object);
if (!locale_object)
return {};
auto* locale_object = TRY_OR_DISCARD(typed_this_object(global_object));
// 3. Return loc.[[Locale]].
return js_string(vm, locale_object->locale());
@ -102,9 +96,7 @@ JS_DEFINE_NATIVE_GETTER(LocalePrototype::base_name)
{
// 1. Let loc be the this value.
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
auto* locale_object = typed_this_object(global_object);
if (!locale_object)
return {};
auto* locale_object = TRY_OR_DISCARD(typed_this_object(global_object));
// 3. Let locale be loc.[[Locale]].
auto locale = Unicode::parse_unicode_locale_id(locale_object->locale());
@ -126,15 +118,13 @@ JS_DEFINE_NATIVE_GETTER(LocalePrototype::base_name)
// 14.3.9 get Intl.Locale.prototype.collation, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.collation
// 14.3.10 get Intl.Locale.prototype.hourCycle, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.hourCycle
// 14.3.12 get Intl.Locale.prototype.numberingSystem, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.numberingSystem
#define __JS_ENUMERATE(keyword) \
JS_DEFINE_NATIVE_GETTER(LocalePrototype::keyword) \
{ \
auto* locale_object = typed_this_object(global_object); \
if (!locale_object) \
return {}; \
if (!locale_object->has_##keyword()) \
return js_undefined(); \
return js_string(vm, locale_object->keyword()); \
#define __JS_ENUMERATE(keyword) \
JS_DEFINE_NATIVE_GETTER(LocalePrototype::keyword) \
{ \
auto* locale_object = TRY_OR_DISCARD(typed_this_object(global_object)); \
if (!locale_object->has_##keyword()) \
return js_undefined(); \
return js_string(vm, locale_object->keyword()); \
}
JS_ENUMERATE_LOCALE_KEYWORD_PROPERTIES
#undef __JS_ENUMERATE
@ -144,9 +134,7 @@ JS_DEFINE_NATIVE_GETTER(LocalePrototype::numeric)
{
// 1. Let loc be the this value.
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
auto* locale_object = typed_this_object(global_object);
if (!locale_object)
return {};
auto* locale_object = TRY_OR_DISCARD(typed_this_object(global_object));
// 3. Return loc.[[Numeric]].
return Value(locale_object->numeric());
@ -157,9 +145,7 @@ JS_DEFINE_NATIVE_GETTER(LocalePrototype::language)
{
// 1. Let loc be the this value.
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
auto* locale_object = typed_this_object(global_object);
if (!locale_object)
return {};
auto* locale_object = TRY_OR_DISCARD(typed_this_object(global_object));
// 3. Let locale be loc.[[Locale]].
auto locale = Unicode::parse_unicode_locale_id(locale_object->locale());
@ -176,9 +162,7 @@ JS_DEFINE_NATIVE_GETTER(LocalePrototype::script)
{
// 1. Let loc be the this value.
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
auto* locale_object = typed_this_object(global_object);
if (!locale_object)
return {};
auto* locale_object = TRY_OR_DISCARD(typed_this_object(global_object));
// 3. Let locale be loc.[[Locale]].
auto locale = Unicode::parse_unicode_locale_id(locale_object->locale());
@ -199,9 +183,7 @@ JS_DEFINE_NATIVE_GETTER(LocalePrototype::region)
{
// 1. Let loc be the this value.
// 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
auto* locale_object = typed_this_object(global_object);
if (!locale_object)
return {};
auto* locale_object = TRY_OR_DISCARD(typed_this_object(global_object));
// 3. Let locale be loc.[[Locale]].
auto locale = Unicode::parse_unicode_locale_id(locale_object->locale());

View file

@ -37,9 +37,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::resolved_options)
// 2. If the implementation supports the normative optional constructor mode of 4.3 Note 1, then
// a. Set nf to ? UnwrapNumberFormat(nf).
// 3. Perform ? RequireInternalSlot(nf, [[InitializedNumberFormat]]).
auto* number_format = typed_this_object(global_object);
if (vm.exception())
return {};
auto* number_format = TRY_OR_DISCARD(typed_this_object(global_object));
// 4. Let options be ! OrdinaryObjectCreate(%Object.prototype%).
auto* options = Object::create(global_object, global_object.object_prototype());

View file

@ -45,9 +45,7 @@ MapPrototype::~MapPrototype()
// 24.1.3.1 Map.prototype.clear ( ), https://tc39.es/ecma262/#sec-map.prototype.clear
JS_DEFINE_NATIVE_FUNCTION(MapPrototype::clear)
{
auto* map = typed_this_object(global_object);
if (!map)
return {};
auto* map = TRY_OR_DISCARD(typed_this_object(global_object));
map->entries().clear();
return js_undefined();
}
@ -55,18 +53,14 @@ JS_DEFINE_NATIVE_FUNCTION(MapPrototype::clear)
// 24.1.3.3 Map.prototype.delete ( key ), https://tc39.es/ecma262/#sec-map.prototype.delete
JS_DEFINE_NATIVE_FUNCTION(MapPrototype::delete_)
{
auto* map = typed_this_object(global_object);
if (!map)
return {};
auto* map = TRY_OR_DISCARD(typed_this_object(global_object));
return Value(map->entries().remove(vm.argument(0)));
}
// 24.1.3.4 Map.prototype.entries ( ), https://tc39.es/ecma262/#sec-map.prototype.entries
JS_DEFINE_NATIVE_FUNCTION(MapPrototype::entries)
{
auto* map = typed_this_object(global_object);
if (!map)
return {};
auto* map = TRY_OR_DISCARD(typed_this_object(global_object));
return MapIterator::create(global_object, *map, Object::PropertyKind::KeyAndValue);
}
@ -74,9 +68,7 @@ JS_DEFINE_NATIVE_FUNCTION(MapPrototype::entries)
// 24.1.3.5 Map.prototype.forEach ( callbackfn [ , thisArg ] ), https://tc39.es/ecma262/#sec-map.prototype.foreach
JS_DEFINE_NATIVE_FUNCTION(MapPrototype::for_each)
{
auto* map = typed_this_object(global_object);
if (!map)
return {};
auto* map = TRY_OR_DISCARD(typed_this_object(global_object));
if (!vm.argument(0).is_function()) {
vm.throw_exception<TypeError>(global_object, ErrorType::NotAFunction, vm.argument(0).to_string_without_side_effects());
return {};
@ -93,9 +85,7 @@ JS_DEFINE_NATIVE_FUNCTION(MapPrototype::for_each)
// 24.1.3.6 Map.prototype.get ( key ), https://tc39.es/ecma262/#sec-map.prototype.get
JS_DEFINE_NATIVE_FUNCTION(MapPrototype::get)
{
auto* map = typed_this_object(global_object);
if (!map)
return {};
auto* map = TRY_OR_DISCARD(typed_this_object(global_object));
auto result = map->entries().get(vm.argument(0));
if (!result.has_value())
return js_undefined();
@ -105,9 +95,7 @@ JS_DEFINE_NATIVE_FUNCTION(MapPrototype::get)
// 24.1.3.7 Map.prototype.has ( key ), https://tc39.es/ecma262/#sec-map.prototype.has
JS_DEFINE_NATIVE_FUNCTION(MapPrototype::has)
{
auto* map = typed_this_object(global_object);
if (!map)
return {};
auto* map = TRY_OR_DISCARD(typed_this_object(global_object));
auto& entries = map->entries();
return Value(entries.find(vm.argument(0)) != entries.end());
}
@ -115,9 +103,7 @@ JS_DEFINE_NATIVE_FUNCTION(MapPrototype::has)
// 24.1.3.8 Map.prototype.keys ( ), https://tc39.es/ecma262/#sec-map.prototype.keys
JS_DEFINE_NATIVE_FUNCTION(MapPrototype::keys)
{
auto* map = typed_this_object(global_object);
if (!map)
return {};
auto* map = TRY_OR_DISCARD(typed_this_object(global_object));
return MapIterator::create(global_object, *map, Object::PropertyKind::Key);
}
@ -125,9 +111,7 @@ JS_DEFINE_NATIVE_FUNCTION(MapPrototype::keys)
// 24.1.3.9 Map.prototype.set ( key, value ), https://tc39.es/ecma262/#sec-map.prototype.set
JS_DEFINE_NATIVE_FUNCTION(MapPrototype::set)
{
auto* map = typed_this_object(global_object);
if (!map)
return {};
auto* map = TRY_OR_DISCARD(typed_this_object(global_object));
auto key = vm.argument(0);
if (key.is_negative_zero())
key = Value(0);
@ -138,9 +122,7 @@ JS_DEFINE_NATIVE_FUNCTION(MapPrototype::set)
// 24.1.3.11 Map.prototype.values ( ), https://tc39.es/ecma262/#sec-map.prototype.values
JS_DEFINE_NATIVE_FUNCTION(MapPrototype::values)
{
auto* map = typed_this_object(global_object);
if (!map)
return {};
auto* map = TRY_OR_DISCARD(typed_this_object(global_object));
return MapIterator::create(global_object, *map, Object::PropertyKind::Value);
}
@ -148,9 +130,7 @@ JS_DEFINE_NATIVE_FUNCTION(MapPrototype::values)
// 24.1.3.10 get Map.prototype.size, https://tc39.es/ecma262/#sec-get-map.prototype.size
JS_DEFINE_NATIVE_GETTER(MapPrototype::size_getter)
{
auto* map = typed_this_object(global_object);
if (!map)
return {};
auto* map = TRY_OR_DISCARD(typed_this_object(global_object));
return Value(map->entries().size());
}

View file

@ -38,9 +38,7 @@ void PromisePrototype::initialize(GlobalObject& global_object)
// 27.2.5.4 Promise.prototype.then ( onFulfilled, onRejected ), https://tc39.es/ecma262/#sec-promise.prototype.then
JS_DEFINE_NATIVE_FUNCTION(PromisePrototype::then)
{
auto* promise = typed_this_object(global_object);
if (!promise)
return {};
auto* promise = TRY_OR_DISCARD(typed_this_object(global_object));
auto on_fulfilled = vm.argument(0);
auto on_rejected = vm.argument(1);
auto* constructor = TRY_OR_DISCARD(species_constructor(global_object, *promise, *global_object.promise_constructor()));

View file

@ -36,17 +36,12 @@ public:
}
// Use typed_this_object() when the spec coerces |this| value to an object.
static ObjectType* typed_this_object(GlobalObject& global_object)
static ThrowCompletionOr<ObjectType*> typed_this_object(GlobalObject& global_object)
{
auto& vm = global_object.vm();
auto* this_object = TRY_OR_DISCARD(vm.this_value(global_object).to_object(global_object));
if (!is<ObjectType>(this_object)) {
vm.throw_exception<TypeError>(global_object, ErrorType::NotAnObjectOfType, PrototypeType::display_name());
return nullptr;
}
auto* this_object = TRY(vm.this_value(global_object).to_object(global_object));
if (!is<ObjectType>(this_object))
return vm.throw_completion<TypeError>(global_object, ErrorType::NotAnObjectOfType, PrototypeType::display_name());
return static_cast<ObjectType*>(this_object);
}

View file

@ -329,9 +329,7 @@ JS_DEFINE_NATIVE_GETTER(RegExpPrototype::source)
// 22.2.5.2 RegExp.prototype.exec ( string ), https://tc39.es/ecma262/#sec-regexp.prototype.exec
JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::exec)
{
auto* regexp_object = typed_this_object(global_object);
if (!regexp_object)
return {};
auto* regexp_object = TRY_OR_DISCARD(typed_this_object(global_object));
auto string = TRY_OR_DISCARD(vm.argument(0).to_utf16_string(global_object));
@ -674,9 +672,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::symbol_split)
// B.2.4.1 RegExp.prototype.compile ( pattern, flags ), https://tc39.es/ecma262/#sec-regexp.prototype.compile
JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::compile)
{
auto* regexp_object = typed_this_object(global_object);
if (!regexp_object)
return {};
auto* regexp_object = TRY_OR_DISCARD(typed_this_object(global_object));
auto pattern = vm.argument(0);
auto flags = vm.argument(1);

View file

@ -47,9 +47,7 @@ SetPrototype::~SetPrototype()
// 24.2.3.1 Set.prototype.add ( value ), https://tc39.es/ecma262/#sec-set.prototype.add
JS_DEFINE_NATIVE_FUNCTION(SetPrototype::add)
{
auto* set = typed_this_object(global_object);
if (!set)
return {};
auto* set = TRY_OR_DISCARD(typed_this_object(global_object));
auto value = vm.argument(0);
if (value.is_negative_zero())
value = Value(0);
@ -60,9 +58,7 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::add)
// 24.2.3.2 Set.prototype.clear ( ), https://tc39.es/ecma262/#sec-set.prototype.clear
JS_DEFINE_NATIVE_FUNCTION(SetPrototype::clear)
{
auto* set = typed_this_object(global_object);
if (!set)
return {};
auto* set = TRY_OR_DISCARD(typed_this_object(global_object));
set->values().clear();
return js_undefined();
}
@ -70,18 +66,14 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::clear)
// 24.2.3.4 Set.prototype.delete ( value ), https://tc39.es/ecma262/#sec-set.prototype.delete
JS_DEFINE_NATIVE_FUNCTION(SetPrototype::delete_)
{
auto* set = typed_this_object(global_object);
if (!set)
return {};
auto* set = TRY_OR_DISCARD(typed_this_object(global_object));
return Value(set->values().remove(vm.argument(0)));
}
// 24.2.3.5 Set.prototype.entries ( ), https://tc39.es/ecma262/#sec-set.prototype.entries
JS_DEFINE_NATIVE_FUNCTION(SetPrototype::entries)
{
auto* set = typed_this_object(global_object);
if (!set)
return {};
auto* set = TRY_OR_DISCARD(typed_this_object(global_object));
return SetIterator::create(global_object, *set, Object::PropertyKind::KeyAndValue);
}
@ -89,9 +81,7 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::entries)
// 24.2.3.6 Set.prototype.forEach ( callbackfn [ , thisArg ] ), https://tc39.es/ecma262/#sec-set.prototype.foreach
JS_DEFINE_NATIVE_FUNCTION(SetPrototype::for_each)
{
auto* set = typed_this_object(global_object);
if (!set)
return {};
auto* set = TRY_OR_DISCARD(typed_this_object(global_object));
if (!vm.argument(0).is_function()) {
vm.throw_exception<TypeError>(global_object, ErrorType::NotAFunction, vm.argument(0).to_string_without_side_effects());
return {};
@ -108,9 +98,7 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::for_each)
// 24.2.3.7 Set.prototype.has ( value ), https://tc39.es/ecma262/#sec-set.prototype.has
JS_DEFINE_NATIVE_FUNCTION(SetPrototype::has)
{
auto* set = typed_this_object(global_object);
if (!set)
return {};
auto* set = TRY_OR_DISCARD(typed_this_object(global_object));
auto& values = set->values();
return Value(values.find(vm.argument(0)) != values.end());
}
@ -118,9 +106,7 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::has)
// 24.2.3.10 Set.prototype.values ( ), https://tc39.es/ecma262/#sec-set.prototype.values
JS_DEFINE_NATIVE_FUNCTION(SetPrototype::values)
{
auto* set = typed_this_object(global_object);
if (!set)
return {};
auto* set = TRY_OR_DISCARD(typed_this_object(global_object));
return SetIterator::create(global_object, *set, Object::PropertyKind::Value);
}
@ -128,9 +114,7 @@ JS_DEFINE_NATIVE_FUNCTION(SetPrototype::values)
// 24.2.3.9 get Set.prototype.size, https://tc39.es/ecma262/#sec-get-set.prototype.size
JS_DEFINE_NATIVE_GETTER(SetPrototype::size_getter)
{
auto* set = typed_this_object(global_object);
if (!set)
return {};
auto* set = TRY_OR_DISCARD(typed_this_object(global_object));
return Value(set->values().size());
}

View file

@ -36,9 +36,7 @@ JS_DEFINE_NATIVE_FUNCTION(ShadowRealmPrototype::evaluate)
// 1. Let O be this value.
// 2. Perform ? ValidateShadowRealmObject(O).
auto* object = typed_this_object(global_object);
if (vm.exception())
return {};
auto* object = TRY_OR_DISCARD(typed_this_object(global_object));
// 3. If Type(sourceText) is not String, throw a TypeError exception.
if (!source_text.is_string()) {
@ -64,9 +62,7 @@ JS_DEFINE_NATIVE_FUNCTION(ShadowRealmPrototype::import_value)
// 1. Let O be this value.
// 2. Perform ? ValidateShadowRealmObject(O).
auto* object = typed_this_object(global_object);
if (vm.exception())
return {};
auto* object = TRY_OR_DISCARD(typed_this_object(global_object));
// 3. Let specifierString be ? ToString(specifier).
auto specifier_string = TRY_OR_DISCARD(specifier.to_string(global_object));

View file

@ -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()))) {

View file

@ -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())));

View file

@ -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()) {

View file

@ -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)));

View file

@ -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());

View file

@ -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());

View file

@ -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);

View file

@ -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());

View file

@ -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());

View file

@ -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());

View file

@ -37,9 +37,7 @@ WeakMapPrototype::~WeakMapPrototype()
// 24.3.3.2 WeakMap.prototype.delete ( key ), https://tc39.es/ecma262/#sec-weakmap.prototype.delete
JS_DEFINE_NATIVE_FUNCTION(WeakMapPrototype::delete_)
{
auto* weak_map = typed_this_object(global_object);
if (!weak_map)
return {};
auto* weak_map = TRY_OR_DISCARD(typed_this_object(global_object));
auto value = vm.argument(0);
if (!value.is_object())
return Value(false);
@ -49,9 +47,7 @@ JS_DEFINE_NATIVE_FUNCTION(WeakMapPrototype::delete_)
// 24.3.3.3 WeakMap.prototype.get ( key ), https://tc39.es/ecma262/#sec-weakmap.prototype.get
JS_DEFINE_NATIVE_FUNCTION(WeakMapPrototype::get)
{
auto* weak_map = typed_this_object(global_object);
if (!weak_map)
return {};
auto* weak_map = TRY_OR_DISCARD(typed_this_object(global_object));
auto value = vm.argument(0);
if (!value.is_object())
return js_undefined();
@ -65,9 +61,7 @@ JS_DEFINE_NATIVE_FUNCTION(WeakMapPrototype::get)
// 24.3.3.4 WeakMap.prototype.has ( key ), https://tc39.es/ecma262/#sec-weakmap.prototype.has
JS_DEFINE_NATIVE_FUNCTION(WeakMapPrototype::has)
{
auto* weak_map = typed_this_object(global_object);
if (!weak_map)
return {};
auto* weak_map = TRY_OR_DISCARD(typed_this_object(global_object));
auto value = vm.argument(0);
if (!value.is_object())
return Value(false);
@ -78,9 +72,7 @@ JS_DEFINE_NATIVE_FUNCTION(WeakMapPrototype::has)
// 24.3.3.5 WeakMap.prototype.set ( key, value ), https://tc39.es/ecma262/#sec-weakmap.prototype.set
JS_DEFINE_NATIVE_FUNCTION(WeakMapPrototype::set)
{
auto* weak_map = typed_this_object(global_object);
if (!weak_map)
return {};
auto* weak_map = TRY_OR_DISCARD(typed_this_object(global_object));
auto value = vm.argument(0);
if (!value.is_object()) {
vm.throw_exception<TypeError>(global_object, ErrorType::NotAnObject, value.to_string_without_side_effects());

View file

@ -31,9 +31,7 @@ WeakRefPrototype::~WeakRefPrototype()
// 26.1.3.2 WeakRef.prototype.deref ( ), https://tc39.es/ecma262/#sec-weak-ref.prototype.deref
JS_DEFINE_NATIVE_FUNCTION(WeakRefPrototype::deref)
{
auto* weak_ref = typed_this_object(global_object);
if (vm.exception())
return {};
auto* weak_ref = TRY_OR_DISCARD(typed_this_object(global_object));
weak_ref->update_execution_generation();
return weak_ref->value() ?: js_undefined();

View file

@ -36,9 +36,7 @@ WeakSetPrototype::~WeakSetPrototype()
// 24.4.3.1 WeakSet.prototype.add ( value ), https://tc39.es/ecma262/#sec-weakset.prototype.add
JS_DEFINE_NATIVE_FUNCTION(WeakSetPrototype::add)
{
auto* weak_set = typed_this_object(global_object);
if (!weak_set)
return {};
auto* weak_set = TRY_OR_DISCARD(typed_this_object(global_object));
auto value = vm.argument(0);
if (!value.is_object()) {
vm.throw_exception<TypeError>(global_object, ErrorType::NotAnObject, value.to_string_without_side_effects());
@ -51,9 +49,7 @@ JS_DEFINE_NATIVE_FUNCTION(WeakSetPrototype::add)
// 24.4.3.3 WeakSet.prototype.delete ( value ), https://tc39.es/ecma262/#sec-weakset.prototype.delete
JS_DEFINE_NATIVE_FUNCTION(WeakSetPrototype::delete_)
{
auto* weak_set = typed_this_object(global_object);
if (!weak_set)
return {};
auto* weak_set = TRY_OR_DISCARD(typed_this_object(global_object));
auto value = vm.argument(0);
if (!value.is_object())
return Value(false);
@ -63,9 +59,7 @@ JS_DEFINE_NATIVE_FUNCTION(WeakSetPrototype::delete_)
// 24.4.3.4 WeakSet.prototype.has ( value ), https://tc39.es/ecma262/#sec-weakset.prototype.has
JS_DEFINE_NATIVE_FUNCTION(WeakSetPrototype::has)
{
auto* weak_set = typed_this_object(global_object);
if (!weak_set)
return {};
auto* weak_set = TRY_OR_DISCARD(typed_this_object(global_object));
auto value = vm.argument(0);
if (!value.is_object())
return Value(false);