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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
301 if (receiver == null && !IS_UNDETECTABLE(receiver)) { | 301 if (receiver == null && !IS_UNDETECTABLE(receiver)) { |
302 receiver = %GlobalReceiver(global); | 302 receiver = %GlobalReceiver(global); |
303 } | 303 } |
304 return %LookupAccessor(ToObject(receiver), ToString(name), SETTER); | 304 return %LookupAccessor(ToObject(receiver), ToString(name), SETTER); |
305 } | 305 } |
306 | 306 |
307 | 307 |
308 function ObjectKeys(obj) { | 308 function ObjectKeys(obj) { |
309 if (!IS_SPEC_OBJECT(obj)) | 309 if (!IS_SPEC_OBJECT(obj)) |
310 throw MakeTypeError("obj_ctor_property_non_object", ["keys"]); | 310 throw MakeTypeError("obj_ctor_property_non_object", ["keys"]); |
311 if (%IsJSProxy(obj)) { | |
312 var handler = %GetHandler(obj); | |
313 var keys = handler.keys; | |
314 if (IS_UNDEFINED(keys)) keys = DerivedKeysTrap; | |
315 var names = keys.call(handler); | |
316 return ToStringArray(names); | |
317 } | |
311 return %LocalKeys(obj); | 318 return %LocalKeys(obj); |
312 } | 319 } |
313 | 320 |
314 | 321 |
315 // ES5 8.10.1. | 322 // ES5 8.10.1. |
316 function IsAccessorDescriptor(desc) { | 323 function IsAccessorDescriptor(desc) { |
317 if (IS_UNDEFINED(desc)) return false; | 324 if (IS_UNDEFINED(desc)) return false; |
318 return desc.hasGetter() || desc.hasSetter(); | 325 return desc.hasGetter() || desc.hasSetter(); |
319 } | 326 } |
320 | 327 |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
581 if (%IsJSProxy(obj)) { | 588 if (%IsJSProxy(obj)) { |
582 var handler = %GetHandler(obj); | 589 var handler = %GetHandler(obj); |
583 var getProperty = handler.getPropertyDescriptor; | 590 var getProperty = handler.getPropertyDescriptor; |
584 if (IS_UNDEFINED(getProperty)) { | 591 if (IS_UNDEFINED(getProperty)) { |
585 throw MakeTypeError("handler_trap_missing", | 592 throw MakeTypeError("handler_trap_missing", |
586 [handler, "getPropertyDescriptor"]); | 593 [handler, "getPropertyDescriptor"]); |
587 } | 594 } |
588 var descriptor = getProperty.call(handler, p); | 595 var descriptor = getProperty.call(handler, p); |
589 if (IS_UNDEFINED(descriptor)) return descriptor; | 596 if (IS_UNDEFINED(descriptor)) return descriptor; |
590 var desc = ToCompletePropertyDescriptor(descriptor); | 597 var desc = ToCompletePropertyDescriptor(descriptor); |
591 if (!desc.configurable) { | 598 if (!desc.isConfigurable()) { |
592 throw MakeTypeError("proxy_prop_not_configurable", | 599 throw MakeTypeError("proxy_prop_not_configurable", |
593 [handler, "getPropertyDescriptor", p, descriptor]); | 600 [handler, "getPropertyDescriptor", p, descriptor]); |
594 } | 601 } |
595 return desc; | 602 return desc; |
596 } | 603 } |
597 var prop = GetOwnProperty(obj); | 604 var prop = GetOwnProperty(obj); |
598 if (!IS_UNDEFINED(prop)) return prop; | 605 if (!IS_UNDEFINED(prop)) return prop; |
599 var proto = %GetPrototype(obj); | 606 var proto = %GetPrototype(obj); |
600 if (IS_NULL(proto)) return void 0; | 607 if (IS_NULL(proto)) return void 0; |
601 return GetProperty(proto, p); | 608 return GetProperty(proto, p); |
602 } | 609 } |
603 | 610 |
604 | 611 |
605 // ES5 section 8.12.6 | 612 // ES5 section 8.12.6 |
606 function HasProperty(obj, p) { | 613 function HasProperty(obj, p) { |
607 if (%IsJSProxy(obj)) { | 614 if (%IsJSProxy(obj)) { |
608 var handler = %GetHandler(obj); | 615 var handler = %GetHandler(obj); |
609 var has = handler.has; | 616 var has = handler.has; |
610 if (IS_UNDEFINED(has)) has = DerivedHasTrap; | 617 if (IS_UNDEFINED(has)) has = DerivedHasTrap; |
611 return ToBoolean(has.call(handler, obj, p)); | 618 return ToBoolean(has.call(handler, obj, p)); |
612 } | 619 } |
613 var desc = GetProperty(obj, p); | 620 var desc = GetProperty(obj, p); |
614 return IS_UNDEFINED(desc) ? false : true; | 621 return IS_UNDEFINED(desc) ? false : true; |
615 } | 622 } |
616 | 623 |
617 | 624 |
618 // ES5 section 8.12.1. | 625 // ES5 section 8.12.1. |
619 function GetOwnProperty(obj, p) { | 626 function GetOwnProperty(obj, p) { |
627 if (%IsJSProxy(obj)) { | |
628 var handler = %GetHandler(obj); | |
629 var getOwnProperty = handler.getOwnPropertyDescriptor; | |
630 if (IS_UNDEFINED(getOwnProperty)) { | |
631 throw MakeTypeError("handler_trap_missing", | |
632 [handler, "getOwnPropertyDescriptor"]); | |
633 } | |
634 var descriptor = getOwnProperty.call(handler, p); | |
Mads Ager (chromium)
2011/07/12 13:45:42
Want to rely on Function.prototype.call which can
rossberg
2011/07/15 08:48:38
Done.
| |
635 if (IS_UNDEFINED(descriptor)) return descriptor; | |
636 var desc = ToCompletePropertyDescriptor(descriptor); | |
637 if (!desc.isConfigurable()) { | |
638 throw MakeTypeError("proxy_prop_not_configurable", | |
639 [handler, "getOwnPropertyDescriptor", p, descriptor]); | |
640 } | |
641 return desc; | |
642 } | |
643 | |
620 // GetOwnProperty returns an array indexed by the constants | 644 // GetOwnProperty returns an array indexed by the constants |
621 // defined in macros.py. | 645 // defined in macros.py. |
622 // If p is not a property on obj undefined is returned. | 646 // If p is not a property on obj undefined is returned. |
623 var props = %GetOwnProperty(ToObject(obj), ToString(p)); | 647 var props = %GetOwnProperty(ToObject(obj), ToString(p)); |
624 | 648 |
625 // A false value here means that access checks failed. | 649 // A false value here means that access checks failed. |
626 if (props === false) return void 0; | 650 if (props === false) return void 0; |
627 | 651 |
628 return ConvertDescriptorArrayToDescriptor(props); | 652 return ConvertDescriptorArrayToDescriptor(props); |
629 } | 653 } |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
822 function ObjectGetPrototypeOf(obj) { | 846 function ObjectGetPrototypeOf(obj) { |
823 if (!IS_SPEC_OBJECT(obj)) | 847 if (!IS_SPEC_OBJECT(obj)) |
824 throw MakeTypeError("obj_ctor_property_non_object", ["getPrototypeOf"]); | 848 throw MakeTypeError("obj_ctor_property_non_object", ["getPrototypeOf"]); |
825 return %GetPrototype(obj); | 849 return %GetPrototype(obj); |
826 } | 850 } |
827 | 851 |
828 | 852 |
829 // ES5 section 15.2.3.3 | 853 // ES5 section 15.2.3.3 |
830 function ObjectGetOwnPropertyDescriptor(obj, p) { | 854 function ObjectGetOwnPropertyDescriptor(obj, p) { |
831 if (!IS_SPEC_OBJECT(obj)) | 855 if (!IS_SPEC_OBJECT(obj)) |
832 throw MakeTypeError("obj_ctor_property_non_object", ["getOwnPropertyDescript or"]); | 856 throw MakeTypeError("obj_ctor_property_non_object", |
857 ["getOwnPropertyDescriptor"]); | |
833 var desc = GetOwnProperty(obj, p); | 858 var desc = GetOwnProperty(obj, p); |
834 return FromPropertyDescriptor(desc); | 859 return FromPropertyDescriptor(desc); |
835 } | 860 } |
836 | 861 |
837 | 862 |
838 // For Harmony proxies | 863 // For Harmony proxies |
839 function ToStringArray(obj, trap) { | 864 function ToStringArray(obj, trap) { |
840 if (!IS_SPEC_OBJECT(obj)) { | 865 if (!IS_SPEC_OBJECT(obj)) { |
841 throw MakeTypeError("proxy_non_object_prop_names", [obj, trap]); | 866 throw MakeTypeError("proxy_non_object_prop_names", [obj, trap]); |
842 } | 867 } |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1457 // ---------------------------------------------------------------------------- | 1482 // ---------------------------------------------------------------------------- |
1458 | 1483 |
1459 function SetupFunction() { | 1484 function SetupFunction() { |
1460 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 1485 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
1461 "bind", FunctionBind, | 1486 "bind", FunctionBind, |
1462 "toString", FunctionToString | 1487 "toString", FunctionToString |
1463 )); | 1488 )); |
1464 } | 1489 } |
1465 | 1490 |
1466 SetupFunction(); | 1491 SetupFunction(); |
OLD | NEW |