| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| 11 // with the distribution. | 11 // with the distribution. |
| 12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
| 13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
| 14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
| 15 // | 15 // |
| 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 // This file relies on the fact that the following declarations have been made | 28 // This file relies on the fact that the following declarations have been made |
| 29 // | |
| 30 // in runtime.js: | 29 // in runtime.js: |
| 31 // var $Object = global.Object; | 30 // var $Object = global.Object; |
| 32 // var $Boolean = global.Boolean; | 31 // var $Boolean = global.Boolean; |
| 33 // var $Number = global.Number; | 32 // var $Number = global.Number; |
| 34 // var $Function = global.Function; | 33 // var $Function = global.Function; |
| 35 // var $Array = global.Array; | 34 // var $Array = global.Array; |
| 36 // var $NaN = 0/0; | 35 // var $NaN = 0/0; |
| 37 // | 36 // |
| 38 // in math.js: | 37 // in math.js: |
| 39 // var $floor = MathFloor | 38 // var $floor = MathFloor |
| 40 | 39 |
| 41 var $isNaN = GlobalIsNaN; | 40 var $isNaN = GlobalIsNaN; |
| 42 var $isFinite = GlobalIsFinite; | 41 var $isFinite = GlobalIsFinite; |
| 43 | 42 |
| 44 // ---------------------------------------------------------------------------- | 43 // ---------------------------------------------------------------------------- |
| 45 | 44 |
| 46 | |
| 47 // Helper function used to install functions on objects. | 45 // Helper function used to install functions on objects. |
| 48 function InstallFunctions(object, attributes, functions) { | 46 function InstallFunctions(object, attributes, functions) { |
| 49 if (functions.length >= 8) { | 47 if (functions.length >= 8) { |
| 50 %OptimizeObjectForAddingMultipleProperties(object, functions.length >> 1); | 48 %OptimizeObjectForAddingMultipleProperties(object, functions.length >> 1); |
| 51 } | 49 } |
| 52 for (var i = 0; i < functions.length; i += 2) { | 50 for (var i = 0; i < functions.length; i += 2) { |
| 53 var key = functions[i]; | 51 var key = functions[i]; |
| 54 var f = functions[i + 1]; | 52 var f = functions[i + 1]; |
| 55 %FunctionSetName(f, key); | 53 %FunctionSetName(f, key); |
| 56 %FunctionRemovePrototype(f); | 54 %FunctionRemovePrototype(f); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 | 189 |
| 192 return %_CallFunction(global_receiver, f); | 190 return %_CallFunction(global_receiver, f); |
| 193 } | 191 } |
| 194 | 192 |
| 195 | 193 |
| 196 // ---------------------------------------------------------------------------- | 194 // ---------------------------------------------------------------------------- |
| 197 | 195 |
| 198 // Set up global object. | 196 // Set up global object. |
| 199 function SetUpGlobal() { | 197 function SetUpGlobal() { |
| 200 %CheckIsBootstrapping(); | 198 %CheckIsBootstrapping(); |
| 199 |
| 201 // ECMA 262 - 15.1.1.1. | 200 // ECMA 262 - 15.1.1.1. |
| 202 %SetProperty(global, "NaN", $NaN, DONT_ENUM | DONT_DELETE | READ_ONLY); | 201 %SetProperty(global, "NaN", $NaN, DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 203 | 202 |
| 204 // ECMA-262 - 15.1.1.2. | 203 // ECMA-262 - 15.1.1.2. |
| 205 %SetProperty(global, "Infinity", 1/0, DONT_ENUM | DONT_DELETE | READ_ONLY); | 204 %SetProperty(global, "Infinity", 1/0, DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 206 | 205 |
| 207 // ECMA-262 - 15.1.1.3. | 206 // ECMA-262 - 15.1.1.3. |
| 208 %SetProperty(global, "undefined", void 0, | 207 %SetProperty(global, "undefined", void 0, |
| 209 DONT_ENUM | DONT_DELETE | READ_ONLY); | 208 DONT_ENUM | DONT_DELETE | READ_ONLY); |
| 210 | 209 |
| 211 // Set up non-enumerable function on the global object. | 210 // Set up non-enumerable function on the global object. |
| 212 InstallFunctions(global, DONT_ENUM, $Array( | 211 InstallFunctions(global, DONT_ENUM, $Array( |
| 213 "isNaN", GlobalIsNaN, | 212 "isNaN", GlobalIsNaN, |
| 214 "isFinite", GlobalIsFinite, | 213 "isFinite", GlobalIsFinite, |
| 215 "parseInt", GlobalParseInt, | 214 "parseInt", GlobalParseInt, |
| 216 "parseFloat", GlobalParseFloat, | 215 "parseFloat", GlobalParseFloat, |
| 217 "eval", GlobalEval | 216 "eval", GlobalEval |
| 218 )); | 217 )); |
| 219 } | 218 } |
| 220 | 219 |
| 221 SetUpGlobal(); | 220 SetUpGlobal(); |
| 222 | 221 |
| 223 // ---------------------------------------------------------------------------- | |
| 224 // Boolean (first part of definition) | |
| 225 | |
| 226 | |
| 227 %SetCode($Boolean, function(x) { | |
| 228 if (%_IsConstructCall()) { | |
| 229 %_SetValueOf(this, ToBoolean(x)); | |
| 230 } else { | |
| 231 return ToBoolean(x); | |
| 232 } | |
| 233 }); | |
| 234 | |
| 235 %FunctionSetPrototype($Boolean, new $Boolean(false)); | |
| 236 | |
| 237 %SetProperty($Boolean.prototype, "constructor", $Boolean, DONT_ENUM); | |
| 238 | 222 |
| 239 // ---------------------------------------------------------------------------- | 223 // ---------------------------------------------------------------------------- |
| 240 // Object | 224 // Object |
| 241 | 225 |
| 242 $Object.prototype.constructor = $Object; | |
| 243 | |
| 244 // ECMA-262 - 15.2.4.2 | 226 // ECMA-262 - 15.2.4.2 |
| 245 function ObjectToString() { | 227 function ObjectToString() { |
| 246 if (IS_UNDEFINED(this) && !IS_UNDETECTABLE(this)) return "[object Undefined]"; | 228 if (IS_UNDEFINED(this) && !IS_UNDETECTABLE(this)) return "[object Undefined]"; |
| 247 if (IS_NULL(this)) return "[object Null]"; | 229 if (IS_NULL(this)) return "[object Null]"; |
| 248 return "[object " + %_ClassOf(ToObject(this)) + "]"; | 230 return "[object " + %_ClassOf(ToObject(this)) + "]"; |
| 249 } | 231 } |
| 250 | 232 |
| 251 | 233 |
| 252 // ECMA-262 - 15.2.4.3 | 234 // ECMA-262 - 15.2.4.3 |
| 253 function ObjectToLocaleString() { | 235 function ObjectToLocaleString() { |
| (...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1350 return %SetPrototype(this, obj); | 1332 return %SetPrototype(this, obj); |
| 1351 } | 1333 } |
| 1352 | 1334 |
| 1353 | 1335 |
| 1354 // Harmony __proto__ poison pill. | 1336 // Harmony __proto__ poison pill. |
| 1355 function ObjectPoisonProto(obj) { | 1337 function ObjectPoisonProto(obj) { |
| 1356 throw MakeTypeError("proto_poison_pill", []); | 1338 throw MakeTypeError("proto_poison_pill", []); |
| 1357 } | 1339 } |
| 1358 | 1340 |
| 1359 | 1341 |
| 1360 %SetCode($Object, function(x) { | 1342 function ObjectConstructor(x) { |
| 1361 if (%_IsConstructCall()) { | 1343 if (%_IsConstructCall()) { |
| 1362 if (x == null) return this; | 1344 if (x == null) return this; |
| 1363 return ToObject(x); | 1345 return ToObject(x); |
| 1364 } else { | 1346 } else { |
| 1365 if (x == null) return { }; | 1347 if (x == null) return { }; |
| 1366 return ToObject(x); | 1348 return ToObject(x); |
| 1367 } | 1349 } |
| 1368 }); | 1350 } |
| 1369 | 1351 |
| 1370 | 1352 |
| 1371 // ---------------------------------------------------------------------------- | 1353 // ---------------------------------------------------------------------------- |
| 1372 // Object | 1354 // Object |
| 1373 | 1355 |
| 1374 function SetUpObject() { | 1356 function SetUpObject() { |
| 1375 %CheckIsBootstrapping(); | 1357 %CheckIsBootstrapping(); |
| 1376 | 1358 |
| 1359 $Object.prototype.constructor = $Object; |
| 1360 %SetCode($Object, ObjectConstructor); |
| 1377 %FunctionSetName(ObjectPoisonProto, "__proto__"); | 1361 %FunctionSetName(ObjectPoisonProto, "__proto__"); |
| 1378 %FunctionRemovePrototype(ObjectPoisonProto); | 1362 %FunctionRemovePrototype(ObjectPoisonProto); |
| 1379 %SetExpectedNumberOfProperties($Object, 4); | 1363 %SetExpectedNumberOfProperties($Object, 4); |
| 1380 | 1364 |
| 1381 // Set up non-enumerable functions on the Object.prototype object. | 1365 // Set up non-enumerable functions on the Object.prototype object. |
| 1382 InstallFunctions($Object.prototype, DONT_ENUM, $Array( | 1366 InstallFunctions($Object.prototype, DONT_ENUM, $Array( |
| 1383 "toString", ObjectToString, | 1367 "toString", ObjectToString, |
| 1384 "toLocaleString", ObjectToLocaleString, | 1368 "toLocaleString", ObjectToLocaleString, |
| 1385 "valueOf", ObjectValueOf, | 1369 "valueOf", ObjectValueOf, |
| 1386 "hasOwnProperty", ObjectHasOwnProperty, | 1370 "hasOwnProperty", ObjectHasOwnProperty, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1408 "isExtensible", ObjectIsExtensible, | 1392 "isExtensible", ObjectIsExtensible, |
| 1409 "isFrozen", ObjectIsFrozen, | 1393 "isFrozen", ObjectIsFrozen, |
| 1410 "isSealed", ObjectIsSealed, | 1394 "isSealed", ObjectIsSealed, |
| 1411 "preventExtensions", ObjectPreventExtension, | 1395 "preventExtensions", ObjectPreventExtension, |
| 1412 "seal", ObjectSeal | 1396 "seal", ObjectSeal |
| 1413 )); | 1397 )); |
| 1414 } | 1398 } |
| 1415 | 1399 |
| 1416 SetUpObject(); | 1400 SetUpObject(); |
| 1417 | 1401 |
| 1402 |
| 1418 // ---------------------------------------------------------------------------- | 1403 // ---------------------------------------------------------------------------- |
| 1419 // Boolean | 1404 // Boolean |
| 1420 | 1405 |
| 1406 function BooleanConstructor(x) { |
| 1407 if (%_IsConstructCall()) { |
| 1408 %_SetValueOf(this, ToBoolean(x)); |
| 1409 } else { |
| 1410 return ToBoolean(x); |
| 1411 } |
| 1412 } |
| 1413 |
| 1414 |
| 1421 function BooleanToString() { | 1415 function BooleanToString() { |
| 1422 // NOTE: Both Boolean objects and values can enter here as | 1416 // NOTE: Both Boolean objects and values can enter here as |
| 1423 // 'this'. This is not as dictated by ECMA-262. | 1417 // 'this'. This is not as dictated by ECMA-262. |
| 1424 var b = this; | 1418 var b = this; |
| 1425 if (!IS_BOOLEAN(b)) { | 1419 if (!IS_BOOLEAN(b)) { |
| 1426 if (!IS_BOOLEAN_WRAPPER(b)) { | 1420 if (!IS_BOOLEAN_WRAPPER(b)) { |
| 1427 throw new $TypeError('Boolean.prototype.toString is not generic'); | 1421 throw new $TypeError('Boolean.prototype.toString is not generic'); |
| 1428 } | 1422 } |
| 1429 b = %_ValueOf(b); | 1423 b = %_ValueOf(b); |
| 1430 } | 1424 } |
| 1431 return b ? 'true' : 'false'; | 1425 return b ? 'true' : 'false'; |
| 1432 } | 1426 } |
| 1433 | 1427 |
| 1434 | 1428 |
| 1435 function BooleanValueOf() { | 1429 function BooleanValueOf() { |
| 1436 // NOTE: Both Boolean objects and values can enter here as | 1430 // NOTE: Both Boolean objects and values can enter here as |
| 1437 // 'this'. This is not as dictated by ECMA-262. | 1431 // 'this'. This is not as dictated by ECMA-262. |
| 1438 if (!IS_BOOLEAN(this) && !IS_BOOLEAN_WRAPPER(this)) { | 1432 if (!IS_BOOLEAN(this) && !IS_BOOLEAN_WRAPPER(this)) { |
| 1439 throw new $TypeError('Boolean.prototype.valueOf is not generic'); | 1433 throw new $TypeError('Boolean.prototype.valueOf is not generic'); |
| 1440 } | 1434 } |
| 1441 return %_ValueOf(this); | 1435 return %_ValueOf(this); |
| 1442 } | 1436 } |
| 1443 | 1437 |
| 1444 | 1438 |
| 1445 // ---------------------------------------------------------------------------- | 1439 // ---------------------------------------------------------------------------- |
| 1446 | 1440 |
| 1447 | |
| 1448 function SetUpBoolean () { | 1441 function SetUpBoolean () { |
| 1449 %CheckIsBootstrapping(); | 1442 %CheckIsBootstrapping(); |
| 1443 |
| 1444 %SetCode($Boolean, BooleanConstructor); |
| 1445 %FunctionSetPrototype($Boolean, new $Boolean(false)); |
| 1446 %SetProperty($Boolean.prototype, "constructor", $Boolean, DONT_ENUM); |
| 1447 |
| 1450 InstallFunctions($Boolean.prototype, DONT_ENUM, $Array( | 1448 InstallFunctions($Boolean.prototype, DONT_ENUM, $Array( |
| 1451 "toString", BooleanToString, | 1449 "toString", BooleanToString, |
| 1452 "valueOf", BooleanValueOf | 1450 "valueOf", BooleanValueOf |
| 1453 )); | 1451 )); |
| 1454 } | 1452 } |
| 1455 | 1453 |
| 1456 SetUpBoolean(); | 1454 SetUpBoolean(); |
| 1457 | 1455 |
| 1458 | 1456 |
| 1459 // ---------------------------------------------------------------------------- | 1457 // ---------------------------------------------------------------------------- |
| 1460 // Number | 1458 // Number |
| 1461 | 1459 |
| 1462 // Set the Number function and constructor. | 1460 function NumberConstructor(x) { |
| 1463 %SetCode($Number, function(x) { | |
| 1464 var value = %_ArgumentsLength() == 0 ? 0 : ToNumber(x); | 1461 var value = %_ArgumentsLength() == 0 ? 0 : ToNumber(x); |
| 1465 if (%_IsConstructCall()) { | 1462 if (%_IsConstructCall()) { |
| 1466 %_SetValueOf(this, value); | 1463 %_SetValueOf(this, value); |
| 1467 } else { | 1464 } else { |
| 1468 return value; | 1465 return value; |
| 1469 } | 1466 } |
| 1470 }); | 1467 } |
| 1471 | 1468 |
| 1472 %FunctionSetPrototype($Number, new $Number(0)); | |
| 1473 | 1469 |
| 1474 // ECMA-262 section 15.7.4.2. | 1470 // ECMA-262 section 15.7.4.2. |
| 1475 function NumberToString(radix) { | 1471 function NumberToString(radix) { |
| 1476 // NOTE: Both Number objects and values can enter here as | 1472 // NOTE: Both Number objects and values can enter here as |
| 1477 // 'this'. This is not as dictated by ECMA-262. | 1473 // 'this'. This is not as dictated by ECMA-262. |
| 1478 var number = this; | 1474 var number = this; |
| 1479 if (!IS_NUMBER(this)) { | 1475 if (!IS_NUMBER(this)) { |
| 1480 if (!IS_NUMBER_WRAPPER(this)) { | 1476 if (!IS_NUMBER_WRAPPER(this)) { |
| 1481 throw new $TypeError('Number.prototype.toString is not generic'); | 1477 throw new $TypeError('Number.prototype.toString is not generic'); |
| 1482 } | 1478 } |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1600 // Harmony isNaN. | 1596 // Harmony isNaN. |
| 1601 function NumberIsNaN(number) { | 1597 function NumberIsNaN(number) { |
| 1602 return IS_NUMBER(number) && NUMBER_IS_NAN(number); | 1598 return IS_NUMBER(number) && NUMBER_IS_NAN(number); |
| 1603 } | 1599 } |
| 1604 | 1600 |
| 1605 | 1601 |
| 1606 // ---------------------------------------------------------------------------- | 1602 // ---------------------------------------------------------------------------- |
| 1607 | 1603 |
| 1608 function SetUpNumber() { | 1604 function SetUpNumber() { |
| 1609 %CheckIsBootstrapping(); | 1605 %CheckIsBootstrapping(); |
| 1606 |
| 1607 %SetCode($Number, NumberConstructor); |
| 1608 %FunctionSetPrototype($Number, new $Number(0)); |
| 1609 |
| 1610 %OptimizeObjectForAddingMultipleProperties($Number.prototype, 8); | 1610 %OptimizeObjectForAddingMultipleProperties($Number.prototype, 8); |
| 1611 // Set up the constructor property on the Number prototype object. | 1611 // Set up the constructor property on the Number prototype object. |
| 1612 %SetProperty($Number.prototype, "constructor", $Number, DONT_ENUM); | 1612 %SetProperty($Number.prototype, "constructor", $Number, DONT_ENUM); |
| 1613 | 1613 |
| 1614 %OptimizeObjectForAddingMultipleProperties($Number, 5); | 1614 %OptimizeObjectForAddingMultipleProperties($Number, 5); |
| 1615 // ECMA-262 section 15.7.3.1. | 1615 // ECMA-262 section 15.7.3.1. |
| 1616 %SetProperty($Number, | 1616 %SetProperty($Number, |
| 1617 "MAX_VALUE", | 1617 "MAX_VALUE", |
| 1618 1.7976931348623157e+308, | 1618 1.7976931348623157e+308, |
| 1619 DONT_ENUM | DONT_DELETE | READ_ONLY); | 1619 DONT_ENUM | DONT_DELETE | READ_ONLY); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1652 "isNaN", NumberIsNaN | 1652 "isNaN", NumberIsNaN |
| 1653 )); | 1653 )); |
| 1654 } | 1654 } |
| 1655 | 1655 |
| 1656 SetUpNumber(); | 1656 SetUpNumber(); |
| 1657 | 1657 |
| 1658 | 1658 |
| 1659 // ---------------------------------------------------------------------------- | 1659 // ---------------------------------------------------------------------------- |
| 1660 // Function | 1660 // Function |
| 1661 | 1661 |
| 1662 $Function.prototype.constructor = $Function; | |
| 1663 | |
| 1664 function FunctionSourceString(func) { | 1662 function FunctionSourceString(func) { |
| 1665 while (%IsJSFunctionProxy(func)) { | 1663 while (%IsJSFunctionProxy(func)) { |
| 1666 func = %GetCallTrap(func); | 1664 func = %GetCallTrap(func); |
| 1667 } | 1665 } |
| 1668 | 1666 |
| 1669 if (!IS_FUNCTION(func)) { | 1667 if (!IS_FUNCTION(func)) { |
| 1670 throw new $TypeError('Function.prototype.toString is not generic'); | 1668 throw new $TypeError('Function.prototype.toString is not generic'); |
| 1671 } | 1669 } |
| 1672 | 1670 |
| 1673 var source = %FunctionGetSourceCode(func); | 1671 var source = %FunctionGetSourceCode(func); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1777 | 1775 |
| 1778 // The call to SetNewFunctionAttributes will ensure the prototype | 1776 // The call to SetNewFunctionAttributes will ensure the prototype |
| 1779 // property of the resulting function is enumerable (ECMA262, 15.3.5.2). | 1777 // property of the resulting function is enumerable (ECMA262, 15.3.5.2). |
| 1780 var global_receiver = %GlobalReceiver(global); | 1778 var global_receiver = %GlobalReceiver(global); |
| 1781 var f = %_CallFunction(global_receiver, %CompileString(source, true)); | 1779 var f = %_CallFunction(global_receiver, %CompileString(source, true)); |
| 1782 | 1780 |
| 1783 %FunctionMarkNameShouldPrintAsAnonymous(f); | 1781 %FunctionMarkNameShouldPrintAsAnonymous(f); |
| 1784 return %SetNewFunctionAttributes(f); | 1782 return %SetNewFunctionAttributes(f); |
| 1785 } | 1783 } |
| 1786 | 1784 |
| 1787 %SetCode($Function, NewFunction); | |
| 1788 | 1785 |
| 1789 // ---------------------------------------------------------------------------- | 1786 // ---------------------------------------------------------------------------- |
| 1790 | 1787 |
| 1791 function SetUpFunction() { | 1788 function SetUpFunction() { |
| 1792 %CheckIsBootstrapping(); | 1789 %CheckIsBootstrapping(); |
| 1790 |
| 1791 $Function.prototype.constructor = $Function; |
| 1792 %SetCode($Function, NewFunction); |
| 1793 |
| 1793 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 1794 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
| 1794 "bind", FunctionBind, | 1795 "bind", FunctionBind, |
| 1795 "toString", FunctionToString | 1796 "toString", FunctionToString |
| 1796 )); | 1797 )); |
| 1797 } | 1798 } |
| 1798 | 1799 |
| 1799 SetUpFunction(); | 1800 SetUpFunction(); |
| OLD | NEW |