OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 (function(global, utils) { | 5 (function(global, utils) { |
6 | 6 |
7 %CheckIsBootstrapping(); | 7 %CheckIsBootstrapping(); |
8 | 8 |
9 // ---------------------------------------------------------------------------- | 9 // ---------------------------------------------------------------------------- |
10 // Imports | 10 // Imports |
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 return obj; | 771 return obj; |
772 } | 772 } |
773 | 773 |
774 | 774 |
775 // ES6 section 19.1.2.6 | 775 // ES6 section 19.1.2.6 |
776 function ObjectGetOwnPropertyDescriptor(obj, p) { | 776 function ObjectGetOwnPropertyDescriptor(obj, p) { |
777 return %GetOwnProperty(obj, p); | 777 return %GetOwnProperty(obj, p); |
778 } | 778 } |
779 | 779 |
780 | 780 |
781 // ES5 section 15.2.3.4. | |
782 function ObjectGetOwnPropertyNames(obj) { | |
783 obj = TO_OBJECT(obj); | |
784 return %GetOwnPropertyKeys(obj, PROPERTY_FILTER_SKIP_SYMBOLS); | |
785 } | |
786 | |
787 | |
788 // ES5 section 15.2.3.6. | 781 // ES5 section 15.2.3.6. |
789 function ObjectDefineProperty(obj, p, attributes) { | 782 function ObjectDefineProperty(obj, p, attributes) { |
790 // The new pure-C++ implementation doesn't support O.o. | 783 // The new pure-C++ implementation doesn't support O.o. |
791 // TODO(jkummerow): Implement missing features and remove fallback path. | 784 // TODO(jkummerow): Implement missing features and remove fallback path. |
792 if (%IsObserved(obj)) { | 785 if (%IsObserved(obj)) { |
793 if (!IS_RECEIVER(obj)) { | 786 if (!IS_RECEIVER(obj)) { |
794 throw MakeTypeError(kCalledOnNonObject, "Object.defineProperty"); | 787 throw MakeTypeError(kCalledOnNonObject, "Object.defineProperty"); |
795 } | 788 } |
796 var name = TO_NAME(p); | 789 var name = TO_NAME(p); |
797 var desc = ToPropertyDescriptor(attributes); | 790 var desc = ToPropertyDescriptor(attributes); |
798 DefineOwnProperty(obj, name, desc, true); | 791 DefineOwnProperty(obj, name, desc, true); |
799 return obj; | 792 return obj; |
800 } | 793 } |
801 return %ObjectDefineProperty(obj, p, attributes); | 794 return %ObjectDefineProperty(obj, p, attributes); |
802 } | 795 } |
803 | 796 |
804 | 797 |
805 function GetOwnEnumerablePropertyNames(object) { | |
806 return %GetOwnPropertyKeys(object, PROPERTY_FILTER_ONLY_ENUMERABLE); | |
807 } | |
808 | |
809 | |
810 // ES5 section 15.2.3.7. | 798 // ES5 section 15.2.3.7. |
811 function ObjectDefineProperties(obj, properties) { | 799 function ObjectDefineProperties(obj, properties) { |
812 // The new pure-C++ implementation doesn't support O.o. | 800 // The new pure-C++ implementation doesn't support O.o. |
813 // TODO(jkummerow): Implement missing features and remove fallback path. | 801 // TODO(jkummerow): Implement missing features and remove fallback path. |
814 if (%IsObserved(obj)) { | 802 if (%IsObserved(obj)) { |
815 if (!IS_RECEIVER(obj)) { | 803 if (!IS_RECEIVER(obj)) { |
816 throw MakeTypeError(kCalledOnNonObject, "Object.defineProperties"); | 804 throw MakeTypeError(kCalledOnNonObject, "Object.defineProperties"); |
817 } | 805 } |
818 var props = TO_OBJECT(properties); | 806 var props = TO_OBJECT(properties); |
819 var names = GetOwnEnumerablePropertyNames(props); | 807 var names = %GetOwnPropertyKeys(props, PROPERTY_FILTER_ONLY_ENUMERABLE); |
820 var descriptors = new InternalArray(); | 808 var descriptors = new InternalArray(); |
821 for (var i = 0; i < names.length; i++) { | 809 for (var i = 0; i < names.length; i++) { |
822 descriptors.push(ToPropertyDescriptor(props[names[i]])); | 810 descriptors.push(ToPropertyDescriptor(props[names[i]])); |
823 } | 811 } |
824 for (var i = 0; i < names.length; i++) { | 812 for (var i = 0; i < names.length; i++) { |
825 DefineOwnProperty(obj, names[i], descriptors[i], true); | 813 DefineOwnProperty(obj, names[i], descriptors[i], true); |
826 } | 814 } |
827 return obj; | 815 return obj; |
828 } | 816 } |
829 return %ObjectDefineProperties(obj, properties); | 817 return %ObjectDefineProperties(obj, properties); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
883 | 871 |
884 // Set up non-enumerable functions in the Object object. | 872 // Set up non-enumerable functions in the Object object. |
885 utils.InstallFunctions(GlobalObject, DONT_ENUM, [ | 873 utils.InstallFunctions(GlobalObject, DONT_ENUM, [ |
886 // assign is added in bootstrapper.cc. | 874 // assign is added in bootstrapper.cc. |
887 // keys is added in bootstrapper.cc. | 875 // keys is added in bootstrapper.cc. |
888 "defineProperty", ObjectDefineProperty, | 876 "defineProperty", ObjectDefineProperty, |
889 "defineProperties", ObjectDefineProperties, | 877 "defineProperties", ObjectDefineProperties, |
890 "getPrototypeOf", ObjectGetPrototypeOf, | 878 "getPrototypeOf", ObjectGetPrototypeOf, |
891 "setPrototypeOf", ObjectSetPrototypeOf, | 879 "setPrototypeOf", ObjectSetPrototypeOf, |
892 "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor, | 880 "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor, |
893 "getOwnPropertyNames", ObjectGetOwnPropertyNames, | |
894 // getOwnPropertySymbols is added in symbol.js. | 881 // getOwnPropertySymbols is added in symbol.js. |
895 "is", SameValue, // ECMA-262, Edition 6, section 19.1.2.10 | 882 "is", SameValue, // ECMA-262, Edition 6, section 19.1.2.10 |
896 // deliverChangeRecords, getNotifier, observe and unobserve are added | 883 // deliverChangeRecords, getNotifier, observe and unobserve are added |
897 // in object-observe.js. | 884 // in object-observe.js. |
898 ]); | 885 ]); |
899 | 886 |
900 | 887 |
901 // ---------------------------------------------------------------------------- | 888 // ---------------------------------------------------------------------------- |
902 // Boolean | 889 // Boolean |
903 | 890 |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1181 to.ObjectDefineProperties = ObjectDefineProperties; | 1168 to.ObjectDefineProperties = ObjectDefineProperties; |
1182 to.ObjectDefineProperty = ObjectDefineProperty; | 1169 to.ObjectDefineProperty = ObjectDefineProperty; |
1183 to.ObjectHasOwnProperty = ObjectHasOwnProperty; | 1170 to.ObjectHasOwnProperty = ObjectHasOwnProperty; |
1184 }); | 1171 }); |
1185 | 1172 |
1186 %InstallToContext([ | 1173 %InstallToContext([ |
1187 "object_value_of", ObjectValueOf, | 1174 "object_value_of", ObjectValueOf, |
1188 ]); | 1175 ]); |
1189 | 1176 |
1190 }) | 1177 }) |
OLD | NEW |