| OLD | NEW |
| 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; | |
| 6 var $functionSourceString; | 5 var $functionSourceString; |
| 7 var $getIterator; | |
| 8 var $getMethod; | |
| 9 var $globalEval; | 6 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; | |
| 20 var $objectGetOwnPropertyDescriptor; | 7 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; | |
| 32 var $toCompletePropertyDescriptor; | 8 var $toCompletePropertyDescriptor; |
| 33 var $toNameArray; | |
| 34 | 9 |
| 35 (function(global, utils) { | 10 (function(global, utils) { |
| 36 | 11 |
| 37 %CheckIsBootstrapping(); | 12 %CheckIsBootstrapping(); |
| 38 | 13 |
| 39 // ---------------------------------------------------------------------------- | 14 // ---------------------------------------------------------------------------- |
| 40 // Imports | 15 // Imports |
| 41 | 16 |
| 42 var GlobalArray = global.Array; | 17 var GlobalArray = global.Array; |
| 43 var GlobalBoolean = global.Boolean; | 18 var GlobalBoolean = global.Boolean; |
| 44 var GlobalFunction = global.Function; | 19 var GlobalFunction = global.Function; |
| 45 var GlobalNumber = global.Number; | 20 var GlobalNumber = global.Number; |
| 46 var GlobalObject = global.Object; | 21 var GlobalObject = global.Object; |
| 47 var InternalArray = utils.InternalArray; | 22 var InternalArray = utils.InternalArray; |
| 48 | 23 |
| 49 var MathAbs; | 24 var MathAbs; |
| 25 var ProxyDelegateCallAndConstruct; |
| 26 var ProxyDerivedHasOwnTrap; |
| 27 var ProxyDerivedKeysTrap; |
| 50 var StringIndexOf; | 28 var StringIndexOf; |
| 51 | 29 |
| 52 utils.Import(function(from) { | 30 utils.Import(function(from) { |
| 53 MathAbs = from.MathAbs; | 31 MathAbs = from.MathAbs; |
| 54 StringIndexOf = from.StringIndexOf; | 32 StringIndexOf = from.StringIndexOf; |
| 55 }); | 33 }); |
| 56 | 34 |
| 35 utils.ImportFromExperimental(function(from) { |
| 36 ProxyDelegateCallAndConstruct = from.ProxyDelegateCallAndConstruct; |
| 37 ProxyDerivedHasOwnTrap = from.ProxyDerivedHasOwnTrap; |
| 38 ProxyDerivedKeysTrap = from.ProxyDerivedKeysTrap; |
| 39 }); |
| 40 |
| 57 // ---------------------------------------------------------------------------- | 41 // ---------------------------------------------------------------------------- |
| 58 | 42 |
| 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 | |
| 167 | 43 |
| 168 // ECMA 262 - 15.1.4 | 44 // ECMA 262 - 15.1.4 |
| 169 function GlobalIsNaN(number) { | 45 function GlobalIsNaN(number) { |
| 170 number = TO_NUMBER_INLINE(number); | 46 number = TO_NUMBER_INLINE(number); |
| 171 return NUMBER_IS_NAN(number); | 47 return NUMBER_IS_NAN(number); |
| 172 } | 48 } |
| 173 | 49 |
| 174 | 50 |
| 175 // ECMA 262 - 15.1.5 | 51 // ECMA 262 - 15.1.5 |
| 176 function GlobalIsFinite(number) { | 52 function GlobalIsFinite(number) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 | 107 |
| 232 return %_CallFunction(global_proxy, f); | 108 return %_CallFunction(global_proxy, f); |
| 233 } | 109 } |
| 234 | 110 |
| 235 | 111 |
| 236 // ---------------------------------------------------------------------------- | 112 // ---------------------------------------------------------------------------- |
| 237 | 113 |
| 238 // Set up global object. | 114 // Set up global object. |
| 239 var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY; | 115 var attributes = DONT_ENUM | DONT_DELETE | READ_ONLY; |
| 240 | 116 |
| 241 InstallConstants(global, [ | 117 utils.InstallConstants(global, [ |
| 242 // ECMA 262 - 15.1.1.1. | 118 // ECMA 262 - 15.1.1.1. |
| 243 "NaN", NAN, | 119 "NaN", NAN, |
| 244 // ECMA-262 - 15.1.1.2. | 120 // ECMA-262 - 15.1.1.2. |
| 245 "Infinity", INFINITY, | 121 "Infinity", INFINITY, |
| 246 // ECMA-262 - 15.1.1.2. | 122 // ECMA-262 - 15.1.1.2. |
| 247 "undefined", UNDEFINED, | 123 "undefined", UNDEFINED, |
| 248 ]); | 124 ]); |
| 249 | 125 |
| 250 // Set up non-enumerable function on the global object. | 126 // Set up non-enumerable function on the global object. |
| 251 InstallFunctions(global, DONT_ENUM, [ | 127 utils.InstallFunctions(global, DONT_ENUM, [ |
| 252 "isNaN", GlobalIsNaN, | 128 "isNaN", GlobalIsNaN, |
| 253 "isFinite", GlobalIsFinite, | 129 "isFinite", GlobalIsFinite, |
| 254 "parseInt", GlobalParseInt, | 130 "parseInt", GlobalParseInt, |
| 255 "parseFloat", GlobalParseFloat, | 131 "parseFloat", GlobalParseFloat, |
| 256 "eval", GlobalEval | 132 "eval", GlobalEval |
| 257 ]); | 133 ]); |
| 258 | 134 |
| 259 | 135 |
| 260 // ---------------------------------------------------------------------------- | 136 // ---------------------------------------------------------------------------- |
| 261 // Object | 137 // Object |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 } | 171 } |
| 296 | 172 |
| 297 | 173 |
| 298 // ECMA-262 - 15.2.4.5 | 174 // ECMA-262 - 15.2.4.5 |
| 299 function ObjectHasOwnProperty(V) { | 175 function ObjectHasOwnProperty(V) { |
| 300 if (%_IsJSProxy(this)) { | 176 if (%_IsJSProxy(this)) { |
| 301 // TODO(rossberg): adjust once there is a story for symbols vs proxies. | 177 // TODO(rossberg): adjust once there is a story for symbols vs proxies. |
| 302 if (IS_SYMBOL(V)) return false; | 178 if (IS_SYMBOL(V)) return false; |
| 303 | 179 |
| 304 var handler = %GetHandler(this); | 180 var handler = %GetHandler(this); |
| 305 return CallTrap1(handler, "hasOwn", $proxyDerivedHasOwnTrap, $toName(V)); | 181 return CallTrap1(handler, "hasOwn", ProxyDerivedHasOwnTrap, $toName(V)); |
| 306 } | 182 } |
| 307 return %HasOwnProperty(TO_OBJECT_INLINE(this), $toName(V)); | 183 return %HasOwnProperty(TO_OBJECT_INLINE(this), $toName(V)); |
| 308 } | 184 } |
| 309 | 185 |
| 310 | 186 |
| 311 // ECMA-262 - 15.2.4.6 | 187 // ECMA-262 - 15.2.4.6 |
| 312 function ObjectIsPrototypeOf(V) { | 188 function ObjectIsPrototypeOf(V) { |
| 313 if (!IS_SPEC_OBJECT(V)) return false; | 189 if (!IS_SPEC_OBJECT(V)) return false; |
| 314 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.isPrototypeOf"); | 190 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.isPrototypeOf"); |
| 315 return %IsInPrototypeChain(this, V); | 191 return %IsInPrototypeChain(this, V); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 receiver = %GlobalProxy(ObjectLookupSetter); | 254 receiver = %GlobalProxy(ObjectLookupSetter); |
| 379 } | 255 } |
| 380 return %LookupAccessor(TO_OBJECT_INLINE(receiver), $toName(name), SETTER); | 256 return %LookupAccessor(TO_OBJECT_INLINE(receiver), $toName(name), SETTER); |
| 381 } | 257 } |
| 382 | 258 |
| 383 | 259 |
| 384 function ObjectKeys(obj) { | 260 function ObjectKeys(obj) { |
| 385 obj = TO_OBJECT_INLINE(obj); | 261 obj = TO_OBJECT_INLINE(obj); |
| 386 if (%_IsJSProxy(obj)) { | 262 if (%_IsJSProxy(obj)) { |
| 387 var handler = %GetHandler(obj); | 263 var handler = %GetHandler(obj); |
| 388 var names = CallTrap0(handler, "keys", $proxyDerivedKeysTrap); | 264 var names = CallTrap0(handler, "keys", ProxyDerivedKeysTrap); |
| 389 return ToNameArray(names, "keys", false); | 265 return ToNameArray(names, "keys", false); |
| 390 } | 266 } |
| 391 return %OwnKeys(obj); | 267 return %OwnKeys(obj); |
| 392 } | 268 } |
| 393 | 269 |
| 394 | 270 |
| 395 // ES5 8.10.1. | 271 // ES5 8.10.1. |
| 396 function IsAccessorDescriptor(desc) { | 272 function IsAccessorDescriptor(desc) { |
| 397 if (IS_UNDEFINED(desc)) return false; | 273 if (IS_UNDEFINED(desc)) return false; |
| 398 return desc.hasGetter() || desc.hasSetter(); | 274 return desc.hasGetter() || desc.hasSetter(); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 this.enumerable_ = false; | 411 this.enumerable_ = false; |
| 536 this.hasEnumerable_ = false; | 412 this.hasEnumerable_ = false; |
| 537 this.configurable_ = false; | 413 this.configurable_ = false; |
| 538 this.hasConfigurable_ = false; | 414 this.hasConfigurable_ = false; |
| 539 this.get_ = UNDEFINED; | 415 this.get_ = UNDEFINED; |
| 540 this.hasGetter_ = false; | 416 this.hasGetter_ = false; |
| 541 this.set_ = UNDEFINED; | 417 this.set_ = UNDEFINED; |
| 542 this.hasSetter_ = false; | 418 this.hasSetter_ = false; |
| 543 } | 419 } |
| 544 | 420 |
| 545 SetUpLockedPrototype(PropertyDescriptor, [ | 421 utils.SetUpLockedPrototype(PropertyDescriptor, [ |
| 546 "value_", | 422 "value_", |
| 547 "hasValue_", | 423 "hasValue_", |
| 548 "writable_", | 424 "writable_", |
| 549 "hasWritable_", | 425 "hasWritable_", |
| 550 "enumerable_", | 426 "enumerable_", |
| 551 "hasEnumerable_", | 427 "hasEnumerable_", |
| 552 "configurable_", | 428 "configurable_", |
| 553 "hasConfigurable_", | 429 "hasConfigurable_", |
| 554 "get_", | 430 "get_", |
| 555 "hasGetter_", | 431 "hasGetter_", |
| (...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1279 function ProxyFix(obj) { | 1155 function ProxyFix(obj) { |
| 1280 var handler = %GetHandler(obj); | 1156 var handler = %GetHandler(obj); |
| 1281 var props = CallTrap0(handler, "fix", UNDEFINED); | 1157 var props = CallTrap0(handler, "fix", UNDEFINED); |
| 1282 if (IS_UNDEFINED(props)) { | 1158 if (IS_UNDEFINED(props)) { |
| 1283 throw MakeTypeError(kProxyHandlerReturned, handler, "undefined", "fix"); | 1159 throw MakeTypeError(kProxyHandlerReturned, handler, "undefined", "fix"); |
| 1284 } | 1160 } |
| 1285 | 1161 |
| 1286 if (%IsJSFunctionProxy(obj)) { | 1162 if (%IsJSFunctionProxy(obj)) { |
| 1287 var callTrap = %GetCallTrap(obj); | 1163 var callTrap = %GetCallTrap(obj); |
| 1288 var constructTrap = %GetConstructTrap(obj); | 1164 var constructTrap = %GetConstructTrap(obj); |
| 1289 var code = $proxyDelegateCallAndConstruct(callTrap, constructTrap); | 1165 var code = ProxyDelegateCallAndConstruct(callTrap, constructTrap); |
| 1290 %Fix(obj); // becomes a regular function | 1166 %Fix(obj); // becomes a regular function |
| 1291 %SetCode(obj, code); | 1167 %SetCode(obj, code); |
| 1292 // TODO(rossberg): What about length and other properties? Not specified. | 1168 // TODO(rossberg): What about length and other properties? Not specified. |
| 1293 // We just put in some half-reasonable defaults for now. | 1169 // We just put in some half-reasonable defaults for now. |
| 1294 var prototype = new GlobalObject(); | 1170 var prototype = new GlobalObject(); |
| 1295 ObjectDefineProperty(prototype, "constructor", | 1171 ObjectDefineProperty(prototype, "constructor", |
| 1296 {value: obj, writable: true, enumerable: false, configurable: true}); | 1172 {value: obj, writable: true, enumerable: false, configurable: true}); |
| 1297 // TODO(v8:1530): defineProperty does not handle prototype and length. | 1173 // TODO(v8:1530): defineProperty does not handle prototype and length. |
| 1298 %FunctionSetPrototype(obj, prototype); | 1174 %FunctionSetPrototype(obj, prototype); |
| 1299 obj.length = 0; | 1175 obj.length = 0; |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1457 // ---------------------------------------------------------------------------- | 1333 // ---------------------------------------------------------------------------- |
| 1458 // Object | 1334 // Object |
| 1459 | 1335 |
| 1460 %SetNativeFlag(GlobalObject); | 1336 %SetNativeFlag(GlobalObject); |
| 1461 %SetCode(GlobalObject, ObjectConstructor); | 1337 %SetCode(GlobalObject, ObjectConstructor); |
| 1462 | 1338 |
| 1463 %AddNamedProperty(GlobalObject.prototype, "constructor", GlobalObject, | 1339 %AddNamedProperty(GlobalObject.prototype, "constructor", GlobalObject, |
| 1464 DONT_ENUM); | 1340 DONT_ENUM); |
| 1465 | 1341 |
| 1466 // Set up non-enumerable functions on the Object.prototype object. | 1342 // Set up non-enumerable functions on the Object.prototype object. |
| 1467 InstallFunctions(GlobalObject.prototype, DONT_ENUM, [ | 1343 utils.InstallFunctions(GlobalObject.prototype, DONT_ENUM, [ |
| 1468 "toString", ObjectToString, | 1344 "toString", ObjectToString, |
| 1469 "toLocaleString", ObjectToLocaleString, | 1345 "toLocaleString", ObjectToLocaleString, |
| 1470 "valueOf", ObjectValueOf, | 1346 "valueOf", ObjectValueOf, |
| 1471 "hasOwnProperty", ObjectHasOwnProperty, | 1347 "hasOwnProperty", ObjectHasOwnProperty, |
| 1472 "isPrototypeOf", ObjectIsPrototypeOf, | 1348 "isPrototypeOf", ObjectIsPrototypeOf, |
| 1473 "propertyIsEnumerable", ObjectPropertyIsEnumerable, | 1349 "propertyIsEnumerable", ObjectPropertyIsEnumerable, |
| 1474 "__defineGetter__", ObjectDefineGetter, | 1350 "__defineGetter__", ObjectDefineGetter, |
| 1475 "__lookupGetter__", ObjectLookupGetter, | 1351 "__lookupGetter__", ObjectLookupGetter, |
| 1476 "__defineSetter__", ObjectDefineSetter, | 1352 "__defineSetter__", ObjectDefineSetter, |
| 1477 "__lookupSetter__", ObjectLookupSetter | 1353 "__lookupSetter__", ObjectLookupSetter |
| 1478 ]); | 1354 ]); |
| 1479 InstallGetterSetter(GlobalObject.prototype, "__proto__", ObjectGetProto, | 1355 utils.InstallGetterSetter(GlobalObject.prototype, "__proto__", ObjectGetProto, |
| 1480 ObjectSetProto); | 1356 ObjectSetProto); |
| 1481 | 1357 |
| 1482 // Set up non-enumerable functions in the Object object. | 1358 // Set up non-enumerable functions in the Object object. |
| 1483 InstallFunctions(GlobalObject, DONT_ENUM, [ | 1359 utils.InstallFunctions(GlobalObject, DONT_ENUM, [ |
| 1484 "keys", ObjectKeys, | 1360 "keys", ObjectKeys, |
| 1485 "create", ObjectCreate, | 1361 "create", ObjectCreate, |
| 1486 "defineProperty", ObjectDefineProperty, | 1362 "defineProperty", ObjectDefineProperty, |
| 1487 "defineProperties", ObjectDefineProperties, | 1363 "defineProperties", ObjectDefineProperties, |
| 1488 "freeze", ObjectFreezeJS, | 1364 "freeze", ObjectFreezeJS, |
| 1489 "getPrototypeOf", ObjectGetPrototypeOf, | 1365 "getPrototypeOf", ObjectGetPrototypeOf, |
| 1490 "setPrototypeOf", ObjectSetPrototypeOf, | 1366 "setPrototypeOf", ObjectSetPrototypeOf, |
| 1491 "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor, | 1367 "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor, |
| 1492 "getOwnPropertyNames", ObjectGetOwnPropertyNames, | 1368 "getOwnPropertyNames", ObjectGetOwnPropertyNames, |
| 1493 // getOwnPropertySymbols is added in symbol.js. | 1369 // getOwnPropertySymbols is added in symbol.js. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1538 } | 1414 } |
| 1539 | 1415 |
| 1540 | 1416 |
| 1541 // ---------------------------------------------------------------------------- | 1417 // ---------------------------------------------------------------------------- |
| 1542 | 1418 |
| 1543 %SetCode(GlobalBoolean, BooleanConstructor); | 1419 %SetCode(GlobalBoolean, BooleanConstructor); |
| 1544 %FunctionSetPrototype(GlobalBoolean, new GlobalBoolean(false)); | 1420 %FunctionSetPrototype(GlobalBoolean, new GlobalBoolean(false)); |
| 1545 %AddNamedProperty(GlobalBoolean.prototype, "constructor", GlobalBoolean, | 1421 %AddNamedProperty(GlobalBoolean.prototype, "constructor", GlobalBoolean, |
| 1546 DONT_ENUM); | 1422 DONT_ENUM); |
| 1547 | 1423 |
| 1548 InstallFunctions(GlobalBoolean.prototype, DONT_ENUM, [ | 1424 utils.InstallFunctions(GlobalBoolean.prototype, DONT_ENUM, [ |
| 1549 "toString", BooleanToString, | 1425 "toString", BooleanToString, |
| 1550 "valueOf", BooleanValueOf | 1426 "valueOf", BooleanValueOf |
| 1551 ]); | 1427 ]); |
| 1552 | 1428 |
| 1553 | 1429 |
| 1554 // ---------------------------------------------------------------------------- | 1430 // ---------------------------------------------------------------------------- |
| 1555 // Number | 1431 // Number |
| 1556 | 1432 |
| 1557 function NumberConstructor(x) { | 1433 function NumberConstructor(x) { |
| 1558 var value = %_ArgumentsLength() == 0 ? 0 : $toNumber(x); | 1434 var value = %_ArgumentsLength() == 0 ? 0 : $toNumber(x); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1715 // ---------------------------------------------------------------------------- | 1591 // ---------------------------------------------------------------------------- |
| 1716 | 1592 |
| 1717 %SetCode(GlobalNumber, NumberConstructor); | 1593 %SetCode(GlobalNumber, NumberConstructor); |
| 1718 %FunctionSetPrototype(GlobalNumber, new GlobalNumber(0)); | 1594 %FunctionSetPrototype(GlobalNumber, new GlobalNumber(0)); |
| 1719 | 1595 |
| 1720 %OptimizeObjectForAddingMultipleProperties(GlobalNumber.prototype, 8); | 1596 %OptimizeObjectForAddingMultipleProperties(GlobalNumber.prototype, 8); |
| 1721 // Set up the constructor property on the Number prototype object. | 1597 // Set up the constructor property on the Number prototype object. |
| 1722 %AddNamedProperty(GlobalNumber.prototype, "constructor", GlobalNumber, | 1598 %AddNamedProperty(GlobalNumber.prototype, "constructor", GlobalNumber, |
| 1723 DONT_ENUM); | 1599 DONT_ENUM); |
| 1724 | 1600 |
| 1725 InstallConstants(GlobalNumber, [ | 1601 utils.InstallConstants(GlobalNumber, [ |
| 1726 // ECMA-262 section 15.7.3.1. | 1602 // ECMA-262 section 15.7.3.1. |
| 1727 "MAX_VALUE", 1.7976931348623157e+308, | 1603 "MAX_VALUE", 1.7976931348623157e+308, |
| 1728 // ECMA-262 section 15.7.3.2. | 1604 // ECMA-262 section 15.7.3.2. |
| 1729 "MIN_VALUE", 5e-324, | 1605 "MIN_VALUE", 5e-324, |
| 1730 // ECMA-262 section 15.7.3.3. | 1606 // ECMA-262 section 15.7.3.3. |
| 1731 "NaN", NAN, | 1607 "NaN", NAN, |
| 1732 // ECMA-262 section 15.7.3.4. | 1608 // ECMA-262 section 15.7.3.4. |
| 1733 "NEGATIVE_INFINITY", -INFINITY, | 1609 "NEGATIVE_INFINITY", -INFINITY, |
| 1734 // ECMA-262 section 15.7.3.5. | 1610 // ECMA-262 section 15.7.3.5. |
| 1735 "POSITIVE_INFINITY", INFINITY, | 1611 "POSITIVE_INFINITY", INFINITY, |
| 1736 | 1612 |
| 1737 // --- Harmony constants (no spec refs until settled.) | 1613 // --- Harmony constants (no spec refs until settled.) |
| 1738 | 1614 |
| 1739 "MAX_SAFE_INTEGER", %_MathPow(2, 53) - 1, | 1615 "MAX_SAFE_INTEGER", %_MathPow(2, 53) - 1, |
| 1740 "MIN_SAFE_INTEGER", -%_MathPow(2, 53) + 1, | 1616 "MIN_SAFE_INTEGER", -%_MathPow(2, 53) + 1, |
| 1741 "EPSILON", %_MathPow(2, -52) | 1617 "EPSILON", %_MathPow(2, -52) |
| 1742 ]); | 1618 ]); |
| 1743 | 1619 |
| 1744 // Set up non-enumerable functions on the Number prototype object. | 1620 // Set up non-enumerable functions on the Number prototype object. |
| 1745 InstallFunctions(GlobalNumber.prototype, DONT_ENUM, [ | 1621 utils.InstallFunctions(GlobalNumber.prototype, DONT_ENUM, [ |
| 1746 "toString", NumberToStringJS, | 1622 "toString", NumberToStringJS, |
| 1747 "toLocaleString", NumberToLocaleString, | 1623 "toLocaleString", NumberToLocaleString, |
| 1748 "valueOf", NumberValueOf, | 1624 "valueOf", NumberValueOf, |
| 1749 "toFixed", NumberToFixedJS, | 1625 "toFixed", NumberToFixedJS, |
| 1750 "toExponential", NumberToExponentialJS, | 1626 "toExponential", NumberToExponentialJS, |
| 1751 "toPrecision", NumberToPrecisionJS | 1627 "toPrecision", NumberToPrecisionJS |
| 1752 ]); | 1628 ]); |
| 1753 | 1629 |
| 1754 // Harmony Number constructor additions | 1630 // Harmony Number constructor additions |
| 1755 InstallFunctions(GlobalNumber, DONT_ENUM, [ | 1631 utils.InstallFunctions(GlobalNumber, DONT_ENUM, [ |
| 1756 "isFinite", NumberIsFinite, | 1632 "isFinite", NumberIsFinite, |
| 1757 "isInteger", NumberIsInteger, | 1633 "isInteger", NumberIsInteger, |
| 1758 "isNaN", NumberIsNaN, | 1634 "isNaN", NumberIsNaN, |
| 1759 "isSafeInteger", NumberIsSafeInteger, | 1635 "isSafeInteger", NumberIsSafeInteger, |
| 1760 "parseInt", GlobalParseInt, | 1636 "parseInt", GlobalParseInt, |
| 1761 "parseFloat", GlobalParseFloat | 1637 "parseFloat", GlobalParseFloat |
| 1762 ]); | 1638 ]); |
| 1763 | 1639 |
| 1764 %SetForceInlineFlag(NumberIsNaN); | 1640 %SetForceInlineFlag(NumberIsNaN); |
| 1765 | 1641 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1913 return f; | 1789 return f; |
| 1914 } | 1790 } |
| 1915 | 1791 |
| 1916 | 1792 |
| 1917 // ---------------------------------------------------------------------------- | 1793 // ---------------------------------------------------------------------------- |
| 1918 | 1794 |
| 1919 %SetCode(GlobalFunction, FunctionConstructor); | 1795 %SetCode(GlobalFunction, FunctionConstructor); |
| 1920 %AddNamedProperty(GlobalFunction.prototype, "constructor", GlobalFunction, | 1796 %AddNamedProperty(GlobalFunction.prototype, "constructor", GlobalFunction, |
| 1921 DONT_ENUM); | 1797 DONT_ENUM); |
| 1922 | 1798 |
| 1923 InstallFunctions(GlobalFunction.prototype, DONT_ENUM, [ | 1799 utils.InstallFunctions(GlobalFunction.prototype, DONT_ENUM, [ |
| 1924 "bind", FunctionBind, | 1800 "bind", FunctionBind, |
| 1925 "toString", FunctionToString | 1801 "toString", FunctionToString |
| 1926 ]); | 1802 ]); |
| 1927 | 1803 |
| 1928 // ---------------------------------------------------------------------------- | 1804 // ---------------------------------------------------------------------------- |
| 1929 // Iterator related spec functions. | 1805 // Iterator related spec functions. |
| 1930 | 1806 |
| 1931 // ES6 rev 33, 2015-02-12 | 1807 // ES6 rev 33, 2015-02-12 |
| 1932 // 7.4.1 GetIterator ( obj, method ) | 1808 // 7.4.1 GetIterator ( obj, method ) |
| 1933 function GetIterator(obj, method) { | 1809 function GetIterator(obj, method) { |
| 1934 if (IS_UNDEFINED(method)) { | 1810 if (IS_UNDEFINED(method)) { |
| 1935 method = obj[symbolIterator]; | 1811 method = obj[symbolIterator]; |
| 1936 } | 1812 } |
| 1937 if (!IS_SPEC_FUNCTION(method)) { | 1813 if (!IS_SPEC_FUNCTION(method)) { |
| 1938 throw MakeTypeError(kNotIterable, obj); | 1814 throw MakeTypeError(kNotIterable, obj); |
| 1939 } | 1815 } |
| 1940 var iterator = %_CallFunction(obj, method); | 1816 var iterator = %_CallFunction(obj, method); |
| 1941 if (!IS_SPEC_OBJECT(iterator)) { | 1817 if (!IS_SPEC_OBJECT(iterator)) { |
| 1942 throw MakeTypeError(kNotAnIterator, iterator); | 1818 throw MakeTypeError(kNotAnIterator, iterator); |
| 1943 } | 1819 } |
| 1944 return iterator; | 1820 return iterator; |
| 1945 } | 1821 } |
| 1946 | 1822 |
| 1947 //---------------------------------------------------------------------------- | 1823 // ---------------------------------------------------------------------------- |
| 1824 // Exports |
| 1948 | 1825 |
| 1949 $delete = Delete; | |
| 1950 $functionSourceString = FunctionSourceString; | 1826 $functionSourceString = FunctionSourceString; |
| 1951 $getIterator = GetIterator; | |
| 1952 $getMethod = GetMethod; | |
| 1953 $globalEval = GlobalEval; | 1827 $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; | |
| 1964 $objectGetOwnPropertyDescriptor = ObjectGetOwnPropertyDescriptor; | 1828 $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; | |
| 1976 $toCompletePropertyDescriptor = ToCompletePropertyDescriptor; | 1829 $toCompletePropertyDescriptor = ToCompletePropertyDescriptor; |
| 1977 $toNameArray = ToNameArray; | 1830 |
| 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 }); |
| 1978 | 1852 |
| 1979 }) | 1853 }) |
| OLD | NEW |