Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: src/js/i18n.js

Issue 1828543007: Add new semantics + compat fallback to Intl constructor Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add tests; make more minimal Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 11 matching lines...) Expand all
22 var ArrayPush; 22 var ArrayPush;
23 var InstallFunctions = utils.InstallFunctions; 23 var InstallFunctions = utils.InstallFunctions;
24 var InstallGetter = utils.InstallGetter; 24 var InstallGetter = utils.InstallGetter;
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 GlobalSymbol = global.Symbol;
32 var MakeError; 33 var MakeError;
33 var MakeRangeError; 34 var MakeRangeError;
34 var MakeTypeError; 35 var MakeTypeError;
35 var MathFloor; 36 var MathFloor;
36 var ObjectDefineProperties = utils.ImportNow("ObjectDefineProperties"); 37 var ObjectDefineProperties = utils.ImportNow("ObjectDefineProperties");
37 var ObjectDefineProperty = utils.ImportNow("ObjectDefineProperty"); 38 var ObjectDefineProperty = utils.ImportNow("ObjectDefineProperty");
38 var ObjectHasOwnProperty = utils.ImportNow("ObjectHasOwnProperty"); 39 var ObjectHasOwnProperty = utils.ImportNow("ObjectHasOwnProperty");
39 var OverrideFunction = utils.OverrideFunction; 40 var OverrideFunction = utils.OverrideFunction;
40 var patternSymbol = utils.ImportNow("intl_pattern_symbol"); 41 var patternSymbol = utils.ImportNow("intl_pattern_symbol");
41 var RegExpTest; 42 var RegExpTest;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 78
78 79
79 function InstallConstructor(object, name, func) { 80 function InstallConstructor(object, name, func) {
80 %CheckIsBootstrapping(); 81 %CheckIsBootstrapping();
81 SetFunctionName(func, name); 82 SetFunctionName(func, name);
82 %AddNamedProperty(object, name, func, DONT_ENUM); 83 %AddNamedProperty(object, name, func, DONT_ENUM);
83 %SetNativeFlag(func); 84 %SetNativeFlag(func);
84 %ToFastProperties(object); 85 %ToFastProperties(object);
85 } 86 }
86 87
88 var fallbackSymbol = GlobalSymbol("intl fallback");
89
87 /** 90 /**
88 * Adds bound method to the prototype of the given object. 91 * Adds bound method to the prototype of the given object.
89 */ 92 */
90 function AddBoundMethod(obj, methodName, implementation, length) { 93 function AddBoundMethod(obj, methodName, implementation, length, typename, compa t) {
91 %CheckIsBootstrapping(); 94 %CheckIsBootstrapping();
92 var internalName = %CreatePrivateSymbol(methodName); 95 var internalName = %CreatePrivateSymbol(methodName);
93 var getter = function() { 96 var getter = function() {
94 if (!%IsInitializedIntlObject(this)) { 97 var receiver = Unwrap(this, typename, obj, methodName, compat);
95 throw MakeTypeError(kMethodCalledOnWrongObject, methodName); 98 if (IS_UNDEFINED(receiver[internalName])) {
96 }
97 if (IS_UNDEFINED(this[internalName])) {
98 var boundMethod; 99 var boundMethod;
99 if (IS_UNDEFINED(length) || length === 2) { 100 if (IS_UNDEFINED(length) || length === 2) {
100 boundMethod = (x, y) => implementation(this, x, y); 101 boundMethod = (x, y) => implementation(receiver, x, y);
101 } else if (length === 1) { 102 } else if (length === 1) {
102 boundMethod = x => implementation(this, x); 103 boundMethod = x => implementation(receiver, x);
103 } else { 104 } else {
104 boundMethod = (...args) => { 105 boundMethod = (...args) => {
105 // DateTimeFormat.format needs to be 0 arg method, but can stil 106 // DateTimeFormat.format needs to be 0 arg method, but can stil
106 // receive optional dateValue param. If one was provided, pass it 107 // receive optional dateValue param. If one was provided, pass it
107 // along. 108 // along.
108 if (args.length > 0) { 109 if (args.length > 0) {
109 return implementation(this, args[0]); 110 return implementation(receiver, args[0]);
110 } else { 111 } else {
111 return implementation(this); 112 return implementation(receiver);
112 } 113 }
113 } 114 }
114 } 115 }
115 // TODO(littledan): Once function name reform is shipped, remove the 116 // TODO(littledan): Once function name reform is shipped, remove the
116 // following line and wrap the boundMethod definition in an anonymous 117 // following line and wrap the boundMethod definition in an anonymous
117 // function macro. 118 // function macro.
118 %FunctionSetName(boundMethod, '__bound' + methodName + '__'); 119 %FunctionSetName(boundMethod, '__bound' + methodName + '__');
119 %FunctionRemovePrototype(boundMethod); 120 %FunctionRemovePrototype(boundMethod);
120 %SetNativeFlag(boundMethod); 121 %SetNativeFlag(boundMethod);
121 this[internalName] = boundMethod; 122 receiver[internalName] = boundMethod;
122 } 123 }
123 return this[internalName]; 124 return receiver[internalName];
124 }; 125 };
125 126
126 InstallGetter(obj.prototype, methodName, getter, DONT_ENUM); 127 InstallGetter(obj.prototype, methodName, getter, DONT_ENUM);
127 } 128 }
128 129
130 function IntlConstruct(receiver, constructor, initializer, newTarget, args,
131 compat) {
132 var locales = args[0];
133 var options = args[1];
134
135 if (IS_UNDEFINED(newTarget)) {
136 if (compat && receiver instanceof constructor) {
137 let success = ObjectDefineProperty(receiver, fallbackSymbol,
138 { value: new constructor(locales, options) });
139 if (!success) {
140 throw MakeTypeError(kReinitializeIntl, constructor);
141 }
142 return receiver;
143 }
144
145 return new constructor(locales, options);
146 }
147
148 return initializer(receiver, locales, options);
149 }
150
151
152
153 function Unwrap(receiver, typename, constructor, method, compat) {
154 if (!%IsInitializedIntlObjectOfType(receiver, typename)) {
155 if (compat && receiver instanceof constructor) {
156 let fallback = receiver[fallbackSymbol];
157 if (%IsInitializedIntlObjectOfType(fallback, typename)) {
158 return fallback;
159 }
160 }
161 throw MakeTypeError(kIncompatibleMethodReceiver, method, receiver);
162 }
163 return receiver;
164 }
165
166
129 // ------------------------------------------------------------------- 167 // -------------------------------------------------------------------
130 168
131 var Intl = {}; 169 var Intl = {};
132 170
133 %AddNamedProperty(global, "Intl", Intl, DONT_ENUM); 171 %AddNamedProperty(global, "Intl", Intl, DONT_ENUM);
134 172
135 /** 173 /**
136 * Caches available locales for each service. 174 * Caches available locales for each service.
137 */ 175 */
138 var AVAILABLE_LOCALES = { 176 var AVAILABLE_LOCALES = {
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 return collator; 1033 return collator;
996 } 1034 }
997 1035
998 1036
999 /** 1037 /**
1000 * Constructs Intl.Collator object given optional locales and options 1038 * Constructs Intl.Collator object given optional locales and options
1001 * parameters. 1039 * parameters.
1002 * 1040 *
1003 * @constructor 1041 * @constructor
1004 */ 1042 */
1005 InstallConstructor(Intl, 'Collator', function() { 1043 function Collator() {
1006 var locales = arguments[0]; 1044 return IntlConstruct(this, Collator, initializeCollator, new.target,
1007 var options = arguments[1]; 1045 arguments);
1008 1046 }
1009 if (!this || this === Intl) { 1047 InstallConstructor(Intl, 'Collator', Collator);
1010 // Constructor is called as a function.
1011 return new Intl.Collator(locales, options);
1012 }
1013
1014 return initializeCollator(TO_OBJECT(this), locales, options);
1015 }
1016 );
1017 1048
1018 1049
1019 /** 1050 /**
1020 * Collator resolvedOptions method. 1051 * Collator resolvedOptions method.
1021 */ 1052 */
1022 InstallFunction(Intl.Collator.prototype, 'resolvedOptions', function() { 1053 InstallFunction(Intl.Collator.prototype, 'resolvedOptions', function() {
1023 if (!IS_UNDEFINED(new.target)) { 1054 if (!IS_UNDEFINED(new.target)) {
1024 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); 1055 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
1025 } 1056 }
1026 1057
1027 if (!%IsInitializedIntlObjectOfType(this, 'collator')) { 1058 var coll = Unwrap(this, 'collator', Collator, 'resolvedOptions', true);
1028 throw MakeTypeError(kResolvedOptionsCalledOnNonObject, "Collator");
1029 }
1030
1031 var coll = this;
1032 var locale = getOptimalLanguageTag(coll[resolvedSymbol].requestedLocale, 1059 var locale = getOptimalLanguageTag(coll[resolvedSymbol].requestedLocale,
1033 coll[resolvedSymbol].locale); 1060 coll[resolvedSymbol].locale);
1034 1061
1035 return { 1062 return {
1036 locale: locale, 1063 locale: locale,
1037 usage: coll[resolvedSymbol].usage, 1064 usage: coll[resolvedSymbol].usage,
1038 sensitivity: coll[resolvedSymbol].sensitivity, 1065 sensitivity: coll[resolvedSymbol].sensitivity,
1039 ignorePunctuation: coll[resolvedSymbol].ignorePunctuation, 1066 ignorePunctuation: coll[resolvedSymbol].ignorePunctuation,
1040 numeric: coll[resolvedSymbol].numeric, 1067 numeric: coll[resolvedSymbol].numeric,
1041 caseFirst: coll[resolvedSymbol].caseFirst, 1068 caseFirst: coll[resolvedSymbol].caseFirst,
(...skipping 28 matching lines...) Expand all
1070 * of this Collator object, and will be negative, zero, or positive, depending 1097 * of this Collator object, and will be negative, zero, or positive, depending
1071 * on whether x comes before y in the sort order, the Strings are equal under 1098 * on whether x comes before y in the sort order, the Strings are equal under
1072 * the sort order, or x comes after y in the sort order, respectively. 1099 * the sort order, or x comes after y in the sort order, respectively.
1073 */ 1100 */
1074 function compare(collator, x, y) { 1101 function compare(collator, x, y) {
1075 return %InternalCompare(%GetImplFromInitializedIntlObject(collator), 1102 return %InternalCompare(%GetImplFromInitializedIntlObject(collator),
1076 GlobalString(x), GlobalString(y)); 1103 GlobalString(x), GlobalString(y));
1077 }; 1104 };
1078 1105
1079 1106
1080 AddBoundMethod(Intl.Collator, 'compare', compare, 2); 1107 AddBoundMethod(Intl.Collator, 'compare', compare, 2, 'collator', Collator);
1081 1108
1082 /** 1109 /**
1083 * Verifies that the input is a well-formed ISO 4217 currency code. 1110 * Verifies that the input is a well-formed ISO 4217 currency code.
1084 * Don't uppercase to test. It could convert invalid code into a valid one. 1111 * Don't uppercase to test. It could convert invalid code into a valid one.
1085 * For example \u00DFP (Eszett+P) becomes SSP. 1112 * For example \u00DFP (Eszett+P) becomes SSP.
1086 */ 1113 */
1087 function isWellFormedCurrencyCode(currency) { 1114 function isWellFormedCurrencyCode(currency) {
1088 return typeof currency == "string" && 1115 return typeof currency == "string" &&
1089 currency.length == 3 && 1116 currency.length == 3 &&
1090 %_Call(StringMatch, currency, /[^A-Za-z]/) == null; 1117 %_Call(StringMatch, currency, /[^A-Za-z]/) == null;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 return numberFormat; 1266 return numberFormat;
1240 } 1267 }
1241 1268
1242 1269
1243 /** 1270 /**
1244 * Constructs Intl.NumberFormat object given optional locales and options 1271 * Constructs Intl.NumberFormat object given optional locales and options
1245 * parameters. 1272 * parameters.
1246 * 1273 *
1247 * @constructor 1274 * @constructor
1248 */ 1275 */
1249 InstallConstructor(Intl, 'NumberFormat', function() { 1276 function NumberFormat() {
1250 var locales = arguments[0]; 1277 return IntlConstruct(this, NumberFormat, initializeNumberFormat, new.target,
1251 var options = arguments[1]; 1278 arguments, true);
1252 1279 }
1253 if (!this || this === Intl) { 1280 InstallConstructor(Intl, 'NumberFormat', NumberFormat);
1254 // Constructor is called as a function.
1255 return new Intl.NumberFormat(locales, options);
1256 }
1257
1258 return initializeNumberFormat(TO_OBJECT(this), locales, options);
1259 }
1260 );
1261 1281
1262 1282
1263 /** 1283 /**
1264 * NumberFormat resolvedOptions method. 1284 * NumberFormat resolvedOptions method.
1265 */ 1285 */
1266 InstallFunction(Intl.NumberFormat.prototype, 'resolvedOptions', function() { 1286 InstallFunction(Intl.NumberFormat.prototype, 'resolvedOptions', function() {
1267 if (!IS_UNDEFINED(new.target)) { 1287 if (!IS_UNDEFINED(new.target)) {
1268 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); 1288 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
1269 } 1289 }
1270 1290
1271 if (!%IsInitializedIntlObjectOfType(this, 'numberformat')) { 1291 var format = Unwrap(this, 'numberformat', NumberFormat,
1272 throw MakeTypeError(kResolvedOptionsCalledOnNonObject, "NumberFormat"); 1292 'resolvedOptions', true);
1273 }
1274
1275 var format = this;
1276 var locale = getOptimalLanguageTag(format[resolvedSymbol].requestedLocale, 1293 var locale = getOptimalLanguageTag(format[resolvedSymbol].requestedLocale,
1277 format[resolvedSymbol].locale); 1294 format[resolvedSymbol].locale);
1278 1295
1279 var result = { 1296 var result = {
1280 locale: locale, 1297 locale: locale,
1281 numberingSystem: format[resolvedSymbol].numberingSystem, 1298 numberingSystem: format[resolvedSymbol].numberingSystem,
1282 style: format[resolvedSymbol].style, 1299 style: format[resolvedSymbol].style,
1283 useGrouping: format[resolvedSymbol].useGrouping, 1300 useGrouping: format[resolvedSymbol].useGrouping,
1284 minimumIntegerDigits: format[resolvedSymbol].minimumIntegerDigits, 1301 minimumIntegerDigits: format[resolvedSymbol].minimumIntegerDigits,
1285 minimumFractionDigits: format[resolvedSymbol].minimumFractionDigits, 1302 minimumFractionDigits: format[resolvedSymbol].minimumFractionDigits,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 1356
1340 /** 1357 /**
1341 * Returns a Number that represents string value that was passed in. 1358 * Returns a Number that represents string value that was passed in.
1342 */ 1359 */
1343 function parseNumber(formatter, value) { 1360 function parseNumber(formatter, value) {
1344 return %InternalNumberParse(%GetImplFromInitializedIntlObject(formatter), 1361 return %InternalNumberParse(%GetImplFromInitializedIntlObject(formatter),
1345 GlobalString(value)); 1362 GlobalString(value));
1346 } 1363 }
1347 1364
1348 1365
1349 AddBoundMethod(Intl.NumberFormat, 'format', formatNumber, 1); 1366 AddBoundMethod(Intl.NumberFormat, 'format', formatNumber, 1, 'numberformat', tru e);
1350 AddBoundMethod(Intl.NumberFormat, 'v8Parse', parseNumber, 1); 1367 AddBoundMethod(Intl.NumberFormat, 'v8Parse', parseNumber, 1, 'numberformat');
1351 1368
1352 /** 1369 /**
1353 * Returns a string that matches LDML representation of the options object. 1370 * Returns a string that matches LDML representation of the options object.
1354 */ 1371 */
1355 function toLDMLString(options) { 1372 function toLDMLString(options) {
1356 var getOption = getGetOption(options, 'dateformat'); 1373 var getOption = getGetOption(options, 'dateformat');
1357 1374
1358 var ldmlString = ''; 1375 var ldmlString = '';
1359 1376
1360 var option = getOption('weekday', 'string', ['narrow', 'short', 'long']); 1377 var option = getOption('weekday', 'string', ['narrow', 'short', 'long']);
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1633 return dateFormat; 1650 return dateFormat;
1634 } 1651 }
1635 1652
1636 1653
1637 /** 1654 /**
1638 * Constructs Intl.DateTimeFormat object given optional locales and options 1655 * Constructs Intl.DateTimeFormat object given optional locales and options
1639 * parameters. 1656 * parameters.
1640 * 1657 *
1641 * @constructor 1658 * @constructor
1642 */ 1659 */
1643 InstallConstructor(Intl, 'DateTimeFormat', function() { 1660 function DateTimeFormat() {
1644 var locales = arguments[0]; 1661 return IntlConstruct(this, DateTimeFormat, initializeDateTimeFormat,
1645 var options = arguments[1]; 1662 new.target, arguments, true);
1646 1663 }
1647 if (!this || this === Intl) { 1664 InstallConstructor(Intl, 'DateTimeFormat', DateTimeFormat);
1648 // Constructor is called as a function.
1649 return new Intl.DateTimeFormat(locales, options);
1650 }
1651
1652 return initializeDateTimeFormat(TO_OBJECT(this), locales, options);
1653 }
1654 );
1655 1665
1656 1666
1657 /** 1667 /**
1658 * DateTimeFormat resolvedOptions method. 1668 * DateTimeFormat resolvedOptions method.
1659 */ 1669 */
1660 InstallFunction(Intl.DateTimeFormat.prototype, 'resolvedOptions', function() { 1670 InstallFunction(Intl.DateTimeFormat.prototype, 'resolvedOptions', function() {
1661 if (!IS_UNDEFINED(new.target)) { 1671 if (!IS_UNDEFINED(new.target)) {
1662 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); 1672 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
1663 } 1673 }
1664 1674
1665 if (!%IsInitializedIntlObjectOfType(this, 'dateformat')) { 1675 var format = Unwrap(this, 'dateformat', DateTimeFormat,
1666 throw MakeTypeError(kResolvedOptionsCalledOnNonObject, "DateTimeFormat"); 1676 'resolvedOptions', true);
1667 }
1668 1677
1669 /** 1678 /**
1670 * Maps ICU calendar names into LDML type. 1679 * Maps ICU calendar names into LDML type.
1671 */ 1680 */
1672 var ICU_CALENDAR_MAP = { 1681 var ICU_CALENDAR_MAP = {
1673 'gregorian': 'gregory', 1682 'gregorian': 'gregory',
1674 'japanese': 'japanese', 1683 'japanese': 'japanese',
1675 'buddhist': 'buddhist', 1684 'buddhist': 'buddhist',
1676 'roc': 'roc', 1685 'roc': 'roc',
1677 'persian': 'persian', 1686 'persian': 'persian',
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1762 * DateTimeFormat. 1771 * DateTimeFormat.
1763 * Returns undefined if date string cannot be parsed. 1772 * Returns undefined if date string cannot be parsed.
1764 */ 1773 */
1765 function parseDate(formatter, value) { 1774 function parseDate(formatter, value) {
1766 return %InternalDateParse(%GetImplFromInitializedIntlObject(formatter), 1775 return %InternalDateParse(%GetImplFromInitializedIntlObject(formatter),
1767 GlobalString(value)); 1776 GlobalString(value));
1768 } 1777 }
1769 1778
1770 1779
1771 // 0 because date is optional argument. 1780 // 0 because date is optional argument.
1772 AddBoundMethod(Intl.DateTimeFormat, 'format', formatDate, 0); 1781 AddBoundMethod(Intl.DateTimeFormat, 'format', formatDate, 0, 'dateformat', true) ;
1773 AddBoundMethod(Intl.DateTimeFormat, 'v8Parse', parseDate, 1); 1782 AddBoundMethod(Intl.DateTimeFormat, 'v8Parse', parseDate, 1, 'dateformat');
1774 1783
1775 1784
1776 /** 1785 /**
1777 * Returns canonical Area/Location(/Location) name, or throws an exception 1786 * Returns canonical Area/Location(/Location) name, or throws an exception
1778 * if the zone name is invalid IANA name. 1787 * if the zone name is invalid IANA name.
1779 */ 1788 */
1780 function canonicalizeTimeZoneID(tzID) { 1789 function canonicalizeTimeZoneID(tzID) {
1781 // Skip undefined zones. 1790 // Skip undefined zones.
1782 if (IS_UNDEFINED(tzID)) { 1791 if (IS_UNDEFINED(tzID)) {
1783 return tzID; 1792 return tzID;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1850 return iterator; 1859 return iterator;
1851 } 1860 }
1852 1861
1853 1862
1854 /** 1863 /**
1855 * Constructs Intl.v8BreakIterator object given optional locales and options 1864 * Constructs Intl.v8BreakIterator object given optional locales and options
1856 * parameters. 1865 * parameters.
1857 * 1866 *
1858 * @constructor 1867 * @constructor
1859 */ 1868 */
1860 InstallConstructor(Intl, 'v8BreakIterator', function() { 1869 function v8BreakIterator() {
1861 var locales = arguments[0]; 1870 return IntlConstruct(this, v8BreakIterator, initializeBreakIterator,
1862 var options = arguments[1]; 1871 new.target, arguments);
1863 1872 }
1864 if (!this || this === Intl) { 1873 InstallConstructor(Intl, 'v8BreakIterator', v8BreakIterator);
1865 // Constructor is called as a function.
1866 return new Intl.v8BreakIterator(locales, options);
1867 }
1868
1869 return initializeBreakIterator(TO_OBJECT(this), locales, options);
1870 }
1871 );
1872 1874
1873 1875
1874 /** 1876 /**
1875 * BreakIterator resolvedOptions method. 1877 * BreakIterator resolvedOptions method.
1876 */ 1878 */
1877 InstallFunction(Intl.v8BreakIterator.prototype, 'resolvedOptions', 1879 InstallFunction(Intl.v8BreakIterator.prototype, 'resolvedOptions',
1878 function() { 1880 function() {
1879 if (!IS_UNDEFINED(new.target)) { 1881 if (!IS_UNDEFINED(new.target)) {
1880 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); 1882 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor);
1881 } 1883 }
1882 1884
1883 if (!%IsInitializedIntlObjectOfType(this, 'breakiterator')) { 1885 var format = Unwrap(this, 'breakiterator', v8BreakIterator, 'resolvedOptions ');
1884 throw MakeTypeError(kResolvedOptionsCalledOnNonObject, "v8BreakIterator");
1885 }
1886 1886
1887 var segmenter = this; 1887 var segmenter = this;
1888 var locale = 1888 var locale =
1889 getOptimalLanguageTag(segmenter[resolvedSymbol].requestedLocale, 1889 getOptimalLanguageTag(segmenter[resolvedSymbol].requestedLocale,
1890 segmenter[resolvedSymbol].locale); 1890 segmenter[resolvedSymbol].locale);
1891 1891
1892 return { 1892 return {
1893 locale: locale, 1893 locale: locale,
1894 type: segmenter[resolvedSymbol].type 1894 type: segmenter[resolvedSymbol].type
1895 }; 1895 };
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1949 1949
1950 1950
1951 /** 1951 /**
1952 * Returns type of the current break. 1952 * Returns type of the current break.
1953 */ 1953 */
1954 function breakType(iterator) { 1954 function breakType(iterator) {
1955 return %BreakIteratorBreakType(%GetImplFromInitializedIntlObject(iterator)); 1955 return %BreakIteratorBreakType(%GetImplFromInitializedIntlObject(iterator));
1956 } 1956 }
1957 1957
1958 1958
1959 AddBoundMethod(Intl.v8BreakIterator, 'adoptText', adoptText, 1); 1959 AddBoundMethod(Intl.v8BreakIterator, 'adoptText', adoptText, 1, 'breakiterator') ;
1960 AddBoundMethod(Intl.v8BreakIterator, 'first', first, 0); 1960 AddBoundMethod(Intl.v8BreakIterator, 'first', first, 0, 'breakiterator');
1961 AddBoundMethod(Intl.v8BreakIterator, 'next', next, 0); 1961 AddBoundMethod(Intl.v8BreakIterator, 'next', next, 0, 'breakiterator');
1962 AddBoundMethod(Intl.v8BreakIterator, 'current', current, 0); 1962 AddBoundMethod(Intl.v8BreakIterator, 'current', current, 0, 'breakiterator');
1963 AddBoundMethod(Intl.v8BreakIterator, 'breakType', breakType, 0); 1963 AddBoundMethod(Intl.v8BreakIterator, 'breakType', breakType, 0, 'breakiterator') ;
1964 1964
1965 // Save references to Intl objects and methods we use, for added security. 1965 // Save references to Intl objects and methods we use, for added security.
1966 var savedObjects = { 1966 var savedObjects = {
1967 'collator': Intl.Collator, 1967 'collator': Intl.Collator,
1968 'numberformat': Intl.NumberFormat, 1968 'numberformat': Intl.NumberFormat,
1969 'dateformatall': Intl.DateTimeFormat, 1969 'dateformatall': Intl.DateTimeFormat,
1970 'dateformatdate': Intl.DateTimeFormat, 1970 'dateformatdate': Intl.DateTimeFormat,
1971 'dateformattime': Intl.DateTimeFormat 1971 'dateformattime': Intl.DateTimeFormat
1972 }; 1972 };
1973 1973
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
2138 } 2138 }
2139 2139
2140 var locales = arguments[0]; 2140 var locales = arguments[0];
2141 var options = arguments[1]; 2141 var options = arguments[1];
2142 return toLocaleDateTime( 2142 return toLocaleDateTime(
2143 this, locales, options, 'time', 'time', 'dateformattime'); 2143 this, locales, options, 'time', 'time', 'dateformattime');
2144 } 2144 }
2145 ); 2145 );
2146 2146
2147 }) 2147 })
OLDNEW
« no previous file with comments | « no previous file | src/messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698