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

Side by Side Diff: src/v8natives.js

Issue 1154743003: Revert of Hook up more import/exports in natives. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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 | « src/uri.js ('k') | src/weak-collection.js » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 var $delete;
5 var $functionSourceString; 6 var $functionSourceString;
7 var $getIterator;
8 var $getMethod;
6 var $globalEval; 9 var $globalEval;
10 var $installConstants;
11 var $installFunctions;
12 var $installGetter;
13 var $isFinite;
14 var $isNaN;
15 var $newFunctionString;
16 var $numberIsNaN;
17 var $objectDefineProperties;
18 var $objectDefineProperty;
19 var $objectFreeze;
7 var $objectGetOwnPropertyDescriptor; 20 var $objectGetOwnPropertyDescriptor;
21 var $objectGetOwnPropertyKeys;
22 var $objectHasOwnProperty;
23 var $objectIsFrozen;
24 var $objectIsSealed;
25 var $objectLookupGetter;
26 var $objectLookupSetter;
27 var $objectToString;
28 var $overrideFunction;
29 var $ownPropertyKeys;
30 var $setFunctionName;
31 var $setUpLockedPrototype;
8 var $toCompletePropertyDescriptor; 32 var $toCompletePropertyDescriptor;
33 var $toNameArray;
9 34
10 (function(global, utils) { 35 (function(global, utils) {
11 36
12 %CheckIsBootstrapping(); 37 %CheckIsBootstrapping();
13 38
14 // ---------------------------------------------------------------------------- 39 // ----------------------------------------------------------------------------
15 // Imports 40 // Imports
16 41
17 var GlobalArray = global.Array; 42 var GlobalArray = global.Array;
18 var GlobalBoolean = global.Boolean; 43 var GlobalBoolean = global.Boolean;
19 var GlobalFunction = global.Function; 44 var GlobalFunction = global.Function;
20 var GlobalNumber = global.Number; 45 var GlobalNumber = global.Number;
21 var GlobalObject = global.Object; 46 var GlobalObject = global.Object;
22 var InternalArray = utils.InternalArray; 47 var InternalArray = utils.InternalArray;
23 48
24 var MathAbs; 49 var MathAbs;
25 var ProxyDelegateCallAndConstruct;
26 var ProxyDerivedHasOwnTrap;
27 var ProxyDerivedKeysTrap;
28 var StringIndexOf; 50 var StringIndexOf;
29 51
30 utils.Import(function(from) { 52 utils.Import(function(from) {
31 MathAbs = from.MathAbs; 53 MathAbs = from.MathAbs;
32 StringIndexOf = from.StringIndexOf; 54 StringIndexOf = from.StringIndexOf;
33 }); 55 });
34 56
35 utils.ImportFromExperimental(function(from) {
36 ProxyDelegateCallAndConstruct = from.ProxyDelegateCallAndConstruct;
37 ProxyDerivedHasOwnTrap = from.ProxyDerivedHasOwnTrap;
38 ProxyDerivedKeysTrap = from.ProxyDerivedKeysTrap;
39 });
40
41 // ---------------------------------------------------------------------------- 57 // ----------------------------------------------------------------------------
42 58
59 // ES6 - 9.2.11 SetFunctionName
60 function SetFunctionName(f, name, prefix) {
61 if (IS_SYMBOL(name)) {
62 name = "[" + %SymbolDescription(name) + "]";
63 }
64 if (IS_UNDEFINED(prefix)) {
65 %FunctionSetName(f, name);
66 } else {
67 %FunctionSetName(f, prefix + " " + name);
68 }
69 }
70
71
72 // Helper function used to install functions on objects.
73 function InstallFunctions(object, attributes, functions) {
74 %OptimizeObjectForAddingMultipleProperties(object, functions.length >> 1);
75 for (var i = 0; i < functions.length; i += 2) {
76 var key = functions[i];
77 var f = functions[i + 1];
78 SetFunctionName(f, key);
79 %FunctionRemovePrototype(f);
80 %AddNamedProperty(object, key, f, attributes);
81 %SetNativeFlag(f);
82 }
83 %ToFastProperties(object);
84 }
85
86
87 function OverrideFunction(object, name, f) {
88 ObjectDefineProperty(object, name, { value: f,
89 writeable: true,
90 configurable: true,
91 enumerable: false });
92 SetFunctionName(f, name);
93 %FunctionRemovePrototype(f);
94 %SetNativeFlag(f);
95 }
96
97
98 // Helper function to install a getter-only accessor property.
99 function InstallGetter(object, name, getter, attributes) {
100 if (typeof attributes == "undefined") {
101 attributes = DONT_ENUM;
102 }
103 SetFunctionName(getter, name, "get");
104 %FunctionRemovePrototype(getter);
105 %DefineAccessorPropertyUnchecked(object, name, getter, null, attributes);
106 %SetNativeFlag(getter);
107 }
108
109
110 // Helper function to install a getter/setter accessor property.
111 function InstallGetterSetter(object, name, getter, setter) {
112 SetFunctionName(getter, name, "get");
113 SetFunctionName(setter, name, "set");
114 %FunctionRemovePrototype(getter);
115 %FunctionRemovePrototype(setter);
116 %DefineAccessorPropertyUnchecked(object, name, getter, setter, DONT_ENUM);
117 %SetNativeFlag(getter);
118 %SetNativeFlag(setter);
119 }
120
121
122 // Helper function for installing constant properties on objects.
123 function InstallConstants(object, constants) {
124 %OptimizeObjectForAddingMultipleProperties(object, constants.length >> 1);
125 var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY;
126 for (var i = 0; i < constants.length; i += 2) {
127 var name = constants[i];
128 var k = constants[i + 1];
129 %AddNamedProperty(object, name, k, attributes);
130 }
131 %ToFastProperties(object);
132 }
133
134
135 // Prevents changes to the prototype of a built-in function.
136 // The "prototype" property of the function object is made non-configurable,
137 // and the prototype object is made non-extensible. The latter prevents
138 // changing the __proto__ property.
139 function SetUpLockedPrototype(constructor, fields, methods) {
140 %CheckIsBootstrapping();
141 var prototype = constructor.prototype;
142 // Install functions first, because this function is used to initialize
143 // PropertyDescriptor itself.
144 var property_count = (methods.length >> 1) + (fields ? fields.length : 0);
145 if (property_count >= 4) {
146 %OptimizeObjectForAddingMultipleProperties(prototype, property_count);
147 }
148 if (fields) {
149 for (var i = 0; i < fields.length; i++) {
150 %AddNamedProperty(prototype, fields[i],
151 UNDEFINED, DONT_ENUM | DONT_DELETE);
152 }
153 }
154 for (var i = 0; i < methods.length; i += 2) {
155 var key = methods[i];
156 var f = methods[i + 1];
157 %AddNamedProperty(prototype, key, f, DONT_ENUM | DONT_DELETE | READ_ONLY);
158 %SetNativeFlag(f);
159 }
160 %InternalSetPrototype(prototype, null);
161 %ToFastProperties(prototype);
162 }
163
164
165 // ----------------------------------------------------------------------------
166
43 167
44 // ECMA 262 - 15.1.4 168 // ECMA 262 - 15.1.4
45 function GlobalIsNaN(number) { 169 function GlobalIsNaN(number) {
46 number = TO_NUMBER_INLINE(number); 170 number = TO_NUMBER_INLINE(number);
47 return NUMBER_IS_NAN(number); 171 return NUMBER_IS_NAN(number);
48 } 172 }
49 173
50 174
51 // ECMA 262 - 15.1.5 175 // ECMA 262 - 15.1.5
52 function GlobalIsFinite(number) { 176 function GlobalIsFinite(number) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 231
108 return %_CallFunction(global_proxy, f); 232 return %_CallFunction(global_proxy, f);
109 } 233 }
110 234
111 235
112 // ---------------------------------------------------------------------------- 236 // ----------------------------------------------------------------------------
113 237
114 // Set up global object. 238 // Set up global object.
115 var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY; 239 var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY;
116 240
117 utils.InstallConstants(global, [ 241 InstallConstants(global, [
118 // ECMA 262 - 15.1.1.1. 242 // ECMA 262 - 15.1.1.1.
119 "NaN", NAN, 243 "NaN", NAN,
120 // ECMA-262 - 15.1.1.2. 244 // ECMA-262 - 15.1.1.2.
121 "Infinity", INFINITY, 245 "Infinity", INFINITY,
122 // ECMA-262 - 15.1.1.2. 246 // ECMA-262 - 15.1.1.2.
123 "undefined", UNDEFINED, 247 "undefined", UNDEFINED,
124 ]); 248 ]);
125 249
126 // Set up non-enumerable function on the global object. 250 // Set up non-enumerable function on the global object.
127 utils.InstallFunctions(global, DONT_ENUM, [ 251 InstallFunctions(global, DONT_ENUM, [
128 "isNaN", GlobalIsNaN, 252 "isNaN", GlobalIsNaN,
129 "isFinite", GlobalIsFinite, 253 "isFinite", GlobalIsFinite,
130 "parseInt", GlobalParseInt, 254 "parseInt", GlobalParseInt,
131 "parseFloat", GlobalParseFloat, 255 "parseFloat", GlobalParseFloat,
132 "eval", GlobalEval 256 "eval", GlobalEval
133 ]); 257 ]);
134 258
135 259
136 // ---------------------------------------------------------------------------- 260 // ----------------------------------------------------------------------------
137 // Object 261 // Object
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 295 }
172 296
173 297
174 // ECMA-262 - 15.2.4.5 298 // ECMA-262 - 15.2.4.5
175 function ObjectHasOwnProperty(V) { 299 function ObjectHasOwnProperty(V) {
176 if (%_IsJSProxy(this)) { 300 if (%_IsJSProxy(this)) {
177 // TODO(rossberg): adjust once there is a story for symbols vs proxies. 301 // TODO(rossberg): adjust once there is a story for symbols vs proxies.
178 if (IS_SYMBOL(V)) return false; 302 if (IS_SYMBOL(V)) return false;
179 303
180 var handler = %GetHandler(this); 304 var handler = %GetHandler(this);
181 return CallTrap1(handler, "hasOwn", ProxyDerivedHasOwnTrap, $toName(V)); 305 return CallTrap1(handler, "hasOwn", $proxyDerivedHasOwnTrap, $toName(V));
182 } 306 }
183 return %HasOwnProperty(TO_OBJECT_INLINE(this), $toName(V)); 307 return %HasOwnProperty(TO_OBJECT_INLINE(this), $toName(V));
184 } 308 }
185 309
186 310
187 // ECMA-262 - 15.2.4.6 311 // ECMA-262 - 15.2.4.6
188 function ObjectIsPrototypeOf(V) { 312 function ObjectIsPrototypeOf(V) {
189 if (!IS_SPEC_OBJECT(V)) return false; 313 if (!IS_SPEC_OBJECT(V)) return false;
190 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.isPrototypeOf"); 314 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.isPrototypeOf");
191 return %IsInPrototypeChain(this, V); 315 return %IsInPrototypeChain(this, V);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 receiver = %GlobalProxy(ObjectLookupSetter); 378 receiver = %GlobalProxy(ObjectLookupSetter);
255 } 379 }
256 return %LookupAccessor(TO_OBJECT_INLINE(receiver), $toName(name), SETTER); 380 return %LookupAccessor(TO_OBJECT_INLINE(receiver), $toName(name), SETTER);
257 } 381 }
258 382
259 383
260 function ObjectKeys(obj) { 384 function ObjectKeys(obj) {
261 obj = TO_OBJECT_INLINE(obj); 385 obj = TO_OBJECT_INLINE(obj);
262 if (%_IsJSProxy(obj)) { 386 if (%_IsJSProxy(obj)) {
263 var handler = %GetHandler(obj); 387 var handler = %GetHandler(obj);
264 var names = CallTrap0(handler, "keys", ProxyDerivedKeysTrap); 388 var names = CallTrap0(handler, "keys", $proxyDerivedKeysTrap);
265 return ToNameArray(names, "keys", false); 389 return ToNameArray(names, "keys", false);
266 } 390 }
267 return %OwnKeys(obj); 391 return %OwnKeys(obj);
268 } 392 }
269 393
270 394
271 // ES5 8.10.1. 395 // ES5 8.10.1.
272 function IsAccessorDescriptor(desc) { 396 function IsAccessorDescriptor(desc) {
273 if (IS_UNDEFINED(desc)) return false; 397 if (IS_UNDEFINED(desc)) return false;
274 return desc.hasGetter() || desc.hasSetter(); 398 return desc.hasGetter() || desc.hasSetter();
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 this.enumerable_ = false; 535 this.enumerable_ = false;
412 this.hasEnumerable_ = false; 536 this.hasEnumerable_ = false;
413 this.configurable_ = false; 537 this.configurable_ = false;
414 this.hasConfigurable_ = false; 538 this.hasConfigurable_ = false;
415 this.get_ = UNDEFINED; 539 this.get_ = UNDEFINED;
416 this.hasGetter_ = false; 540 this.hasGetter_ = false;
417 this.set_ = UNDEFINED; 541 this.set_ = UNDEFINED;
418 this.hasSetter_ = false; 542 this.hasSetter_ = false;
419 } 543 }
420 544
421 utils.SetUpLockedPrototype(PropertyDescriptor, [ 545 SetUpLockedPrototype(PropertyDescriptor, [
422 "value_", 546 "value_",
423 "hasValue_", 547 "hasValue_",
424 "writable_", 548 "writable_",
425 "hasWritable_", 549 "hasWritable_",
426 "enumerable_", 550 "enumerable_",
427 "hasEnumerable_", 551 "hasEnumerable_",
428 "configurable_", 552 "configurable_",
429 "hasConfigurable_", 553 "hasConfigurable_",
430 "get_", 554 "get_",
431 "hasGetter_", 555 "hasGetter_",
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 function ProxyFix(obj) { 1279 function ProxyFix(obj) {
1156 var handler = %GetHandler(obj); 1280 var handler = %GetHandler(obj);
1157 var props = CallTrap0(handler, "fix", UNDEFINED); 1281 var props = CallTrap0(handler, "fix", UNDEFINED);
1158 if (IS_UNDEFINED(props)) { 1282 if (IS_UNDEFINED(props)) {
1159 throw MakeTypeError(kProxyHandlerReturned, handler, "undefined", "fix"); 1283 throw MakeTypeError(kProxyHandlerReturned, handler, "undefined", "fix");
1160 } 1284 }
1161 1285
1162 if (%IsJSFunctionProxy(obj)) { 1286 if (%IsJSFunctionProxy(obj)) {
1163 var callTrap = %GetCallTrap(obj); 1287 var callTrap = %GetCallTrap(obj);
1164 var constructTrap = %GetConstructTrap(obj); 1288 var constructTrap = %GetConstructTrap(obj);
1165 var code = ProxyDelegateCallAndConstruct(callTrap, constructTrap); 1289 var code = $proxyDelegateCallAndConstruct(callTrap, constructTrap);
1166 %Fix(obj); // becomes a regular function 1290 %Fix(obj); // becomes a regular function
1167 %SetCode(obj, code); 1291 %SetCode(obj, code);
1168 // TODO(rossberg): What about length and other properties? Not specified. 1292 // TODO(rossberg): What about length and other properties? Not specified.
1169 // We just put in some half-reasonable defaults for now. 1293 // We just put in some half-reasonable defaults for now.
1170 var prototype = new GlobalObject(); 1294 var prototype = new GlobalObject();
1171 ObjectDefineProperty(prototype, "constructor", 1295 ObjectDefineProperty(prototype, "constructor",
1172 {value: obj, writable: true, enumerable: false, configurable: true}); 1296 {value: obj, writable: true, enumerable: false, configurable: true});
1173 // TODO(v8:1530): defineProperty does not handle prototype and length. 1297 // TODO(v8:1530): defineProperty does not handle prototype and length.
1174 %FunctionSetPrototype(obj, prototype); 1298 %FunctionSetPrototype(obj, prototype);
1175 obj.length = 0; 1299 obj.length = 0;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 // ---------------------------------------------------------------------------- 1457 // ----------------------------------------------------------------------------
1334 // Object 1458 // Object
1335 1459
1336 %SetNativeFlag(GlobalObject); 1460 %SetNativeFlag(GlobalObject);
1337 %SetCode(GlobalObject, ObjectConstructor); 1461 %SetCode(GlobalObject, ObjectConstructor);
1338 1462
1339 %AddNamedProperty(GlobalObject.prototype, "constructor", GlobalObject, 1463 %AddNamedProperty(GlobalObject.prototype, "constructor", GlobalObject,
1340 DONT_ENUM); 1464 DONT_ENUM);
1341 1465
1342 // Set up non-enumerable functions on the Object.prototype object. 1466 // Set up non-enumerable functions on the Object.prototype object.
1343 utils.InstallFunctions(GlobalObject.prototype, DONT_ENUM, [ 1467 InstallFunctions(GlobalObject.prototype, DONT_ENUM, [
1344 "toString", ObjectToString, 1468 "toString", ObjectToString,
1345 "toLocaleString", ObjectToLocaleString, 1469 "toLocaleString", ObjectToLocaleString,
1346 "valueOf", ObjectValueOf, 1470 "valueOf", ObjectValueOf,
1347 "hasOwnProperty", ObjectHasOwnProperty, 1471 "hasOwnProperty", ObjectHasOwnProperty,
1348 "isPrototypeOf", ObjectIsPrototypeOf, 1472 "isPrototypeOf", ObjectIsPrototypeOf,
1349 "propertyIsEnumerable", ObjectPropertyIsEnumerable, 1473 "propertyIsEnumerable", ObjectPropertyIsEnumerable,
1350 "__defineGetter__", ObjectDefineGetter, 1474 "__defineGetter__", ObjectDefineGetter,
1351 "__lookupGetter__", ObjectLookupGetter, 1475 "__lookupGetter__", ObjectLookupGetter,
1352 "__defineSetter__", ObjectDefineSetter, 1476 "__defineSetter__", ObjectDefineSetter,
1353 "__lookupSetter__", ObjectLookupSetter 1477 "__lookupSetter__", ObjectLookupSetter
1354 ]); 1478 ]);
1355 utils.InstallGetterSetter(GlobalObject.prototype, "__proto__", ObjectGetProto, 1479 InstallGetterSetter(GlobalObject.prototype, "__proto__", ObjectGetProto,
1356 ObjectSetProto); 1480 ObjectSetProto);
1357 1481
1358 // Set up non-enumerable functions in the Object object. 1482 // Set up non-enumerable functions in the Object object.
1359 utils.InstallFunctions(GlobalObject, DONT_ENUM, [ 1483 InstallFunctions(GlobalObject, DONT_ENUM, [
1360 "keys", ObjectKeys, 1484 "keys", ObjectKeys,
1361 "create", ObjectCreate, 1485 "create", ObjectCreate,
1362 "defineProperty", ObjectDefineProperty, 1486 "defineProperty", ObjectDefineProperty,
1363 "defineProperties", ObjectDefineProperties, 1487 "defineProperties", ObjectDefineProperties,
1364 "freeze", ObjectFreezeJS, 1488 "freeze", ObjectFreezeJS,
1365 "getPrototypeOf", ObjectGetPrototypeOf, 1489 "getPrototypeOf", ObjectGetPrototypeOf,
1366 "setPrototypeOf", ObjectSetPrototypeOf, 1490 "setPrototypeOf", ObjectSetPrototypeOf,
1367 "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor, 1491 "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor,
1368 "getOwnPropertyNames", ObjectGetOwnPropertyNames, 1492 "getOwnPropertyNames", ObjectGetOwnPropertyNames,
1369 // getOwnPropertySymbols is added in symbol.js. 1493 // getOwnPropertySymbols is added in symbol.js.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 } 1538 }
1415 1539
1416 1540
1417 // ---------------------------------------------------------------------------- 1541 // ----------------------------------------------------------------------------
1418 1542
1419 %SetCode(GlobalBoolean, BooleanConstructor); 1543 %SetCode(GlobalBoolean, BooleanConstructor);
1420 %FunctionSetPrototype(GlobalBoolean, new GlobalBoolean(false)); 1544 %FunctionSetPrototype(GlobalBoolean, new GlobalBoolean(false));
1421 %AddNamedProperty(GlobalBoolean.prototype, "constructor", GlobalBoolean, 1545 %AddNamedProperty(GlobalBoolean.prototype, "constructor", GlobalBoolean,
1422 DONT_ENUM); 1546 DONT_ENUM);
1423 1547
1424 utils.InstallFunctions(GlobalBoolean.prototype, DONT_ENUM, [ 1548 InstallFunctions(GlobalBoolean.prototype, DONT_ENUM, [
1425 "toString", BooleanToString, 1549 "toString", BooleanToString,
1426 "valueOf", BooleanValueOf 1550 "valueOf", BooleanValueOf
1427 ]); 1551 ]);
1428 1552
1429 1553
1430 // ---------------------------------------------------------------------------- 1554 // ----------------------------------------------------------------------------
1431 // Number 1555 // Number
1432 1556
1433 function NumberConstructor(x) { 1557 function NumberConstructor(x) {
1434 var value = %_ArgumentsLength() == 0 ? 0 : $toNumber(x); 1558 var value = %_ArgumentsLength() == 0 ? 0 : $toNumber(x);
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1591 // ---------------------------------------------------------------------------- 1715 // ----------------------------------------------------------------------------
1592 1716
1593 %SetCode(GlobalNumber, NumberConstructor); 1717 %SetCode(GlobalNumber, NumberConstructor);
1594 %FunctionSetPrototype(GlobalNumber, new GlobalNumber(0)); 1718 %FunctionSetPrototype(GlobalNumber, new GlobalNumber(0));
1595 1719
1596 %OptimizeObjectForAddingMultipleProperties(GlobalNumber.prototype, 8); 1720 %OptimizeObjectForAddingMultipleProperties(GlobalNumber.prototype, 8);
1597 // Set up the constructor property on the Number prototype object. 1721 // Set up the constructor property on the Number prototype object.
1598 %AddNamedProperty(GlobalNumber.prototype, "constructor", GlobalNumber, 1722 %AddNamedProperty(GlobalNumber.prototype, "constructor", GlobalNumber,
1599 DONT_ENUM); 1723 DONT_ENUM);
1600 1724
1601 utils.InstallConstants(GlobalNumber, [ 1725 InstallConstants(GlobalNumber, [
1602 // ECMA-262 section 15.7.3.1. 1726 // ECMA-262 section 15.7.3.1.
1603 "MAX_VALUE", 1.7976931348623157e+308, 1727 "MAX_VALUE", 1.7976931348623157e+308,
1604 // ECMA-262 section 15.7.3.2. 1728 // ECMA-262 section 15.7.3.2.
1605 "MIN_VALUE", 5e-324, 1729 "MIN_VALUE", 5e-324,
1606 // ECMA-262 section 15.7.3.3. 1730 // ECMA-262 section 15.7.3.3.
1607 "NaN", NAN, 1731 "NaN", NAN,
1608 // ECMA-262 section 15.7.3.4. 1732 // ECMA-262 section 15.7.3.4.
1609 "NEGATIVE_INFINITY", -INFINITY, 1733 "NEGATIVE_INFINITY", -INFINITY,
1610 // ECMA-262 section 15.7.3.5. 1734 // ECMA-262 section 15.7.3.5.
1611 "POSITIVE_INFINITY", INFINITY, 1735 "POSITIVE_INFINITY", INFINITY,
1612 1736
1613 // --- Harmony constants (no spec refs until settled.) 1737 // --- Harmony constants (no spec refs until settled.)
1614 1738
1615 "MAX_SAFE_INTEGER", %_MathPow(2, 53) - 1, 1739 "MAX_SAFE_INTEGER", %_MathPow(2, 53) - 1,
1616 "MIN_SAFE_INTEGER", -%_MathPow(2, 53) + 1, 1740 "MIN_SAFE_INTEGER", -%_MathPow(2, 53) + 1,
1617 "EPSILON", %_MathPow(2, -52) 1741 "EPSILON", %_MathPow(2, -52)
1618 ]); 1742 ]);
1619 1743
1620 // Set up non-enumerable functions on the Number prototype object. 1744 // Set up non-enumerable functions on the Number prototype object.
1621 utils.InstallFunctions(GlobalNumber.prototype, DONT_ENUM, [ 1745 InstallFunctions(GlobalNumber.prototype, DONT_ENUM, [
1622 "toString", NumberToStringJS, 1746 "toString", NumberToStringJS,
1623 "toLocaleString", NumberToLocaleString, 1747 "toLocaleString", NumberToLocaleString,
1624 "valueOf", NumberValueOf, 1748 "valueOf", NumberValueOf,
1625 "toFixed", NumberToFixedJS, 1749 "toFixed", NumberToFixedJS,
1626 "toExponential", NumberToExponentialJS, 1750 "toExponential", NumberToExponentialJS,
1627 "toPrecision", NumberToPrecisionJS 1751 "toPrecision", NumberToPrecisionJS
1628 ]); 1752 ]);
1629 1753
1630 // Harmony Number constructor additions 1754 // Harmony Number constructor additions
1631 utils.InstallFunctions(GlobalNumber, DONT_ENUM, [ 1755 InstallFunctions(GlobalNumber, DONT_ENUM, [
1632 "isFinite", NumberIsFinite, 1756 "isFinite", NumberIsFinite,
1633 "isInteger", NumberIsInteger, 1757 "isInteger", NumberIsInteger,
1634 "isNaN", NumberIsNaN, 1758 "isNaN", NumberIsNaN,
1635 "isSafeInteger", NumberIsSafeInteger, 1759 "isSafeInteger", NumberIsSafeInteger,
1636 "parseInt", GlobalParseInt, 1760 "parseInt", GlobalParseInt,
1637 "parseFloat", GlobalParseFloat 1761 "parseFloat", GlobalParseFloat
1638 ]); 1762 ]);
1639 1763
1640 %SetForceInlineFlag(NumberIsNaN); 1764 %SetForceInlineFlag(NumberIsNaN);
1641 1765
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1789 return f; 1913 return f;
1790 } 1914 }
1791 1915
1792 1916
1793 // ---------------------------------------------------------------------------- 1917 // ----------------------------------------------------------------------------
1794 1918
1795 %SetCode(GlobalFunction, FunctionConstructor); 1919 %SetCode(GlobalFunction, FunctionConstructor);
1796 %AddNamedProperty(GlobalFunction.prototype, "constructor", GlobalFunction, 1920 %AddNamedProperty(GlobalFunction.prototype, "constructor", GlobalFunction,
1797 DONT_ENUM); 1921 DONT_ENUM);
1798 1922
1799 utils.InstallFunctions(GlobalFunction.prototype, DONT_ENUM, [ 1923 InstallFunctions(GlobalFunction.prototype, DONT_ENUM, [
1800 "bind", FunctionBind, 1924 "bind", FunctionBind,
1801 "toString", FunctionToString 1925 "toString", FunctionToString
1802 ]); 1926 ]);
1803 1927
1804 // ---------------------------------------------------------------------------- 1928 // ----------------------------------------------------------------------------
1805 // Iterator related spec functions. 1929 // Iterator related spec functions.
1806 1930
1807 // ES6 rev 33, 2015-02-12 1931 // ES6 rev 33, 2015-02-12
1808 // 7.4.1 GetIterator ( obj, method ) 1932 // 7.4.1 GetIterator ( obj, method )
1809 function GetIterator(obj, method) { 1933 function GetIterator(obj, method) {
1810 if (IS_UNDEFINED(method)) { 1934 if (IS_UNDEFINED(method)) {
1811 method = obj[symbolIterator]; 1935 method = obj[symbolIterator];
1812 } 1936 }
1813 if (!IS_SPEC_FUNCTION(method)) { 1937 if (!IS_SPEC_FUNCTION(method)) {
1814 throw MakeTypeError(kNotIterable, obj); 1938 throw MakeTypeError(kNotIterable, obj);
1815 } 1939 }
1816 var iterator = %_CallFunction(obj, method); 1940 var iterator = %_CallFunction(obj, method);
1817 if (!IS_SPEC_OBJECT(iterator)) { 1941 if (!IS_SPEC_OBJECT(iterator)) {
1818 throw MakeTypeError(kNotAnIterator, iterator); 1942 throw MakeTypeError(kNotAnIterator, iterator);
1819 } 1943 }
1820 return iterator; 1944 return iterator;
1821 } 1945 }
1822 1946
1823 // ---------------------------------------------------------------------------- 1947 //----------------------------------------------------------------------------
1824 // Exports
1825 1948
1949 $delete = Delete;
1826 $functionSourceString = FunctionSourceString; 1950 $functionSourceString = FunctionSourceString;
1951 $getIterator = GetIterator;
1952 $getMethod = GetMethod;
1827 $globalEval = GlobalEval; 1953 $globalEval = GlobalEval;
1954 $installConstants = InstallConstants;
1955 $installFunctions = InstallFunctions;
1956 $installGetter = InstallGetter;
1957 $isFinite = GlobalIsFinite;
1958 $isNaN = GlobalIsNaN;
1959 $newFunctionString = NewFunctionString;
1960 $numberIsNaN = NumberIsNaN;
1961 $objectDefineProperties = ObjectDefineProperties;
1962 $objectDefineProperty = ObjectDefineProperty;
1963 $objectFreeze = ObjectFreezeJS;
1828 $objectGetOwnPropertyDescriptor = ObjectGetOwnPropertyDescriptor; 1964 $objectGetOwnPropertyDescriptor = ObjectGetOwnPropertyDescriptor;
1965 $objectGetOwnPropertyKeys = ObjectGetOwnPropertyKeys;
1966 $objectHasOwnProperty = ObjectHasOwnProperty;
1967 $objectIsFrozen = ObjectIsFrozen;
1968 $objectIsSealed = ObjectIsSealed;
1969 $objectLookupGetter = ObjectLookupGetter;
1970 $objectLookupSetter = ObjectLookupSetter;
1971 $objectToString = ObjectToString;
1972 $overrideFunction = OverrideFunction;
1973 $ownPropertyKeys = OwnPropertyKeys;
1974 $setFunctionName = SetFunctionName;
1975 $setUpLockedPrototype = SetUpLockedPrototype;
1829 $toCompletePropertyDescriptor = ToCompletePropertyDescriptor; 1976 $toCompletePropertyDescriptor = ToCompletePropertyDescriptor;
1830 1977 $toNameArray = ToNameArray;
1831 utils.ObjectDefineProperties = ObjectDefineProperties;
1832 utils.ObjectDefineProperty = ObjectDefineProperty;
1833
1834 utils.Export(function(to) {
1835 to.Delete = Delete;
1836 to.GetIterator = GetIterator;
1837 to.GetMethod = GetMethod;
1838 to.IsFinite = GlobalIsFinite;
1839 to.IsNaN = GlobalIsNaN;
1840 to.NewFunctionString = NewFunctionString;
1841 to.NumberIsNaN = NumberIsNaN;
1842 to.ObjectDefineProperty = ObjectDefineProperty;
1843 to.ObjectFreeze = ObjectFreezeJS;
1844 to.ObjectGetOwnPropertyKeys = ObjectGetOwnPropertyKeys;
1845 to.ObjectHasOwnProperty = ObjectHasOwnProperty;
1846 to.ObjectIsFrozen = ObjectIsFrozen;
1847 to.ObjectIsSealed = ObjectIsSealed;
1848 to.ObjectToString = ObjectToString;
1849 to.OwnPropertyKeys = OwnPropertyKeys;
1850 to.ToNameArray = ToNameArray;
1851 });
1852 1978
1853 }) 1979 })
OLDNEW
« no previous file with comments | « src/uri.js ('k') | src/weak-collection.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698