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 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 return collator; | 940 return collator; |
941 } | 941 } |
942 | 942 |
943 | 943 |
944 /** | 944 /** |
945 * Constructs Intl.Collator object given optional locales and options | 945 * Constructs Intl.Collator object given optional locales and options |
946 * parameters. | 946 * parameters. |
947 * | 947 * |
948 * @constructor | 948 * @constructor |
949 */ | 949 */ |
950 %AddNamedProperty(Intl, 'Collator', function() { | 950 function Collator() { |
951 var locales = %_Arguments(0); | 951 var locales = %_Arguments(0); |
952 var options = %_Arguments(1); | 952 var options = %_Arguments(1); |
953 | 953 |
954 if (!this || this === Intl) { | 954 if (IS_UNDEFINED(new.target)) return new Collator(locales, options); |
955 // Constructor is called as a function. | |
956 return new Intl.Collator(locales, options); | |
957 } | |
958 | 955 |
959 return initializeCollator(TO_OBJECT(this), locales, options); | 956 return initializeCollator(this, locales, options); |
960 }, | 957 } |
961 DONT_ENUM | 958 |
962 ); | 959 %AddNamedProperty(Intl, 'Collator', Collator, DONT_ENUM); |
963 | 960 |
964 | 961 |
965 /** | 962 /** |
966 * Collator resolvedOptions method. | 963 * Collator resolvedOptions method. |
967 */ | 964 */ |
968 %AddNamedProperty(Intl.Collator.prototype, 'resolvedOptions', function() { | 965 %AddNamedProperty(Intl.Collator.prototype, 'resolvedOptions', function() { |
969 if (%_IsConstructCall()) { | 966 if (%_IsConstructCall()) { |
970 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 967 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
971 } | 968 } |
972 | 969 |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1182 return numberFormat; | 1179 return numberFormat; |
1183 } | 1180 } |
1184 | 1181 |
1185 | 1182 |
1186 /** | 1183 /** |
1187 * Constructs Intl.NumberFormat object given optional locales and options | 1184 * Constructs Intl.NumberFormat object given optional locales and options |
1188 * parameters. | 1185 * parameters. |
1189 * | 1186 * |
1190 * @constructor | 1187 * @constructor |
1191 */ | 1188 */ |
1192 %AddNamedProperty(Intl, 'NumberFormat', function() { | 1189 function NumberFormat() { |
1193 var locales = %_Arguments(0); | 1190 var locales = %_Arguments(0); |
1194 var options = %_Arguments(1); | 1191 var options = %_Arguments(1); |
1195 | 1192 |
1196 if (!this || this === Intl) { | 1193 if (IS_UNDEFINED(new.target)) return new NumberFormat(locales, options); |
1197 // Constructor is called as a function. | |
1198 return new Intl.NumberFormat(locales, options); | |
1199 } | |
1200 | 1194 |
1201 return initializeNumberFormat(TO_OBJECT(this), locales, options); | 1195 return initializeNumberFormat(this, locales, options); |
1202 }, | 1196 } |
1203 DONT_ENUM | 1197 %AddNamedProperty(Intl, 'NumberFormat', NumberFormat, DONT_ENUM); |
1204 ); | |
1205 | 1198 |
1206 | 1199 |
1207 /** | 1200 /** |
1208 * NumberFormat resolvedOptions method. | 1201 * NumberFormat resolvedOptions method. |
1209 */ | 1202 */ |
1210 %AddNamedProperty(Intl.NumberFormat.prototype, 'resolvedOptions', function() { | 1203 %AddNamedProperty(Intl.NumberFormat.prototype, 'resolvedOptions', function() { |
1211 if (%_IsConstructCall()) { | 1204 if (%_IsConstructCall()) { |
1212 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 1205 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
1213 } | 1206 } |
1214 | 1207 |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1584 return dateFormat; | 1577 return dateFormat; |
1585 } | 1578 } |
1586 | 1579 |
1587 | 1580 |
1588 /** | 1581 /** |
1589 * Constructs Intl.DateTimeFormat object given optional locales and options | 1582 * Constructs Intl.DateTimeFormat object given optional locales and options |
1590 * parameters. | 1583 * parameters. |
1591 * | 1584 * |
1592 * @constructor | 1585 * @constructor |
1593 */ | 1586 */ |
1594 %AddNamedProperty(Intl, 'DateTimeFormat', function() { | 1587 function DateTimeFormat() { |
1595 var locales = %_Arguments(0); | 1588 var locales = %_Arguments(0); |
1596 var options = %_Arguments(1); | 1589 var options = %_Arguments(1); |
1597 | 1590 |
1598 if (!this || this === Intl) { | 1591 if (IS_UNDEFINED(new.target)) return new DateTimeFormat(locales, options); |
1599 // Constructor is called as a function. | |
1600 return new Intl.DateTimeFormat(locales, options); | |
1601 } | |
1602 | 1592 |
1603 return initializeDateTimeFormat(TO_OBJECT(this), locales, options); | 1593 return initializeDateTimeFormat(this, locales, options); |
1604 }, | 1594 } |
1605 DONT_ENUM | 1595 %AddNamedProperty(Intl, 'DateTimeFormat', DateTimeFormat, DONT_ENUM); |
1606 ); | |
1607 | 1596 |
1608 | 1597 |
1609 /** | 1598 /** |
1610 * DateTimeFormat resolvedOptions method. | 1599 * DateTimeFormat resolvedOptions method. |
1611 */ | 1600 */ |
1612 %AddNamedProperty(Intl.DateTimeFormat.prototype, 'resolvedOptions', function() { | 1601 %AddNamedProperty(Intl.DateTimeFormat.prototype, 'resolvedOptions', function() { |
1613 if (%_IsConstructCall()) { | 1602 if (%_IsConstructCall()) { |
1614 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); | 1603 throw MakeTypeError(kOrdinaryFunctionCalledAsConstructor); |
1615 } | 1604 } |
1616 | 1605 |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2113 } | 2102 } |
2114 | 2103 |
2115 var locales = %_Arguments(0); | 2104 var locales = %_Arguments(0); |
2116 var options = %_Arguments(1); | 2105 var options = %_Arguments(1); |
2117 return toLocaleDateTime( | 2106 return toLocaleDateTime( |
2118 this, locales, options, 'time', 'time', 'dateformattime'); | 2107 this, locales, options, 'time', 'time', 'dateformattime'); |
2119 } | 2108 } |
2120 ); | 2109 ); |
2121 | 2110 |
2122 }) | 2111 }) |
OLD | NEW |