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 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 } | 738 } |
739 for (var i = 0; i < key_values.length; i += 2) { | 739 for (var i = 0; i < key_values.length; i += 2) { |
740 var key = key_values[i]; | 740 var key = key_values[i]; |
741 var desc = key_values[i + 1]; | 741 var desc = key_values[i + 1]; |
742 DefineOwnProperty(obj, key, desc, true); | 742 DefineOwnProperty(obj, key, desc, true); |
743 } | 743 } |
744 return obj; | 744 return obj; |
745 } | 745 } |
746 | 746 |
747 | 747 |
| 748 // ES5 section 15.2.3.10 |
| 749 function ObjectPreventExtension(obj) { |
| 750 if ((!IS_SPEC_OBJECT_OR_NULL(obj) || IS_NULL_OR_UNDEFINED(obj)) && |
| 751 !IS_UNDETECTABLE(obj)) { |
| 752 throw MakeTypeError("obj_ctor_property_non_object", ["preventExtension"]); |
| 753 } |
| 754 %PreventExtensions(obj); |
| 755 return obj; |
| 756 } |
| 757 |
| 758 |
| 759 // ES5 section 15.2.3.13 |
| 760 function ObjectIsExtensible(obj) { |
| 761 if ((!IS_SPEC_OBJECT_OR_NULL(obj) || IS_NULL_OR_UNDEFINED(obj)) && |
| 762 !IS_UNDETECTABLE(obj)) { |
| 763 throw MakeTypeError("obj_ctor_property_non_object", ["preventExtension"]); |
| 764 } |
| 765 return %IsExtensible(obj); |
| 766 } |
| 767 |
| 768 |
748 %SetCode($Object, function(x) { | 769 %SetCode($Object, function(x) { |
749 if (%_IsConstructCall()) { | 770 if (%_IsConstructCall()) { |
750 if (x == null) return this; | 771 if (x == null) return this; |
751 return ToObject(x); | 772 return ToObject(x); |
752 } else { | 773 } else { |
753 if (x == null) return { }; | 774 if (x == null) return { }; |
754 return ToObject(x); | 775 return ToObject(x); |
755 } | 776 } |
756 }); | 777 }); |
757 | 778 |
(...skipping 15 matching lines...) Expand all Loading... |
773 "__defineSetter__", ObjectDefineSetter, | 794 "__defineSetter__", ObjectDefineSetter, |
774 "__lookupSetter__", ObjectLookupSetter | 795 "__lookupSetter__", ObjectLookupSetter |
775 )); | 796 )); |
776 InstallFunctions($Object, DONT_ENUM, $Array( | 797 InstallFunctions($Object, DONT_ENUM, $Array( |
777 "keys", ObjectKeys, | 798 "keys", ObjectKeys, |
778 "create", ObjectCreate, | 799 "create", ObjectCreate, |
779 "defineProperty", ObjectDefineProperty, | 800 "defineProperty", ObjectDefineProperty, |
780 "defineProperties", ObjectDefineProperties, | 801 "defineProperties", ObjectDefineProperties, |
781 "getPrototypeOf", ObjectGetPrototypeOf, | 802 "getPrototypeOf", ObjectGetPrototypeOf, |
782 "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor, | 803 "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor, |
783 "getOwnPropertyNames", ObjectGetOwnPropertyNames | 804 "getOwnPropertyNames", ObjectGetOwnPropertyNames, |
| 805 "isExtensible", ObjectIsExtensible, |
| 806 "preventExtensions", ObjectPreventExtension |
784 )); | 807 )); |
785 } | 808 } |
786 | 809 |
787 SetupObject(); | 810 SetupObject(); |
788 | 811 |
789 | 812 |
790 // ---------------------------------------------------------------------------- | 813 // ---------------------------------------------------------------------------- |
791 // Boolean | 814 // Boolean |
792 | 815 |
793 function BooleanToString() { | 816 function BooleanToString() { |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1041 | 1064 |
1042 // ---------------------------------------------------------------------------- | 1065 // ---------------------------------------------------------------------------- |
1043 | 1066 |
1044 function SetupFunction() { | 1067 function SetupFunction() { |
1045 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 1068 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
1046 "toString", FunctionToString | 1069 "toString", FunctionToString |
1047 )); | 1070 )); |
1048 } | 1071 } |
1049 | 1072 |
1050 SetupFunction(); | 1073 SetupFunction(); |
OLD | NEW |