Bladeren bron

LibJS: Reorganize spec steps for Intl.ListFormat

This is an editorial change in the Intl spec:
https://github.com/tc39/ecma402/commit/61bc370
Timothy Flynn 3 jaren geleden
bovenliggende
commit
6677e03a52

+ 6 - 6
Userland/Libraries/LibJS/Runtime/Intl/ListFormat.cpp

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021, Tim Flynn <trflynn89@serenityos.org>
+ * Copyright (c) 2021-2022, Tim Flynn <trflynn89@serenityos.org>
  *
  * SPDX-License-Identifier: BSD-2-Clause
  */
@@ -45,7 +45,7 @@ StringView ListFormat::type_string() const
     }
 }
 
-// 13.1.1 DeconstructPattern ( pattern, placeables ), https://tc39.es/ecma402/#sec-deconstructpattern
+// 13.5.1 DeconstructPattern ( pattern, placeables ), https://tc39.es/ecma402/#sec-deconstructpattern
 Vector<PatternPartition> deconstruct_pattern(StringView pattern, Placeables placeables)
 {
     // 1. Let patternParts be PartitionPattern(pattern).
@@ -92,7 +92,7 @@ Vector<PatternPartition> deconstruct_pattern(StringView pattern, Placeables plac
     return result;
 }
 
-// 13.1.2 CreatePartsFromList ( listFormat, list ), https://tc39.es/ecma402/#sec-createpartsfromlist
+// 13.5.2 CreatePartsFromList ( listFormat, list ), https://tc39.es/ecma402/#sec-createpartsfromlist
 Vector<PatternPartition> create_parts_from_list(ListFormat const& list_format, Vector<String> const& list)
 {
     auto list_patterns = Unicode::get_locale_list_patterns(list_format.locale(), list_format.type_string(), list_format.style());
@@ -181,7 +181,7 @@ Vector<PatternPartition> create_parts_from_list(ListFormat const& list_format, V
     return parts;
 }
 
-// 13.1.3 FormatList ( listFormat, list ), https://tc39.es/ecma402/#sec-formatlist
+// 13.5.3 FormatList ( listFormat, list ), https://tc39.es/ecma402/#sec-formatlist
 String format_list(ListFormat const& list_format, Vector<String> const& list)
 {
     // 1. Let parts be CreatePartsFromList(listFormat, list).
@@ -200,7 +200,7 @@ String format_list(ListFormat const& list_format, Vector<String> const& list)
     return result.build();
 }
 
-// 13.1.4 FormatListToParts ( listFormat, list ), https://tc39.es/ecma402/#sec-formatlisttoparts
+// 13.5.4 FormatListToParts ( listFormat, list ), https://tc39.es/ecma402/#sec-formatlisttoparts
 Array* format_list_to_parts(GlobalObject& global_object, ListFormat const& list_format, Vector<String> const& list)
 {
     auto& vm = global_object.vm();
@@ -236,7 +236,7 @@ Array* format_list_to_parts(GlobalObject& global_object, ListFormat const& list_
     return result;
 }
 
-// 13.1.5 StringListFromIterable ( iterable ), https://tc39.es/ecma402/#sec-createstringlistfromiterable
+// 13.5.5 StringListFromIterable ( iterable ), https://tc39.es/ecma402/#sec-createstringlistfromiterable
 ThrowCompletionOr<Vector<String>> string_list_from_iterable(GlobalObject& global_object, Value iterable)
 {
     auto& vm = global_object.vm();

+ 6 - 6
Userland/Libraries/LibJS/Runtime/Intl/ListFormatConstructor.cpp

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021, Tim Flynn <trflynn89@serenityos.org>
+ * Copyright (c) 2021-2022, Tim Flynn <trflynn89@serenityos.org>
  *
  * SPDX-License-Identifier: BSD-2-Clause
  */
@@ -14,7 +14,7 @@
 
 namespace JS::Intl {
 
-// 13.2 The Intl.ListFormat Constructor, https://tc39.es/ecma402/#sec-intl-listformat-constructor
+// 13.1 The Intl.ListFormat Constructor, https://tc39.es/ecma402/#sec-intl-listformat-constructor
 ListFormatConstructor::ListFormatConstructor(GlobalObject& global_object)
     : NativeFunction(vm().names.ListFormat.as_string(), *global_object.function_prototype())
 {
@@ -26,7 +26,7 @@ void ListFormatConstructor::initialize(GlobalObject& global_object)
 
     auto& vm = this->vm();
 
-    // 13.3.1 Intl.ListFormat.prototype, https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype
+    // 13.2.1 Intl.ListFormat.prototype, https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype
     define_direct_property(vm.names.prototype, global_object.intl_list_format_prototype(), 0);
 
     u8 attr = Attribute::Writable | Attribute::Configurable;
@@ -35,14 +35,14 @@ void ListFormatConstructor::initialize(GlobalObject& global_object)
     define_direct_property(vm.names.length, Value(0), Attribute::Configurable);
 }
 
-// 13.2.1 Intl.ListFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-Intl.ListFormat
+// 13.1.1 Intl.ListFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-Intl.ListFormat
 ThrowCompletionOr<Value> ListFormatConstructor::call()
 {
     // 1. If NewTarget is undefined, throw a TypeError exception.
     return vm().throw_completion<TypeError>(global_object(), ErrorType::ConstructorWithoutNew, "Intl.ListFormat");
 }
 
-// 13.2.1 Intl.ListFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-Intl.ListFormat
+// 13.1.1 Intl.ListFormat ( [ locales [ , options ] ] ), https://tc39.es/ecma402/#sec-Intl.ListFormat
 ThrowCompletionOr<Object*> ListFormatConstructor::construct(FunctionObject& new_target)
 {
     auto& vm = this->vm();
@@ -95,7 +95,7 @@ ThrowCompletionOr<Object*> ListFormatConstructor::construct(FunctionObject& new_
     return list_format;
 }
 
-// 13.3.2 Intl.ListFormat.supportedLocalesOf ( locales [ , options ] ), https://tc39.es/ecma402/#sec-Intl.ListFormat.supportedLocalesOf
+// 13.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);

+ 7 - 7
Userland/Libraries/LibJS/Runtime/Intl/ListFormatPrototype.cpp

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021, Tim Flynn <trflynn89@serenityos.org>
+ * Copyright (c) 2021-2022, Tim Flynn <trflynn89@serenityos.org>
  *
  * SPDX-License-Identifier: BSD-2-Clause
  */
@@ -12,7 +12,7 @@
 
 namespace JS::Intl {
 
-// 13.4 Properties of the Intl.ListFormat Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-listformat-prototype-object
+// 13.3 Properties of the Intl.ListFormat Prototype Object, https://tc39.es/ecma402/#sec-properties-of-intl-listformat-prototype-object
 ListFormatPrototype::ListFormatPrototype(GlobalObject& global_object)
     : PrototypeObject(*global_object.object_prototype())
 {
@@ -24,7 +24,7 @@ void ListFormatPrototype::initialize(GlobalObject& global_object)
 
     auto& vm = this->vm();
 
-    // 13.4.2 Intl.ListFormat.prototype [ @@toStringTag ], https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype-toStringTag
+    // 13.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(), js_string(vm, "Intl.ListFormat"), Attribute::Configurable);
 
     u8 attr = Attribute::Writable | Attribute::Configurable;
@@ -33,7 +33,7 @@ void ListFormatPrototype::initialize(GlobalObject& global_object)
     define_native_function(vm.names.resolvedOptions, resolved_options, 0, attr);
 }
 
-// 13.4.3 Intl.ListFormat.prototype.format ( list ), https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype.format
+// 13.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);
@@ -50,7 +50,7 @@ JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::format)
     return js_string(vm, move(formatted));
 }
 
-// 13.4.4 Intl.ListFormat.prototype.formatToParts ( list ), https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype.formatToParts
+// 13.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);
@@ -66,7 +66,7 @@ JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::format_to_parts)
     return format_list_to_parts(global_object, *list_format, string_list);
 }
 
-// 13.4.5 Intl.ListFormat.prototype.resolvedOptions ( ), https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype.resolvedoptions
+// 13.3.5 Intl.ListFormat.prototype.resolvedOptions ( ), https://tc39.es/ecma402/#sec-Intl.ListFormat.prototype.resolvedoptions
 JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::resolved_options)
 {
     // 1. Let lf be the this value.
@@ -76,7 +76,7 @@ JS_DEFINE_NATIVE_FUNCTION(ListFormatPrototype::resolved_options)
     // 3. Let options be ! OrdinaryObjectCreate(%Object.prototype%).
     auto* options = Object::create(global_object, global_object.object_prototype());
 
-    // 4. For each row of Table 9, except the header row, in table order, do
+    // 4. For each row of Table 10, 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.