| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // ECMAScript 402 API implementation. | 5 // ECMAScript 402 API implementation. |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Intl object is a single object that has some named properties, | 8 * Intl object is a single object that has some named properties, |
| 9 * all of which are constructors. | 9 * all of which are constructors. |
| 10 */ | 10 */ |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 function getter() { | 190 function getter() { |
| 191 if (!%IsInitializedIntlObject(this)) { | 191 if (!%IsInitializedIntlObject(this)) { |
| 192 throw MakeTypeError(kMethodCalledOnWrongObject, methodName); | 192 throw MakeTypeError(kMethodCalledOnWrongObject, methodName); |
| 193 } | 193 } |
| 194 var internalName = '__bound' + methodName + '__'; | 194 var internalName = '__bound' + methodName + '__'; |
| 195 if (IS_UNDEFINED(this[internalName])) { | 195 if (IS_UNDEFINED(this[internalName])) { |
| 196 var that = this; | 196 var that = this; |
| 197 var boundMethod; | 197 var boundMethod; |
| 198 if (IS_UNDEFINED(length) || length === 2) { | 198 if (IS_UNDEFINED(length) || length === 2) { |
| 199 boundMethod = function(x, y) { | 199 boundMethod = function(x, y) { |
| 200 if (%_IsConstructCall()) { | 200 if (!IS_UNDEFINED(new.target)) { |
| 201 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 201 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 202 } | 202 } |
| 203 return implementation(that, x, y); | 203 return implementation(that, x, y); |
| 204 } | 204 } |
| 205 } else if (length === 1) { | 205 } else if (length === 1) { |
| 206 boundMethod = function(x) { | 206 boundMethod = function(x) { |
| 207 if (%_IsConstructCall()) { | 207 if (!IS_UNDEFINED(new.target)) { |
| 208 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 208 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 209 } | 209 } |
| 210 return implementation(that, x); | 210 return implementation(that, x); |
| 211 } | 211 } |
| 212 } else { | 212 } else { |
| 213 boundMethod = function() { | 213 boundMethod = function() { |
| 214 if (%_IsConstructCall()) { | 214 if (!IS_UNDEFINED(new.target)) { |
| 215 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 215 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 216 } | 216 } |
| 217 // DateTimeFormat.format needs to be 0 arg method, but can stil | 217 // DateTimeFormat.format needs to be 0 arg method, but can stil |
| 218 // receive optional dateValue param. If one was provided, pass it | 218 // receive optional dateValue param. If one was provided, pass it |
| 219 // along. | 219 // along. |
| 220 if (%_ArgumentsLength() > 0) { | 220 if (%_ArgumentsLength() > 0) { |
| 221 return implementation(that, %_Arguments(0)); | 221 return implementation(that, %_Arguments(0)); |
| 222 } else { | 222 } else { |
| 223 return implementation(that); | 223 return implementation(that); |
| 224 } | 224 } |
| (...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 return initializeCollator(TO_OBJECT(this), locales, options); | 959 return initializeCollator(TO_OBJECT(this), locales, options); |
| 960 }, | 960 }, |
| 961 DONT_ENUM | 961 DONT_ENUM |
| 962 ); | 962 ); |
| 963 | 963 |
| 964 | 964 |
| 965 /** | 965 /** |
| 966 * Collator resolvedOptions method. | 966 * Collator resolvedOptions method. |
| 967 */ | 967 */ |
| 968 %AddNamedProperty(Intl.Collator.prototype, 'resolvedOptions', function() { | 968 %AddNamedProperty(Intl.Collator.prototype, 'resolvedOptions', function() { |
| 969 if (%_IsConstructCall()) { | 969 if (!IS_UNDEFINED(new.target)) { |
| 970 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 970 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 971 } | 971 } |
| 972 | 972 |
| 973 if (!%IsInitializedIntlObjectOfType(this, 'collator')) { | 973 if (!%IsInitializedIntlObjectOfType(this, 'collator')) { |
| 974 throw MakeTypeError(kResolvedOptionsCalledOnNonObject, "Collator"); | 974 throw MakeTypeError(kResolvedOptionsCalledOnNonObject, "Collator"); |
| 975 } | 975 } |
| 976 | 976 |
| 977 var coll = this; | 977 var coll = this; |
| 978 var locale = getOptimalLanguageTag(coll.resolved.requestedLocale, | 978 var locale = getOptimalLanguageTag(coll.resolved.requestedLocale, |
| 979 coll.resolved.locale); | 979 coll.resolved.locale); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 995 %SetNativeFlag(Intl.Collator.prototype.resolvedOptions); | 995 %SetNativeFlag(Intl.Collator.prototype.resolvedOptions); |
| 996 | 996 |
| 997 | 997 |
| 998 /** | 998 /** |
| 999 * Returns the subset of the given locale list for which this locale list | 999 * Returns the subset of the given locale list for which this locale list |
| 1000 * has a matching (possibly fallback) locale. Locales appear in the same | 1000 * has a matching (possibly fallback) locale. Locales appear in the same |
| 1001 * order in the returned list as in the input list. | 1001 * order in the returned list as in the input list. |
| 1002 * Options are optional parameter. | 1002 * Options are optional parameter. |
| 1003 */ | 1003 */ |
| 1004 %AddNamedProperty(Intl.Collator, 'supportedLocalesOf', function(locales) { | 1004 %AddNamedProperty(Intl.Collator, 'supportedLocalesOf', function(locales) { |
| 1005 if (%_IsConstructCall()) { | 1005 if (!IS_UNDEFINED(new.target)) { |
| 1006 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 1006 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 1007 } | 1007 } |
| 1008 | 1008 |
| 1009 return supportedLocalesOf('collator', locales, %_Arguments(1)); | 1009 return supportedLocalesOf('collator', locales, %_Arguments(1)); |
| 1010 }, | 1010 }, |
| 1011 DONT_ENUM | 1011 DONT_ENUM |
| 1012 ); | 1012 ); |
| 1013 %FunctionSetName(Intl.Collator.supportedLocalesOf, 'supportedLocalesOf'); | 1013 %FunctionSetName(Intl.Collator.supportedLocalesOf, 'supportedLocalesOf'); |
| 1014 %FunctionRemovePrototype(Intl.Collator.supportedLocalesOf); | 1014 %FunctionRemovePrototype(Intl.Collator.supportedLocalesOf); |
| 1015 %SetNativeFlag(Intl.Collator.supportedLocalesOf); | 1015 %SetNativeFlag(Intl.Collator.supportedLocalesOf); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1201 return initializeNumberFormat(TO_OBJECT(this), locales, options); | 1201 return initializeNumberFormat(TO_OBJECT(this), locales, options); |
| 1202 }, | 1202 }, |
| 1203 DONT_ENUM | 1203 DONT_ENUM |
| 1204 ); | 1204 ); |
| 1205 | 1205 |
| 1206 | 1206 |
| 1207 /** | 1207 /** |
| 1208 * NumberFormat resolvedOptions method. | 1208 * NumberFormat resolvedOptions method. |
| 1209 */ | 1209 */ |
| 1210 %AddNamedProperty(Intl.NumberFormat.prototype, 'resolvedOptions', function() { | 1210 %AddNamedProperty(Intl.NumberFormat.prototype, 'resolvedOptions', function() { |
| 1211 if (%_IsConstructCall()) { | 1211 if (!IS_UNDEFINED(new.target)) { |
| 1212 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 1212 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 1213 } | 1213 } |
| 1214 | 1214 |
| 1215 if (!%IsInitializedIntlObjectOfType(this, 'numberformat')) { | 1215 if (!%IsInitializedIntlObjectOfType(this, 'numberformat')) { |
| 1216 throw MakeTypeError(kResolvedOptionsCalledOnNonObject, "NumberFormat"); | 1216 throw MakeTypeError(kResolvedOptionsCalledOnNonObject, "NumberFormat"); |
| 1217 } | 1217 } |
| 1218 | 1218 |
| 1219 var format = this; | 1219 var format = this; |
| 1220 var locale = getOptimalLanguageTag(format.resolved.requestedLocale, | 1220 var locale = getOptimalLanguageTag(format.resolved.requestedLocale, |
| 1221 format.resolved.locale); | 1221 format.resolved.locale); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1256 %SetNativeFlag(Intl.NumberFormat.prototype.resolvedOptions); | 1256 %SetNativeFlag(Intl.NumberFormat.prototype.resolvedOptions); |
| 1257 | 1257 |
| 1258 | 1258 |
| 1259 /** | 1259 /** |
| 1260 * Returns the subset of the given locale list for which this locale list | 1260 * Returns the subset of the given locale list for which this locale list |
| 1261 * has a matching (possibly fallback) locale. Locales appear in the same | 1261 * has a matching (possibly fallback) locale. Locales appear in the same |
| 1262 * order in the returned list as in the input list. | 1262 * order in the returned list as in the input list. |
| 1263 * Options are optional parameter. | 1263 * Options are optional parameter. |
| 1264 */ | 1264 */ |
| 1265 %AddNamedProperty(Intl.NumberFormat, 'supportedLocalesOf', function(locales) { | 1265 %AddNamedProperty(Intl.NumberFormat, 'supportedLocalesOf', function(locales) { |
| 1266 if (%_IsConstructCall()) { | 1266 if (!IS_UNDEFINED(new.target)) { |
| 1267 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 1267 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 1268 } | 1268 } |
| 1269 | 1269 |
| 1270 return supportedLocalesOf('numberformat', locales, %_Arguments(1)); | 1270 return supportedLocalesOf('numberformat', locales, %_Arguments(1)); |
| 1271 }, | 1271 }, |
| 1272 DONT_ENUM | 1272 DONT_ENUM |
| 1273 ); | 1273 ); |
| 1274 %FunctionSetName(Intl.NumberFormat.supportedLocalesOf, 'supportedLocalesOf'); | 1274 %FunctionSetName(Intl.NumberFormat.supportedLocalesOf, 'supportedLocalesOf'); |
| 1275 %FunctionRemovePrototype(Intl.NumberFormat.supportedLocalesOf); | 1275 %FunctionRemovePrototype(Intl.NumberFormat.supportedLocalesOf); |
| 1276 %SetNativeFlag(Intl.NumberFormat.supportedLocalesOf); | 1276 %SetNativeFlag(Intl.NumberFormat.supportedLocalesOf); |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1603 return initializeDateTimeFormat(TO_OBJECT(this), locales, options); | 1603 return initializeDateTimeFormat(TO_OBJECT(this), locales, options); |
| 1604 }, | 1604 }, |
| 1605 DONT_ENUM | 1605 DONT_ENUM |
| 1606 ); | 1606 ); |
| 1607 | 1607 |
| 1608 | 1608 |
| 1609 /** | 1609 /** |
| 1610 * DateTimeFormat resolvedOptions method. | 1610 * DateTimeFormat resolvedOptions method. |
| 1611 */ | 1611 */ |
| 1612 %AddNamedProperty(Intl.DateTimeFormat.prototype, 'resolvedOptions', function() { | 1612 %AddNamedProperty(Intl.DateTimeFormat.prototype, 'resolvedOptions', function() { |
| 1613 if (%_IsConstructCall()) { | 1613 if (!IS_UNDEFINED(new.target)) { |
| 1614 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 1614 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 1615 } | 1615 } |
| 1616 | 1616 |
| 1617 if (!%IsInitializedIntlObjectOfType(this, 'dateformat')) { | 1617 if (!%IsInitializedIntlObjectOfType(this, 'dateformat')) { |
| 1618 throw MakeTypeError(kResolvedOptionsCalledOnNonObject, "DateTimeFormat"); | 1618 throw MakeTypeError(kResolvedOptionsCalledOnNonObject, "DateTimeFormat"); |
| 1619 } | 1619 } |
| 1620 | 1620 |
| 1621 /** | 1621 /** |
| 1622 * Maps ICU calendar names into LDML type. | 1622 * Maps ICU calendar names into LDML type. |
| 1623 */ | 1623 */ |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1677 %SetNativeFlag(Intl.DateTimeFormat.prototype.resolvedOptions); | 1677 %SetNativeFlag(Intl.DateTimeFormat.prototype.resolvedOptions); |
| 1678 | 1678 |
| 1679 | 1679 |
| 1680 /** | 1680 /** |
| 1681 * Returns the subset of the given locale list for which this locale list | 1681 * Returns the subset of the given locale list for which this locale list |
| 1682 * has a matching (possibly fallback) locale. Locales appear in the same | 1682 * has a matching (possibly fallback) locale. Locales appear in the same |
| 1683 * order in the returned list as in the input list. | 1683 * order in the returned list as in the input list. |
| 1684 * Options are optional parameter. | 1684 * Options are optional parameter. |
| 1685 */ | 1685 */ |
| 1686 %AddNamedProperty(Intl.DateTimeFormat, 'supportedLocalesOf', function(locales) { | 1686 %AddNamedProperty(Intl.DateTimeFormat, 'supportedLocalesOf', function(locales) { |
| 1687 if (%_IsConstructCall()) { | 1687 if (!IS_UNDEFINED(new.target)) { |
| 1688 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 1688 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 1689 } | 1689 } |
| 1690 | 1690 |
| 1691 return supportedLocalesOf('dateformat', locales, %_Arguments(1)); | 1691 return supportedLocalesOf('dateformat', locales, %_Arguments(1)); |
| 1692 }, | 1692 }, |
| 1693 DONT_ENUM | 1693 DONT_ENUM |
| 1694 ); | 1694 ); |
| 1695 %FunctionSetName(Intl.DateTimeFormat.supportedLocalesOf, 'supportedLocalesOf'); | 1695 %FunctionSetName(Intl.DateTimeFormat.supportedLocalesOf, 'supportedLocalesOf'); |
| 1696 %FunctionRemovePrototype(Intl.DateTimeFormat.supportedLocalesOf); | 1696 %FunctionRemovePrototype(Intl.DateTimeFormat.supportedLocalesOf); |
| 1697 %SetNativeFlag(Intl.DateTimeFormat.supportedLocalesOf); | 1697 %SetNativeFlag(Intl.DateTimeFormat.supportedLocalesOf); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1824 }, | 1824 }, |
| 1825 DONT_ENUM | 1825 DONT_ENUM |
| 1826 ); | 1826 ); |
| 1827 | 1827 |
| 1828 | 1828 |
| 1829 /** | 1829 /** |
| 1830 * BreakIterator resolvedOptions method. | 1830 * BreakIterator resolvedOptions method. |
| 1831 */ | 1831 */ |
| 1832 %AddNamedProperty(Intl.v8BreakIterator.prototype, 'resolvedOptions', | 1832 %AddNamedProperty(Intl.v8BreakIterator.prototype, 'resolvedOptions', |
| 1833 function() { | 1833 function() { |
| 1834 if (%_IsConstructCall()) { | 1834 if (!IS_UNDEFINED(new.target)) { |
| 1835 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 1835 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 1836 } | 1836 } |
| 1837 | 1837 |
| 1838 if (!%IsInitializedIntlObjectOfType(this, 'breakiterator')) { | 1838 if (!%IsInitializedIntlObjectOfType(this, 'breakiterator')) { |
| 1839 throw MakeTypeError(kResolvedOptionsCalledOnNonObject, "v8BreakIterator"); | 1839 throw MakeTypeError(kResolvedOptionsCalledOnNonObject, "v8BreakIterator"); |
| 1840 } | 1840 } |
| 1841 | 1841 |
| 1842 var segmenter = this; | 1842 var segmenter = this; |
| 1843 var locale = getOptimalLanguageTag(segmenter.resolved.requestedLocale, | 1843 var locale = getOptimalLanguageTag(segmenter.resolved.requestedLocale, |
| 1844 segmenter.resolved.locale); | 1844 segmenter.resolved.locale); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1857 | 1857 |
| 1858 | 1858 |
| 1859 /** | 1859 /** |
| 1860 * Returns the subset of the given locale list for which this locale list | 1860 * Returns the subset of the given locale list for which this locale list |
| 1861 * has a matching (possibly fallback) locale. Locales appear in the same | 1861 * has a matching (possibly fallback) locale. Locales appear in the same |
| 1862 * order in the returned list as in the input list. | 1862 * order in the returned list as in the input list. |
| 1863 * Options are optional parameter. | 1863 * Options are optional parameter. |
| 1864 */ | 1864 */ |
| 1865 %AddNamedProperty(Intl.v8BreakIterator, 'supportedLocalesOf', | 1865 %AddNamedProperty(Intl.v8BreakIterator, 'supportedLocalesOf', |
| 1866 function(locales) { | 1866 function(locales) { |
| 1867 if (%_IsConstructCall()) { | 1867 if (!IS_UNDEFINED(new.target)) { |
| 1868 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 1868 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 1869 } | 1869 } |
| 1870 | 1870 |
| 1871 return supportedLocalesOf('breakiterator', locales, %_Arguments(1)); | 1871 return supportedLocalesOf('breakiterator', locales, %_Arguments(1)); |
| 1872 }, | 1872 }, |
| 1873 DONT_ENUM | 1873 DONT_ENUM |
| 1874 ); | 1874 ); |
| 1875 %FunctionSetName(Intl.v8BreakIterator.supportedLocalesOf, 'supportedLocalesOf'); | 1875 %FunctionSetName(Intl.v8BreakIterator.supportedLocalesOf, 'supportedLocalesOf'); |
| 1876 %FunctionRemovePrototype(Intl.v8BreakIterator.supportedLocalesOf); | 1876 %FunctionRemovePrototype(Intl.v8BreakIterator.supportedLocalesOf); |
| 1877 %SetNativeFlag(Intl.v8BreakIterator.supportedLocalesOf); | 1877 %SetNativeFlag(Intl.v8BreakIterator.supportedLocalesOf); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1971 %FunctionSetName(f, name); | 1971 %FunctionSetName(f, name); |
| 1972 %FunctionRemovePrototype(f); | 1972 %FunctionRemovePrototype(f); |
| 1973 %SetNativeFlag(f); | 1973 %SetNativeFlag(f); |
| 1974 } | 1974 } |
| 1975 | 1975 |
| 1976 /** | 1976 /** |
| 1977 * Compares this and that, and returns less than 0, 0 or greater than 0 value. | 1977 * Compares this and that, and returns less than 0, 0 or greater than 0 value. |
| 1978 * Overrides the built-in method. | 1978 * Overrides the built-in method. |
| 1979 */ | 1979 */ |
| 1980 OverrideFunction(GlobalString.prototype, 'localeCompare', function(that) { | 1980 OverrideFunction(GlobalString.prototype, 'localeCompare', function(that) { |
| 1981 if (%_IsConstructCall()) { | 1981 if (!IS_UNDEFINED(new.target)) { |
| 1982 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 1982 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 1983 } | 1983 } |
| 1984 | 1984 |
| 1985 if (IS_NULL_OR_UNDEFINED(this)) { | 1985 if (IS_NULL_OR_UNDEFINED(this)) { |
| 1986 throw MakeTypeError(kMethodInvokedOnNullOrUndefined); | 1986 throw MakeTypeError(kMethodInvokedOnNullOrUndefined); |
| 1987 } | 1987 } |
| 1988 | 1988 |
| 1989 var locales = %_Arguments(1); | 1989 var locales = %_Arguments(1); |
| 1990 var options = %_Arguments(2); | 1990 var options = %_Arguments(2); |
| 1991 var collator = cachedOrNewService('collator', locales, options); | 1991 var collator = cachedOrNewService('collator', locales, options); |
| 1992 return compare(collator, this, that); | 1992 return compare(collator, this, that); |
| 1993 } | 1993 } |
| 1994 ); | 1994 ); |
| 1995 | 1995 |
| 1996 | 1996 |
| 1997 /** | 1997 /** |
| 1998 * Unicode normalization. This method is called with one argument that | 1998 * Unicode normalization. This method is called with one argument that |
| 1999 * specifies the normalization form. | 1999 * specifies the normalization form. |
| 2000 * If none is specified, "NFC" is assumed. | 2000 * If none is specified, "NFC" is assumed. |
| 2001 * If the form is not one of "NFC", "NFD", "NFKC", or "NFKD", then throw | 2001 * If the form is not one of "NFC", "NFD", "NFKC", or "NFKD", then throw |
| 2002 * a RangeError Exception. | 2002 * a RangeError Exception. |
| 2003 */ | 2003 */ |
| 2004 | 2004 |
| 2005 OverrideFunction(GlobalString.prototype, 'normalize', function() { | 2005 OverrideFunction(GlobalString.prototype, 'normalize', function() { |
| 2006 if (%_IsConstructCall()) { | 2006 if (!IS_UNDEFINED(new.target)) { |
| 2007 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 2007 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 2008 } | 2008 } |
| 2009 | 2009 |
| 2010 CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize"); | 2010 CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize"); |
| 2011 var s = TO_STRING(this); | 2011 var s = TO_STRING(this); |
| 2012 | 2012 |
| 2013 var formArg = %_Arguments(0); | 2013 var formArg = %_Arguments(0); |
| 2014 var form = IS_UNDEFINED(formArg) ? 'NFC' : TO_STRING(formArg); | 2014 var form = IS_UNDEFINED(formArg) ? 'NFC' : TO_STRING(formArg); |
| 2015 | 2015 |
| 2016 var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD']; | 2016 var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD']; |
| 2017 | 2017 |
| 2018 var normalizationForm = %_Call(ArrayIndexOf, NORMALIZATION_FORMS, form); | 2018 var normalizationForm = %_Call(ArrayIndexOf, NORMALIZATION_FORMS, form); |
| 2019 if (normalizationForm === -1) { | 2019 if (normalizationForm === -1) { |
| 2020 throw MakeRangeError(kNormalizationForm, | 2020 throw MakeRangeError(kNormalizationForm, |
| 2021 %_Call(ArrayJoin, NORMALIZATION_FORMS, ', ')); | 2021 %_Call(ArrayJoin, NORMALIZATION_FORMS, ', ')); |
| 2022 } | 2022 } |
| 2023 | 2023 |
| 2024 return %StringNormalize(s, normalizationForm); | 2024 return %StringNormalize(s, normalizationForm); |
| 2025 } | 2025 } |
| 2026 ); | 2026 ); |
| 2027 | 2027 |
| 2028 | 2028 |
| 2029 /** | 2029 /** |
| 2030 * Formats a Number object (this) using locale and options values. | 2030 * Formats a Number object (this) using locale and options values. |
| 2031 * If locale or options are omitted, defaults are used. | 2031 * If locale or options are omitted, defaults are used. |
| 2032 */ | 2032 */ |
| 2033 OverrideFunction(GlobalNumber.prototype, 'toLocaleString', function() { | 2033 OverrideFunction(GlobalNumber.prototype, 'toLocaleString', function() { |
| 2034 if (%_IsConstructCall()) { | 2034 if (!IS_UNDEFINED(new.target)) { |
| 2035 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 2035 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 2036 } | 2036 } |
| 2037 | 2037 |
| 2038 if (!(this instanceof GlobalNumber) && typeof(this) !== 'number') { | 2038 if (!(this instanceof GlobalNumber) && typeof(this) !== 'number') { |
| 2039 throw MakeTypeError(kMethodInvokedOnWrongType, "Number"); | 2039 throw MakeTypeError(kMethodInvokedOnWrongType, "Number"); |
| 2040 } | 2040 } |
| 2041 | 2041 |
| 2042 var locales = %_Arguments(0); | 2042 var locales = %_Arguments(0); |
| 2043 var options = %_Arguments(1); | 2043 var options = %_Arguments(1); |
| 2044 var numberFormat = cachedOrNewService('numberformat', locales, options); | 2044 var numberFormat = cachedOrNewService('numberformat', locales, options); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2065 return formatDate(dateFormat, date); | 2065 return formatDate(dateFormat, date); |
| 2066 } | 2066 } |
| 2067 | 2067 |
| 2068 | 2068 |
| 2069 /** | 2069 /** |
| 2070 * Formats a Date object (this) using locale and options values. | 2070 * Formats a Date object (this) using locale and options values. |
| 2071 * If locale or options are omitted, defaults are used - both date and time are | 2071 * If locale or options are omitted, defaults are used - both date and time are |
| 2072 * present in the output. | 2072 * present in the output. |
| 2073 */ | 2073 */ |
| 2074 OverrideFunction(GlobalDate.prototype, 'toLocaleString', function() { | 2074 OverrideFunction(GlobalDate.prototype, 'toLocaleString', function() { |
| 2075 if (%_IsConstructCall()) { | 2075 if (!IS_UNDEFINED(new.target)) { |
| 2076 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 2076 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 2077 } | 2077 } |
| 2078 | 2078 |
| 2079 var locales = %_Arguments(0); | 2079 var locales = %_Arguments(0); |
| 2080 var options = %_Arguments(1); | 2080 var options = %_Arguments(1); |
| 2081 return toLocaleDateTime( | 2081 return toLocaleDateTime( |
| 2082 this, locales, options, 'any', 'all', 'dateformatall'); | 2082 this, locales, options, 'any', 'all', 'dateformatall'); |
| 2083 } | 2083 } |
| 2084 ); | 2084 ); |
| 2085 | 2085 |
| 2086 | 2086 |
| 2087 /** | 2087 /** |
| 2088 * Formats a Date object (this) using locale and options values. | 2088 * Formats a Date object (this) using locale and options values. |
| 2089 * If locale or options are omitted, defaults are used - only date is present | 2089 * If locale or options are omitted, defaults are used - only date is present |
| 2090 * in the output. | 2090 * in the output. |
| 2091 */ | 2091 */ |
| 2092 OverrideFunction(GlobalDate.prototype, 'toLocaleDateString', function() { | 2092 OverrideFunction(GlobalDate.prototype, 'toLocaleDateString', function() { |
| 2093 if (%_IsConstructCall()) { | 2093 if (!IS_UNDEFINED(new.target)) { |
| 2094 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 2094 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 2095 } | 2095 } |
| 2096 | 2096 |
| 2097 var locales = %_Arguments(0); | 2097 var locales = %_Arguments(0); |
| 2098 var options = %_Arguments(1); | 2098 var options = %_Arguments(1); |
| 2099 return toLocaleDateTime( | 2099 return toLocaleDateTime( |
| 2100 this, locales, options, 'date', 'date', 'dateformatdate'); | 2100 this, locales, options, 'date', 'date', 'dateformatdate'); |
| 2101 } | 2101 } |
| 2102 ); | 2102 ); |
| 2103 | 2103 |
| 2104 | 2104 |
| 2105 /** | 2105 /** |
| 2106 * Formats a Date object (this) using locale and options values. | 2106 * Formats a Date object (this) using locale and options values. |
| 2107 * If locale or options are omitted, defaults are used - only time is present | 2107 * If locale or options are omitted, defaults are used - only time is present |
| 2108 * in the output. | 2108 * in the output. |
| 2109 */ | 2109 */ |
| 2110 OverrideFunction(GlobalDate.prototype, 'toLocaleTimeString', function() { | 2110 OverrideFunction(GlobalDate.prototype, 'toLocaleTimeString', function() { |
| 2111 if (%_IsConstructCall()) { | 2111 if (!IS_UNDEFINED(new.target)) { |
| 2112 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 2112 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 2113 } | 2113 } |
| 2114 | 2114 |
| 2115 var locales = %_Arguments(0); | 2115 var locales = %_Arguments(0); |
| 2116 var options = %_Arguments(1); | 2116 var options = %_Arguments(1); |
| 2117 return toLocaleDateTime( | 2117 return toLocaleDateTime( |
| 2118 this, locales, options, 'time', 'time', 'dateformattime'); | 2118 this, locales, options, 'time', 'time', 'dateformattime'); |
| 2119 } | 2119 } |
| 2120 ); | 2120 ); |
| 2121 | 2121 |
| 2122 }) | 2122 }) |
| OLD | NEW |