| 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 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 return obj; | 736 return obj; |
| 737 } | 737 } |
| 738 | 738 |
| 739 | 739 |
| 740 // ES5 section 15.2.3.8. | 740 // ES5 section 15.2.3.8. |
| 741 function ObjectSeal(obj) { | 741 function ObjectSeal(obj) { |
| 742 if (!IS_SPEC_OBJECT(obj)) { | 742 if (!IS_SPEC_OBJECT(obj)) { |
| 743 throw MakeTypeError("obj_ctor_property_non_object", ["seal"]); | 743 throw MakeTypeError("obj_ctor_property_non_object", ["seal"]); |
| 744 } | 744 } |
| 745 var names = ObjectGetOwnPropertyNames(obj); | 745 var names = ObjectGetOwnPropertyNames(obj); |
| 746 for (var key in names) { | 746 for (var i = 0; i < names.length; i++) { |
| 747 var name = names[key]; | 747 var name = names[i]; |
| 748 var desc = GetOwnProperty(obj, name); | 748 var desc = GetOwnProperty(obj, name); |
| 749 if (desc.isConfigurable()) desc.setConfigurable(false); | 749 if (desc.isConfigurable()) desc.setConfigurable(false); |
| 750 DefineOwnProperty(obj, name, desc, true); | 750 DefineOwnProperty(obj, name, desc, true); |
| 751 } | 751 } |
| 752 return ObjectPreventExtension(obj); | 752 return ObjectPreventExtension(obj); |
| 753 } | 753 } |
| 754 | 754 |
| 755 | 755 |
| 756 // ES5 section 15.2.3.9. | 756 // ES5 section 15.2.3.9. |
| 757 function ObjectFreeze(obj) { | 757 function ObjectFreeze(obj) { |
| 758 if (!IS_SPEC_OBJECT(obj)) { | 758 if (!IS_SPEC_OBJECT(obj)) { |
| 759 throw MakeTypeError("obj_ctor_property_non_object", ["freeze"]); | 759 throw MakeTypeError("obj_ctor_property_non_object", ["freeze"]); |
| 760 } | 760 } |
| 761 var names = ObjectGetOwnPropertyNames(obj); | 761 var names = ObjectGetOwnPropertyNames(obj); |
| 762 for (var key in names) { | 762 for (var i = 0; i < names.length; i++) { |
| 763 var name = names[key]; | 763 var name = names[i]; |
| 764 var desc = GetOwnProperty(obj, name); | 764 var desc = GetOwnProperty(obj, name); |
| 765 if (IsDataDescriptor(desc)) desc.setWritable(false); | 765 if (IsDataDescriptor(desc)) desc.setWritable(false); |
| 766 if (desc.isConfigurable()) desc.setConfigurable(false); | 766 if (desc.isConfigurable()) desc.setConfigurable(false); |
| 767 DefineOwnProperty(obj, name, desc, true); | 767 DefineOwnProperty(obj, name, desc, true); |
| 768 } | 768 } |
| 769 return ObjectPreventExtension(obj); | 769 return ObjectPreventExtension(obj); |
| 770 } | 770 } |
| 771 | 771 |
| 772 | 772 |
| 773 // ES5 section 15.2.3.10 | 773 // ES5 section 15.2.3.10 |
| 774 function ObjectPreventExtension(obj) { | 774 function ObjectPreventExtension(obj) { |
| 775 if (!IS_SPEC_OBJECT(obj)) { | 775 if (!IS_SPEC_OBJECT(obj)) { |
| 776 throw MakeTypeError("obj_ctor_property_non_object", ["preventExtension"]); | 776 throw MakeTypeError("obj_ctor_property_non_object", ["preventExtension"]); |
| 777 } | 777 } |
| 778 %PreventExtensions(obj); | 778 %PreventExtensions(obj); |
| 779 return obj; | 779 return obj; |
| 780 } | 780 } |
| 781 | 781 |
| 782 | 782 |
| 783 // ES5 section 15.2.3.11 | 783 // ES5 section 15.2.3.11 |
| 784 function ObjectIsSealed(obj) { | 784 function ObjectIsSealed(obj) { |
| 785 if (!IS_SPEC_OBJECT(obj)) { | 785 if (!IS_SPEC_OBJECT(obj)) { |
| 786 throw MakeTypeError("obj_ctor_property_non_object", ["isSealed"]); | 786 throw MakeTypeError("obj_ctor_property_non_object", ["isSealed"]); |
| 787 } | 787 } |
| 788 var names = ObjectGetOwnPropertyNames(obj); | 788 var names = ObjectGetOwnPropertyNames(obj); |
| 789 for (var key in names) { | 789 for (var i = 0; i < names.length; i++) { |
| 790 var name = names[key]; | 790 var name = names[i]; |
| 791 var desc = GetOwnProperty(obj, name); | 791 var desc = GetOwnProperty(obj, name); |
| 792 if (desc.isConfigurable()) return false; | 792 if (desc.isConfigurable()) return false; |
| 793 } | 793 } |
| 794 if (!ObjectIsExtensible(obj)) { | 794 if (!ObjectIsExtensible(obj)) { |
| 795 return true; | 795 return true; |
| 796 } | 796 } |
| 797 return false; | 797 return false; |
| 798 } | 798 } |
| 799 | 799 |
| 800 | 800 |
| 801 // ES5 section 15.2.3.12 | 801 // ES5 section 15.2.3.12 |
| 802 function ObjectIsFrozen(obj) { | 802 function ObjectIsFrozen(obj) { |
| 803 if (!IS_SPEC_OBJECT(obj)) { | 803 if (!IS_SPEC_OBJECT(obj)) { |
| 804 throw MakeTypeError("obj_ctor_property_non_object", ["isFrozen"]); | 804 throw MakeTypeError("obj_ctor_property_non_object", ["isFrozen"]); |
| 805 } | 805 } |
| 806 var names = ObjectGetOwnPropertyNames(obj); | 806 var names = ObjectGetOwnPropertyNames(obj); |
| 807 for (var key in names) { | 807 for (var i = 0; i < names.length; i++) { |
| 808 var name = names[key]; | 808 var name = names[i]; |
| 809 var desc = GetOwnProperty(obj, name); | 809 var desc = GetOwnProperty(obj, name); |
| 810 if (IsDataDescriptor(desc) && desc.isWritable()) return false; | 810 if (IsDataDescriptor(desc) && desc.isWritable()) return false; |
| 811 if (desc.isConfigurable()) return false; | 811 if (desc.isConfigurable()) return false; |
| 812 } | 812 } |
| 813 if (!ObjectIsExtensible(obj)) { | 813 if (!ObjectIsExtensible(obj)) { |
| 814 return true; | 814 return true; |
| 815 } | 815 } |
| 816 return false; | 816 return false; |
| 817 } | 817 } |
| 818 | 818 |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1179 // ---------------------------------------------------------------------------- | 1179 // ---------------------------------------------------------------------------- |
| 1180 | 1180 |
| 1181 function SetupFunction() { | 1181 function SetupFunction() { |
| 1182 InstallFunctions($Function.prototype, DONT_ENUM, $Array( | 1182 InstallFunctions($Function.prototype, DONT_ENUM, $Array( |
| 1183 "bind", FunctionBind, | 1183 "bind", FunctionBind, |
| 1184 "toString", FunctionToString | 1184 "toString", FunctionToString |
| 1185 )); | 1185 )); |
| 1186 } | 1186 } |
| 1187 | 1187 |
| 1188 SetupFunction(); | 1188 SetupFunction(); |
| OLD | NEW |