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 1986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1997 * If the form is not one of "NFC", "NFD", "NFKC", or "NFKD", then throw | 1997 * If the form is not one of "NFC", "NFD", "NFKC", or "NFKD", then throw |
1998 * a RangeError Exception. | 1998 * a RangeError Exception. |
1999 */ | 1999 */ |
2000 | 2000 |
2001 OverrideFunction(GlobalString.prototype, 'normalize', function() { | 2001 OverrideFunction(GlobalString.prototype, 'normalize', function() { |
2002 if (%_IsConstructCall()) { | 2002 if (%_IsConstructCall()) { |
2003 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 2003 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
2004 } | 2004 } |
2005 | 2005 |
2006 CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize"); | 2006 CHECK_OBJECT_COERCIBLE(this, "String.prototype.normalize"); |
2007 var s = TO_STRING_INLINE(this); | 2007 var s = TO_STRING(this); |
2008 | 2008 |
2009 var formArg = %_Arguments(0); | 2009 var formArg = %_Arguments(0); |
2010 var form = IS_UNDEFINED(formArg) ? 'NFC' : TO_STRING_INLINE(formArg); | 2010 var form = IS_UNDEFINED(formArg) ? 'NFC' : TO_STRING(formArg); |
2011 | 2011 |
2012 var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD']; | 2012 var NORMALIZATION_FORMS = ['NFC', 'NFD', 'NFKC', 'NFKD']; |
2013 | 2013 |
2014 var normalizationForm = | 2014 var normalizationForm = |
2015 %_CallFunction(NORMALIZATION_FORMS, form, ArrayIndexOf); | 2015 %_CallFunction(NORMALIZATION_FORMS, form, ArrayIndexOf); |
2016 if (normalizationForm === -1) { | 2016 if (normalizationForm === -1) { |
2017 throw MakeRangeError(kNormalizationForm, | 2017 throw MakeRangeError(kNormalizationForm, |
2018 %_CallFunction(NORMALIZATION_FORMS, ', ', ArrayJoin)); | 2018 %_CallFunction(NORMALIZATION_FORMS, ', ', ArrayJoin)); |
2019 } | 2019 } |
2020 | 2020 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2110 } | 2110 } |
2111 | 2111 |
2112 var locales = %_Arguments(0); | 2112 var locales = %_Arguments(0); |
2113 var options = %_Arguments(1); | 2113 var options = %_Arguments(1); |
2114 return toLocaleDateTime( | 2114 return toLocaleDateTime( |
2115 this, locales, options, 'time', 'time', 'dateformattime'); | 2115 this, locales, options, 'time', 'time', 'dateformattime'); |
2116 } | 2116 } |
2117 ); | 2117 ); |
2118 | 2118 |
2119 }) | 2119 }) |
OLD | NEW |