| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 function ObjectLookupSetter(name) { | 269 function ObjectLookupSetter(name) { |
| 270 if (this == null) { | 270 if (this == null) { |
| 271 throw new $TypeError('Object.prototype.__lookupSetter__: this is Null'); | 271 throw new $TypeError('Object.prototype.__lookupSetter__: this is Null'); |
| 272 } | 272 } |
| 273 return %LookupAccessor(ToObject(this), ToString(name), SETTER); | 273 return %LookupAccessor(ToObject(this), ToString(name), SETTER); |
| 274 } | 274 } |
| 275 | 275 |
| 276 | 276 |
| 277 function ObjectKeys(obj) { | 277 function ObjectKeys(obj) { |
| 278 if ((!IS_OBJECT(obj) || IS_NULL_OR_UNDEFINED(obj)) && !IS_FUNCTION(obj)) | 278 if ((!IS_OBJECT(obj) || IS_NULL_OR_UNDEFINED(obj)) && !IS_FUNCTION(obj)) |
| 279 throw MakeTypeError('object_keys_non_object', [obj]); | 279 throw MakeTypeError("obj_ctor_property_non_object", ["keys"]); |
| 280 return %LocalKeys(obj); | 280 return %LocalKeys(obj); |
| 281 } | 281 } |
| 282 | 282 |
| 283 | 283 |
| 284 // ES5 8.10.1. | 284 // ES5 8.10.1. |
| 285 function IsAccessorDescriptor(desc) { | 285 function IsAccessorDescriptor(desc) { |
| 286 if (IS_UNDEFINED(desc)) return false; | 286 if (IS_UNDEFINED(desc)) return false; |
| 287 return desc.hasGetter_ || desc.hasSetter_; | 287 return desc.hasGetter_ || desc.hasSetter_; |
| 288 } | 288 } |
| 289 | 289 |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 } else { | 486 } else { |
| 487 if (IS_FUNCTION(desc.getGet())) %DefineAccessor(obj, p, GETTER, desc.getGet(
), flag); | 487 if (IS_FUNCTION(desc.getGet())) %DefineAccessor(obj, p, GETTER, desc.getGet(
), flag); |
| 488 if (IS_FUNCTION(desc.getSet())) %DefineAccessor(obj, p, SETTER, desc.getSet(
), flag); | 488 if (IS_FUNCTION(desc.getSet())) %DefineAccessor(obj, p, SETTER, desc.getSet(
), flag); |
| 489 } | 489 } |
| 490 return true; | 490 return true; |
| 491 } | 491 } |
| 492 | 492 |
| 493 | 493 |
| 494 // ES5 section 15.2.3.2. | 494 // ES5 section 15.2.3.2. |
| 495 function ObjectGetPrototypeOf(obj) { | 495 function ObjectGetPrototypeOf(obj) { |
| 496 if (!IS_OBJECT(obj) && !IS_FUNCTION(obj)) { | 496 if ((!IS_OBJECT(obj) || IS_NULL_OR_UNDEFINED(obj)) && !IS_FUNCTION(obj)) |
| 497 throw MakeTypeError("object_get_prototype_non_object", [obj]); | 497 throw MakeTypeError("obj_ctor_property_non_object", ["getPrototypeOf"]); |
| 498 } | 498 return obj.__proto__; |
| 499 return obj.__proto__; | |
| 500 } | 499 } |
| 501 | 500 |
| 502 | 501 |
| 503 // ES5 section 15.2.3.3 | 502 // ES5 section 15.2.3.3 |
| 504 function ObjectGetOwnPropertyDescriptor(obj, p) { | 503 function ObjectGetOwnPropertyDescriptor(obj, p) { |
| 505 if (!IS_OBJECT(obj) && !IS_FUNCTION(obj)) { | 504 if ((!IS_OBJECT(obj) || IS_NULL_OR_UNDEFINED(obj)) && !IS_FUNCTION(obj)) |
| 506 throw MakeTypeError("object_get_prototype_non_object", [obj]); | 505 throw MakeTypeError("obj_ctor_property_non_object", ["getOwnPropertyDescript
or"]); |
| 507 } | |
| 508 var desc = GetOwnProperty(obj, p); | 506 var desc = GetOwnProperty(obj, p); |
| 509 return FromPropertyDescriptor(desc); | 507 return FromPropertyDescriptor(desc); |
| 510 } | 508 } |
| 511 | 509 |
| 512 | 510 |
| 511 // ES5 section 15.2.3.4. |
| 512 function ObjectGetOwnPropertyNames(obj) { |
| 513 if ((!IS_OBJECT(obj) || IS_NULL_OR_UNDEFINED(obj)) && !IS_FUNCTION(obj)) |
| 514 throw MakeTypeError("obj_ctor_property_non_object", ["getOwnPropertyNames"])
; |
| 515 |
| 516 // Find all the indexed properties. |
| 517 |
| 518 // Get the local element names. |
| 519 var propertyNames = %GetLocalElementNames(obj); |
| 520 |
| 521 // Get names for indexed interceptor properties. |
| 522 if (%GetInterceptorInfo(obj) & 1) { |
| 523 var indexedInterceptorNames = |
| 524 %GetIndexedInterceptorElementNames(obj); |
| 525 if (indexedInterceptorNames) { |
| 526 propertyNames = propertyNames.concat(indexedInterceptorNames); |
| 527 } |
| 528 } |
| 529 |
| 530 // Find all the named properties. |
| 531 |
| 532 // Get the local property names. |
| 533 propertyNames = propertyNames.concat(%GetLocalPropertyNames(obj)); |
| 534 |
| 535 // Get names for named interceptor properties if any. |
| 536 |
| 537 if (%GetInterceptorInfo(obj) & 2) { |
| 538 var namedInterceptorNames = |
| 539 %GetNamedInterceptorPropertyNames(obj); |
| 540 if (namedInterceptorNames) { |
| 541 propertyNames = propertyNames.concat(namedInterceptorNames); |
| 542 } |
| 543 } |
| 544 |
| 545 return propertyNames; |
| 546 } |
| 547 |
| 548 |
| 513 // ES5 section 15.2.3.5. | 549 // ES5 section 15.2.3.5. |
| 514 function ObjectCreate(proto, properties) { | 550 function ObjectCreate(proto, properties) { |
| 515 if (!IS_OBJECT(proto) && !IS_NULL(proto)) { | 551 if (!IS_OBJECT(proto) && !IS_NULL(proto)) { |
| 516 throw MakeTypeError("proto_object_or_null", [proto]); | 552 throw MakeTypeError("proto_object_or_null", [proto]); |
| 517 } | 553 } |
| 518 var obj = new $Object(); | 554 var obj = new $Object(); |
| 519 obj.__proto__ = proto; | 555 obj.__proto__ = proto; |
| 520 if (!IS_UNDEFINED(properties)) ObjectDefineProperties(obj, properties); | 556 if (!IS_UNDEFINED(properties)) ObjectDefineProperties(obj, properties); |
| 521 return obj; | 557 return obj; |
| 522 } | 558 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 "propertyIsEnumerable", ObjectPropertyIsEnumerable, | 605 "propertyIsEnumerable", ObjectPropertyIsEnumerable, |
| 570 "__defineGetter__", ObjectDefineGetter, | 606 "__defineGetter__", ObjectDefineGetter, |
| 571 "__lookupGetter__", ObjectLookupGetter, | 607 "__lookupGetter__", ObjectLookupGetter, |
| 572 "__defineSetter__", ObjectDefineSetter, | 608 "__defineSetter__", ObjectDefineSetter, |
| 573 "__lookupSetter__", ObjectLookupSetter | 609 "__lookupSetter__", ObjectLookupSetter |
| 574 )); | 610 )); |
| 575 InstallFunctions($Object, DONT_ENUM, $Array( | 611 InstallFunctions($Object, DONT_ENUM, $Array( |
| 576 "keys", ObjectKeys, | 612 "keys", ObjectKeys, |
| 577 "create", ObjectCreate, | 613 "create", ObjectCreate, |
| 578 "getPrototypeOf", ObjectGetPrototypeOf, | 614 "getPrototypeOf", ObjectGetPrototypeOf, |
| 579 "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor | 615 "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor, |
| 616 "getOwnPropertyNames", ObjectGetOwnPropertyNames |
| 580 )); | 617 )); |
| 581 } | 618 } |
| 582 | 619 |
| 583 SetupObject(); | 620 SetupObject(); |
| 584 | 621 |
| 585 | 622 |
| 586 // ---------------------------------------------------------------------------- | 623 // ---------------------------------------------------------------------------- |
| 587 // Boolean | 624 // Boolean |
| 588 | 625 |
| 589 function BooleanToString() { | 626 function BooleanToString() { |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 | 874 |
| 838 // ---------------------------------------------------------------------------- | 875 // ---------------------------------------------------------------------------- |
| 839 | 876 |
| 840 function SetupFunction() { | 877 function SetupFunction() { |
| 841 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 878 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
| 842 "toString", FunctionToString | 879 "toString", FunctionToString |
| 843 )); | 880 )); |
| 844 } | 881 } |
| 845 | 882 |
| 846 SetupFunction(); | 883 SetupFunction(); |
| OLD | NEW |