From 5764eeab05ccd7d23581e7b34f8901da49cd639d Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Fri, 28 Feb 2025 08:54:42 -0500 Subject: [PATCH] LibJS: Update spec numbers for the Intl.DurationFormat proposal This proposal has reached stage 4 and was merged into the ECMA-402 spec. See: https://github.com/tc39/ecma402/commit/3ff3cc7 --- Libraries/LibJS/Runtime/ArrayPrototype.cpp | 2 +- Libraries/LibJS/Runtime/BigIntPrototype.cpp | 2 +- Libraries/LibJS/Runtime/DatePrototype.cpp | 8 +-- Libraries/LibJS/Runtime/Intl/DateTimeFormat.h | 4 +- Libraries/LibJS/Runtime/Intl/DisplayNames.cpp | 4 +- .../Runtime/Intl/DisplayNamesPrototype.cpp | 4 +- .../LibJS/Runtime/Intl/DurationFormat.cpp | 30 +++++----- Libraries/LibJS/Runtime/Intl/DurationFormat.h | 10 ++-- .../Intl/DurationFormatConstructor.cpp | 56 ++++++++----------- .../Runtime/Intl/DurationFormatPrototype.cpp | 14 ++--- Libraries/LibJS/Runtime/Intl/ListFormat.cpp | 12 ++-- .../Runtime/Intl/ListFormatConstructor.cpp | 14 ++--- .../Runtime/Intl/ListFormatPrototype.cpp | 14 ++--- Libraries/LibJS/Runtime/Intl/Locale.cpp | 4 +- Libraries/LibJS/Runtime/Intl/Locale.h | 4 +- .../LibJS/Runtime/Intl/LocaleConstructor.cpp | 12 ++-- .../LibJS/Runtime/Intl/LocalePrototype.cpp | 32 +++++------ Libraries/LibJS/Runtime/Intl/NumberFormat.cpp | 22 ++++---- Libraries/LibJS/Runtime/Intl/NumberFormat.h | 4 +- .../Runtime/Intl/NumberFormatConstructor.cpp | 16 +++--- .../Runtime/Intl/NumberFormatFunction.cpp | 4 +- .../Runtime/Intl/NumberFormatPrototype.cpp | 20 +++---- Libraries/LibJS/Runtime/Intl/PluralRules.cpp | 8 +-- .../Runtime/Intl/PluralRulesConstructor.cpp | 12 ++-- .../Runtime/Intl/PluralRulesPrototype.cpp | 14 ++--- .../LibJS/Runtime/Intl/RelativeTimeFormat.cpp | 12 ++-- .../LibJS/Runtime/Intl/RelativeTimeFormat.h | 4 +- .../Intl/RelativeTimeFormatConstructor.cpp | 12 ++-- .../Intl/RelativeTimeFormatPrototype.cpp | 14 ++--- .../LibJS/Runtime/Intl/SegmentIterator.cpp | 4 +- .../Runtime/Intl/SegmentIteratorPrototype.cpp | 6 +- Libraries/LibJS/Runtime/Intl/Segmenter.cpp | 8 +-- .../Runtime/Intl/SegmenterConstructor.cpp | 12 ++-- .../LibJS/Runtime/Intl/SegmenterPrototype.cpp | 10 ++-- Libraries/LibJS/Runtime/Intl/Segments.cpp | 4 +- .../LibJS/Runtime/Intl/SegmentsPrototype.cpp | 6 +- Libraries/LibJS/Runtime/NumberPrototype.cpp | 2 +- Libraries/LibJS/Runtime/StringPrototype.cpp | 8 +-- 38 files changed, 208 insertions(+), 220 deletions(-) diff --git a/Libraries/LibJS/Runtime/ArrayPrototype.cpp b/Libraries/LibJS/Runtime/ArrayPrototype.cpp index 2d9b432419e..c1071888bde 100644 --- a/Libraries/LibJS/Runtime/ArrayPrototype.cpp +++ b/Libraries/LibJS/Runtime/ArrayPrototype.cpp @@ -1607,7 +1607,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::splice) } // 23.1.3.32 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ), https://tc39.es/ecma262/#sec-array.prototype.tolocalestring -// 19.5.1 Array.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sup-array.prototype.tolocalestring +// 20.5.1 Array.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sup-array.prototype.tolocalestring JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::to_locale_string) { auto locales = vm.argument(0); diff --git a/Libraries/LibJS/Runtime/BigIntPrototype.cpp b/Libraries/LibJS/Runtime/BigIntPrototype.cpp index 952355f7a66..bf2073ec54e 100644 --- a/Libraries/LibJS/Runtime/BigIntPrototype.cpp +++ b/Libraries/LibJS/Runtime/BigIntPrototype.cpp @@ -78,7 +78,7 @@ JS_DEFINE_NATIVE_FUNCTION(BigIntPrototype::to_string) } // 21.2.3.2 BigInt.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ), https://tc39.es/ecma262/#sec-bigint.prototype.tolocalestring -// 19.3.1 BigInt.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sup-bigint.prototype.tolocalestring +// 20.3.1 BigInt.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sup-bigint.prototype.tolocalestring JS_DEFINE_NATIVE_FUNCTION(BigIntPrototype::to_locale_string) { auto& realm = *vm.current_realm(); diff --git a/Libraries/LibJS/Runtime/DatePrototype.cpp b/Libraries/LibJS/Runtime/DatePrototype.cpp index fd31423bff3..b6c84e27e0f 100644 --- a/Libraries/LibJS/Runtime/DatePrototype.cpp +++ b/Libraries/LibJS/Runtime/DatePrototype.cpp @@ -2,7 +2,7 @@ * Copyright (c) 2020-2023, Linus Groh * Copyright (c) 2021, Petróczi Zoltán * Copyright (c) 2021, Idan Horowitz - * Copyright (c) 2022-2024, Tim Flynn + * Copyright (c) 2022-2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -989,7 +989,7 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_json) } // 21.4.4.38 Date.prototype.toLocaleDateString ( [ reserved1 [ , reserved2 ] ] ), https://tc39.es/ecma262/#sec-date.prototype.tolocaledatestring -// 19.4.2 Date.prototype.toLocaleDateString ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sup-date.prototype.tolocaledatestring +// 20.4.2 Date.prototype.toLocaleDateString ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sup-date.prototype.tolocaledatestring JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_locale_date_string) { auto& realm = *vm.current_realm(); @@ -1013,7 +1013,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 -// 19.4.1 Date.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sup-date.prototype.tolocalestring +// 20.4.1 Date.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sup-date.prototype.tolocalestring JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_locale_string) { auto& realm = *vm.current_realm(); @@ -1037,7 +1037,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 -// 19.4.3 Date.prototype.toLocaleTimeString ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sup-date.prototype.tolocaletimestring +// 20.4.3 Date.prototype.toLocaleTimeString ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sup-date.prototype.tolocaletimestring JS_DEFINE_NATIVE_FUNCTION(DatePrototype::to_locale_time_string) { auto& realm = *vm.current_realm(); diff --git a/Libraries/LibJS/Runtime/Intl/DateTimeFormat.h b/Libraries/LibJS/Runtime/Intl/DateTimeFormat.h index d192e750e8f..b758bdd09d6 100644 --- a/Libraries/LibJS/Runtime/Intl/DateTimeFormat.h +++ b/Libraries/LibJS/Runtime/Intl/DateTimeFormat.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024, Tim Flynn + * Copyright (c) 2021-2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -165,7 +165,7 @@ ThrowCompletionOr for_each_calendar_field(VM& vm, Unicode::CalendarPattern constexpr auto two_digit_numeric_narrow_short_long = AK::Array { "2-digit"sv, "numeric"sv, "narrow"sv, "short"sv, "long"sv }; constexpr auto time_zone = AK::Array { "short"sv, "long"sv, "shortOffset"sv, "longOffset"sv, "shortGeneric"sv, "longGeneric"sv }; - // Table 6: Components of date and time formats, https://tc39.es/ecma402/#table-datetimeformat-components + // Table 16: Components of date and time formats, https://tc39.es/ecma402/#table-datetimeformat-components TRY(callback(pattern.weekday, vm.names.weekday, narrow_short_long)); TRY(callback(pattern.era, vm.names.era, narrow_short_long)); TRY(callback(pattern.year, vm.names.year, two_digit_numeric)); diff --git a/Libraries/LibJS/Runtime/Intl/DisplayNames.cpp b/Libraries/LibJS/Runtime/Intl/DisplayNames.cpp index cecb57a2b23..8ed78f4ee2f 100644 --- a/Libraries/LibJS/Runtime/Intl/DisplayNames.cpp +++ b/Libraries/LibJS/Runtime/Intl/DisplayNames.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024, Tim Flynn + * Copyright (c) 2021-2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -160,7 +160,7 @@ ThrowCompletionOr canonical_code_for_display_names(VM& vm, DisplayNames:: // 12.5.2 IsValidDateTimeFieldCode ( field ), https://tc39.es/ecma402/#sec-isvaliddatetimefieldcode bool is_valid_date_time_field_code(StringView field) { - // 1. If field is listed in the Code column of Table 9, return true. + // 1. If field is listed in the Code column of Table 19, return true. // 2. Return false. return field.is_one_of("era"sv, "year"sv, "quarter"sv, "month"sv, "weekOfYear"sv, "weekday"sv, "day"sv, "dayPeriod"sv, "hour"sv, "minute"sv, "second"sv, "timeZoneName"sv); } diff --git a/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp b/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp index 14b774af7a0..0e933589a81 100644 --- a/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp +++ b/Libraries/LibJS/Runtime/Intl/DisplayNamesPrototype.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024, Tim Flynn + * Copyright (c) 2021-2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -101,7 +101,7 @@ JS_DEFINE_NATIVE_FUNCTION(DisplayNamesPrototype::resolved_options) // 3. Let options be OrdinaryObjectCreate(%Object.prototype%). auto options = Object::create(realm, realm.intrinsics().object_prototype()); - // 4. For each row of Table 8, except the header row, in table order, do + // 4. For each row of Table 18, except the header row, in table order, do // a. Let p be the Property value of the current row. // b. Let v be the value of displayNames's internal slot whose name is the Internal Slot value of the current row. // c. Assert: v is not undefined. diff --git a/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp b/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp index 08e4a1991f4..abbe230158d 100644 --- a/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp +++ b/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2022, Idan Horowitz - * Copyright (c) 2022-2024, Tim Flynn + * Copyright (c) 2022-2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -24,7 +24,7 @@ namespace JS::Intl { GC_DEFINE_ALLOCATOR(DurationFormat); -// 1 DurationFormat Objects, https://tc39.es/proposal-intl-duration-format/#durationformat-objects +// 13 DurationFormat Objects, https://tc39.es/ecma402/#durationformat-objects DurationFormat::DurationFormat(Object& prototype) : Object(ConstructWithPrototypeTag::Tag, prototype) { @@ -186,7 +186,7 @@ static GC::Ref construct_list_format(VM& vm, DurationFormat const& d return static_cast(*list_format); } -// 1.1.3 ToDurationRecord ( input ), https://tc39.es/proposal-intl-duration-format/#sec-todurationrecord +// 13.1.3 ToDurationRecord ( input ), https://tc39.es/ecma402/#sec-todurationrecord ThrowCompletionOr to_duration_record(VM& vm, Value input) { // 1. If input is not an Object, then @@ -270,7 +270,7 @@ ThrowCompletionOr to_duration_record(VM& vm, Value input) return result; } -// 1.1.4 DurationSign ( duration ), https://tc39.es/proposal-intl-duration-format/#sec-durationsign +// 13.1.4 DurationSign ( duration ), https://tc39.es/ecma402/#sec-durationsign i8 duration_sign(DurationRecord const& duration) { // 1. For each value v of « duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], duration.[[Hours]], duration.[[Minutes]], duration.[[Seconds]], duration.[[Milliseconds]], duration.[[Microseconds]], duration.[[Nanoseconds]] », do @@ -288,7 +288,7 @@ i8 duration_sign(DurationRecord const& duration) return 0; } -// 1.1.6 GetDurationUnitOptions ( unit, options, baseStyle, stylesList, digitalBase, prevStyle, twoDigitHours ), https://tc39.es/proposal-intl-duration-format/#sec-getdurationunitoptions +// 13.1.6 GetDurationUnitOptions ( unit, options, baseStyle, stylesList, digitalBase, prevStyle, twoDigitHours ), https://tc39.es/ecma402/#sec-getdurationunitoptions ThrowCompletionOr get_duration_unit_options(VM& vm, DurationFormat::Unit unit, Object const& options, DurationFormat::Style base_style, ReadonlySpan styles_list, DurationFormat::ValueStyle digital_base, Optional previous_style, bool two_digit_hours) { auto const& unit_property_key = unit_to_property_key(vm, unit); @@ -398,7 +398,7 @@ ThrowCompletionOr get_duration_unit_options(VM& vm, Duratio return DurationUnitOptions { .style = style, .display = display }; } -// 1.1.7 ComputeFractionalDigits ( durationFormat, duration ), https://tc39.es/proposal-intl-duration-format/#sec-computefractionaldigits +// 13.1.7 ComputeFractionalDigits ( durationFormat, duration ), https://tc39.es/ecma402/#sec-computefractionaldigits Crypto::BigFraction compute_fractional_digits(DurationFormat const& duration_format, DurationRecord const& duration) { // 1. Let result be 0. @@ -407,7 +407,7 @@ Crypto::BigFraction compute_fractional_digits(DurationFormat const& duration_for // 2. Let exponent be 3. double exponent = 3; - // 3. For each row of Table 2, except the header row, in table order, do + // 3. For each row of Table 21, except the header row, in table order, do for (auto const& duration_instances_component : duration_instances_components) { // a. Let style be the value of durationFormat's internal slot whose name is the Style Slot value of the current row. auto style = (duration_format.*duration_instances_component.get_style_slot)(); @@ -436,7 +436,7 @@ Crypto::BigFraction compute_fractional_digits(DurationFormat const& duration_for return result; } -// 1.1.8 NextUnitFractional ( durationFormat, unit ), https://tc39.es/proposal-intl-duration-format/#sec-nextunitfractional +// 13.1.8 NextUnitFractional ( durationFormat, unit ), https://tc39.es/ecma402/#sec-nextunitfractional bool next_unit_fractional(DurationFormat const& duration_format, DurationFormat::Unit unit) { // 1. Assert: unit is "seconds", "milliseconds", or "microseconds". @@ -458,7 +458,7 @@ bool next_unit_fractional(DurationFormat const& duration_format, DurationFormat: return false; } -// 1.1.9 FormatNumericHours ( durationFormat, hoursValue, signDisplayed ), https://tc39.es/proposal-intl-duration-format/#sec-formatnumerichours +// 13.1.9 FormatNumericHours ( durationFormat, hoursValue, signDisplayed ), https://tc39.es/ecma402/#sec-formatnumerichours Vector format_numeric_hours(VM& vm, DurationFormat const& duration_format, MathematicalValue const& hours_value, bool sign_displayed) { auto& realm = *vm.current_realm(); @@ -514,7 +514,7 @@ Vector format_numeric_hours(VM& vm, DurationFormat const& du return result; } -// 1.1.10 FormatNumericMinutes ( durationFormat, minutesValue, hoursDisplayed, signDisplayed ), https://tc39.es/proposal-intl-duration-format/#sec-formatnumericminutes +// 13.1.10 FormatNumericMinutes ( durationFormat, minutesValue, hoursDisplayed, signDisplayed ), https://tc39.es/ecma402/#sec-formatnumericminutes Vector format_numeric_minutes(VM& vm, DurationFormat const& duration_format, MathematicalValue const& minutes_value, bool hours_displayed, bool sign_displayed) { auto& realm = *vm.current_realm(); @@ -579,7 +579,7 @@ Vector format_numeric_minutes(VM& vm, DurationFormat const& return result; } -// 1.1.11 FormatNumericSeconds ( durationFormat, secondsValue, minutesDisplayed, signDisplayed ), https://tc39.es/proposal-intl-duration-format/#sec-formatnumericseconds +// 13.1.11 FormatNumericSeconds ( durationFormat, secondsValue, minutesDisplayed, signDisplayed ), https://tc39.es/ecma402/#sec-formatnumericseconds Vector format_numeric_seconds(VM& vm, DurationFormat const& duration_format, MathematicalValue const& seconds_value, bool minutes_displayed, bool sign_displayed) { auto& realm = *vm.current_realm(); @@ -673,7 +673,7 @@ Vector format_numeric_seconds(VM& vm, DurationFormat const& return result; } -// 1.1.12 FormatNumericUnits ( durationFormat, duration, firstNumericUnit, signDisplayed ), https://tc39.es/proposal-intl-duration-format/#sec-formatnumericunits +// 13.1.12 FormatNumericUnits ( durationFormat, duration, firstNumericUnit, signDisplayed ), https://tc39.es/ecma402/#sec-formatnumericunits Vector format_numeric_units(VM& vm, DurationFormat const& duration_format, DurationRecord const& duration, DurationFormat::Unit first_numeric_unit, bool sign_displayed) { // 1. Assert: firstNumericUnit is "hours", "minutes", or "seconds". @@ -800,7 +800,7 @@ Vector format_numeric_units(VM& vm, DurationFormat const& du return numeric_parts_list; } -// 1.1.13 ListFormatParts ( durationFormat, partitionedPartsList ), https://tc39.es/proposal-intl-duration-format/#sec-listformatparts +// 13.1.13 ListFormatParts ( durationFormat, partitionedPartsList ), https://tc39.es/ecma402/#sec-listformatparts Vector list_format_parts(VM& vm, DurationFormat const& duration_format, Vector>& partitioned_parts_list) { auto& realm = *vm.current_realm(); @@ -891,7 +891,7 @@ Vector list_format_parts(VM& vm, DurationFormat const& durat return flattened_parts_list; } -// 1.1.7 PartitionDurationFormatPattern ( durationFormat, duration ), https://tc39.es/proposal-intl-duration-format/#sec-partitiondurationformatpattern +// 13.1.14 PartitionDurationFormatPattern ( durationFormat, duration ), https://tc39.es/ecma402/#sec-partitiondurationformatpattern Vector partition_duration_format_pattern(VM& vm, DurationFormat const& duration_format, DurationRecord const& duration) { auto& realm = *vm.current_realm(); @@ -905,7 +905,7 @@ Vector partition_duration_format_pattern(VM& vm, DurationFor // 3. Let numericUnitFound be false. auto numeric_unit_found = false; - // 4. While numericUnitFound is false, repeat for each row in Table 2 in table order, except the header row: + // 4. While numericUnitFound is false, repeat for each row in Table 21 in table order, except the header row: for (size_t i = 0; !numeric_unit_found && i < duration_instances_components.size(); ++i) { auto const& duration_instances_component = duration_instances_components[i]; diff --git a/Libraries/LibJS/Runtime/Intl/DurationFormat.h b/Libraries/LibJS/Runtime/Intl/DurationFormat.h index 049e314d675..4c9ec7a2a05 100644 --- a/Libraries/LibJS/Runtime/Intl/DurationFormat.h +++ b/Libraries/LibJS/Runtime/Intl/DurationFormat.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2022, Idan Horowitz - * Copyright (c) 2022-2024, Tim Flynn + * Copyright (c) 2022-2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -67,7 +67,7 @@ public: static constexpr auto relevant_extension_keys() { - // 1.3.3 Internal slots, https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat-internal-slots + // 13.3.3 Internal slots, https://tc39.es/ecma402/#sec-Intl.DurationFormat-internal-slots // The value of the [[RelevantExtensionKeys]] internal slot is « "nu" ». return AK::Array { "nu"sv }; } @@ -206,7 +206,7 @@ private: Optional m_fractional_digits; // [[FractionalDigits]] }; -// 1.1.1 Duration Records, https://tc39.es/proposal-intl-duration-format/#sec-duration-records +// 13.1.1 Duration Records, https://tc39.es/ecma402/#sec-duration-records struct DurationRecord { double years { 0 }; double months { 0 }; @@ -231,8 +231,8 @@ struct DurationInstanceComponent { DurationFormat::ValueStyle digital_default; }; -// Table 2: DurationFormat instance internal slots and properties relevant to PartitionDurationFormatPattern, https://tc39.es/proposal-intl-duration-format/#table-partition-duration-format-pattern -// Table 3: Internal slots and property names of DurationFormat instances relevant to Intl.DurationFormat constructor, https://tc39.es/proposal-intl-duration-format/#table-durationformat +// Table 21: DurationFormat instance internal slots and properties relevant to PartitionDurationFormatPattern, https://tc39.es/ecma402/#table-partition-duration-format-pattern +// Table 22: Internal slots and property names of DurationFormat instances relevant to Intl.DurationFormat constructor, https://tc39.es/ecma402/#table-durationformat static constexpr auto date_values = AK::Array { "long"sv, "short"sv, "narrow"sv }; static constexpr auto time_values = AK::Array { "long"sv, "short"sv, "narrow"sv, "numeric"sv, "2-digit"sv }; static constexpr auto sub_second_values = AK::Array { "long"sv, "short"sv, "narrow"sv, "numeric"sv }; diff --git a/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp b/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp index 2705ce02530..58fa42aeedb 100644 --- a/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp +++ b/Libraries/LibJS/Runtime/Intl/DurationFormatConstructor.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2022, Idan Horowitz - * Copyright (c) 2022-2024, Tim Flynn + * Copyright (c) 2022-2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -18,7 +18,7 @@ namespace JS::Intl { GC_DEFINE_ALLOCATOR(DurationFormatConstructor); -// 1.2 The Intl.DurationFormat Constructor, https://tc39.es/proposal-intl-duration-format/#sec-intl-durationformat-constructor +// 13.2 The Intl.DurationFormat Constructor, https://tc39.es/ecma402/#sec-intl-durationformat-constructor DurationFormatConstructor::DurationFormatConstructor(Realm& realm) : NativeFunction(realm.vm().names.DurationFormat.as_string(), realm.intrinsics().function_prototype()) { @@ -30,7 +30,7 @@ void DurationFormatConstructor::initialize(Realm& realm) auto& vm = this->vm(); - // 1.3.1 Intl.DurationFormat.prototype, https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat.prototype + // 1.3.1 Intl.DurationFormat.prototype, https://tc39.es/ecma402/#sec-Intl.DurationFormat.prototype define_direct_property(vm.names.prototype, realm.intrinsics().intl_duration_format_prototype(), 0); define_direct_property(vm.names.length, Value(0), Attribute::Configurable); @@ -38,14 +38,14 @@ void DurationFormatConstructor::initialize(Realm& realm) define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr); } -// 1.2.1 Intl.DurationFormat ( [ locales [ , options ] ] ), https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat +// 13.2.1 Intl.DurationFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-Intl.DurationFormat ThrowCompletionOr DurationFormatConstructor::call() { // 1. If NewTarget is undefined, throw a TypeError exception. return vm().throw_completion(ErrorType::ConstructorWithoutNew, "Intl.DurationFormat"); } -// 1.2.1 Intl.DurationFormat ( [ locales [ , options ] ] ), https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat +// 13.2.1 Intl.DurationFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-Intl.DurationFormat ThrowCompletionOr> DurationFormatConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -53,7 +53,7 @@ ThrowCompletionOr> DurationFormatConstructor::construct(Function auto locales = vm.argument(0); auto options_value = vm.argument(1); - // 2. Let durationFormat be ? OrdinaryCreateFromConstructor(NewTarget, "%Intl.DurationFormatPrototype%", « [[InitializedDurationFormat]], [[Locale]], [[DataLocale]], [[NumberingSystem]], [[Style]], [[YearsStyle]], [[YearsDisplay]], [[MonthsStyle]], [[MonthsDisplay]], [[WeeksStyle]], [[WeeksDisplay]], [[DaysStyle]], [[DaysDisplay]], [[HoursStyle]], [[HoursDisplay]], [[MinutesStyle]], [[MinutesDisplay]], [[SecondsStyle]], [[SecondsDisplay]], [[MillisecondsStyle]], [[MillisecondsDisplay]], [[MicrosecondsStyle]], [[MicrosecondsDisplay]], [[NanosecondsStyle]], [[NanosecondsDisplay]], [[HourMinuteSeparator]], [[MinuteSecondSeparator]], [[FractionalDigits]] »). + // 2. Let durationFormat be ? OrdinaryCreateFromConstructor(NewTarget, "%Intl.DurationFormatPrototype%", « [[InitializedDurationFormat]], [[Locale]], [[NumberingSystem]], [[Style]], [[YearsStyle]], [[YearsDisplay]], [[MonthsStyle]], [[MonthsDisplay]], [[WeeksStyle]], [[WeeksDisplay]], [[DaysStyle]], [[DaysDisplay]], [[HoursStyle]], [[HoursDisplay]], [[MinutesStyle]], [[MinutesDisplay]], [[SecondsStyle]], [[SecondsDisplay]], [[MillisecondsStyle]], [[MillisecondsDisplay]], [[MicrosecondsStyle]], [[MicrosecondsDisplay]], [[NanosecondsStyle]], [[NanosecondsDisplay]], [[HourMinuteSeparator]], [[MinuteSecondSeparator]], [[FractionalDigits]] »). auto duration_format = TRY(ordinary_create_from_constructor(vm, new_target, &Intrinsics::intl_duration_format_prototype)); // 3. Let requestedLocales be ? CanonicalizeLocaleList(locales). @@ -83,46 +83,34 @@ ThrowCompletionOr> DurationFormatConstructor::construct(Function // 9. Let r be ResolveLocale(%Intl.DurationFormat%.[[AvailableLocales]], requestedLocales, opt, %Intl.DurationFormat%.[[RelevantExtensionKeys]], %Intl.DurationFormat%.[[LocaleData]]). auto result = resolve_locale(requested_locales, opt, DurationFormat::relevant_extension_keys()); - // 10. Let locale be r.[[locale]]. - auto locale = move(result.locale); + // 10. Set durationFormat.[[Locale]] to r.[[Locale]]. + duration_format->set_locale(move(result.locale)); - // 11. Set durationFormat.[[Locale]] to locale. - duration_format->set_locale(move(locale)); + // 11. Let resolvedLocaleData be r.[[LocaleData]]. - // 12. Set durationFormat.[[DataLocale]] to r.[[dataLocale]]. - // FIXME: Spec issue: The [[dataLocale]] internal slot no longer exists. See: - // https://github.com/tc39/proposal-intl-duration-format/issues/189 - - // 13. Let dataLocale be durationFormat.[[DataLocale]]. - // 14. Let dataLocaleData be durationFormat.[[LocaleData]].[[]]. - // 15. Let digitalFormat be dataLocaleData.[[DigitalFormat]]. + // 12. Let digitalFormat be resolvedLocaleData.[[DigitalFormat]]. auto digital_format = Unicode::digital_format(duration_format->locale()); - // 16. Let twoDigitHours be digitalFormat.[[TwoDigitHours]]. - auto two_digit_hours = digital_format.uses_two_digit_hours; - - // 17. Let hourMinuteSeparator be digitalFormat.[[HourMinuteSeparator]]. - // 18. Set durationFormat.[[HourMinuteSeparator]] to hourMinuteSeparator. + // 13. Set durationFormat.[[HourMinuteSeparator]] to digitalFormat.[[HourMinuteSeparator]]. duration_format->set_hour_minute_separator(move(digital_format.hours_minutes_separator)); - // 19. Let minuteSecondSeparator be digitalFormat.[[MinuteSecondSeparator]]. - // 20. Set durationFormat.[[MinuteSecondSeparator]] to minuteSecondSeparator. + // 14. Set durationFormat.[[MinuteSecondSeparator]] to digitalFormat.[[MinuteSecondSeparator]]. duration_format->set_minute_second_separator(move(digital_format.minutes_seconds_separator)); - // 21. Set durationFormat.[[NumberingSystem]] to r.[[nu]]. + // 15. Set durationFormat.[[NumberingSystem]] to r.[[nu]]. if (auto* resolved_numbering_system = result.nu.get_pointer()) duration_format->set_numbering_system(move(*resolved_numbering_system)); - // 22. Let style be ? GetOption(options, "style", STRING, « "long", "short", "narrow", "digital" », "short"). + // 16. Let style be ? GetOption(options, "style", STRING, « "long", "short", "narrow", "digital" », "short"). auto style = TRY(get_option(vm, *options, vm.names.style, OptionType::String, { "long"sv, "short"sv, "narrow"sv, "digital"sv }, "short"sv)); - // 23. Set durationFormat.[[Style]] to style. + // 17. Set durationFormat.[[Style]] to style. duration_format->set_style(style.as_string().utf8_string_view()); - // 24. Let prevStyle be the empty String. + // 18. Let prevStyle be the empty String. Optional previous_style; - // 25. For each row of Table 3, except the header row, in table order, do + // 19. For each row of Table 22, except the header row, in table order, do for (auto const& duration_instances_component : duration_instances_components) { // a. Let styleSlot be the Style Slot value of the current row. auto style_slot = duration_instances_component.set_style_slot; @@ -139,8 +127,8 @@ ThrowCompletionOr> DurationFormatConstructor::construct(Function // e. Let digitalBase be the Digital Default value of the current row. auto digital_base = duration_instances_component.digital_default; - // f. Let unitOptions be ? GetDurationUnitOptions(unit, options, style, valueList, digitalBase, prevStyle, twoDigitHours). - auto unit_options = TRY(get_duration_unit_options(vm, unit, *options, duration_format->style(), value_list, digital_base, previous_style, two_digit_hours)); + // f. Let unitOptions be ? GetDurationUnitOptions(unit, options, style, valueList, digitalBase, prevStyle, digitalFormat.[[TwoDigitHours]]). + auto unit_options = TRY(get_duration_unit_options(vm, unit, *options, duration_format->style(), value_list, digital_base, previous_style, digital_format.uses_two_digit_hours)); // g. Set the value of the styleSlot slot of durationFormat to unitOptions.[[Style]]. (duration_format->*style_slot)(unit_options.style); @@ -155,14 +143,14 @@ ThrowCompletionOr> DurationFormatConstructor::construct(Function } } - // 26. Set durationFormat.[[FractionalDigits]] to ? GetNumberOption(options, "fractionalDigits", 0, 9, undefined). + // 20. Set durationFormat.[[FractionalDigits]] to ? GetNumberOption(options, "fractionalDigits", 0, 9, undefined). duration_format->set_fractional_digits(Optional(TRY(get_number_option(vm, *options, vm.names.fractionalDigits, 0, 9, {})))); - // 27. Return durationFormat. + // 21. Return durationFormat. return duration_format; } -// 1.3.2 Intl.DurationFormat.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat.supportedLocalesOf +// 13.3.2 Intl.DurationFormat.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-Intl.DurationFormat.supportedLocalesOf JS_DEFINE_NATIVE_FUNCTION(DurationFormatConstructor::supported_locales_of) { auto locales = vm.argument(0); diff --git a/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp b/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp index a4ccc26b3a7..821c78ae2af 100644 --- a/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp +++ b/Libraries/LibJS/Runtime/Intl/DurationFormatPrototype.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2022, Idan Horowitz - * Copyright (c) 2022-2024, Tim Flynn + * Copyright (c) 2022-2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -15,7 +15,7 @@ namespace JS::Intl { GC_DEFINE_ALLOCATOR(DurationFormatPrototype); -// 1.4 Properties of the Intl.DurationFormat Prototype Object, https://tc39.es/proposal-intl-duration-format/#sec-properties-of-intl-durationformat-prototype-object +// 13.4 Properties of the Intl.DurationFormat Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-durationformat-prototype-object DurationFormatPrototype::DurationFormatPrototype(Realm& realm) : PrototypeObject(realm.intrinsics().object_prototype()) { @@ -27,7 +27,7 @@ void DurationFormatPrototype::initialize(Realm& realm) auto& vm = this->vm(); - // 1.4.2 Intl.DurationFormat.prototype [ @@toStringTag ], https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat.prototype-@@tostringtag + // 13.4.2 Intl.DurationFormat.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-Intl.DurationFormat.prototype-@@tostringtag define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.DurationFormat"_string), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; @@ -36,7 +36,7 @@ void DurationFormatPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr); } -// 1.4.3 Intl.DurationFormat.prototype.format ( duration ), https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat.prototype.format +// 13.4.3 Intl.DurationFormat.prototype.format ( duration ), https://tc39.es/ecma402/#sec-Intl.DurationFormat.prototype.format JS_DEFINE_NATIVE_FUNCTION(DurationFormatPrototype::format) { // 1. Let df be this value. @@ -62,7 +62,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationFormatPrototype::format) return PrimitiveString::create(vm, MUST(result.to_string())); } -// 1.4.4 Intl.DurationFormat.prototype.formatToParts ( duration ), https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat.prototype.formatToParts +// 13.4.4 Intl.DurationFormat.prototype.formatToParts ( duration ), https://tc39.es/ecma402/#sec-Intl.DurationFormat.prototype.formatToParts JS_DEFINE_NATIVE_FUNCTION(DurationFormatPrototype::format_to_parts) { auto& realm = *vm.current_realm(); @@ -106,7 +106,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationFormatPrototype::format_to_parts) return result; } -// 1.4.5 Intl.DurationFormat.prototype.resolvedOptions ( ), https://tc39.es/proposal-intl-duration-format/#sec-Intl.DurationFormat.prototype.resolvedOptions +// 13.4.5 Intl.DurationFormat.prototype.resolvedOptions ( ), https://tc39.es/ecma402/#sec-Intl.DurationFormat.prototype.resolvedOptions JS_DEFINE_NATIVE_FUNCTION(DurationFormatPrototype::resolved_options) { auto& realm = *vm.current_realm(); @@ -118,7 +118,7 @@ JS_DEFINE_NATIVE_FUNCTION(DurationFormatPrototype::resolved_options) // 3. Let options be OrdinaryObjectCreate(%Object.prototype%). auto options = Object::create(realm, realm.intrinsics().object_prototype()); - // 4. For each row of Table 4, except the header row, in table order, do + // 4. For each row of Table 23, except the header row, in table order, do auto create_option = [&](PropertyKey const& property, StringView value) { // a. Let p be the Property value of the current row. // b. Let v be the value of df's internal slot whose name is the Internal Slot value of the current row. diff --git a/Libraries/LibJS/Runtime/Intl/ListFormat.cpp b/Libraries/LibJS/Runtime/Intl/ListFormat.cpp index 474529e05ed..e978263bbb8 100644 --- a/Libraries/LibJS/Runtime/Intl/ListFormat.cpp +++ b/Libraries/LibJS/Runtime/Intl/ListFormat.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024, Tim Flynn + * Copyright (c) 2021-2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -15,19 +15,19 @@ namespace JS::Intl { GC_DEFINE_ALLOCATOR(ListFormat); -// 13 ListFormat Objects, https://tc39.es/ecma402/#listformat-objects +// 14 ListFormat Objects, https://tc39.es/ecma402/#listformat-objects ListFormat::ListFormat(Object& prototype) : Object(ConstructWithPrototypeTag::Tag, prototype) { } -// 13.5.2 CreatePartsFromList ( listFormat, list ), https://tc39.es/ecma402/#sec-createpartsfromlist +// 14.5.2 CreatePartsFromList ( listFormat, list ), https://tc39.es/ecma402/#sec-createpartsfromlist Vector create_parts_from_list(ListFormat const& list_format, ReadonlySpan list) { return list_format.formatter().format_to_parts(list); } -// 13.5.3 FormatList ( listFormat, list ), https://tc39.es/ecma402/#sec-formatlist +// 14.5.3 FormatList ( listFormat, list ), https://tc39.es/ecma402/#sec-formatlist String format_list(ListFormat const& list_format, ReadonlySpan list) { // 1. Let parts be ! CreatePartsFromList(listFormat, list). @@ -38,7 +38,7 @@ String format_list(ListFormat const& list_format, ReadonlySpan list) return list_format.formatter().format(list); } -// 13.5.4 FormatListToParts ( listFormat, list ), https://tc39.es/ecma402/#sec-formatlisttoparts +// 14.5.4 FormatListToParts ( listFormat, list ), https://tc39.es/ecma402/#sec-formatlisttoparts GC::Ref format_list_to_parts(VM& vm, ListFormat const& list_format, ReadonlySpan list) { auto& realm = *vm.current_realm(); @@ -74,7 +74,7 @@ GC::Ref format_list_to_parts(VM& vm, ListFormat const& list_format, Reado return result; } -// 13.5.5 StringListFromIterable ( iterable ), https://tc39.es/ecma402/#sec-createstringlistfromiterable +// 14.5.5 StringListFromIterable ( iterable ), https://tc39.es/ecma402/#sec-createstringlistfromiterable ThrowCompletionOr> string_list_from_iterable(VM& vm, Value iterable) { // 1. If iterable is undefined, then diff --git a/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp b/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp index 57aa811c510..1af09d66c4a 100644 --- a/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp +++ b/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024, Tim Flynn + * Copyright (c) 2021-2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -16,7 +16,7 @@ namespace JS::Intl { GC_DEFINE_ALLOCATOR(ListFormatConstructor); -// 13.1 The Intl.ListFormat Constructor, https://tc39.es/ecma402/#sec-intl-listformat-constructor +// 14.1 The Intl.ListFormat Constructor, https://tc39.es/ecma402/#sec-intl-listformat-constructor ListFormatConstructor::ListFormatConstructor(Realm& realm) : NativeFunction(realm.vm().names.ListFormat.as_string(), realm.intrinsics().function_prototype()) { @@ -28,7 +28,7 @@ void ListFormatConstructor::initialize(Realm& realm) auto& vm = this->vm(); - // 13.2.1 Intl.ListFormat.prototype, https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype + // 14.2.1 Intl.ListFormat.prototype, https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype define_direct_property(vm.names.prototype, realm.intrinsics().intl_list_format_prototype(), 0); u8 attr = Attribute::Writable | Attribute::Configurable; @@ -37,14 +37,14 @@ void ListFormatConstructor::initialize(Realm& realm) define_direct_property(vm.names.length, Value(0), Attribute::Configurable); } -// 13.1.1 Intl.ListFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-Intl.ListFormat +// 14.1.1 Intl.ListFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-Intl.ListFormat ThrowCompletionOr ListFormatConstructor::call() { // 1. If NewTarget is undefined, throw a TypeError exception. return vm().throw_completion(ErrorType::ConstructorWithoutNew, "Intl.ListFormat"); } -// 13.1.1 Intl.ListFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-Intl.ListFormat +// 14.1.1 Intl.ListFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-Intl.ListFormat ThrowCompletionOr> ListFormatConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -85,7 +85,7 @@ ThrowCompletionOr> ListFormatConstructor::construct(FunctionObje // 12. Let style be ? GetOption(options, "style", string, « "long", "short", "narrow" », "long"). auto style = TRY(get_option(vm, *options, vm.names.style, OptionType::String, { "long"sv, "short"sv, "narrow"sv }, "long"sv)); - // 13. Set listFormat.[[Style]] to style. + // 14. Set listFormat.[[Style]] to style. list_format->set_style(style.as_string().utf8_string_view()); // 14. Let resolvedLocaleData be r.[[LocaleData]]. @@ -101,7 +101,7 @@ ThrowCompletionOr> ListFormatConstructor::construct(FunctionObje return list_format; } -// 13.2.2 Intl.ListFormat.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-Intl.ListFormat.supportedLocalesOf +// 14.2.2 Intl.ListFormat.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-Intl.ListFormat.supportedLocalesOf JS_DEFINE_NATIVE_FUNCTION(ListFormatConstructor::supported_locales_of) { auto locales = vm.argument(0); diff --git a/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp b/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp index d0305efc054..5d3f6760058 100644 --- a/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp +++ b/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, Tim Flynn + * Copyright (c) 2021-2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -14,7 +14,7 @@ namespace JS::Intl { GC_DEFINE_ALLOCATOR(ListFormatPrototype); -// 13.3 Properties of the Intl.ListFormat Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-listformat-prototype-object +// 14.3 Properties of the Intl.ListFormat Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-listformat-prototype-object ListFormatPrototype::ListFormatPrototype(Realm& realm) : PrototypeObject(realm.intrinsics().object_prototype()) { @@ -26,7 +26,7 @@ void ListFormatPrototype::initialize(Realm& realm) auto& vm = this->vm(); - // 13.3.2 Intl.ListFormat.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype-toStringTag + // 14.3.2 Intl.ListFormat.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype-toStringTag define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.ListFormat"_string), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; @@ -35,7 +35,7 @@ void ListFormatPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr); } -// 13.3.3 Intl.ListFormat.prototype.format ( list ), https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype.format +// 14.3.3 Intl.ListFormat.prototype.format ( list ), https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype.format JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::format) { auto list = vm.argument(0); @@ -52,7 +52,7 @@ JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::format) return PrimitiveString::create(vm, move(formatted)); } -// 13.3.4 Intl.ListFormat.prototype.formatToParts ( list ), https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype.formatToParts +// 14.3.4 Intl.ListFormat.prototype.formatToParts ( list ), https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype.formatToParts JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::format_to_parts) { auto list = vm.argument(0); @@ -68,7 +68,7 @@ JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::format_to_parts) return format_list_to_parts(vm, list_format, string_list); } -// 13.3.5 Intl.ListFormat.prototype.resolvedOptions ( ), https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype.resolvedoptions +// 14.3.5 Intl.ListFormat.prototype.resolvedOptions ( ), https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype.resolvedoptions JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::resolved_options) { auto& realm = *vm.current_realm(); @@ -80,7 +80,7 @@ JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::resolved_options) // 3. Let options be OrdinaryObjectCreate(%Object.prototype%). auto options = Object::create(realm, realm.intrinsics().object_prototype()); - // 4. For each row of Table 10, except the header row, in table order, do + // 4. For each row of Table 24, except the header row, in table order, do // a. Let p be the Property value of the current row. // b. Let v be the value of lf's internal slot whose name is the Internal Slot value of the current row. // c. Assert: v is not undefined. diff --git a/Libraries/LibJS/Runtime/Intl/Locale.cpp b/Libraries/LibJS/Runtime/Intl/Locale.cpp index 14ad97488ae..85a2b641e1a 100644 --- a/Libraries/LibJS/Runtime/Intl/Locale.cpp +++ b/Libraries/LibJS/Runtime/Intl/Locale.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024, Tim Flynn + * Copyright (c) 2021-2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -32,7 +32,7 @@ GC::Ref Locale::create(Realm& realm, GC::Ref source_locale, Stri return locale; } -// 14 Locale Objects, https://tc39.es/ecma402/#locale-objects +// 15 Locale Objects, https://tc39.es/ecma402/#locale-objects Locale::Locale(Object& prototype) : Object(ConstructWithPrototypeTag::Tag, prototype) { diff --git a/Libraries/LibJS/Runtime/Intl/Locale.h b/Libraries/LibJS/Runtime/Intl/Locale.h index 8cc5e1f0fdb..9a04f795151 100644 --- a/Libraries/LibJS/Runtime/Intl/Locale.h +++ b/Libraries/LibJS/Runtime/Intl/Locale.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024, Tim Flynn + * Copyright (c) 2021-2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -27,7 +27,7 @@ public: static constexpr auto relevant_extension_keys() { - // 14.2.2 Internal slots, https://tc39.es/ecma402/#sec-intl.locale-internal-slots + // 15.2.2 Internal slots, https://tc39.es/ecma402/#sec-intl.locale-internal-slots // 1.3.2 Internal slots, https://tc39.es/proposal-intl-locale-info/#sec-intl.locale-internal-slots // The value of the [[RelevantExtensionKeys]] internal slot is « "ca", "co", "fw", "hc", "kf", "kn", "nu" ». // If %Collator%.[[RelevantExtensionKeys]] does not contain "kf", then remove "kf" from %Locale%.[[RelevantExtensionKeys]]. diff --git a/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp b/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp index 15e867645fc..1e90cd919cd 100644 --- a/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp +++ b/Libraries/LibJS/Runtime/Intl/LocaleConstructor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024, Tim Flynn + * Copyright (c) 2021-2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -42,7 +42,7 @@ static ThrowCompletionOr> get_string_option(VM& vm, Object cons return option.as_string().utf8_string(); } -// 14.1.2 ApplyOptionsToTag ( tag, options ), https://tc39.es/ecma402/#sec-apply-options-to-tag +// 15.1.2 ApplyOptionsToTag ( tag, options ), https://tc39.es/ecma402/#sec-apply-options-to-tag static ThrowCompletionOr apply_options_to_tag(VM& vm, StringView tag, Object const& options) { // 1. Assert: Type(tag) is String. @@ -108,7 +108,7 @@ static ThrowCompletionOr apply_options_to_tag(VM& vm, StringView tag, Ob return JS::Intl::canonicalize_unicode_locale_id(canonicalized_tag); } -// 14.1.3 ApplyUnicodeExtensionToTag ( tag, options, relevantExtensionKeys ), https://tc39.es/ecma402/#sec-apply-unicode-extension-to-tag +// 15.1.3 ApplyUnicodeExtensionToTag ( tag, options, relevantExtensionKeys ), https://tc39.es/ecma402/#sec-apply-unicode-extension-to-tag static LocaleAndKeys apply_unicode_extension_to_tag(StringView tag, LocaleAndKeys options, ReadonlySpan relevant_extension_keys) { auto locale_id = Unicode::parse_unicode_locale_id(tag); @@ -218,7 +218,7 @@ static LocaleAndKeys apply_unicode_extension_to_tag(StringView tag, LocaleAndKey return result; } -// 14.1 The Intl.Locale Constructor, https://tc39.es/ecma402/#sec-intl-locale-constructor +// 15.1 The Intl.Locale Constructor, https://tc39.es/ecma402/#sec-intl-locale-constructor LocaleConstructor::LocaleConstructor(Realm& realm) : NativeFunction(realm.vm().names.Locale.as_string(), realm.intrinsics().function_prototype()) { @@ -235,14 +235,14 @@ void LocaleConstructor::initialize(Realm& realm) define_direct_property(vm.names.length, Value(1), Attribute::Configurable); } -// 14.1.1 Intl.Locale ( tag [ , options ] ), https://tc39.es/ecma402/#sec-Intl.Locale +// 15.1.1 Intl.Locale ( tag [ , options ] ), https://tc39.es/ecma402/#sec-Intl.Locale ThrowCompletionOr LocaleConstructor::call() { // 1. If NewTarget is undefined, throw a TypeError exception. return vm().throw_completion(ErrorType::ConstructorWithoutNew, "Intl.Locale"); } -// 14.1.1 Intl.Locale ( tag [ , options ] ), https://tc39.es/ecma402/#sec-Intl.Locale +// 15.1.1 Intl.Locale ( tag [ , options ] ), https://tc39.es/ecma402/#sec-Intl.Locale // 1.2.3 Intl.Locale ( tag [ , options ] ), https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale ThrowCompletionOr> LocaleConstructor::construct(FunctionObject& new_target) { diff --git a/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp b/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp index 76824a90660..c743f5fd1d0 100644 --- a/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp +++ b/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2022, Tim Flynn + * Copyright (c) 2021-2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -15,7 +15,7 @@ namespace JS::Intl { GC_DEFINE_ALLOCATOR(LocalePrototype); -// 14.3 Properties of the Intl.Locale Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-locale-prototype-object +// 15.3 Properties of the Intl.Locale Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-locale-prototype-object LocalePrototype::LocalePrototype(Realm& realm) : PrototypeObject(realm.intrinsics().object_prototype()) { @@ -39,7 +39,7 @@ void LocalePrototype::initialize(Realm& realm) define_native_function(realm, vm.names.getTextInfo, get_text_info, 0, attr); define_native_function(realm, vm.names.getWeekInfo, get_week_info, 0, attr); - // 14.3.2 Intl.Locale.prototype[ @@toStringTag ], https://tc39.es/ecma402/#sec-Intl.Locale.prototype-@@tostringtag + // 15.3.2 Intl.Locale.prototype[ @@toStringTag ], https://tc39.es/ecma402/#sec-Intl.Locale.prototype-@@tostringtag define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.Locale"_string), Attribute::Configurable); define_native_accessor(realm, vm.names.baseName, base_name, {}, Attribute::Configurable); @@ -55,7 +55,7 @@ void LocalePrototype::initialize(Realm& realm) define_native_accessor(realm, vm.names.region, region, {}, Attribute::Configurable); } -// 14.3.3 Intl.Locale.prototype.maximize ( ), https://tc39.es/ecma402/#sec-Intl.Locale.prototype.maximize +// 15.3.3 Intl.Locale.prototype.maximize ( ), https://tc39.es/ecma402/#sec-Intl.Locale.prototype.maximize JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::maximize) { auto& realm = *vm.current_realm(); @@ -71,7 +71,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::maximize) return Locale::create(realm, locale_object, move(maximal)); } -// 14.3.4 Intl.Locale.prototype.minimize ( ), https://tc39.es/ecma402/#sec-Intl.Locale.prototype.minimize +// 15.3.4 Intl.Locale.prototype.minimize ( ), https://tc39.es/ecma402/#sec-Intl.Locale.prototype.minimize JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::minimize) { auto& realm = *vm.current_realm(); @@ -87,7 +87,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::minimize) return Locale::create(realm, locale_object, move(minimal)); } -// 14.3.5 Intl.Locale.prototype.toString ( ), https://tc39.es/ecma402/#sec-Intl.Locale.prototype.toString +// 15.3.5 Intl.Locale.prototype.toString ( ), https://tc39.es/ecma402/#sec-Intl.Locale.prototype.toString JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::to_string) { // 1. Let loc be the this value. @@ -98,7 +98,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::to_string) return PrimitiveString::create(vm, locale_object->locale()); } -// 14.3.6 get Intl.Locale.prototype.baseName, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.baseName +// 15.3.6 get Intl.Locale.prototype.baseName, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.baseName JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::base_name) { // 1. Let loc be the this value. @@ -121,12 +121,12 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::base_name) __JS_ENUMERATE(hour_cycle) \ __JS_ENUMERATE(numbering_system) -// 14.3.7 get Intl.Locale.prototype.calendar, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.calendar -// 14.3.8 get Intl.Locale.prototype.caseFirst, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.caseFirst -// 14.3.9 get Intl.Locale.prototype.collation, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.collation +// 15.3.7 get Intl.Locale.prototype.calendar, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.calendar +// 15.3.8 get Intl.Locale.prototype.caseFirst, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.caseFirst +// 15.3.9 get Intl.Locale.prototype.collation, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.collation // 1.4.10 get Intl.Locale.prototype.firstDayOfWeek, https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.firstDayOfWeek -// 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 +// 15.3.10 get Intl.Locale.prototype.hourCycle, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.hourCycle +// 15.3.12 get Intl.Locale.prototype.numberingSystem, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.numberingSystem #define __JS_ENUMERATE(keyword) \ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::keyword) \ { \ @@ -138,7 +138,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::base_name) JS_ENUMERATE_LOCALE_KEYWORD_PROPERTIES #undef __JS_ENUMERATE -// 14.3.11 get Intl.Locale.prototype.numeric, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.numeric +// 15.3.11 get Intl.Locale.prototype.numeric, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.numeric JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::numeric) { // 1. Let loc be the this value. @@ -149,7 +149,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::numeric) return Value(locale_object->numeric()); } -// 14.3.13 get Intl.Locale.prototype.language, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.language +// 15.3.13 get Intl.Locale.prototype.language, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.language JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::language) { // 1. Let loc be the this value. @@ -166,7 +166,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::language) return PrimitiveString::create(vm, locale->language_id.language.release_value()); } -// 14.3.14 get Intl.Locale.prototype.script, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.script +// 15.3.14 get Intl.Locale.prototype.script, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.script JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::script) { // 1. Let loc be the this value. @@ -187,7 +187,7 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::script) return PrimitiveString::create(vm, locale->language_id.script.release_value()); } -// 14.3.15 get Intl.Locale.prototype.region, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.region +// 15.3.15 get Intl.Locale.prototype.region, https://tc39.es/ecma402/#sec-Intl.Locale.prototype.region JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::region) { // 1. Let loc be the this value. diff --git a/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp b/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp index b79cb931905..27af81036ee 100644 --- a/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp +++ b/Libraries/LibJS/Runtime/Intl/NumberFormat.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024, Tim Flynn + * Copyright (c) 2021-2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -31,7 +31,7 @@ NumberFormatBase::NumberFormatBase(Object& prototype) { } -// 15 NumberFormat Objects, https://tc39.es/ecma402/#numberformat-objects +// 16 NumberFormat Objects, https://tc39.es/ecma402/#numberformat-objects NumberFormat::NumberFormat(Object& prototype) : NumberFormatBase(prototype) { @@ -115,7 +115,7 @@ Unicode::DisplayOptions NumberFormat::display_options() const }; } -// 15.5.1 CurrencyDigits ( currency ), https://tc39.es/ecma402/#sec-currencydigits +// 16.5.1 CurrencyDigits ( currency ), https://tc39.es/ecma402/#sec-currencydigits int currency_digits(StringView currency) { // 1. If the ISO 4217 currency and funds code list contains currency as an alphabetic code, return the minor @@ -125,19 +125,19 @@ int currency_digits(StringView currency) return 2; } -// 15.5.3 FormatNumericToString ( intlObject, x ), https://tc39.es/ecma402/#sec-formatnumberstring +// 16.5.3 FormatNumericToString ( intlObject, x ), https://tc39.es/ecma402/#sec-formatnumberstring String format_numeric_to_string(NumberFormatBase const& intl_object, MathematicalValue const& number) { return intl_object.formatter().format_to_decimal(number.to_value()); } -// 15.5.4 PartitionNumberPattern ( numberFormat, x ), https://tc39.es/ecma402/#sec-partitionnumberpattern +// 16.5.4 PartitionNumberPattern ( numberFormat, x ), https://tc39.es/ecma402/#sec-partitionnumberpattern Vector partition_number_pattern(NumberFormat const& number_format, MathematicalValue const& number) { return number_format.formatter().format_to_parts(number.to_value()); } -// 15.5.6 FormatNumeric ( numberFormat, x ), https://tc39.es/ecma402/#sec-formatnumber +// 16.5.6 FormatNumeric ( numberFormat, x ), https://tc39.es/ecma402/#sec-formatnumber String format_numeric(NumberFormat const& number_format, MathematicalValue const& number) { // 1. Let parts be ? PartitionNumberPattern(numberFormat, x). @@ -148,7 +148,7 @@ String format_numeric(NumberFormat const& number_format, MathematicalValue const return number_format.formatter().format(number.to_value()); } -// 15.5.7 FormatNumericToParts ( numberFormat, x ), https://tc39.es/ecma402/#sec-formatnumbertoparts +// 16.5.7 FormatNumericToParts ( numberFormat, x ), https://tc39.es/ecma402/#sec-formatnumbertoparts GC::Ref format_numeric_to_parts(VM& vm, NumberFormat const& number_format, MathematicalValue const& number) { auto& realm = *vm.current_realm(); @@ -184,7 +184,7 @@ GC::Ref format_numeric_to_parts(VM& vm, NumberFormat const& number_format return result; } -// 15.5.16 ToIntlMathematicalValue ( value ), https://tc39.es/ecma402/#sec-tointlmathematicalvalue +// 16.5.16 ToIntlMathematicalValue ( value ), https://tc39.es/ecma402/#sec-tointlmathematicalvalue ThrowCompletionOr to_intl_mathematical_value(VM& vm, Value value) { // 1. Let primValue be ? ToPrimitive(value, number). @@ -231,7 +231,7 @@ ThrowCompletionOr to_intl_mathematical_value(VM& vm, Value va return string; } -// 15.5.19 PartitionNumberRangePattern ( numberFormat, x, y ), https://tc39.es/ecma402/#sec-partitionnumberrangepattern +// 16.5.19 PartitionNumberRangePattern ( numberFormat, x, y ), https://tc39.es/ecma402/#sec-partitionnumberrangepattern ThrowCompletionOr> partition_number_range_pattern(VM& vm, NumberFormat const& number_format, MathematicalValue const& start, MathematicalValue const& end) { // 1. If x is NaN or y is NaN, throw a RangeError exception. @@ -243,7 +243,7 @@ ThrowCompletionOr> partition_number_ran return number_format.formatter().format_range_to_parts(start.to_value(), end.to_value()); } -// 15.5.22 FormatNumericRange ( numberFormat, x, y ), https://tc39.es/ecma402/#sec-formatnumericrange +// 16.5.22 FormatNumericRange ( numberFormat, x, y ), https://tc39.es/ecma402/#sec-formatnumericrange ThrowCompletionOr format_numeric_range(VM& vm, NumberFormat const& number_format, MathematicalValue const& start, MathematicalValue const& end) { // 1. Let parts be ? PartitionNumberRangePattern(numberFormat, x, y). @@ -265,7 +265,7 @@ ThrowCompletionOr format_numeric_range(VM& vm, NumberFormat const& numbe return number_format.formatter().format_range(start.to_value(), end.to_value()); } -// 15.5.23 FormatNumericRangeToParts ( numberFormat, x, y ), https://tc39.es/ecma402/#sec-formatnumericrangetoparts +// 16.5.23 FormatNumericRangeToParts ( numberFormat, x, y ), https://tc39.es/ecma402/#sec-formatnumericrangetoparts ThrowCompletionOr> format_numeric_range_to_parts(VM& vm, NumberFormat const& number_format, MathematicalValue const& start, MathematicalValue const& end) { auto& realm = *vm.current_realm(); diff --git a/Libraries/LibJS/Runtime/Intl/NumberFormat.h b/Libraries/LibJS/Runtime/Intl/NumberFormat.h index faf4a1c0206..d9811e6ae16 100644 --- a/Libraries/LibJS/Runtime/Intl/NumberFormat.h +++ b/Libraries/LibJS/Runtime/Intl/NumberFormat.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024, Tim Flynn + * Copyright (c) 2021-2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -104,7 +104,7 @@ class NumberFormat final : public NumberFormatBase { public: static constexpr auto relevant_extension_keys() { - // 15.2.3 Internal slots, https://tc39.es/ecma402/#sec-intl.numberformat-internal-slots + // 16.2.3 Internal slots, https://tc39.es/ecma402/#sec-intl.numberformat-internal-slots // The value of the [[RelevantExtensionKeys]] internal slot is « "nu" ». return AK::Array { "nu"sv }; } diff --git a/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp b/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp index 49b2a9253b3..61cd635a423 100644 --- a/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp +++ b/Libraries/LibJS/Runtime/Intl/NumberFormatConstructor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024, Tim Flynn + * Copyright (c) 2021-2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -15,7 +15,7 @@ namespace JS::Intl { GC_DEFINE_ALLOCATOR(NumberFormatConstructor); -// 15.1 The Intl.NumberFormat Constructor, https://tc39.es/ecma402/#sec-intl-numberformat-constructor +// 16.1 The Intl.NumberFormat Constructor, https://tc39.es/ecma402/#sec-intl-numberformat-constructor NumberFormatConstructor::NumberFormatConstructor(Realm& realm) : NativeFunction(realm.vm().names.NumberFormat.as_string(), realm.intrinsics().function_prototype()) { @@ -27,7 +27,7 @@ void NumberFormatConstructor::initialize(Realm& realm) auto& vm = this->vm(); - // 15.2.1 Intl.NumberFormat.prototype, https://tc39.es/ecma402/#sec-intl.numberformat.prototype + // 16.2.1 Intl.NumberFormat.prototype, https://tc39.es/ecma402/#sec-intl.numberformat.prototype define_direct_property(vm.names.prototype, realm.intrinsics().intl_number_format_prototype(), 0); u8 attr = Attribute::Writable | Attribute::Configurable; @@ -36,14 +36,14 @@ void NumberFormatConstructor::initialize(Realm& realm) define_direct_property(vm.names.length, Value(0), Attribute::Configurable); } -// 15.1.1 Intl.NumberFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.numberformat +// 16.1.1 Intl.NumberFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.numberformat ThrowCompletionOr NumberFormatConstructor::call() { // 1. If NewTarget is undefined, let newTarget be the active function object, else let newTarget be NewTarget. return TRY(construct(*this)); } -// 15.1.1 Intl.NumberFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.numberformat +// 16.1.1 Intl.NumberFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.numberformat ThrowCompletionOr> NumberFormatConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -194,7 +194,7 @@ ThrowCompletionOr> NumberFormatConstructor::construct(FunctionOb return number_format; } -// 15.1.2 SetNumberFormatDigitOptions ( intlObj, options, mnfdDefault, mxfdDefault, notation ), https://tc39.es/ecma402/#sec-setnfdigitoptions +// 16.1.2 SetNumberFormatDigitOptions ( intlObj, options, mnfdDefault, mxfdDefault, notation ), https://tc39.es/ecma402/#sec-setnfdigitoptions ThrowCompletionOr set_number_format_digit_options(VM& vm, NumberFormatBase& intl_object, Object const& options, int default_min_fraction_digits, int default_max_fraction_digits, Unicode::Notation notation) { // 1. Let mnid be ? GetNumberOption(options, "minimumIntegerDigits,", 1, 21, 1). @@ -399,7 +399,7 @@ ThrowCompletionOr set_number_format_digit_options(VM& vm, NumberFormatBase return {}; } -// 15.1.3 SetNumberFormatUnitOptions ( intlObj, options ), https://tc39.es/ecma402/#sec-setnumberformatunitoptions +// 16.1.3 SetNumberFormatUnitOptions ( intlObj, options ), https://tc39.es/ecma402/#sec-setnumberformatunitoptions ThrowCompletionOr set_number_format_unit_options(VM& vm, NumberFormat& intl_object, Object const& options) { // 1. Let style be ? GetOption(options, "style", string, « "decimal", "percent", "currency", "unit" », "decimal"). @@ -472,7 +472,7 @@ ThrowCompletionOr set_number_format_unit_options(VM& vm, NumberFormat& int return {}; } -// 15.2.2 Intl.NumberFormat.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-intl.numberformat.supportedlocalesof +// 16.2.2 Intl.NumberFormat.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-intl.numberformat.supportedlocalesof JS_DEFINE_NATIVE_FUNCTION(NumberFormatConstructor::supported_locales_of) { auto locales = vm.argument(0); diff --git a/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp b/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp index 37eaf4b438e..6634597f49b 100644 --- a/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp +++ b/Libraries/LibJS/Runtime/Intl/NumberFormatFunction.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2024, Tim Flynn + * Copyright (c) 2021-2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -12,7 +12,7 @@ namespace JS::Intl { GC_DEFINE_ALLOCATOR(NumberFormatFunction); -// 15.5.2 Number Format Functions, https://tc39.es/ecma402/#sec-number-format-functions +// 16.5.2 Number Format Functions, https://tc39.es/ecma402/#sec-number-format-functions GC::Ref NumberFormatFunction::create(Realm& realm, NumberFormat& number_format) { return realm.create(number_format, realm.intrinsics().function_prototype()); diff --git a/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp b/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp index c70d5251071..29f10418ed7 100644 --- a/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp +++ b/Libraries/LibJS/Runtime/Intl/NumberFormatPrototype.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021-2023, Tim Flynn + * Copyright (c) 2021-2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -15,7 +15,7 @@ namespace JS::Intl { GC_DEFINE_ALLOCATOR(NumberFormatPrototype); -// 15.3 Properties of the Intl.NumberFormat Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-numberformat-prototype-object +// 16.3 Properties of the Intl.NumberFormat Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-numberformat-prototype-object NumberFormatPrototype::NumberFormatPrototype(Realm& realm) : PrototypeObject(realm.intrinsics().object_prototype()) { @@ -27,7 +27,7 @@ void NumberFormatPrototype::initialize(Realm& realm) auto& vm = this->vm(); - // 15.3.2 Intl.NumberFormat.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-intl.numberformat.prototype-@@tostringtag + // 16.3.2 Intl.NumberFormat.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-intl.numberformat.prototype-@@tostringtag define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.NumberFormat"_string), Attribute::Configurable); define_native_accessor(realm, vm.names.format, format, nullptr, Attribute::Configurable); @@ -39,7 +39,7 @@ void NumberFormatPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr); } -// 15.3.3 get Intl.NumberFormat.prototype.format, https://tc39.es/ecma402/#sec-intl.numberformat.prototype.format +// 16.3.3 get Intl.NumberFormat.prototype.format, https://tc39.es/ecma402/#sec-intl.numberformat.prototype.format JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::format) { auto& realm = *vm.current_realm(); @@ -52,7 +52,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::format) // 4. If nf.[[BoundFormat]] is undefined, then if (!number_format->bound_format()) { - // a. Let F be a new built-in function object as defined in Number Format Functions (15.1.4). + // a. Let F be a new built-in function object as defined in Number Format Functions (16.1.4). // b. Set F.[[NumberFormat]] to nf. auto bound_format = NumberFormatFunction::create(realm, number_format); @@ -64,7 +64,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::format) return number_format->bound_format(); } -// 15.3.4 Intl.NumberFormat.prototype.formatToParts ( value ), https://tc39.es/ecma402/#sec-intl.numberformat.prototype.formattoparts +// 16.3.4 Intl.NumberFormat.prototype.formatToParts ( value ), https://tc39.es/ecma402/#sec-intl.numberformat.prototype.formattoparts JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::format_to_parts) { auto value = vm.argument(0); @@ -80,7 +80,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::format_to_parts) return format_numeric_to_parts(vm, number_format, move(mathematical_value)); } -// 15.3.5 Intl.NumberFormat.prototype.formatRange ( start, end ), https://tc39.es/ecma402/#sec-intl.numberformat.prototype.formatrange +// 16.3.5 Intl.NumberFormat.prototype.formatRange ( start, end ), https://tc39.es/ecma402/#sec-intl.numberformat.prototype.formatrange JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::format_range) { auto start = vm.argument(0); @@ -107,7 +107,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::format_range) return PrimitiveString::create(vm, move(formatted)); } -// 15.3.6 Intl.NumberFormat.prototype.formatRangeToParts ( start, end ), https://tc39.es/ecma402/#sec-intl.numberformat.prototype.formatrangetoparts +// 16.3.6 Intl.NumberFormat.prototype.formatRangeToParts ( start, end ), https://tc39.es/ecma402/#sec-intl.numberformat.prototype.formatrangetoparts JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::format_range_to_parts) { auto start = vm.argument(0); @@ -133,7 +133,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::format_range_to_parts) return TRY(format_numeric_range_to_parts(vm, number_format, move(x), move(y))); } -// 15.3.7 Intl.NumberFormat.prototype.resolvedOptions ( ), https://tc39.es/ecma402/#sec-intl.numberformat.prototype.resolvedoptions +// 16.3.7 Intl.NumberFormat.prototype.resolvedOptions ( ), https://tc39.es/ecma402/#sec-intl.numberformat.prototype.resolvedoptions JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::resolved_options) { auto& realm = *vm.current_realm(); @@ -147,7 +147,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberFormatPrototype::resolved_options) // 4. Let options be OrdinaryObjectCreate(%Object.prototype%). auto options = Object::create(realm, realm.intrinsics().object_prototype()); - // 5. For each row of Table 11, except the header row, in table order, do + // 5. For each row of Table 25, except the header row, in table order, do // a. Let p be the Property value of the current row. // b. Let v be the value of nf's internal slot whose name is the Internal Slot value of the current row. // c. If v is not undefined, then diff --git a/Libraries/LibJS/Runtime/Intl/PluralRules.cpp b/Libraries/LibJS/Runtime/Intl/PluralRules.cpp index e88aa94dd76..c45abd30668 100644 --- a/Libraries/LibJS/Runtime/Intl/PluralRules.cpp +++ b/Libraries/LibJS/Runtime/Intl/PluralRules.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024, Tim Flynn + * Copyright (c) 2022-2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -10,13 +10,13 @@ namespace JS::Intl { GC_DEFINE_ALLOCATOR(PluralRules); -// 16 PluralRules Objects, https://tc39.es/ecma402/#pluralrules-objects +// 17 PluralRules Objects, https://tc39.es/ecma402/#pluralrules-objects PluralRules::PluralRules(Object& prototype) : NumberFormatBase(prototype) { } -// 16.5.2 ResolvePlural ( pluralRules, n ), https://tc39.es/ecma402/#sec-resolveplural +// 17.5.2 ResolvePlural ( pluralRules, n ), https://tc39.es/ecma402/#sec-resolveplural Unicode::PluralCategory resolve_plural(PluralRules const& plural_rules, Value number) { // 1. If n is not a finite Number, then @@ -35,7 +35,7 @@ Unicode::PluralCategory resolve_plural(PluralRules const& plural_rules, Value nu return plural_rules.formatter().select_plural(number.as_double()); } -// 16.5.4 ResolvePluralRange ( pluralRules, x, y ), https://tc39.es/ecma402/#sec-resolveplural +// 17.5.4 ResolvePluralRange ( pluralRules, x, y ), https://tc39.es/ecma402/#sec-resolveplural ThrowCompletionOr resolve_plural_range(VM& vm, PluralRules const& plural_rules, Value start, Value end) { // 1. If x is NaN or y is NaN, throw a RangeError exception. diff --git a/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp b/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp index 3c38ccfbec7..df0a4aaf63a 100644 --- a/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp +++ b/Libraries/LibJS/Runtime/Intl/PluralRulesConstructor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024, Tim Flynn + * Copyright (c) 2022-2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -17,7 +17,7 @@ namespace JS::Intl { GC_DEFINE_ALLOCATOR(PluralRulesConstructor); -// 16.1 The Intl.PluralRules Constructor, https://tc39.es/ecma402/#sec-intl-pluralrules-constructor +// 17.1 The Intl.PluralRules Constructor, https://tc39.es/ecma402/#sec-intl-pluralrules-constructor PluralRulesConstructor::PluralRulesConstructor(Realm& realm) : NativeFunction(realm.vm().names.PluralRules.as_string(), realm.intrinsics().function_prototype()) { @@ -29,7 +29,7 @@ void PluralRulesConstructor::initialize(Realm& realm) auto& vm = this->vm(); - // 16.2.1 Intl.PluralRules.prototype, https://tc39.es/ecma402/#sec-intl.pluralrules.prototype + // 17.2.1 Intl.PluralRules.prototype, https://tc39.es/ecma402/#sec-intl.pluralrules.prototype define_direct_property(vm.names.prototype, realm.intrinsics().intl_plural_rules_prototype(), 0); define_direct_property(vm.names.length, Value(0), Attribute::Configurable); @@ -37,14 +37,14 @@ void PluralRulesConstructor::initialize(Realm& realm) define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr); } -// 16.1.1 Intl.PluralRules ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.pluralrules +// 17.1.1 Intl.PluralRules ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.pluralrules ThrowCompletionOr PluralRulesConstructor::call() { // 1. If NewTarget is undefined, throw a TypeError exception. return vm().throw_completion(ErrorType::ConstructorWithoutNew, "Intl.PluralRules"); } -// 16.1.1 Intl.PluralRules ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.pluralrules +// 17.1.1 Intl.PluralRules ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.pluralrules ThrowCompletionOr> PluralRulesConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -99,7 +99,7 @@ ThrowCompletionOr> PluralRulesConstructor::construct(FunctionObj return plural_rules; } -// 16.2.2 Intl.PluralRules.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-intl.pluralrules.supportedlocalesof +// 17.2.2 Intl.PluralRules.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-intl.pluralrules.supportedlocalesof JS_DEFINE_NATIVE_FUNCTION(PluralRulesConstructor::supported_locales_of) { auto locales = vm.argument(0); diff --git a/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp b/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp index 00e0283fae0..ff821d05032 100644 --- a/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp +++ b/Libraries/LibJS/Runtime/Intl/PluralRulesPrototype.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024, Tim Flynn + * Copyright (c) 2022-2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -15,7 +15,7 @@ namespace JS::Intl { GC_DEFINE_ALLOCATOR(PluralRulesPrototype); -// 16.3 Properties of the Intl.PluralRules Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-pluralrules-prototype-object +// 17.3 Properties of the Intl.PluralRules Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-pluralrules-prototype-object PluralRulesPrototype::PluralRulesPrototype(Realm& realm) : PrototypeObject(realm.intrinsics().object_prototype()) { @@ -27,7 +27,7 @@ void PluralRulesPrototype::initialize(Realm& realm) auto& vm = this->vm(); - // 16.3.2 Intl.PluralRules.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-intl.pluralrules.prototype-tostringtag + // 17.3.2 Intl.PluralRules.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-intl.pluralrules.prototype-tostringtag define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.PluralRules"_string), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; @@ -36,7 +36,7 @@ void PluralRulesPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr); } -// 16.3.3 Intl.PluralRules.prototype.select ( value ), https://tc39.es/ecma402/#sec-intl.pluralrules.prototype.select +// 17.3.3 Intl.PluralRules.prototype.select ( value ), https://tc39.es/ecma402/#sec-intl.pluralrules.prototype.select JS_DEFINE_NATIVE_FUNCTION(PluralRulesPrototype::select) { // 1. Let pr be the this value. @@ -51,7 +51,7 @@ JS_DEFINE_NATIVE_FUNCTION(PluralRulesPrototype::select) return PrimitiveString::create(vm, Unicode::plural_category_to_string(plurality)); } -// 16.3.4 Intl.PluralRules.prototype.selectRange ( start, end ), https://tc39.es/ecma402/#sec-intl.pluralrules.prototype.selectrange +// 17.3.4 Intl.PluralRules.prototype.selectRange ( start, end ), https://tc39.es/ecma402/#sec-intl.pluralrules.prototype.selectrange JS_DEFINE_NATIVE_FUNCTION(PluralRulesPrototype::select_range) { auto start = vm.argument(0); @@ -78,7 +78,7 @@ JS_DEFINE_NATIVE_FUNCTION(PluralRulesPrototype::select_range) return PrimitiveString::create(vm, Unicode::plural_category_to_string(plurality)); } -// 16.3.5 Intl.PluralRules.prototype.resolvedOptions ( ), https://tc39.es/ecma402/#sec-intl.pluralrules.prototype.resolvedoptions +// 17.3.5 Intl.PluralRules.prototype.resolvedOptions ( ), https://tc39.es/ecma402/#sec-intl.pluralrules.prototype.resolvedoptions JS_DEFINE_NATIVE_FUNCTION(PluralRulesPrototype::resolved_options) { auto& realm = *vm.current_realm(); @@ -98,7 +98,7 @@ JS_DEFINE_NATIVE_FUNCTION(PluralRulesPrototype::resolved_options) return PrimitiveString::create(vm, Unicode::plural_category_to_string(category)); }); - // 5. For each row of Table 16, except the header row, in table order, do + // 5. For each row of Table 29, except the header row, in table order, do // a. Let p be the Property value of the current row. // b. If p is "pluralCategories", then // i. Let v be CreateArrayFromList(pluralCategories). diff --git a/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.cpp b/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.cpp index d552c608468..4c2a846c730 100644 --- a/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.cpp +++ b/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024, Tim Flynn + * Copyright (c) 2022-2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -18,13 +18,13 @@ namespace JS::Intl { GC_DEFINE_ALLOCATOR(RelativeTimeFormat); -// 17 RelativeTimeFormat Objects, https://tc39.es/ecma402/#relativetimeformat-objects +// 18 RelativeTimeFormat Objects, https://tc39.es/ecma402/#relativetimeformat-objects RelativeTimeFormat::RelativeTimeFormat(Object& prototype) : Object(ConstructWithPrototypeTag::Tag, prototype) { } -// 17.5.1 SingularRelativeTimeUnit ( unit ), https://tc39.es/ecma402/#sec-singularrelativetimeunit +// 18.5.1 SingularRelativeTimeUnit ( unit ), https://tc39.es/ecma402/#sec-singularrelativetimeunit ThrowCompletionOr singular_relative_time_unit(VM& vm, StringView unit) { // 1. If unit is "seconds", return "second". @@ -59,7 +59,7 @@ ThrowCompletionOr singular_relative_time_unit(VM& vm, StringV return vm.throw_completion(ErrorType::IntlInvalidUnit, unit); } -// 17.5.2 PartitionRelativeTimePattern ( relativeTimeFormat, value, unit ), https://tc39.es/ecma402/#sec-PartitionRelativeTimePattern +// 18.5.2 PartitionRelativeTimePattern ( relativeTimeFormat, value, unit ), https://tc39.es/ecma402/#sec-PartitionRelativeTimePattern ThrowCompletionOr> partition_relative_time_pattern(VM& vm, RelativeTimeFormat& relative_time_format, double value, StringView unit) { // 1. If value is NaN, +∞𝔽, or -∞𝔽, throw a RangeError exception. @@ -72,7 +72,7 @@ ThrowCompletionOr> partition_rela return relative_time_format.formatter().format_to_parts(value, time_unit, relative_time_format.numeric()); } -// 17.5.4 FormatRelativeTime ( relativeTimeFormat, value, unit ), https://tc39.es/ecma402/#sec-FormatRelativeTime +// 18.5.4 FormatRelativeTime ( relativeTimeFormat, value, unit ), https://tc39.es/ecma402/#sec-FormatRelativeTime ThrowCompletionOr format_relative_time(VM& vm, RelativeTimeFormat& relative_time_format, double value, StringView unit) { // 1. Let parts be ? PartitionRelativeTimePattern(relativeTimeFormat, value, unit). @@ -95,7 +95,7 @@ ThrowCompletionOr format_relative_time(VM& vm, RelativeTimeFormat& relat return relative_time_format.formatter().format(value, time_unit, relative_time_format.numeric()); } -// 17.5.5 FormatRelativeTimeToParts ( relativeTimeFormat, value, unit ), https://tc39.es/ecma402/#sec-FormatRelativeTimeToParts +// 18.5.5 FormatRelativeTimeToParts ( relativeTimeFormat, value, unit ), https://tc39.es/ecma402/#sec-FormatRelativeTimeToParts ThrowCompletionOr> format_relative_time_to_parts(VM& vm, RelativeTimeFormat& relative_time_format, double value, StringView unit) { auto& realm = *vm.current_realm(); diff --git a/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.h b/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.h index 306871d80c3..cd2c73d6d71 100644 --- a/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.h +++ b/Libraries/LibJS/Runtime/Intl/RelativeTimeFormat.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024, Tim Flynn + * Copyright (c) 2022-2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -25,7 +25,7 @@ class RelativeTimeFormat final : public Object { public: static constexpr auto relevant_extension_keys() { - // 17.2.3 Internal slots, https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat-internal-slots + // 18.2.3 Internal slots, https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat-internal-slots // The value of the [[RelevantExtensionKeys]] internal slot is « "nu" ». return AK::Array { "nu"sv }; } diff --git a/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp b/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp index fbe8a5ef2c4..6d47a3c010a 100644 --- a/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp +++ b/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatConstructor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024, Tim Flynn + * Copyright (c) 2022-2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -16,7 +16,7 @@ namespace JS::Intl { GC_DEFINE_ALLOCATOR(RelativeTimeFormatConstructor); -// 17.1 The Intl.RelativeTimeFormat Constructor, https://tc39.es/ecma402/#sec-intl-relativetimeformat-constructor +// 18.1 The Intl.RelativeTimeFormat Constructor, https://tc39.es/ecma402/#sec-intl-relativetimeformat-constructor RelativeTimeFormatConstructor::RelativeTimeFormatConstructor(Realm& realm) : NativeFunction(realm.vm().names.RelativeTimeFormat.as_string(), realm.intrinsics().function_prototype()) { @@ -28,7 +28,7 @@ void RelativeTimeFormatConstructor::initialize(Realm& realm) auto& vm = this->vm(); - // 17.2.1 Intl.RelativeTimeFormat.prototype, https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.prototype + // 18.2.1 Intl.RelativeTimeFormat.prototype, https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.prototype define_direct_property(vm.names.prototype, realm.intrinsics().intl_relative_time_format_prototype(), 0); define_direct_property(vm.names.length, Value(0), Attribute::Configurable); @@ -36,14 +36,14 @@ void RelativeTimeFormatConstructor::initialize(Realm& realm) define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr); } -// 17.1.1 Intl.RelativeTimeFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat +// 18.1.1 Intl.RelativeTimeFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat ThrowCompletionOr RelativeTimeFormatConstructor::call() { // 1. If NewTarget is undefined, throw a TypeError exception. return vm().throw_completion(ErrorType::ConstructorWithoutNew, "Intl.RelativeTimeFormat"); } -// 17.1.1 Intl.RelativeTimeFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat +// 18.1.1 Intl.RelativeTimeFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat ThrowCompletionOr> RelativeTimeFormatConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -120,7 +120,7 @@ ThrowCompletionOr> RelativeTimeFormatConstructor::construct(Func return relative_time_format; } -// 17.2.2 Intl.RelativeTimeFormat.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.supportedLocalesOf +// 18.2.2 Intl.RelativeTimeFormat.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.supportedLocalesOf JS_DEFINE_NATIVE_FUNCTION(RelativeTimeFormatConstructor::supported_locales_of) { auto locales = vm.argument(0); diff --git a/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp b/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp index 2c05df12931..f12a18e48f7 100644 --- a/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp +++ b/Libraries/LibJS/Runtime/Intl/RelativeTimeFormatPrototype.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Tim Flynn + * Copyright (c) 2022-2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -13,7 +13,7 @@ namespace JS::Intl { GC_DEFINE_ALLOCATOR(RelativeTimeFormatPrototype); -// 17.3 Properties of the Intl.RelativeTimeFormat Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-relativetimeformat-prototype-object +// 18.3 Properties of the Intl.RelativeTimeFormat Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-relativetimeformat-prototype-object RelativeTimeFormatPrototype::RelativeTimeFormatPrototype(Realm& realm) : PrototypeObject(realm.intrinsics().object_prototype()) { @@ -25,7 +25,7 @@ void RelativeTimeFormatPrototype::initialize(Realm& realm) auto& vm = this->vm(); - // 17.3.2 Intl.RelativeTimeFormat.prototype[ @@toStringTag ], https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.prototype-toStringTag + // 18.3.2 Intl.RelativeTimeFormat.prototype[ @@toStringTag ], https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.prototype-toStringTag define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.RelativeTimeFormat"_string), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; @@ -34,7 +34,7 @@ void RelativeTimeFormatPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.resolvedOptions, resolved_options, 0, attr); } -// 17.3.3 Intl.RelativeTimeFormat.prototype.format ( value, unit ), https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.prototype.format +// 18.3.3 Intl.RelativeTimeFormat.prototype.format ( value, unit ), https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.prototype.format JS_DEFINE_NATIVE_FUNCTION(RelativeTimeFormatPrototype::format) { // 1. Let relativeTimeFormat be the this value. @@ -52,7 +52,7 @@ JS_DEFINE_NATIVE_FUNCTION(RelativeTimeFormatPrototype::format) return PrimitiveString::create(vm, move(formatted)); } -// 17.3.4 Intl.RelativeTimeFormat.prototype.formatToParts ( value, unit ), https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.prototype.formatToParts +// 18.3.4 Intl.RelativeTimeFormat.prototype.formatToParts ( value, unit ), https://tc39.es/ecma402/#sec-Intl.RelativeTimeFormat.prototype.formatToParts JS_DEFINE_NATIVE_FUNCTION(RelativeTimeFormatPrototype::format_to_parts) { // 1. Let relativeTimeFormat be the this value. @@ -69,7 +69,7 @@ JS_DEFINE_NATIVE_FUNCTION(RelativeTimeFormatPrototype::format_to_parts) return TRY(format_relative_time_to_parts(vm, relative_time_format, value.as_double(), unit.bytes_as_string_view())); } -// 17.3.5 Intl.RelativeTimeFormat.prototype.resolvedOptions ( ), https://tc39.es/ecma402/#sec-intl.relativetimeformat.prototype.resolvedoptions +// 18.3.5 Intl.RelativeTimeFormat.prototype.resolvedOptions ( ), https://tc39.es/ecma402/#sec-intl.relativetimeformat.prototype.resolvedoptions JS_DEFINE_NATIVE_FUNCTION(RelativeTimeFormatPrototype::resolved_options) { auto& realm = *vm.current_realm(); @@ -81,7 +81,7 @@ JS_DEFINE_NATIVE_FUNCTION(RelativeTimeFormatPrototype::resolved_options) // 3. Let options be OrdinaryObjectCreate(%Object.prototype%). auto options = Object::create(realm, realm.intrinsics().object_prototype()); - // 4. For each row of Table 15, except the header row, in table order, do + // 4. For each row of Table 30, except the header row, in table order, do // a. Let p be the Property value of the current row. // b. Let v be the value of relativeTimeFormat's internal slot whose name is the Internal Slot value of the current row. // c. Assert: v is not undefined. diff --git a/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp b/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp index fcd9bbec8af..cfad1f5346e 100644 --- a/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp +++ b/Libraries/LibJS/Runtime/Intl/SegmentIterator.cpp @@ -12,7 +12,7 @@ namespace JS::Intl { GC_DEFINE_ALLOCATOR(SegmentIterator); -// 18.6.1 CreateSegmentIterator ( segmenter, string ), https://tc39.es/ecma402/#sec-createsegmentsobject +// 19.6.1 CreateSegmentIterator ( segmenter, string ), https://tc39.es/ecma402/#sec-createsegmentsobject GC::Ref SegmentIterator::create(Realm& realm, Unicode::Segmenter const& segmenter, Utf16View const& string, Segments const& segments) { // 1. Let internalSlotsList be « [[IteratingSegmenter]], [[IteratedString]], [[IteratedStringNextSegmentCodeUnitIndex]] ». @@ -24,7 +24,7 @@ GC::Ref SegmentIterator::create(Realm& realm, Unicode::Segmente return realm.create(realm, segmenter, string, segments); } -// 18.6 Segment Iterator Objects, https://tc39.es/ecma402/#sec-segment-iterator-objects +// 19.6 Segment Iterator Objects, https://tc39.es/ecma402/#sec-segment-iterator-objects SegmentIterator::SegmentIterator(Realm& realm, Unicode::Segmenter const& segmenter, Utf16View const& string, Segments const& segments) : Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().intl_segment_iterator_prototype()) , m_iterating_segmenter(segmenter.clone()) diff --git a/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.cpp b/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.cpp index 6a58857e7bd..a4650d469b9 100644 --- a/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.cpp +++ b/Libraries/LibJS/Runtime/Intl/SegmentIteratorPrototype.cpp @@ -14,7 +14,7 @@ namespace JS::Intl { GC_DEFINE_ALLOCATOR(SegmentIteratorPrototype); -// 18.6.2 The %SegmentIteratorPrototype% Object, https://tc39.es/ecma402/#sec-%segmentiteratorprototype%-object +// 19.6.2 The %SegmentIteratorPrototype% Object, https://tc39.es/ecma402/#sec-%segmentiteratorprototype%-object SegmentIteratorPrototype::SegmentIteratorPrototype(Realm& realm) : PrototypeObject(realm.intrinsics().iterator_prototype()) { @@ -26,14 +26,14 @@ void SegmentIteratorPrototype::initialize(Realm& realm) auto& vm = this->vm(); - // 18.6.2.2 %SegmentIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma402/#sec-%segmentiteratorprototype%.@@tostringtag + // 19.6.2.2 %SegmentIteratorPrototype% [ @@toStringTag ], https://tc39.es/ecma402/#sec-%segmentiteratorprototype%.@@tostringtag define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Segmenter String Iterator"_string), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; define_native_function(realm, vm.names.next, next, 0, attr); } -// 18.6.2.1 %SegmentIteratorPrototype%.next ( ), https://tc39.es/ecma402/#sec-%segmentiteratorprototype%.next +// 19.6.2.1 %SegmentIteratorPrototype%.next ( ), https://tc39.es/ecma402/#sec-%segmentiteratorprototype%.next JS_DEFINE_NATIVE_FUNCTION(SegmentIteratorPrototype::next) { // 1. Let iterator be the this value. diff --git a/Libraries/LibJS/Runtime/Intl/Segmenter.cpp b/Libraries/LibJS/Runtime/Intl/Segmenter.cpp index ba3be63b67b..8e9f9a37f15 100644 --- a/Libraries/LibJS/Runtime/Intl/Segmenter.cpp +++ b/Libraries/LibJS/Runtime/Intl/Segmenter.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2022, Idan Horowitz - * Copyright (c) 2023, Tim Flynn + * Copyright (c) 2023-2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -13,13 +13,13 @@ namespace JS::Intl { GC_DEFINE_ALLOCATOR(Segmenter); -// 18 Segmenter Objects, https://tc39.es/ecma402/#segmenter-objects +// 19 Segmenter Objects, https://tc39.es/ecma402/#segmenter-objects Segmenter::Segmenter(Object& prototype) : Object(ConstructWithPrototypeTag::Tag, prototype) { } -// 18.7.1 CreateSegmentDataObject ( segmenter, string, startIndex, endIndex ), https://tc39.es/ecma402/#sec-createsegmentdataobject +// 19.7.1 CreateSegmentDataObject ( segmenter, string, startIndex, endIndex ), https://tc39.es/ecma402/#sec-createsegmentdataobject ThrowCompletionOr> create_segment_data_object(VM& vm, Unicode::Segmenter const& segmenter, Utf16View const& string, size_t start_index, size_t end_index) { auto& realm = *vm.current_realm(); @@ -67,7 +67,7 @@ ThrowCompletionOr> create_segment_data_object(VM& vm, Unicode::S return result; } -// 18.8.1 FindBoundary ( segmenter, string, startIndex, direction ), https://tc39.es/ecma402/#sec-findboundary +// 19.8.1 FindBoundary ( segmenter, string, startIndex, direction ), https://tc39.es/ecma402/#sec-findboundary size_t find_boundary(Unicode::Segmenter& segmenter, Utf16View const& string, size_t start_index, Direction direction) { // 1. Let len be the length of string. diff --git a/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp b/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp index 7215bb6a239..2d14e970808 100644 --- a/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp +++ b/Libraries/LibJS/Runtime/Intl/SegmenterConstructor.cpp @@ -1,6 +1,6 @@ /* * Copyright (c) 2022, Idan Horowitz - * Copyright (c) 2023-2024, Tim Flynn + * Copyright (c) 2023-2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ @@ -17,7 +17,7 @@ namespace JS::Intl { GC_DEFINE_ALLOCATOR(SegmenterConstructor); -// 18.1 The Intl.Segmenter Constructor, https://tc39.es/ecma402/#sec-intl-segmenter-constructor +// 19.1 The Intl.Segmenter Constructor, https://tc39.es/ecma402/#sec-intl-segmenter-constructor SegmenterConstructor::SegmenterConstructor(Realm& realm) : NativeFunction(realm.vm().names.Segmenter.as_string(), realm.intrinsics().function_prototype()) { @@ -29,7 +29,7 @@ void SegmenterConstructor::initialize(Realm& realm) auto& vm = this->vm(); - // 18.2.1 Intl.Segmenter.prototype, https://tc39.es/ecma402/#sec-intl.segmenter.prototype + // 19.2.1 Intl.Segmenter.prototype, https://tc39.es/ecma402/#sec-intl.segmenter.prototype define_direct_property(vm.names.prototype, realm.intrinsics().intl_segmenter_prototype(), 0); define_direct_property(vm.names.length, Value(0), Attribute::Configurable); @@ -37,14 +37,14 @@ void SegmenterConstructor::initialize(Realm& realm) define_native_function(realm, vm.names.supportedLocalesOf, supported_locales_of, 1, attr); } -// 18.1.1 Intl.Segmenter ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.segmenter +// 19.1.1 Intl.Segmenter ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.segmenter ThrowCompletionOr SegmenterConstructor::call() { // 1. If NewTarget is undefined, throw a TypeError exception. return vm().throw_completion(ErrorType::ConstructorWithoutNew, "Intl.Segmenter"); } -// 18.1.1 Intl.Segmenter ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.segmenter +// 19.1.1 Intl.Segmenter ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-intl.segmenter ThrowCompletionOr> SegmenterConstructor::construct(FunctionObject& new_target) { auto& vm = this->vm(); @@ -90,7 +90,7 @@ ThrowCompletionOr> SegmenterConstructor::construct(FunctionObjec return segmenter; } -// 18.2.2 Intl.Segmenter.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-intl.segmenter.supportedlocalesof +// 19.2.2 Intl.Segmenter.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-intl.segmenter.supportedlocalesof JS_DEFINE_NATIVE_FUNCTION(SegmenterConstructor::supported_locales_of) { auto locales = vm.argument(0); diff --git a/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.cpp b/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.cpp index 59dda55cb12..5eea5c83eba 100644 --- a/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.cpp +++ b/Libraries/LibJS/Runtime/Intl/SegmenterPrototype.cpp @@ -13,7 +13,7 @@ namespace JS::Intl { GC_DEFINE_ALLOCATOR(SegmenterPrototype); -// 18.3 Properties of the Intl.Segmenter Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-segmenter-prototype-object +// 19.3 Properties of the Intl.Segmenter Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-segmenter-prototype-object SegmenterPrototype::SegmenterPrototype(Realm& realm) : PrototypeObject(realm.intrinsics().object_prototype()) { @@ -25,7 +25,7 @@ void SegmenterPrototype::initialize(Realm& realm) auto& vm = this->vm(); - // 18.3.2 Intl.Segmenter.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-intl.segmenter.prototype-@@tostringtag + // 19.3.2 Intl.Segmenter.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-intl.segmenter.prototype-@@tostringtag define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.Segmenter"_string), Attribute::Configurable); u8 attr = Attribute::Writable | Attribute::Configurable; @@ -33,7 +33,7 @@ void SegmenterPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.segment, segment, 1, attr); } -// 18.3.4 Intl.Segmenter.prototype.resolvedOptions ( ), https://tc39.es/ecma402/#sec-intl.segmenter.prototype.resolvedoptions +// 19.3.4 Intl.Segmenter.prototype.resolvedOptions ( ), https://tc39.es/ecma402/#sec-intl.segmenter.prototype.resolvedoptions JS_DEFINE_NATIVE_FUNCTION(SegmenterPrototype::resolved_options) { auto& realm = *vm.current_realm(); @@ -45,7 +45,7 @@ JS_DEFINE_NATIVE_FUNCTION(SegmenterPrototype::resolved_options) // 3. Let options be OrdinaryObjectCreate(%Object.prototype%). auto options = Object::create(realm, realm.intrinsics().object_prototype()); - // 4. For each row of Table 16, except the header row, in table order, do + // 4. For each row of Table 31, except the header row, in table order, do // a. Let p be the Property value of the current row. // b. Let v be the value of segmenter's internal slot whose name is the Internal Slot value of the current row. // c. Assert: v is not undefined. @@ -57,7 +57,7 @@ JS_DEFINE_NATIVE_FUNCTION(SegmenterPrototype::resolved_options) return options; } -// 18.3.3 Intl.Segmenter.prototype.segment ( string ), https://tc39.es/ecma402/#sec-intl.segmenter.prototype.segment +// 19.3.3 Intl.Segmenter.prototype.segment ( string ), https://tc39.es/ecma402/#sec-intl.segmenter.prototype.segment JS_DEFINE_NATIVE_FUNCTION(SegmenterPrototype::segment) { auto& realm = *vm.current_realm(); diff --git a/Libraries/LibJS/Runtime/Intl/Segments.cpp b/Libraries/LibJS/Runtime/Intl/Segments.cpp index bd7f027b236..0db35bff1c6 100644 --- a/Libraries/LibJS/Runtime/Intl/Segments.cpp +++ b/Libraries/LibJS/Runtime/Intl/Segments.cpp @@ -12,7 +12,7 @@ namespace JS::Intl { GC_DEFINE_ALLOCATOR(Segments); -// 18.5.1 CreateSegmentsObject ( segmenter, string ), https://tc39.es/ecma402/#sec-createsegmentsobject +// 19.5.1 CreateSegmentsObject ( segmenter, string ), https://tc39.es/ecma402/#sec-createsegmentsobject GC::Ref Segments::create(Realm& realm, Unicode::Segmenter const& segmenter, Utf16String string) { // 1. Let internalSlotsList be « [[SegmentsSegmenter]], [[SegmentsString]] ». @@ -23,7 +23,7 @@ GC::Ref Segments::create(Realm& realm, Unicode::Segmenter const& segme return realm.create(realm, segmenter, move(string)); } -// 18.5 Segments Objects, https://tc39.es/ecma402/#sec-segments-objects +// 19.5 Segments Objects, https://tc39.es/ecma402/#sec-segments-objects Segments::Segments(Realm& realm, Unicode::Segmenter const& segmenter, Utf16String string) : Object(ConstructWithPrototypeTag::Tag, realm.intrinsics().intl_segments_prototype()) , m_segments_segmenter(segmenter.clone()) diff --git a/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.cpp b/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.cpp index 80f54df07d1..26662ac625b 100644 --- a/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.cpp +++ b/Libraries/LibJS/Runtime/Intl/SegmentsPrototype.cpp @@ -13,7 +13,7 @@ namespace JS::Intl { GC_DEFINE_ALLOCATOR(SegmentsPrototype); -// 18.5.2 The %SegmentsPrototype% Object, https://tc39.es/ecma402/#sec-%segmentsprototype%-object +// 19.5.2 The %SegmentsPrototype% Object, https://tc39.es/ecma402/#sec-%segmentsprototype%-object SegmentsPrototype::SegmentsPrototype(Realm& realm) : PrototypeObject(realm.intrinsics().object_prototype()) { @@ -30,7 +30,7 @@ void SegmentsPrototype::initialize(Realm& realm) define_native_function(realm, vm.names.containing, containing, 1, attr); } -// 18.5.2.1 %SegmentsPrototype%.containing ( index ), https://tc39.es/ecma402/#sec-%segmentsprototype%.containing +// 19.5.2.1 %SegmentsPrototype%.containing ( index ), https://tc39.es/ecma402/#sec-%segmentsprototype%.containing JS_DEFINE_NATIVE_FUNCTION(SegmentsPrototype::containing) { // 1. Let segments be the this value. @@ -63,7 +63,7 @@ JS_DEFINE_NATIVE_FUNCTION(SegmentsPrototype::containing) return TRY(create_segment_data_object(vm, segmenter, string, start_index, end_index)); } -// 18.5.2.2 %SegmentsPrototype% [ @@iterator ] ( ), https://tc39.es/ecma402/#sec-%segmentsprototype%-@@iterator +// 19.5.2.2 %SegmentsPrototype% [ @@iterator ] ( ), https://tc39.es/ecma402/#sec-%segmentsprototype%-@@iterator JS_DEFINE_NATIVE_FUNCTION(SegmentsPrototype::symbol_iterator) { auto& realm = *vm.current_realm(); diff --git a/Libraries/LibJS/Runtime/NumberPrototype.cpp b/Libraries/LibJS/Runtime/NumberPrototype.cpp index c51892b9b89..059ad0f47cc 100644 --- a/Libraries/LibJS/Runtime/NumberPrototype.cpp +++ b/Libraries/LibJS/Runtime/NumberPrototype.cpp @@ -260,7 +260,7 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_fixed) return PrimitiveString::create(vm, ByteString::formatted(number_format_string, s, number)); } -// 19.2.1 Number.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sup-number.prototype.tolocalestring +// 20.2.1 Number.prototype.toLocaleString ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sup-number.prototype.tolocalestring JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_locale_string) { auto& realm = *vm.current_realm(); diff --git a/Libraries/LibJS/Runtime/StringPrototype.cpp b/Libraries/LibJS/Runtime/StringPrototype.cpp index 2e694363b7c..e7a92543d24 100644 --- a/Libraries/LibJS/Runtime/StringPrototype.cpp +++ b/Libraries/LibJS/Runtime/StringPrototype.cpp @@ -529,7 +529,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::last_index_of) } // 22.1.3.12 String.prototype.localeCompare ( that [ , reserved1 [ , reserved2 ] ] ), https://tc39.es/ecma262/#sec-string.prototype.localecompare -// 19.1.1 String.prototype.localeCompare ( that [ , locales [ , options ] ] ), https://tc39.es/ecma402/#sup-String.prototype.localeCompare +// 20.1.1 String.prototype.localeCompare ( that [ , locales [ , options ] ] ), https://tc39.es/ecma402/#sup-String.prototype.localeCompare JS_DEFINE_NATIVE_FUNCTION(StringPrototype::locale_compare) { auto& realm = *vm.current_realm(); @@ -1244,7 +1244,7 @@ enum class TargetCase { Upper, }; -// 19.1.2.1 TransformCase ( S, locales, targetCase ), https://tc39.es/ecma402/#sec-transform-case +// 20.1.2.1 TransformCase ( S, locales, targetCase ), https://tc39.es/ecma402/#sec-transform-case static ThrowCompletionOr transform_case(VM& vm, String const& string, Value locales, TargetCase target_case) { // 1. Let requestedLocales be ? CanonicalizeLocaleList(locales). @@ -1295,7 +1295,7 @@ static ThrowCompletionOr transform_case(VM& vm, String const& string, Va } // 22.1.3.26 String.prototype.toLocaleLowerCase ( [ reserved1 [ , reserved2 ] ] ), https://tc39.es/ecma262/#sec-string.prototype.tolocalelowercase -// 19.1.2 String.prototype.toLocaleLowerCase ( [ locales ] ), https://tc39.es/ecma402/#sup-string.prototype.tolocalelowercase +// 20.1.2 String.prototype.toLocaleLowerCase ( [ locales ] ), https://tc39.es/ecma402/#sup-string.prototype.tolocalelowercase JS_DEFINE_NATIVE_FUNCTION(StringPrototype::to_locale_lowercase) { auto locales = vm.argument(0); @@ -1309,7 +1309,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::to_locale_lowercase) } // 22.1.3.27 String.prototype.toLocaleUpperCase ( [ reserved1 [ , reserved2 ] ] ), https://tc39.es/ecma262/#sec-string.prototype.tolocaleuppercase -// 19.1.3 String.prototype.toLocaleUpperCase ( [ locales ] ), https://tc39.es/ecma402/#sup-string.prototype.tolocaleuppercase +// 20.1.3 String.prototype.toLocaleUpperCase ( [ locales ] ), https://tc39.es/ecma402/#sup-string.prototype.tolocaleuppercase JS_DEFINE_NATIVE_FUNCTION(StringPrototype::to_locale_uppercase) { auto locales = vm.argument(0);