Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Side by Side Diff: src/js/v8natives.js

Issue 1531843003: Rename IS_SPEC_OBJECT macro to IS_RECEIVER. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/js/string-iterator.js ('k') | src/js/weak-collection.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 // ES6 7.3.11 156 // ES6 7.3.11
157 function ObjectHasOwnProperty(value) { 157 function ObjectHasOwnProperty(value) {
158 var name = TO_NAME(value); 158 var name = TO_NAME(value);
159 var object = TO_OBJECT(this); 159 var object = TO_OBJECT(this);
160 return %HasOwnProperty(object, name); 160 return %HasOwnProperty(object, name);
161 } 161 }
162 162
163 163
164 // ES6 19.1.3.3 Object.prototype.isPrototypeOf(V) 164 // ES6 19.1.3.3 Object.prototype.isPrototypeOf(V)
165 function ObjectIsPrototypeOf(V) { 165 function ObjectIsPrototypeOf(V) {
166 if (!IS_SPEC_OBJECT(V)) return false; 166 if (!IS_RECEIVER(V)) return false;
167 var O = TO_OBJECT(this); 167 var O = TO_OBJECT(this);
168 return %_HasInPrototypeChain(V, O); 168 return %_HasInPrototypeChain(V, O);
169 } 169 }
170 170
171 171
172 // ES6 19.1.3.4 172 // ES6 19.1.3.4
173 function ObjectPropertyIsEnumerable(V) { 173 function ObjectPropertyIsEnumerable(V) {
174 var P = TO_NAME(V); 174 var P = TO_NAME(V);
175 return %PropertyIsEnumerable(TO_OBJECT(this), P); 175 return %PropertyIsEnumerable(TO_OBJECT(this), P);
176 } 176 }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 } 282 }
283 if (desc.hasConfigurable()) { 283 if (desc.hasConfigurable()) {
284 %AddNamedProperty(obj, "configurable", desc.isConfigurable(), NONE); 284 %AddNamedProperty(obj, "configurable", desc.isConfigurable(), NONE);
285 } 285 }
286 return obj; 286 return obj;
287 } 287 }
288 288
289 289
290 // ES6 6.2.4.5 290 // ES6 6.2.4.5
291 function ToPropertyDescriptor(obj) { 291 function ToPropertyDescriptor(obj) {
292 if (!IS_SPEC_OBJECT(obj)) throw MakeTypeError(kPropertyDescObject, obj); 292 if (!IS_RECEIVER(obj)) throw MakeTypeError(kPropertyDescObject, obj);
293 293
294 var desc = new PropertyDescriptor(); 294 var desc = new PropertyDescriptor();
295 295
296 if ("enumerable" in obj) { 296 if ("enumerable" in obj) {
297 desc.setEnumerable(TO_BOOLEAN(obj.enumerable)); 297 desc.setEnumerable(TO_BOOLEAN(obj.enumerable));
298 } 298 }
299 299
300 if ("configurable" in obj) { 300 if ("configurable" in obj) {
301 desc.setConfigurable(TO_BOOLEAN(obj.configurable)); 301 desc.setConfigurable(TO_BOOLEAN(obj.configurable));
302 } 302 }
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 777
778 // ES6 section 19.1.2.9 778 // ES6 section 19.1.2.9
779 function ObjectGetPrototypeOf(obj) { 779 function ObjectGetPrototypeOf(obj) {
780 return %_GetPrototype(TO_OBJECT(obj)); 780 return %_GetPrototype(TO_OBJECT(obj));
781 } 781 }
782 782
783 // ES6 section 19.1.2.18. 783 // ES6 section 19.1.2.18.
784 function ObjectSetPrototypeOf(obj, proto) { 784 function ObjectSetPrototypeOf(obj, proto) {
785 CHECK_OBJECT_COERCIBLE(obj, "Object.setPrototypeOf"); 785 CHECK_OBJECT_COERCIBLE(obj, "Object.setPrototypeOf");
786 786
787 if (proto !== null && !IS_SPEC_OBJECT(proto)) { 787 if (proto !== null && !IS_RECEIVER(proto)) {
788 throw MakeTypeError(kProtoObjectOrNull, proto); 788 throw MakeTypeError(kProtoObjectOrNull, proto);
789 } 789 }
790 790
791 if (IS_SPEC_OBJECT(obj)) { 791 if (IS_RECEIVER(obj)) {
792 %SetPrototype(obj, proto); 792 %SetPrototype(obj, proto);
793 } 793 }
794 794
795 return obj; 795 return obj;
796 } 796 }
797 797
798 798
799 // ES6 section 19.1.2.6 799 // ES6 section 19.1.2.6
800 function ObjectGetOwnPropertyDescriptor(obj, p) { 800 function ObjectGetOwnPropertyDescriptor(obj, p) {
801 return %GetOwnProperty(obj, p); 801 return %GetOwnProperty(obj, p);
802 } 802 }
803 803
804 804
805 // ES5 section 15.2.3.4. 805 // ES5 section 15.2.3.4.
806 function ObjectGetOwnPropertyNames(obj) { 806 function ObjectGetOwnPropertyNames(obj) {
807 obj = TO_OBJECT(obj); 807 obj = TO_OBJECT(obj);
808 return %GetOwnPropertyKeys(obj, PROPERTY_FILTER_SKIP_SYMBOLS); 808 return %GetOwnPropertyKeys(obj, PROPERTY_FILTER_SKIP_SYMBOLS);
809 } 809 }
810 810
811 811
812 // ES5 section 15.2.3.5. 812 // ES5 section 15.2.3.5.
813 function ObjectCreate(proto, properties) { 813 function ObjectCreate(proto, properties) {
814 if (!IS_SPEC_OBJECT(proto) && proto !== null) { 814 if (!IS_RECEIVER(proto) && proto !== null) {
815 throw MakeTypeError(kProtoObjectOrNull, proto); 815 throw MakeTypeError(kProtoObjectOrNull, proto);
816 } 816 }
817 var obj = {}; 817 var obj = {};
818 %InternalSetPrototype(obj, proto); 818 %InternalSetPrototype(obj, proto);
819 if (!IS_UNDEFINED(properties)) ObjectDefineProperties(obj, properties); 819 if (!IS_UNDEFINED(properties)) ObjectDefineProperties(obj, properties);
820 return obj; 820 return obj;
821 } 821 }
822 822
823 823
824 // ES5 section 15.2.3.6. 824 // ES5 section 15.2.3.6.
825 function ObjectDefineProperty(obj, p, attributes) { 825 function ObjectDefineProperty(obj, p, attributes) {
826 // The new pure-C++ implementation doesn't support O.o. 826 // The new pure-C++ implementation doesn't support O.o.
827 // TODO(jkummerow): Implement missing features and remove fallback path. 827 // TODO(jkummerow): Implement missing features and remove fallback path.
828 if (%IsObserved(obj)) { 828 if (%IsObserved(obj)) {
829 if (!IS_SPEC_OBJECT(obj)) { 829 if (!IS_RECEIVER(obj)) {
830 throw MakeTypeError(kCalledOnNonObject, "Object.defineProperty"); 830 throw MakeTypeError(kCalledOnNonObject, "Object.defineProperty");
831 } 831 }
832 var name = TO_NAME(p); 832 var name = TO_NAME(p);
833 var desc = ToPropertyDescriptor(attributes); 833 var desc = ToPropertyDescriptor(attributes);
834 DefineOwnProperty(obj, name, desc, true); 834 DefineOwnProperty(obj, name, desc, true);
835 return obj; 835 return obj;
836 } 836 }
837 return %ObjectDefineProperty(obj, p, attributes); 837 return %ObjectDefineProperty(obj, p, attributes);
838 } 838 }
839 839
840 840
841 function GetOwnEnumerablePropertyNames(object) { 841 function GetOwnEnumerablePropertyNames(object) {
842 return %GetOwnPropertyKeys(object, PROPERTY_FILTER_ONLY_ENUMERABLE); 842 return %GetOwnPropertyKeys(object, PROPERTY_FILTER_ONLY_ENUMERABLE);
843 } 843 }
844 844
845 845
846 // ES5 section 15.2.3.7. 846 // ES5 section 15.2.3.7.
847 function ObjectDefineProperties(obj, properties) { 847 function ObjectDefineProperties(obj, properties) {
848 // The new pure-C++ implementation doesn't support O.o. 848 // The new pure-C++ implementation doesn't support O.o.
849 // TODO(jkummerow): Implement missing features and remove fallback path. 849 // TODO(jkummerow): Implement missing features and remove fallback path.
850 if (%IsObserved(obj)) { 850 if (%IsObserved(obj)) {
851 if (!IS_SPEC_OBJECT(obj)) { 851 if (!IS_RECEIVER(obj)) {
852 throw MakeTypeError(kCalledOnNonObject, "Object.defineProperties"); 852 throw MakeTypeError(kCalledOnNonObject, "Object.defineProperties");
853 } 853 }
854 var props = TO_OBJECT(properties); 854 var props = TO_OBJECT(properties);
855 var names = GetOwnEnumerablePropertyNames(props); 855 var names = GetOwnEnumerablePropertyNames(props);
856 var descriptors = new InternalArray(); 856 var descriptors = new InternalArray();
857 for (var i = 0; i < names.length; i++) { 857 for (var i = 0; i < names.length; i++) {
858 descriptors.push(ToPropertyDescriptor(props[names[i]])); 858 descriptors.push(ToPropertyDescriptor(props[names[i]]));
859 } 859 }
860 for (var i = 0; i < names.length; i++) { 860 for (var i = 0; i < names.length; i++) {
861 DefineOwnProperty(obj, names[i], descriptors[i], true); 861 DefineOwnProperty(obj, names[i], descriptors[i], true);
862 } 862 }
863 return obj; 863 return obj;
864 } 864 }
865 return %ObjectDefineProperties(obj, properties); 865 return %ObjectDefineProperties(obj, properties);
866 } 866 }
867 867
868 868
869 // ES6 19.1.2.17 869 // ES6 19.1.2.17
870 function ObjectSealJS(obj) { 870 function ObjectSealJS(obj) {
871 if (!IS_SPEC_OBJECT(obj)) return obj; 871 if (!IS_RECEIVER(obj)) return obj;
872 return %ObjectSeal(obj); 872 return %ObjectSeal(obj);
873 } 873 }
874 874
875 875
876 // ES6 19.1.2.5 876 // ES6 19.1.2.5
877 function ObjectFreezeJS(obj) { 877 function ObjectFreezeJS(obj) {
878 if (!IS_SPEC_OBJECT(obj)) return obj; 878 if (!IS_RECEIVER(obj)) return obj;
879 return %ObjectFreeze(obj); 879 return %ObjectFreeze(obj);
880 } 880 }
881 881
882 882
883 // ES6 19.1.2.15 883 // ES6 19.1.2.15
884 function ObjectPreventExtension(obj) { 884 function ObjectPreventExtension(obj) {
885 if (!IS_SPEC_OBJECT(obj)) return obj; 885 if (!IS_RECEIVER(obj)) return obj;
886 return %PreventExtensions(obj); 886 return %PreventExtensions(obj);
887 } 887 }
888 888
889 889
890 // ES6 19.1.2.13 890 // ES6 19.1.2.13
891 function ObjectIsSealed(obj) { 891 function ObjectIsSealed(obj) {
892 if (!IS_SPEC_OBJECT(obj)) return true; 892 if (!IS_RECEIVER(obj)) return true;
893 return %ObjectIsSealed(obj); 893 return %ObjectIsSealed(obj);
894 } 894 }
895 895
896 896
897 // ES6 19.1.2.12 897 // ES6 19.1.2.12
898 function ObjectIsFrozen(obj) { 898 function ObjectIsFrozen(obj) {
899 if (!IS_SPEC_OBJECT(obj)) return true; 899 if (!IS_RECEIVER(obj)) return true;
900 return %ObjectIsFrozen(obj); 900 return %ObjectIsFrozen(obj);
901 } 901 }
902 902
903 903
904 // ES6 19.1.2.11 904 // ES6 19.1.2.11
905 function ObjectIsExtensible(obj) { 905 function ObjectIsExtensible(obj) {
906 if (!IS_SPEC_OBJECT(obj)) return false; 906 if (!IS_RECEIVER(obj)) return false;
907 return %IsExtensible(obj); 907 return %IsExtensible(obj);
908 } 908 }
909 909
910 910
911 // ES6 B.2.2.1.1 911 // ES6 B.2.2.1.1
912 function ObjectGetProto() { 912 function ObjectGetProto() {
913 return %_GetPrototype(TO_OBJECT(this)); 913 return %_GetPrototype(TO_OBJECT(this));
914 } 914 }
915 915
916 916
917 // ES6 B.2.2.1.2 917 // ES6 B.2.2.1.2
918 function ObjectSetProto(proto) { 918 function ObjectSetProto(proto) {
919 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.__proto__"); 919 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.__proto__");
920 920
921 if ((IS_SPEC_OBJECT(proto) || IS_NULL(proto)) && IS_SPEC_OBJECT(this)) { 921 if ((IS_RECEIVER(proto) || IS_NULL(proto)) && IS_RECEIVER(this)) {
922 %SetPrototype(this, proto); 922 %SetPrototype(this, proto);
923 } 923 }
924 } 924 }
925 925
926 926
927 // ES6 19.1.1.1 927 // ES6 19.1.1.1
928 function ObjectConstructor(x) { 928 function ObjectConstructor(x) {
929 if (GlobalObject != new.target && !IS_UNDEFINED(new.target)) { 929 if (GlobalObject != new.target && !IS_UNDEFINED(new.target)) {
930 return this; 930 return this;
931 } 931 }
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
1420 1420
1421 // ES6 7.4.1 GetIterator(obj, method) 1421 // ES6 7.4.1 GetIterator(obj, method)
1422 function GetIterator(obj, method) { 1422 function GetIterator(obj, method) {
1423 if (IS_UNDEFINED(method)) { 1423 if (IS_UNDEFINED(method)) {
1424 method = obj[iteratorSymbol]; 1424 method = obj[iteratorSymbol];
1425 } 1425 }
1426 if (!IS_CALLABLE(method)) { 1426 if (!IS_CALLABLE(method)) {
1427 throw MakeTypeError(kNotIterable, obj); 1427 throw MakeTypeError(kNotIterable, obj);
1428 } 1428 }
1429 var iterator = %_Call(method, obj); 1429 var iterator = %_Call(method, obj);
1430 if (!IS_SPEC_OBJECT(iterator)) { 1430 if (!IS_RECEIVER(iterator)) {
1431 throw MakeTypeError(kNotAnIterator, iterator); 1431 throw MakeTypeError(kNotAnIterator, iterator);
1432 } 1432 }
1433 return iterator; 1433 return iterator;
1434 } 1434 }
1435 1435
1436 // ---------------------------------------------------------------------------- 1436 // ----------------------------------------------------------------------------
1437 // Exports 1437 // Exports
1438 1438
1439 utils.Export(function(to) { 1439 utils.Export(function(to) {
1440 to.FunctionSourceString = FunctionSourceString; 1440 to.FunctionSourceString = FunctionSourceString;
(...skipping 11 matching lines...) Expand all
1452 to.ObjectIsSealed = ObjectIsSealed; 1452 to.ObjectIsSealed = ObjectIsSealed;
1453 to.ObjectKeys = ObjectKeys; 1453 to.ObjectKeys = ObjectKeys;
1454 }); 1454 });
1455 1455
1456 %InstallToContext([ 1456 %InstallToContext([
1457 "global_eval_fun", GlobalEval, 1457 "global_eval_fun", GlobalEval,
1458 "object_value_of", ObjectValueOf, 1458 "object_value_of", ObjectValueOf,
1459 ]); 1459 ]);
1460 1460
1461 }) 1461 })
OLDNEW
« no previous file with comments | « src/js/string-iterator.js ('k') | src/js/weak-collection.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698