1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-23 13:17:36 +00:00

LibJS/Temporal: Rename ToIntegerWithRounding to ToIntegerIfIntegral

This is an editorial change to the Temporal spec.
See: 1dceb57
This commit is contained in:
Jonah 2022-11-13 15:11:55 -06:00 committed by Linus Groh
parent 1cd0b5ad8a
commit 381b36b83f
3 changed files with 24 additions and 24 deletions

View file

@ -161,8 +161,8 @@ ThrowCompletionOr<Temporal::DurationRecord> to_duration_record(VM& vm, Value inp
// i. Set any to true. // i. Set any to true.
any = true; any = true;
// ii. Set value to ? ToIntegerWithoutRounding(value). // ii. Set value to ? ToIntegerIfIntegral(value).
auto value_number = TRY(Temporal::to_integer_without_rounding(vm, value, ErrorType::TemporalInvalidDurationPropertyValueNonIntegral, unit, value)); auto value_number = TRY(Temporal::to_integer_if_integral(vm, value, ErrorType::TemporalInvalidDurationPropertyValueNonIntegral, unit, value));
// iii. Set result.[[<valueSlot>]] to value. // iii. Set result.[[<valueSlot>]] to value.
result.*value_slot = value_number; result.*value_slot = value_number;

View file

@ -201,9 +201,9 @@ ThrowCompletionOr<double> to_integer_throw_on_infinity(VM& vm, Value argument, E
return integer; 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> 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). // 1. Let number be ? ToNumber(argument).
auto number = TRY(argument.to_number(vm)); auto number = TRY(argument.to_number(vm));

View file

@ -50,35 +50,35 @@ ThrowCompletionOr<Object*> DurationConstructor::construct(FunctionObject& new_ta
{ {
auto& vm = this->vm(); auto& vm = this->vm();
// 2. Let y be ? ToIntegerWithoutRounding(years). // 2. Let y be ? ToIntegerIfIntegral(years).
auto y = TRY(to_integer_without_rounding(vm, vm.argument(0), ErrorType::TemporalInvalidDuration)); auto y = TRY(to_integer_if_integral(vm, vm.argument(0), ErrorType::TemporalInvalidDuration));
// 3. Let mo be ? ToIntegerWithoutRounding(months). // 3. Let mo be ? ToIntegerIfIntegral(months).
auto mo = TRY(to_integer_without_rounding(vm, vm.argument(1), ErrorType::TemporalInvalidDuration)); auto mo = TRY(to_integer_if_integral(vm, vm.argument(1), ErrorType::TemporalInvalidDuration));
// 4. Let w be ? ToIntegerWithoutRounding(weeks). // 4. Let w be ? ToIntegerIfIntegral(weeks).
auto w = TRY(to_integer_without_rounding(vm, vm.argument(2), ErrorType::TemporalInvalidDuration)); auto w = TRY(to_integer_if_integral(vm, vm.argument(2), ErrorType::TemporalInvalidDuration));
// 5. Let d be ? ToIntegerWithoutRounding(days). // 5. Let d be ? ToIntegerIfIntegral(days).
auto d = TRY(to_integer_without_rounding(vm, vm.argument(3), ErrorType::TemporalInvalidDuration)); auto d = TRY(to_integer_if_integral(vm, vm.argument(3), ErrorType::TemporalInvalidDuration));
// 6. Let h be ? ToIntegerWithoutRounding(hours). // 6. Let h be ? ToIntegerIfIntegral(hours).
auto h = TRY(to_integer_without_rounding(vm, vm.argument(4), ErrorType::TemporalInvalidDuration)); auto h = TRY(to_integer_if_integral(vm, vm.argument(4), ErrorType::TemporalInvalidDuration));
// 7. Let m be ? ToIntegerWithoutRounding(minutes). // 7. Let m be ? ToIntegerIfIntegral(minutes).
auto m = TRY(to_integer_without_rounding(vm, vm.argument(5), ErrorType::TemporalInvalidDuration)); auto m = TRY(to_integer_if_integral(vm, vm.argument(5), ErrorType::TemporalInvalidDuration));
// 8. Let s be ? ToIntegerWithoutRounding(seconds). // 8. Let s be ? ToIntegerIfIntegral(seconds).
auto s = TRY(to_integer_without_rounding(vm, vm.argument(6), ErrorType::TemporalInvalidDuration)); auto s = TRY(to_integer_if_integral(vm, vm.argument(6), ErrorType::TemporalInvalidDuration));
// 9. Let ms be ? ToIntegerWithoutRounding(milliseconds). // 9. Let ms be ? ToIntegerIfIntegral(milliseconds).
auto ms = TRY(to_integer_without_rounding(vm, vm.argument(7), ErrorType::TemporalInvalidDuration)); auto ms = TRY(to_integer_if_integral(vm, vm.argument(7), ErrorType::TemporalInvalidDuration));
// 10. Let mis be ? ToIntegerWithoutRounding(microseconds). // 10. Let mis be ? ToIntegerIfIntegral(microseconds).
auto mis = TRY(to_integer_without_rounding(vm, vm.argument(8), ErrorType::TemporalInvalidDuration)); auto mis = TRY(to_integer_if_integral(vm, vm.argument(8), ErrorType::TemporalInvalidDuration));
// 11. Let ns be ? ToIntegerWithoutRounding(nanoseconds). // 11. Let ns be ? ToIntegerIfIntegral(nanoseconds).
auto ns = TRY(to_integer_without_rounding(vm, vm.argument(9), ErrorType::TemporalInvalidDuration)); 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). // 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)); return TRY(create_temporal_duration(vm, y, mo, w, d, h, m, s, ms, mis, ns, &new_target));