mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 06:37:40 +00:00
LibJS/Temporal: Rename ToIntegerWithRounding to ToIntegerIfIntegral
This is an editorial change to the Temporal spec.
See: 1dceb57
This commit is contained in:
parent
1cd0b5ad8a
commit
381b36b83f
3 changed files with 24 additions and 24 deletions
|
@ -161,8 +161,8 @@ ThrowCompletionOr<Temporal::DurationRecord> to_duration_record(VM& vm, Value inp
|
|||
// i. Set any to true.
|
||||
any = true;
|
||||
|
||||
// ii. Set value to ? ToIntegerWithoutRounding(value).
|
||||
auto value_number = TRY(Temporal::to_integer_without_rounding(vm, value, ErrorType::TemporalInvalidDurationPropertyValueNonIntegral, unit, value));
|
||||
// ii. Set value to ? ToIntegerIfIntegral(value).
|
||||
auto value_number = TRY(Temporal::to_integer_if_integral(vm, value, ErrorType::TemporalInvalidDurationPropertyValueNonIntegral, unit, value));
|
||||
|
||||
// iii. Set result.[[<valueSlot>]] to value.
|
||||
result.*value_slot = value_number;
|
||||
|
|
|
@ -201,9 +201,9 @@ ThrowCompletionOr<double> to_integer_throw_on_infinity(VM& vm, Value argument, E
|
|||
return integer;
|
||||
}
|
||||
|
||||
// 13.41 ToIntegerWithoutRounding ( argument ), https://tc39.es/proposal-temporal/#sec-temporal-tointegerwithoutrounding
|
||||
// 13.41 ToIntegerIfIntegral ( argument ), https://tc39.es/proposal-temporal/#sec-tointegerifintegral
|
||||
template<typename... Args>
|
||||
ThrowCompletionOr<double> to_integer_without_rounding(VM& vm, Value argument, ErrorType error_type, Args... args)
|
||||
ThrowCompletionOr<double> to_integer_if_integral(VM& vm, Value argument, ErrorType error_type, Args... args)
|
||||
{
|
||||
// 1. Let number be ? ToNumber(argument).
|
||||
auto number = TRY(argument.to_number(vm));
|
||||
|
|
|
@ -50,35 +50,35 @@ ThrowCompletionOr<Object*> DurationConstructor::construct(FunctionObject& new_ta
|
|||
{
|
||||
auto& vm = this->vm();
|
||||
|
||||
// 2. Let y be ? ToIntegerWithoutRounding(years).
|
||||
auto y = TRY(to_integer_without_rounding(vm, vm.argument(0), ErrorType::TemporalInvalidDuration));
|
||||
// 2. Let y be ? ToIntegerIfIntegral(years).
|
||||
auto y = TRY(to_integer_if_integral(vm, vm.argument(0), ErrorType::TemporalInvalidDuration));
|
||||
|
||||
// 3. Let mo be ? ToIntegerWithoutRounding(months).
|
||||
auto mo = TRY(to_integer_without_rounding(vm, vm.argument(1), ErrorType::TemporalInvalidDuration));
|
||||
// 3. Let mo be ? ToIntegerIfIntegral(months).
|
||||
auto mo = TRY(to_integer_if_integral(vm, vm.argument(1), ErrorType::TemporalInvalidDuration));
|
||||
|
||||
// 4. Let w be ? ToIntegerWithoutRounding(weeks).
|
||||
auto w = TRY(to_integer_without_rounding(vm, vm.argument(2), ErrorType::TemporalInvalidDuration));
|
||||
// 4. Let w be ? ToIntegerIfIntegral(weeks).
|
||||
auto w = TRY(to_integer_if_integral(vm, vm.argument(2), ErrorType::TemporalInvalidDuration));
|
||||
|
||||
// 5. Let d be ? ToIntegerWithoutRounding(days).
|
||||
auto d = TRY(to_integer_without_rounding(vm, vm.argument(3), ErrorType::TemporalInvalidDuration));
|
||||
// 5. Let d be ? ToIntegerIfIntegral(days).
|
||||
auto d = TRY(to_integer_if_integral(vm, vm.argument(3), ErrorType::TemporalInvalidDuration));
|
||||
|
||||
// 6. Let h be ? ToIntegerWithoutRounding(hours).
|
||||
auto h = TRY(to_integer_without_rounding(vm, vm.argument(4), ErrorType::TemporalInvalidDuration));
|
||||
// 6. Let h be ? ToIntegerIfIntegral(hours).
|
||||
auto h = TRY(to_integer_if_integral(vm, vm.argument(4), ErrorType::TemporalInvalidDuration));
|
||||
|
||||
// 7. Let m be ? ToIntegerWithoutRounding(minutes).
|
||||
auto m = TRY(to_integer_without_rounding(vm, vm.argument(5), ErrorType::TemporalInvalidDuration));
|
||||
// 7. Let m be ? ToIntegerIfIntegral(minutes).
|
||||
auto m = TRY(to_integer_if_integral(vm, vm.argument(5), ErrorType::TemporalInvalidDuration));
|
||||
|
||||
// 8. Let s be ? ToIntegerWithoutRounding(seconds).
|
||||
auto s = TRY(to_integer_without_rounding(vm, vm.argument(6), ErrorType::TemporalInvalidDuration));
|
||||
// 8. Let s be ? ToIntegerIfIntegral(seconds).
|
||||
auto s = TRY(to_integer_if_integral(vm, vm.argument(6), ErrorType::TemporalInvalidDuration));
|
||||
|
||||
// 9. Let ms be ? ToIntegerWithoutRounding(milliseconds).
|
||||
auto ms = TRY(to_integer_without_rounding(vm, vm.argument(7), ErrorType::TemporalInvalidDuration));
|
||||
// 9. Let ms be ? ToIntegerIfIntegral(milliseconds).
|
||||
auto ms = TRY(to_integer_if_integral(vm, vm.argument(7), ErrorType::TemporalInvalidDuration));
|
||||
|
||||
// 10. Let mis be ? ToIntegerWithoutRounding(microseconds).
|
||||
auto mis = TRY(to_integer_without_rounding(vm, vm.argument(8), ErrorType::TemporalInvalidDuration));
|
||||
// 10. Let mis be ? ToIntegerIfIntegral(microseconds).
|
||||
auto mis = TRY(to_integer_if_integral(vm, vm.argument(8), ErrorType::TemporalInvalidDuration));
|
||||
|
||||
// 11. Let ns be ? ToIntegerWithoutRounding(nanoseconds).
|
||||
auto ns = TRY(to_integer_without_rounding(vm, vm.argument(9), ErrorType::TemporalInvalidDuration));
|
||||
// 11. Let ns be ? ToIntegerIfIntegral(nanoseconds).
|
||||
auto ns = TRY(to_integer_if_integral(vm, vm.argument(9), ErrorType::TemporalInvalidDuration));
|
||||
|
||||
// 12. Return ? CreateTemporalDuration(y, mo, w, d, h, m, s, ms, mis, ns, NewTarget).
|
||||
return TRY(create_temporal_duration(vm, y, mo, w, d, h, m, s, ms, mis, ns, &new_target));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue