| 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 1977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1988 ); | 1988 ); |
| 1989 | 1989 |
| 1990 | 1990 |
| 1991 /** | 1991 /** |
| 1992 * Unicode normalization. This method is called with one argument that | 1992 * Unicode normalization. This method is called with one argument that |
| 1993 * specifies the normalization form. | 1993 * specifies the normalization form. |
| 1994 * If none is specified, "NFC" is assumed. | 1994 * If none is specified, "NFC" is assumed. |
| 1995 * If the form is not one of "NFC", "NFD", "NFKC", or "NFKD", then throw | 1995 * If the form is not one of "NFC", "NFD", "NFKC", or "NFKD", then throw |
| 1996 * a RangeError Exception. | 1996 * a RangeError Exception. |
| 1997 */ | 1997 */ |
| 1998 OverrideFunction(GlobalString.prototype, 'normalize', function(form) { | 1998 |
| 1999 OverrideFunction(GlobalString.prototype, 'normalize', function() { |
| 1999 if (%_IsConstructCall()) { | 2000 if (%_IsConstructCall()) { |
| 2000 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 2001 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
| 2001 } | 2002 } |
| 2002 | 2003 |
| 2003 CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize"); | 2004 CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize"); |
| 2004 | 2005 |
| 2005 form = IS_UNDEFINED(form) ? 'NFC' : form; | 2006 var formArg = %_Arguments(0); |
| 2007 var form = IS_UNDEFINED(formArg) ? 'NFC' : TO_STRING_INLINE(formArg); |
| 2006 | 2008 |
| 2007 var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD']; | 2009 var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD']; |
| 2008 | 2010 |
| 2009 var normalizationForm = | 2011 var normalizationForm = |
| 2010 %_CallFunction(NORMALIZATION_FORMS, form, ArrayIndexOf); | 2012 %_CallFunction(NORMALIZATION_FORMS, form, ArrayIndexOf); |
| 2011 if (normalizationForm === -1) { | 2013 if (normalizationForm === -1) { |
| 2012 throw MakeRangeError(kNormalizationForm, | 2014 throw MakeRangeError(kNormalizationForm, |
| 2013 %_CallFunction(NORMALIZATION_FORMS, ', ', ArrayJoin)); | 2015 %_CallFunction(NORMALIZATION_FORMS, ', ', ArrayJoin)); |
| 2014 } | 2016 } |
| 2015 | 2017 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2105 } | 2107 } |
| 2106 | 2108 |
| 2107 var locales = %_Arguments(0); | 2109 var locales = %_Arguments(0); |
| 2108 var options = %_Arguments(1); | 2110 var options = %_Arguments(1); |
| 2109 return toLocaleDateTime( | 2111 return toLocaleDateTime( |
| 2110 this, locales, options, 'time', 'time', 'dateformattime'); | 2112 this, locales, options, 'time', 'time', 'dateformattime'); |
| 2111 } | 2113 } |
| 2112 ); | 2114 ); |
| 2113 | 2115 |
| 2114 }) | 2116 }) |
| OLD | NEW |