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 14 matching lines...) Expand all Loading... |
25 var IsFinite; | 25 var IsFinite; |
26 var IsNaN; | 26 var IsNaN; |
27 var GlobalBoolean = global.Boolean; | 27 var GlobalBoolean = global.Boolean; |
28 var GlobalDate = global.Date; | 28 var GlobalDate = global.Date; |
29 var GlobalNumber = global.Number; | 29 var GlobalNumber = global.Number; |
30 var GlobalRegExp = global.RegExp; | 30 var GlobalRegExp = global.RegExp; |
31 var GlobalString = global.String; | 31 var GlobalString = global.String; |
32 var MakeError; | 32 var MakeError; |
33 var MakeRangeError; | 33 var MakeRangeError; |
34 var MakeTypeError; | 34 var MakeTypeError; |
35 var MathFloor; | |
36 var ObjectDefineProperties = utils.ImportNow("ObjectDefineProperties"); | 35 var ObjectDefineProperties = utils.ImportNow("ObjectDefineProperties"); |
37 var ObjectDefineProperty = utils.ImportNow("ObjectDefineProperty"); | 36 var ObjectDefineProperty = utils.ImportNow("ObjectDefineProperty"); |
38 var ObjectHasOwnProperty = utils.ImportNow("ObjectHasOwnProperty"); | 37 var ObjectHasOwnProperty = utils.ImportNow("ObjectHasOwnProperty"); |
39 var OverrideFunction = utils.OverrideFunction; | 38 var OverrideFunction = utils.OverrideFunction; |
40 var patternSymbol = utils.ImportNow("intl_pattern_symbol"); | 39 var patternSymbol = utils.ImportNow("intl_pattern_symbol"); |
41 var RegExpTest; | 40 var RegExpTest; |
42 var resolvedSymbol = utils.ImportNow("intl_resolved_symbol"); | 41 var resolvedSymbol = utils.ImportNow("intl_resolved_symbol"); |
43 var SetFunctionName = utils.SetFunctionName; | 42 var SetFunctionName = utils.SetFunctionName; |
44 var StringIndexOf; | 43 var StringIndexOf; |
45 var StringLastIndexOf; | 44 var StringLastIndexOf; |
46 var StringMatch; | 45 var StringMatch; |
47 var StringReplace; | 46 var StringReplace; |
48 var StringSplit; | 47 var StringSplit; |
49 var StringSubstr; | 48 var StringSubstr; |
50 var StringSubstring; | 49 var StringSubstring; |
51 | 50 |
52 utils.Import(function(from) { | 51 utils.Import(function(from) { |
53 ArrayIndexOf = from.ArrayIndexOf; | 52 ArrayIndexOf = from.ArrayIndexOf; |
54 ArrayJoin = from.ArrayJoin; | 53 ArrayJoin = from.ArrayJoin; |
55 ArrayPush = from.ArrayPush; | 54 ArrayPush = from.ArrayPush; |
56 IsFinite = from.IsFinite; | 55 IsFinite = from.IsFinite; |
57 IsNaN = from.IsNaN; | 56 IsNaN = from.IsNaN; |
58 MakeError = from.MakeError; | 57 MakeError = from.MakeError; |
59 MakeRangeError = from.MakeRangeError; | 58 MakeRangeError = from.MakeRangeError; |
60 MakeTypeError = from.MakeTypeError; | 59 MakeTypeError = from.MakeTypeError; |
61 MathFloor = from.MathFloor; | |
62 RegExpTest = from.RegExpTest; | 60 RegExpTest = from.RegExpTest; |
63 StringIndexOf = from.StringIndexOf; | 61 StringIndexOf = from.StringIndexOf; |
64 StringLastIndexOf = from.StringLastIndexOf; | 62 StringLastIndexOf = from.StringLastIndexOf; |
65 StringMatch = from.StringMatch; | 63 StringMatch = from.StringMatch; |
66 StringReplace = from.StringReplace; | 64 StringReplace = from.StringReplace; |
67 StringSplit = from.StringSplit; | 65 StringSplit = from.StringSplit; |
68 StringSubstr = from.StringSubstr; | 66 StringSubstr = from.StringSubstr; |
69 StringSubstring = from.StringSubstring; | 67 StringSubstring = from.StringSubstring; |
70 }); | 68 }); |
71 | 69 |
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 * Returns the valid digit count for a property, or throws RangeError on | 1093 * Returns the valid digit count for a property, or throws RangeError on |
1096 * a value out of the range. | 1094 * a value out of the range. |
1097 */ | 1095 */ |
1098 function getNumberOption(options, property, min, max, fallback) { | 1096 function getNumberOption(options, property, min, max, fallback) { |
1099 var value = options[property]; | 1097 var value = options[property]; |
1100 if (!IS_UNDEFINED(value)) { | 1098 if (!IS_UNDEFINED(value)) { |
1101 value = GlobalNumber(value); | 1099 value = GlobalNumber(value); |
1102 if (IsNaN(value) || value < min || value > max) { | 1100 if (IsNaN(value) || value < min || value > max) { |
1103 throw MakeRangeError(kPropertyValueOutOfRange, property); | 1101 throw MakeRangeError(kPropertyValueOutOfRange, property); |
1104 } | 1102 } |
1105 return MathFloor(value); | 1103 return %math_floor(value); |
1106 } | 1104 } |
1107 | 1105 |
1108 return fallback; | 1106 return fallback; |
1109 } | 1107 } |
1110 | 1108 |
1111 var patternAccessor = { | 1109 var patternAccessor = { |
1112 get() { | 1110 get() { |
1113 %IncrementUseCounter(kIntlPattern); | 1111 %IncrementUseCounter(kIntlPattern); |
1114 return this[patternSymbol]; | 1112 return this[patternSymbol]; |
1115 }, | 1113 }, |
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2138 } | 2136 } |
2139 | 2137 |
2140 var locales = arguments[0]; | 2138 var locales = arguments[0]; |
2141 var options = arguments[1]; | 2139 var options = arguments[1]; |
2142 return toLocaleDateTime( | 2140 return toLocaleDateTime( |
2143 this, locales, options, 'time', 'time', 'dateformattime'); | 2141 this, locales, options, 'time', 'time', 'dateformattime'); |
2144 } | 2142 } |
2145 ); | 2143 ); |
2146 | 2144 |
2147 }) | 2145 }) |
OLD | NEW |