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 15 matching lines...) Expand all Loading... | |
26 var GlobalDate = global.Date; | 26 var GlobalDate = global.Date; |
27 var GlobalNumber = global.Number; | 27 var GlobalNumber = global.Number; |
28 var GlobalRegExp = global.RegExp; | 28 var GlobalRegExp = global.RegExp; |
29 var GlobalString = global.String; | 29 var GlobalString = global.String; |
30 var MakeError; | 30 var MakeError; |
31 var MakeRangeError; | 31 var MakeRangeError; |
32 var MakeTypeError; | 32 var MakeTypeError; |
33 var MathFloor; | 33 var MathFloor; |
34 var ObjectDefineProperties = utils.ImportNow("ObjectDefineProperties"); | 34 var ObjectDefineProperties = utils.ImportNow("ObjectDefineProperties"); |
35 var ObjectDefineProperty = utils.ImportNow("ObjectDefineProperty"); | 35 var ObjectDefineProperty = utils.ImportNow("ObjectDefineProperty"); |
36 var patternSymbol = utils.ImportNow("pattern_symbol"); | |
36 var RegExpTest; | 37 var RegExpTest; |
37 var StringIndexOf; | 38 var StringIndexOf; |
38 var StringLastIndexOf; | 39 var StringLastIndexOf; |
39 var StringMatch; | 40 var StringMatch; |
40 var StringReplace; | 41 var StringReplace; |
41 var StringSplit; | 42 var StringSplit; |
42 var StringSubstr; | 43 var StringSubstr; |
43 var StringSubstring; | 44 var StringSubstring; |
45 const kIntlPattern = 15; | |
44 | 46 |
45 utils.Import(function(from) { | 47 utils.Import(function(from) { |
46 ArrayIndexOf = from.ArrayIndexOf; | 48 ArrayIndexOf = from.ArrayIndexOf; |
47 ArrayJoin = from.ArrayJoin; | 49 ArrayJoin = from.ArrayJoin; |
48 ArrayPush = from.ArrayPush; | 50 ArrayPush = from.ArrayPush; |
49 IsFinite = from.IsFinite; | 51 IsFinite = from.IsFinite; |
50 IsNaN = from.IsNaN; | 52 IsNaN = from.IsNaN; |
51 MakeError = from.MakeError; | 53 MakeError = from.MakeError; |
52 MakeRangeError = from.MakeRangeError; | 54 MakeRangeError = from.MakeRangeError; |
53 MakeTypeError = from.MakeTypeError; | 55 MakeTypeError = from.MakeTypeError; |
(...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1150 | 1152 |
1151 var requestedLocale = locale.locale + extension; | 1153 var requestedLocale = locale.locale + extension; |
1152 var resolved = ObjectDefineProperties({}, { | 1154 var resolved = ObjectDefineProperties({}, { |
1153 currency: {writable: true}, | 1155 currency: {writable: true}, |
1154 currencyDisplay: {writable: true}, | 1156 currencyDisplay: {writable: true}, |
1155 locale: {writable: true}, | 1157 locale: {writable: true}, |
1156 maximumFractionDigits: {writable: true}, | 1158 maximumFractionDigits: {writable: true}, |
1157 minimumFractionDigits: {writable: true}, | 1159 minimumFractionDigits: {writable: true}, |
1158 minimumIntegerDigits: {writable: true}, | 1160 minimumIntegerDigits: {writable: true}, |
1159 numberingSystem: {writable: true}, | 1161 numberingSystem: {writable: true}, |
1162 pattern: {get() { | |
1163 %IncrementUseCounter(kIntlPattern); | |
1164 return this[patternSymbol]; | |
1165 }}, | |
1160 requestedLocale: {value: requestedLocale, writable: true}, | 1166 requestedLocale: {value: requestedLocale, writable: true}, |
1161 style: {value: internalOptions.style, writable: true}, | 1167 style: {value: internalOptions.style, writable: true}, |
1162 useGrouping: {writable: true} | 1168 useGrouping: {writable: true} |
1163 }); | 1169 }); |
1164 if (%HasOwnProperty(internalOptions, 'minimumSignificantDigits')) { | 1170 if (%HasOwnProperty(internalOptions, 'minimumSignificantDigits')) { |
1165 defineWEProperty(resolved, 'minimumSignificantDigits', UNDEFINED); | 1171 defineWEProperty(resolved, 'minimumSignificantDigits', UNDEFINED); |
1166 } | 1172 } |
1167 if (%HasOwnProperty(internalOptions, 'maximumSignificantDigits')) { | 1173 if (%HasOwnProperty(internalOptions, 'maximumSignificantDigits')) { |
1168 defineWEProperty(resolved, 'maximumSignificantDigits', UNDEFINED); | 1174 defineWEProperty(resolved, 'maximumSignificantDigits', UNDEFINED); |
1169 } | 1175 } |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1554 var resolved = ObjectDefineProperties({}, { | 1560 var resolved = ObjectDefineProperties({}, { |
1555 calendar: {writable: true}, | 1561 calendar: {writable: true}, |
1556 day: {writable: true}, | 1562 day: {writable: true}, |
1557 era: {writable: true}, | 1563 era: {writable: true}, |
1558 hour12: {writable: true}, | 1564 hour12: {writable: true}, |
1559 hour: {writable: true}, | 1565 hour: {writable: true}, |
1560 locale: {writable: true}, | 1566 locale: {writable: true}, |
1561 minute: {writable: true}, | 1567 minute: {writable: true}, |
1562 month: {writable: true}, | 1568 month: {writable: true}, |
1563 numberingSystem: {writable: true}, | 1569 numberingSystem: {writable: true}, |
1564 pattern: {writable: true}, | 1570 [patternSymbol]: {writable: true}, |
1571 pattern: {get() { | |
adamk
2016/01/05 19:10:09
Don't you want a setter too, since the old propert
Dan Ehrenberg
2016/01/06 03:20:55
Oh, good point. Done.
| |
1572 %IncrementUseCounter(kIntlPattern); | |
1573 return this[patternSymbol]; | |
1574 }}, | |
1565 requestedLocale: {value: requestedLocale, writable: true}, | 1575 requestedLocale: {value: requestedLocale, writable: true}, |
1566 second: {writable: true}, | 1576 second: {writable: true}, |
1567 timeZone: {writable: true}, | 1577 timeZone: {writable: true}, |
1568 timeZoneName: {writable: true}, | 1578 timeZoneName: {writable: true}, |
1569 tz: {value: tz, writable: true}, | 1579 tz: {value: tz, writable: true}, |
1570 weekday: {writable: true}, | 1580 weekday: {writable: true}, |
1571 year: {writable: true} | 1581 year: {writable: true} |
1572 }); | 1582 }); |
1573 | 1583 |
1574 var formatter = %CreateDateTimeFormat( | 1584 var formatter = %CreateDateTimeFormat( |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1631 'islamic': 'islamic', | 1641 'islamic': 'islamic', |
1632 'hebrew': 'hebrew', | 1642 'hebrew': 'hebrew', |
1633 'chinese': 'chinese', | 1643 'chinese': 'chinese', |
1634 'indian': 'indian', | 1644 'indian': 'indian', |
1635 'coptic': 'coptic', | 1645 'coptic': 'coptic', |
1636 'ethiopic': 'ethiopic', | 1646 'ethiopic': 'ethiopic', |
1637 'ethiopic-amete-alem': 'ethioaa' | 1647 'ethiopic-amete-alem': 'ethioaa' |
1638 }; | 1648 }; |
1639 | 1649 |
1640 var format = this; | 1650 var format = this; |
1641 var fromPattern = fromLDMLString(format.resolved.pattern); | 1651 var fromPattern = fromLDMLString(format.resolved[patternSymbol]); |
1642 var userCalendar = ICU_CALENDAR_MAP[format.resolved.calendar]; | 1652 var userCalendar = ICU_CALENDAR_MAP[format.resolved.calendar]; |
1643 if (IS_UNDEFINED(userCalendar)) { | 1653 if (IS_UNDEFINED(userCalendar)) { |
1644 // Use ICU name if we don't have a match. It shouldn't happen, but | 1654 // Use ICU name if we don't have a match. It shouldn't happen, but |
1645 // it would be too strict to throw for this. | 1655 // it would be too strict to throw for this. |
1646 userCalendar = format.resolved.calendar; | 1656 userCalendar = format.resolved.calendar; |
1647 } | 1657 } |
1648 | 1658 |
1649 var locale = getOptimalLanguageTag(format.resolved.requestedLocale, | 1659 var locale = getOptimalLanguageTag(format.resolved.requestedLocale, |
1650 format.resolved.locale); | 1660 format.resolved.locale); |
1651 | 1661 |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2113 } | 2123 } |
2114 | 2124 |
2115 var locales = %_Arguments(0); | 2125 var locales = %_Arguments(0); |
2116 var options = %_Arguments(1); | 2126 var options = %_Arguments(1); |
2117 return toLocaleDateTime( | 2127 return toLocaleDateTime( |
2118 this, locales, options, 'time', 'time', 'dateformattime'); | 2128 this, locales, options, 'time', 'time', 'dateformattime'); |
2119 } | 2129 } |
2120 ); | 2130 ); |
2121 | 2131 |
2122 }) | 2132 }) |
OLD | NEW |