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 */ |
11 (function(global, utils) { | 11 (function(global, utils) { |
12 | 12 |
13 "use strict"; | 13 "use strict"; |
14 | 14 |
15 %CheckIsBootstrapping(); | 15 %CheckIsBootstrapping(); |
16 | 16 |
17 // ------------------------------------------------------------------- | 17 // ------------------------------------------------------------------- |
18 // Imports | 18 // Imports |
19 | 19 |
| 20 var ArrayIndexOf; |
| 21 var ArrayJoin; |
| 22 var IsFinite; |
| 23 var IsNaN; |
20 var GlobalBoolean = global.Boolean; | 24 var GlobalBoolean = global.Boolean; |
21 var GlobalDate = global.Date; | 25 var GlobalDate = global.Date; |
22 var GlobalNumber = global.Number; | 26 var GlobalNumber = global.Number; |
23 var GlobalRegExp = global.RegExp; | 27 var GlobalRegExp = global.RegExp; |
24 var GlobalString = global.String; | 28 var GlobalString = global.String; |
25 var ObjectDefineProperties = utils.ObjectDefineProperties; | |
26 var ObjectDefineProperty = utils.ObjectDefineProperty; | |
27 var SetFunctionName = utils.SetFunctionName; | |
28 | |
29 var ArrayIndexOf; | |
30 var ArrayJoin; | |
31 var IsFinite; | |
32 var IsNaN; | |
33 var MathFloor; | 29 var MathFloor; |
34 var RegExpTest; | 30 var RegExpTest; |
| 31 var SetFunctionName = utils.SetFunctionName; |
35 var StringIndexOf; | 32 var StringIndexOf; |
36 var StringLastIndexOf; | 33 var StringLastIndexOf; |
37 var StringMatch; | 34 var StringMatch; |
38 var StringReplace; | 35 var StringReplace; |
39 var StringSplit; | 36 var StringSplit; |
40 var StringSubstr; | 37 var StringSubstr; |
41 var StringSubstring; | 38 var StringSubstring; |
42 | 39 |
43 utils.Import(function(from) { | 40 utils.Import(function(from) { |
44 ArrayIndexOf = from.ArrayIndexOf; | 41 ArrayIndexOf = from.ArrayIndexOf; |
45 ArrayJoin = from.ArrayJoin; | 42 ArrayJoin = from.ArrayJoin; |
46 IsFinite = from.IsFinite; | 43 IsFinite = from.IsFinite; |
47 IsNaN = from.IsNaN; | 44 IsNaN = from.IsNaN; |
48 MathFloor = from.MathFloor; | 45 MathFloor = from.MathFloor; |
49 RegExpTest = from.RegExpTest; | 46 RegExpTest = from.RegExpTest; |
50 StringIndexOf = from.StringIndexOf; | 47 StringIndexOf = from.StringIndexOf; |
51 StringLastIndexOf = from.StringLastIndexOf; | 48 StringLastIndexOf = from.StringLastIndexOf; |
52 StringMatch = from.StringMatch; | 49 StringMatch = from.StringMatch; |
53 StringReplace = from.StringReplace; | 50 StringReplace = from.StringReplace; |
54 StringSplit = from.StringSplit; | 51 StringSplit = from.StringSplit; |
55 StringSubstr = from.StringSubstr; | 52 StringSubstr = from.StringSubstr; |
56 StringSubstring = from.StringSubstring; | 53 StringSubstring = from.StringSubstring; |
| 54 ToNumber = from.ToNumber; |
| 55 }); |
| 56 |
| 57 utils.ImportNow(function(from) { |
| 58 ObjectDefineProperties = from.ObjectDefineProperties; |
| 59 ObjectDefineProperty = from.ObjectDefineProperty; |
57 }); | 60 }); |
58 | 61 |
59 // ------------------------------------------------------------------- | 62 // ------------------------------------------------------------------- |
60 | 63 |
61 var Intl = {}; | 64 var Intl = {}; |
62 | 65 |
63 %AddNamedProperty(global, "Intl", Intl, DONT_ENUM); | 66 %AddNamedProperty(global, "Intl", Intl, DONT_ENUM); |
64 | 67 |
65 /** | 68 /** |
66 * Caches available locales for each service. | 69 * Caches available locales for each service. |
(...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1269 %SetNativeFlag(Intl.NumberFormat.supportedLocalesOf); | 1272 %SetNativeFlag(Intl.NumberFormat.supportedLocalesOf); |
1270 | 1273 |
1271 | 1274 |
1272 /** | 1275 /** |
1273 * Returns a String value representing the result of calling ToNumber(value) | 1276 * Returns a String value representing the result of calling ToNumber(value) |
1274 * according to the effective locale and the formatting options of this | 1277 * according to the effective locale and the formatting options of this |
1275 * NumberFormat. | 1278 * NumberFormat. |
1276 */ | 1279 */ |
1277 function formatNumber(formatter, value) { | 1280 function formatNumber(formatter, value) { |
1278 // Spec treats -0 and +0 as 0. | 1281 // Spec treats -0 and +0 as 0. |
1279 var number = $toNumber(value) + 0; | 1282 var number = ToNumber(value) + 0; |
1280 | 1283 |
1281 return %InternalNumberFormat(%GetImplFromInitializedIntlObject(formatter), | 1284 return %InternalNumberFormat(%GetImplFromInitializedIntlObject(formatter), |
1282 number); | 1285 number); |
1283 } | 1286 } |
1284 | 1287 |
1285 | 1288 |
1286 /** | 1289 /** |
1287 * Returns a Number that represents string value that was passed in. | 1290 * Returns a Number that represents string value that was passed in. |
1288 */ | 1291 */ |
1289 function parseNumber(formatter, value) { | 1292 function parseNumber(formatter, value) { |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1694 /** | 1697 /** |
1695 * Returns a String value representing the result of calling ToNumber(date) | 1698 * Returns a String value representing the result of calling ToNumber(date) |
1696 * according to the effective locale and the formatting options of this | 1699 * according to the effective locale and the formatting options of this |
1697 * DateTimeFormat. | 1700 * DateTimeFormat. |
1698 */ | 1701 */ |
1699 function formatDate(formatter, dateValue) { | 1702 function formatDate(formatter, dateValue) { |
1700 var dateMs; | 1703 var dateMs; |
1701 if (IS_UNDEFINED(dateValue)) { | 1704 if (IS_UNDEFINED(dateValue)) { |
1702 dateMs = %DateCurrentTime(); | 1705 dateMs = %DateCurrentTime(); |
1703 } else { | 1706 } else { |
1704 dateMs = $toNumber(dateValue); | 1707 dateMs = ToNumber(dateValue); |
1705 } | 1708 } |
1706 | 1709 |
1707 if (!IsFinite(dateMs)) throw MakeRangeError(kDateRange); | 1710 if (!IsFinite(dateMs)) throw MakeRangeError(kDateRange); |
1708 | 1711 |
1709 return %InternalDateFormat(%GetImplFromInitializedIntlObject(formatter), | 1712 return %InternalDateFormat(%GetImplFromInitializedIntlObject(formatter), |
1710 new GlobalDate(dateMs)); | 1713 new GlobalDate(dateMs)); |
1711 } | 1714 } |
1712 | 1715 |
1713 | 1716 |
1714 /** | 1717 /** |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2108 } | 2111 } |
2109 | 2112 |
2110 var locales = %_Arguments(0); | 2113 var locales = %_Arguments(0); |
2111 var options = %_Arguments(1); | 2114 var options = %_Arguments(1); |
2112 return toLocaleDateTime( | 2115 return toLocaleDateTime( |
2113 this, locales, options, 'time', 'time', 'dateformattime'); | 2116 this, locales, options, 'time', 'time', 'dateformattime'); |
2114 } | 2117 } |
2115 ); | 2118 ); |
2116 | 2119 |
2117 }) | 2120 }) |
OLD | NEW |