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 |
(...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1251 if (!IS_SPEC_OBJECT(obj)) { | 1251 if (!IS_SPEC_OBJECT(obj)) { |
1252 throw MakeTypeError("called_on_non_object", ["Object.isExtensible"]); | 1252 throw MakeTypeError("called_on_non_object", ["Object.isExtensible"]); |
1253 } | 1253 } |
1254 if (%IsJSProxy(obj)) { | 1254 if (%IsJSProxy(obj)) { |
1255 return true; | 1255 return true; |
1256 } | 1256 } |
1257 return %IsExtensible(obj); | 1257 return %IsExtensible(obj); |
1258 } | 1258 } |
1259 | 1259 |
1260 | 1260 |
1261 // Harmony egal. | |
1262 function ObjectIs(obj1, obj2) { | |
1263 if (obj1 === obj2) { | |
1264 return (obj1 !== 0) || ((1 / obj1) === (1 / obj2)); | |
rossberg
2012/03/08 12:42:26
What's with all the redundant parentheses?
Michael Starzinger
2012/03/08 12:50:00
Done.
| |
1265 } else { | |
1266 return (obj1 !== obj1) && (obj2 !== obj2); | |
1267 } | |
1268 } | |
1269 | |
1270 | |
1261 %SetCode($Object, function(x) { | 1271 %SetCode($Object, function(x) { |
1262 if (%_IsConstructCall()) { | 1272 if (%_IsConstructCall()) { |
1263 if (x == null) return this; | 1273 if (x == null) return this; |
1264 return ToObject(x); | 1274 return ToObject(x); |
1265 } else { | 1275 } else { |
1266 if (x == null) return { }; | 1276 if (x == null) return { }; |
1267 return ToObject(x); | 1277 return ToObject(x); |
1268 } | 1278 } |
1269 }); | 1279 }); |
1270 | 1280 |
(...skipping 19 matching lines...) Expand all Loading... | |
1290 )); | 1300 )); |
1291 InstallFunctions($Object, DONT_ENUM, $Array( | 1301 InstallFunctions($Object, DONT_ENUM, $Array( |
1292 "keys", ObjectKeys, | 1302 "keys", ObjectKeys, |
1293 "create", ObjectCreate, | 1303 "create", ObjectCreate, |
1294 "defineProperty", ObjectDefineProperty, | 1304 "defineProperty", ObjectDefineProperty, |
1295 "defineProperties", ObjectDefineProperties, | 1305 "defineProperties", ObjectDefineProperties, |
1296 "freeze", ObjectFreeze, | 1306 "freeze", ObjectFreeze, |
1297 "getPrototypeOf", ObjectGetPrototypeOf, | 1307 "getPrototypeOf", ObjectGetPrototypeOf, |
1298 "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor, | 1308 "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor, |
1299 "getOwnPropertyNames", ObjectGetOwnPropertyNames, | 1309 "getOwnPropertyNames", ObjectGetOwnPropertyNames, |
1310 "is", ObjectIs, | |
1300 "isExtensible", ObjectIsExtensible, | 1311 "isExtensible", ObjectIsExtensible, |
1301 "isFrozen", ObjectIsFrozen, | 1312 "isFrozen", ObjectIsFrozen, |
1302 "isSealed", ObjectIsSealed, | 1313 "isSealed", ObjectIsSealed, |
1303 "preventExtensions", ObjectPreventExtension, | 1314 "preventExtensions", ObjectPreventExtension, |
1304 "seal", ObjectSeal | 1315 "seal", ObjectSeal |
1305 )); | 1316 )); |
1306 } | 1317 } |
1307 | 1318 |
1308 SetUpObject(); | 1319 SetUpObject(); |
1309 | 1320 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1454 if (IS_UNDEFINED(precision)) return ToString(%_ValueOf(this)); | 1465 if (IS_UNDEFINED(precision)) return ToString(%_ValueOf(this)); |
1455 var p = TO_INTEGER(precision); | 1466 var p = TO_INTEGER(precision); |
1456 if (p < 1 || p > 21) { | 1467 if (p < 1 || p > 21) { |
1457 throw new $RangeError("toPrecision() argument must be between 1 and 21"); | 1468 throw new $RangeError("toPrecision() argument must be between 1 and 21"); |
1458 } | 1469 } |
1459 var x = ToNumber(this); | 1470 var x = ToNumber(this); |
1460 return %NumberToPrecision(x, p); | 1471 return %NumberToPrecision(x, p); |
1461 } | 1472 } |
1462 | 1473 |
1463 | 1474 |
1475 // Harmony isFinite. | |
1476 function NumberIsFinite(number) { | |
1477 return IS_NUMBER(number) && NUMBER_IS_FINITE(number); | |
1478 } | |
1479 | |
1480 | |
1481 // Harmony isNaN. | |
1482 function NumberIsNaN(number) { | |
1483 return IS_NUMBER(number) && NUMBER_IS_NAN(number); | |
1484 } | |
1485 | |
1486 | |
1464 // ---------------------------------------------------------------------------- | 1487 // ---------------------------------------------------------------------------- |
1465 | 1488 |
1466 function SetUpNumber() { | 1489 function SetUpNumber() { |
1467 %CheckIsBootstrapping(); | 1490 %CheckIsBootstrapping(); |
1468 %OptimizeObjectForAddingMultipleProperties($Number.prototype, 8); | 1491 %OptimizeObjectForAddingMultipleProperties($Number.prototype, 8); |
1469 // Set up the constructor property on the Number prototype object. | 1492 // Set up the constructor property on the Number prototype object. |
1470 %SetProperty($Number.prototype, "constructor", $Number, DONT_ENUM); | 1493 %SetProperty($Number.prototype, "constructor", $Number, DONT_ENUM); |
1471 | 1494 |
1472 %OptimizeObjectForAddingMultipleProperties($Number, 5); | 1495 %OptimizeObjectForAddingMultipleProperties($Number, 5); |
1473 // ECMA-262 section 15.7.3.1. | 1496 // ECMA-262 section 15.7.3.1. |
(...skipping 24 matching lines...) Expand all Loading... | |
1498 | 1521 |
1499 // Set up non-enumerable functions on the Number prototype object. | 1522 // Set up non-enumerable functions on the Number prototype object. |
1500 InstallFunctions($Number.prototype, DONT_ENUM, $Array( | 1523 InstallFunctions($Number.prototype, DONT_ENUM, $Array( |
1501 "toString", NumberToString, | 1524 "toString", NumberToString, |
1502 "toLocaleString", NumberToLocaleString, | 1525 "toLocaleString", NumberToLocaleString, |
1503 "valueOf", NumberValueOf, | 1526 "valueOf", NumberValueOf, |
1504 "toFixed", NumberToFixed, | 1527 "toFixed", NumberToFixed, |
1505 "toExponential", NumberToExponential, | 1528 "toExponential", NumberToExponential, |
1506 "toPrecision", NumberToPrecision | 1529 "toPrecision", NumberToPrecision |
1507 )); | 1530 )); |
1531 InstallFunctions($Number, DONT_ENUM, $Array( | |
1532 "isFinite", NumberIsFinite, | |
1533 "isNaN", NumberIsNaN | |
1534 )); | |
1508 } | 1535 } |
1509 | 1536 |
1510 SetUpNumber(); | 1537 SetUpNumber(); |
1511 | 1538 |
1512 | 1539 |
1513 // ---------------------------------------------------------------------------- | 1540 // ---------------------------------------------------------------------------- |
1514 // Function | 1541 // Function |
1515 | 1542 |
1516 $Function.prototype.constructor = $Function; | 1543 $Function.prototype.constructor = $Function; |
1517 | 1544 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1638 | 1665 |
1639 function SetUpFunction() { | 1666 function SetUpFunction() { |
1640 %CheckIsBootstrapping(); | 1667 %CheckIsBootstrapping(); |
1641 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 1668 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
1642 "bind", FunctionBind, | 1669 "bind", FunctionBind, |
1643 "toString", FunctionToString | 1670 "toString", FunctionToString |
1644 )); | 1671 )); |
1645 } | 1672 } |
1646 | 1673 |
1647 SetUpFunction(); | 1674 SetUpFunction(); |
OLD | NEW |