mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:57:35 +00:00
LibJS: Replace GlobalObject with VM in Temporal AOs [Part 2/19]
This commit is contained in:
parent
f9705eb2f4
commit
694f66b5ca
58 changed files with 1564 additions and 1600 deletions
|
@ -62,7 +62,7 @@ ThrowCompletionOr<Object*> InstantConstructor::construct(FunctionObject& new_tar
|
|||
return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidEpochNanoseconds);
|
||||
|
||||
// 4. Return ? CreateTemporalInstant(epochNanoseconds, NewTarget).
|
||||
return TRY(create_temporal_instant(global_object, *epoch_nanoseconds, &new_target));
|
||||
return TRY(create_temporal_instant(vm, *epoch_nanoseconds, &new_target));
|
||||
}
|
||||
|
||||
// 8.2.2 Temporal.Instant.from ( item ), https://tc39.es/proposal-temporal/#sec-temporal.instant.from
|
||||
|
@ -73,11 +73,11 @@ JS_DEFINE_NATIVE_FUNCTION(InstantConstructor::from)
|
|||
// 1. If Type(item) is Object and item has an [[InitializedTemporalInstant]] internal slot, then
|
||||
if (item.is_object() && is<Instant>(item.as_object())) {
|
||||
// a. Return ! CreateTemporalInstant(item.[[Nanoseconds]]).
|
||||
return MUST(create_temporal_instant(global_object, *js_bigint(vm, static_cast<Instant&>(item.as_object()).nanoseconds().big_integer())));
|
||||
return MUST(create_temporal_instant(vm, *js_bigint(vm, static_cast<Instant&>(item.as_object()).nanoseconds().big_integer())));
|
||||
}
|
||||
|
||||
// 2. Return ? ToTemporalInstant(item).
|
||||
return TRY(to_temporal_instant(global_object, item));
|
||||
return TRY(to_temporal_instant(vm, item));
|
||||
}
|
||||
|
||||
// 8.2.3 Temporal.Instant.fromEpochSeconds ( epochSeconds ), https://tc39.es/proposal-temporal/#sec-temporal.instant.fromepochseconds
|
||||
|
@ -97,7 +97,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantConstructor::from_epoch_seconds)
|
|||
return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidEpochNanoseconds);
|
||||
|
||||
// 5. Return ! CreateTemporalInstant(epochNanoseconds).
|
||||
return MUST(create_temporal_instant(global_object, *epoch_nanoseconds));
|
||||
return MUST(create_temporal_instant(vm, *epoch_nanoseconds));
|
||||
}
|
||||
|
||||
// 8.2.4 Temporal.Instant.fromEpochMilliseconds ( epochMilliseconds ), https://tc39.es/proposal-temporal/#sec-temporal.instant.fromepochmilliseconds
|
||||
|
@ -117,7 +117,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantConstructor::from_epoch_milliseconds)
|
|||
return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidEpochNanoseconds);
|
||||
|
||||
// 5. Return ! CreateTemporalInstant(epochNanoseconds).
|
||||
return MUST(create_temporal_instant(global_object, *epoch_nanoseconds));
|
||||
return MUST(create_temporal_instant(vm, *epoch_nanoseconds));
|
||||
}
|
||||
|
||||
// 8.2.5 Temporal.Instant.fromEpochMicroseconds ( epochMicroseconds ), https://tc39.es/proposal-temporal/#sec-temporal.instant.fromepochmicroseconds
|
||||
|
@ -134,7 +134,7 @@ JS_DEFINE_NATIVE_FUNCTION(InstantConstructor::from_epoch_microseconds)
|
|||
return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidEpochNanoseconds);
|
||||
|
||||
// 4. Return ! CreateTemporalInstant(epochNanoseconds).
|
||||
return MUST(create_temporal_instant(global_object, *epoch_nanoseconds));
|
||||
return MUST(create_temporal_instant(vm, *epoch_nanoseconds));
|
||||
}
|
||||
|
||||
// 8.2.6 Temporal.Instant.fromEpochNanoseconds ( epochNanoseconds ), https://tc39.es/proposal-temporal/#sec-temporal.instant.fromepochnanoseconds
|
||||
|
@ -148,17 +148,17 @@ JS_DEFINE_NATIVE_FUNCTION(InstantConstructor::from_epoch_nanoseconds)
|
|||
return vm.throw_completion<RangeError>(ErrorType::TemporalInvalidEpochNanoseconds);
|
||||
|
||||
// 3. Return ! CreateTemporalInstant(epochNanoseconds).
|
||||
return MUST(create_temporal_instant(global_object, *epoch_nanoseconds));
|
||||
return MUST(create_temporal_instant(vm, *epoch_nanoseconds));
|
||||
}
|
||||
|
||||
// 8.2.7 Temporal.Instant.compare ( one, two ), https://tc39.es/proposal-temporal/#sec-temporal.instant.compare
|
||||
JS_DEFINE_NATIVE_FUNCTION(InstantConstructor::compare)
|
||||
{
|
||||
// 1. Set one to ? ToTemporalInstant(one).
|
||||
auto* one = TRY(to_temporal_instant(global_object, vm.argument(0)));
|
||||
auto* one = TRY(to_temporal_instant(vm, vm.argument(0)));
|
||||
|
||||
// 2. Set two to ? ToTemporalInstant(two).
|
||||
auto* two = TRY(to_temporal_instant(global_object, vm.argument(1)));
|
||||
auto* two = TRY(to_temporal_instant(vm, vm.argument(1)));
|
||||
|
||||
// 3. Return 𝔽(! CompareEpochNanoseconds(one.[[Nanoseconds]], two.[[Nanoseconds]])).
|
||||
return Value(compare_epoch_nanoseconds(one->nanoseconds(), two->nanoseconds()));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue