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 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 return obj; | 823 return obj; |
824 } | 824 } |
825 | 825 |
826 | 826 |
827 // ES6 section 19.1.2.6 | 827 // ES6 section 19.1.2.6 |
828 function ObjectGetOwnPropertyDescriptor(obj, p) { | 828 function ObjectGetOwnPropertyDescriptor(obj, p) { |
829 return %GetOwnProperty(obj, p); | 829 return %GetOwnProperty(obj, p); |
830 } | 830 } |
831 | 831 |
832 | 832 |
833 // ES6 section 9.1.12 / 9.5.12 | |
834 function OwnPropertyKeys(obj) { | |
835 return %GetOwnPropertyKeys(obj, PROPERTY_FILTER_NONE); | |
836 } | |
837 | |
838 | |
839 // ES5 section 15.2.3.4. | 833 // ES5 section 15.2.3.4. |
840 function ObjectGetOwnPropertyNames(obj) { | 834 function ObjectGetOwnPropertyNames(obj) { |
841 obj = TO_OBJECT(obj); | 835 obj = TO_OBJECT(obj); |
842 return %GetOwnPropertyKeys(obj, PROPERTY_FILTER_SKIP_SYMBOLS); | 836 return %GetOwnPropertyKeys(obj, PROPERTY_FILTER_SKIP_SYMBOLS); |
843 } | 837 } |
844 | 838 |
845 | 839 |
846 // ES5 section 15.2.3.5. | 840 // ES5 section 15.2.3.5. |
847 function ObjectCreate(proto, properties) { | 841 function ObjectCreate(proto, properties) { |
848 if (!IS_SPEC_OBJECT(proto) && proto !== null) { | 842 if (!IS_SPEC_OBJECT(proto) && proto !== null) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
935 } | 929 } |
936 | 930 |
937 | 931 |
938 // ES6 19.1.2.11 | 932 // ES6 19.1.2.11 |
939 function ObjectIsExtensible(obj) { | 933 function ObjectIsExtensible(obj) { |
940 if (!IS_SPEC_OBJECT(obj)) return false; | 934 if (!IS_SPEC_OBJECT(obj)) return false; |
941 return %IsExtensible(obj); | 935 return %IsExtensible(obj); |
942 } | 936 } |
943 | 937 |
944 | 938 |
945 // ES6 19.1.2.1 | |
946 function ObjectAssign(target, sources) { | |
947 // TODO(bmeurer): Move this to toplevel. | |
948 "use strict"; | |
949 var to = TO_OBJECT(target); | |
950 var argsLen = %_ArgumentsLength(); | |
951 if (argsLen < 2) return to; | |
952 | |
953 for (var i = 1; i < argsLen; ++i) { | |
954 var nextSource = %_Arguments(i); | |
955 if (IS_NULL_OR_UNDEFINED(nextSource)) { | |
956 continue; | |
957 } | |
958 | |
959 var from = TO_OBJECT(nextSource); | |
960 var keys = OwnPropertyKeys(from); | |
961 var len = keys.length; | |
962 | |
963 for (var j = 0; j < len; ++j) { | |
964 var key = keys[j]; | |
965 if (%PropertyIsEnumerable(from, key)) { | |
966 var propValue = from[key]; | |
967 to[key] = propValue; | |
968 } | |
969 } | |
970 } | |
971 return to; | |
972 } | |
973 | |
974 | |
975 // ES6 B.2.2.1.1 | 939 // ES6 B.2.2.1.1 |
976 function ObjectGetProto() { | 940 function ObjectGetProto() { |
977 return %_GetPrototype(TO_OBJECT(this)); | 941 return %_GetPrototype(TO_OBJECT(this)); |
978 } | 942 } |
979 | 943 |
980 | 944 |
981 // ES6 B.2.2.1.2 | 945 // ES6 B.2.2.1.2 |
982 function ObjectSetProto(proto) { | 946 function ObjectSetProto(proto) { |
983 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.__proto__"); | 947 CHECK_OBJECT_COERCIBLE(this, "Object.prototype.__proto__"); |
984 | 948 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1018 "__defineGetter__", ObjectDefineGetter, | 982 "__defineGetter__", ObjectDefineGetter, |
1019 "__lookupGetter__", ObjectLookupGetter, | 983 "__lookupGetter__", ObjectLookupGetter, |
1020 "__defineSetter__", ObjectDefineSetter, | 984 "__defineSetter__", ObjectDefineSetter, |
1021 "__lookupSetter__", ObjectLookupSetter | 985 "__lookupSetter__", ObjectLookupSetter |
1022 ]); | 986 ]); |
1023 utils.InstallGetterSetter(GlobalObject.prototype, "__proto__", ObjectGetProto, | 987 utils.InstallGetterSetter(GlobalObject.prototype, "__proto__", ObjectGetProto, |
1024 ObjectSetProto); | 988 ObjectSetProto); |
1025 | 989 |
1026 // Set up non-enumerable functions in the Object object. | 990 // Set up non-enumerable functions in the Object object. |
1027 utils.InstallFunctions(GlobalObject, DONT_ENUM, [ | 991 utils.InstallFunctions(GlobalObject, DONT_ENUM, [ |
1028 "assign", ObjectAssign, | 992 // assign is added in bootstrapper.cc. |
1029 "keys", ObjectKeys, | 993 "keys", ObjectKeys, |
1030 "create", ObjectCreate, | 994 "create", ObjectCreate, |
1031 "defineProperty", ObjectDefineProperty, | 995 "defineProperty", ObjectDefineProperty, |
1032 "defineProperties", ObjectDefineProperties, | 996 "defineProperties", ObjectDefineProperties, |
1033 "freeze", ObjectFreezeJS, | 997 "freeze", ObjectFreezeJS, |
1034 "getPrototypeOf", ObjectGetPrototypeOf, | 998 "getPrototypeOf", ObjectGetPrototypeOf, |
1035 "setPrototypeOf", ObjectSetPrototypeOf, | 999 "setPrototypeOf", ObjectSetPrototypeOf, |
1036 "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor, | 1000 "getOwnPropertyDescriptor", ObjectGetOwnPropertyDescriptor, |
1037 "getOwnPropertyNames", ObjectGetOwnPropertyNames, | 1001 "getOwnPropertyNames", ObjectGetOwnPropertyNames, |
1038 // getOwnPropertySymbols is added in symbol.js. | 1002 // getOwnPropertySymbols is added in symbol.js. |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1518 to.ObjectToString = ObjectToString; | 1482 to.ObjectToString = ObjectToString; |
1519 }); | 1483 }); |
1520 | 1484 |
1521 %InstallToContext([ | 1485 %InstallToContext([ |
1522 "global_eval_fun", GlobalEval, | 1486 "global_eval_fun", GlobalEval, |
1523 "object_value_of", ObjectValueOf, | 1487 "object_value_of", ObjectValueOf, |
1524 "object_to_string", ObjectToString, | 1488 "object_to_string", ObjectToString, |
1525 ]); | 1489 ]); |
1526 | 1490 |
1527 }) | 1491 }) |
OLD | NEW |