|
@@ -376,7 +376,7 @@ int currency_digits(StringView currency)
|
|
|
}
|
|
|
|
|
|
// 15.5.3 FormatNumericToString ( intlObject, x ), https://tc39.es/ecma402/#sec-formatnumberstring
|
|
|
-// 1.1.5 FormatNumericToString ( intlObject, x ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-formatnumberstring
|
|
|
+// 1.5.3 FormatNumericToString ( intlObject, x ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-formatnumberstring
|
|
|
FormatResult format_numeric_to_string(NumberFormatBase const& intl_object, MathematicalValue number)
|
|
|
{
|
|
|
bool is_negative = false;
|
|
@@ -516,7 +516,7 @@ FormatResult format_numeric_to_string(NumberFormatBase const& intl_object, Mathe
|
|
|
}
|
|
|
|
|
|
// 15.5.4 PartitionNumberPattern ( numberFormat, x ), https://tc39.es/ecma402/#sec-partitionnumberpattern
|
|
|
-// 1.1.6 PartitionNumberPattern ( numberFormat, x ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-partitionnumberpattern
|
|
|
+// 1.5.4 PartitionNumberPattern ( numberFormat, x ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-partitionnumberpattern
|
|
|
Vector<PatternPartition> partition_number_pattern(VM& vm, NumberFormat& number_format, MathematicalValue number)
|
|
|
{
|
|
|
// 1. Let exponent be 0.
|
|
@@ -713,7 +713,7 @@ static Vector<StringView> separate_integer_into_groups(::Locale::NumberGroupings
|
|
|
}
|
|
|
|
|
|
// 15.5.5 PartitionNotationSubPattern ( numberFormat, x, n, exponent ), https://tc39.es/ecma402/#sec-partitionnotationsubpattern
|
|
|
-// 1.1.7 PartitionNotationSubPattern ( numberFormat, x, n, exponent ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-partitionnotationsubpattern
|
|
|
+// 1.5.5 PartitionNotationSubPattern ( numberFormat, x, n, exponent ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-partitionnotationsubpattern
|
|
|
Vector<PatternPartition> partition_notation_sub_pattern(NumberFormat& number_format, MathematicalValue const& number, DeprecatedString formatted_string, int exponent)
|
|
|
{
|
|
|
// 1. Let result be a new empty List.
|
|
@@ -1022,7 +1022,7 @@ static auto to_raw_precision_function(MathematicalValue const& number, int preci
|
|
|
}
|
|
|
|
|
|
// 15.5.8 ToRawPrecision ( x, minPrecision, maxPrecision ), https://tc39.es/ecma402/#sec-torawprecision
|
|
|
-// 1.1.10 ToRawPrecision ( x, minPrecision, maxPrecision, unsignedRoundingMode ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-torawprecision
|
|
|
+// 1.5.8 ToRawPrecision ( x, minPrecision, maxPrecision, unsignedRoundingMode ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-torawprecision
|
|
|
RawFormatResult to_raw_precision(MathematicalValue const& number, int min_precision, int max_precision, Optional<NumberFormat::UnsignedRoundingMode> const& unsigned_rounding_mode)
|
|
|
{
|
|
|
RawFormatResult result {};
|
|
@@ -1181,7 +1181,7 @@ static auto to_raw_fixed_function(MathematicalValue const& number, int fraction,
|
|
|
}
|
|
|
|
|
|
// 15.5.9 ToRawFixed ( x, minInteger, minFraction, maxFraction ), https://tc39.es/ecma402/#sec-torawfixed
|
|
|
-// 1.1.11 ToRawFixed ( x, minFraction, maxFraction, roundingIncrement, unsignedRoundingMode ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-torawfixed
|
|
|
+// 1.5.9 ToRawFixed ( x, minFraction, maxFraction, roundingIncrement, unsignedRoundingMode ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-torawfixed
|
|
|
RawFormatResult to_raw_fixed(MathematicalValue const& number, int min_fraction, int max_fraction, int rounding_increment, Optional<NumberFormat::UnsignedRoundingMode> const& unsigned_rounding_mode)
|
|
|
{
|
|
|
RawFormatResult result {};
|
|
@@ -1264,7 +1264,7 @@ RawFormatResult to_raw_fixed(MathematicalValue const& number, int min_fraction,
|
|
|
}
|
|
|
|
|
|
// 15.5.11 GetNumberFormatPattern ( numberFormat, x ), https://tc39.es/ecma402/#sec-getnumberformatpattern
|
|
|
-// 1.1.14 GetNumberFormatPattern ( numberFormat, x ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-getnumberformatpattern
|
|
|
+// 1.5.11 GetNumberFormatPattern ( numberFormat, x ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-getnumberformatpattern
|
|
|
Optional<Variant<StringView, DeprecatedString>> get_number_format_pattern(VM& vm, NumberFormat& number_format, MathematicalValue const& number, ::Locale::NumberFormat& found_pattern)
|
|
|
{
|
|
|
// 1. Let localeData be %NumberFormat%.[[LocaleData]].
|
|
@@ -1583,7 +1583,7 @@ int compute_exponent_for_magnitude(NumberFormat& number_format, int magnitude)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// 1.1.18 ToIntlMathematicalValue ( value ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-tointlmathematicalvalue
|
|
|
+// 1.5.16 ToIntlMathematicalValue ( value ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-tointlmathematicalvalue
|
|
|
ThrowCompletionOr<MathematicalValue> to_intl_mathematical_value(VM& vm, Value value)
|
|
|
{
|
|
|
|
|
@@ -1628,7 +1628,7 @@ ThrowCompletionOr<MathematicalValue> to_intl_mathematical_value(VM& vm, Value va
|
|
|
return mathematical_value;
|
|
|
}
|
|
|
|
|
|
-// 1.1.19 GetUnsignedRoundingMode ( roundingMode, isNegative ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-getunsignedroundingmode
|
|
|
+// 1.5.17 GetUnsignedRoundingMode ( roundingMode, isNegative ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-getunsignedroundingmode
|
|
|
NumberFormat::UnsignedRoundingMode get_unsigned_rounding_mode(NumberFormat::RoundingMode rounding_mode, bool is_negative)
|
|
|
{
|
|
|
// 1. If isNegative is true, return the specification type in the third column of Table 2 where the first column is roundingMode and the second column is "negative".
|
|
@@ -1659,7 +1659,7 @@ NumberFormat::UnsignedRoundingMode get_unsigned_rounding_mode(NumberFormat::Roun
|
|
|
};
|
|
|
}
|
|
|
|
|
|
-// 1.1.20 ApplyUnsignedRoundingMode ( x, r1, r2, unsignedRoundingMode ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-applyunsignedroundingmode
|
|
|
+// 1.5.18 ApplyUnsignedRoundingMode ( x, r1, r2, unsignedRoundingMode ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-applyunsignedroundingmode
|
|
|
RoundingDecision apply_unsigned_rounding_mode(MathematicalValue const& x, MathematicalValue const& r1, MathematicalValue const& r2, Optional<NumberFormat::UnsignedRoundingMode> const& unsigned_rounding_mode)
|
|
|
{
|
|
|
// 1. If x is equal to r1, return r1.
|
|
@@ -1724,7 +1724,7 @@ RoundingDecision apply_unsigned_rounding_mode(MathematicalValue const& x, Mathem
|
|
|
return RoundingDecision::HigherValue;
|
|
|
}
|
|
|
|
|
|
-// 1.1.21 PartitionNumberRangePattern ( numberFormat, x, y ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-partitionnumberrangepattern
|
|
|
+// 1.5.19 PartitionNumberRangePattern ( numberFormat, x, y ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-partitionnumberrangepattern
|
|
|
ThrowCompletionOr<Vector<PatternPartitionWithSource>> partition_number_range_pattern(VM& vm, NumberFormat& number_format, MathematicalValue start, MathematicalValue end)
|
|
|
{
|
|
|
// 1. If x is NaN or y is NaN, throw a RangeError exception.
|
|
@@ -1792,7 +1792,7 @@ ThrowCompletionOr<Vector<PatternPartitionWithSource>> partition_number_range_pat
|
|
|
return collapse_number_range(move(result));
|
|
|
}
|
|
|
|
|
|
-// 1.1.22 FormatApproximately ( numberFormat, result ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-formatapproximately
|
|
|
+// 1.5.20 FormatApproximately ( numberFormat, result ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-formatapproximately
|
|
|
Vector<PatternPartitionWithSource> format_approximately(NumberFormat& number_format, Vector<PatternPartitionWithSource> result)
|
|
|
{
|
|
|
// 1. Let i be an index into result, determined by an implementation-defined algorithm based on numberFormat and result.
|
|
@@ -1812,14 +1812,14 @@ Vector<PatternPartitionWithSource> format_approximately(NumberFormat& number_for
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-// 1.1.23 CollapseNumberRange ( result ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-collapsenumberrange
|
|
|
+// 1.5.21 CollapseNumberRange ( result ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-collapsenumberrange
|
|
|
Vector<PatternPartitionWithSource> collapse_number_range(Vector<PatternPartitionWithSource> result)
|
|
|
{
|
|
|
// Returning result unmodified is guaranteed to be a correct implementation of CollapseNumberRange.
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-// 1.1.24 FormatNumericRange( numberFormat, x, y ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-formatnumericrange
|
|
|
+// 1.5.22 FormatNumericRange( numberFormat, x, y ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-formatnumericrange
|
|
|
ThrowCompletionOr<DeprecatedString> format_numeric_range(VM& vm, NumberFormat& number_format, MathematicalValue start, MathematicalValue end)
|
|
|
{
|
|
|
// 1. Let parts be ? PartitionNumberRangePattern(numberFormat, x, y).
|
|
@@ -1838,7 +1838,7 @@ ThrowCompletionOr<DeprecatedString> format_numeric_range(VM& vm, NumberFormat& n
|
|
|
return result.build();
|
|
|
}
|
|
|
|
|
|
-// 1.1.25 FormatNumericRangeToParts( numberFormat, x, y ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-formatnumericrangetoparts
|
|
|
+// 1.5.23 FormatNumericRangeToParts( numberFormat, x, y ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-formatnumericrangetoparts
|
|
|
ThrowCompletionOr<Array*> format_numeric_range_to_parts(VM& vm, NumberFormat& number_format, MathematicalValue start, MathematicalValue end)
|
|
|
{
|
|
|
auto& realm = *vm.current_realm();
|