| 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 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 910 } | 910 } |
| 911 for (var i = 0; i < names.length; i++) { | 911 for (var i = 0; i < names.length; i++) { |
| 912 DefineOwnProperty(obj, names[i], descriptors[i], true); | 912 DefineOwnProperty(obj, names[i], descriptors[i], true); |
| 913 } | 913 } |
| 914 return obj; | 914 return obj; |
| 915 } | 915 } |
| 916 return %ObjectDefineProperties(obj, properties); | 916 return %ObjectDefineProperties(obj, properties); |
| 917 } | 917 } |
| 918 | 918 |
| 919 | 919 |
| 920 // ES5 section 15.2.3.8. | 920 // ES6 19.1.2.17 |
| 921 function ObjectSealJS(obj) { | 921 function ObjectSealJS(obj) { |
| 922 if (!IS_SPEC_OBJECT(obj)) return obj; | 922 if (!IS_SPEC_OBJECT(obj)) return obj; |
| 923 return %ObjectSeal(obj); | 923 return %ObjectSeal(obj); |
| 924 } | 924 } |
| 925 | 925 |
| 926 | 926 |
| 927 // ES5 section 15.2.3.9. | 927 // ES6 19.1.2.5 |
| 928 function ObjectFreezeJS(obj) { | 928 function ObjectFreezeJS(obj) { |
| 929 if (!IS_SPEC_OBJECT(obj)) return obj; | 929 if (!IS_SPEC_OBJECT(obj)) return obj; |
| 930 return %ObjectFreeze(obj); | 930 return %ObjectFreeze(obj); |
| 931 } | 931 } |
| 932 | 932 |
| 933 | 933 |
| 934 // ES5 section 15.2.3.10 | 934 // ES6 19.1.2.15 |
| 935 function ObjectPreventExtension(obj) { | 935 function ObjectPreventExtension(obj) { |
| 936 if (!IS_SPEC_OBJECT(obj)) return obj; | 936 if (!IS_SPEC_OBJECT(obj)) return obj; |
| 937 return %PreventExtensions(obj); | 937 return %PreventExtensions(obj); |
| 938 } | 938 } |
| 939 | 939 |
| 940 | 940 |
| 941 // ES5 section 15.2.3.11 | 941 // ES6 19.1.2.13 |
| 942 function ObjectIsSealed(obj) { | 942 function ObjectIsSealed(obj) { |
| 943 if (!IS_SPEC_OBJECT(obj)) return true; | 943 if (!IS_SPEC_OBJECT(obj)) return true; |
| 944 if (%_IsJSProxy(obj)) { | 944 return %ObjectIsSealed(obj); |
| 945 return false; // TODO(neis): Must call isExtensible trap and ownKeys trap. | |
| 946 } | |
| 947 if (%IsExtensible(obj)) { | |
| 948 return false; | |
| 949 } | |
| 950 var names = OwnPropertyKeys(obj); | |
| 951 for (var i = 0; i < names.length; i++) { | |
| 952 var name = names[i]; | |
| 953 var desc = GetOwnPropertyJS(obj, name); | |
| 954 if (desc.isConfigurable()) { | |
| 955 return false; | |
| 956 } | |
| 957 } | |
| 958 return true; | |
| 959 } | 945 } |
| 960 | 946 |
| 961 | 947 |
| 962 // ES5 section 15.2.3.12 | 948 // ES6 19.1.2.12 |
| 963 function ObjectIsFrozen(obj) { | 949 function ObjectIsFrozen(obj) { |
| 964 if (!IS_SPEC_OBJECT(obj)) return true; | 950 if (!IS_SPEC_OBJECT(obj)) return true; |
| 965 if (%_IsJSProxy(obj)) { | 951 return %ObjectIsFrozen(obj); |
| 966 return false; // TODO(neis): Must call isExtensible trap and ownKeys trap. | |
| 967 } | |
| 968 if (%IsExtensible(obj)) { | |
| 969 return false; | |
| 970 } | |
| 971 var names = OwnPropertyKeys(obj); | |
| 972 for (var i = 0; i < names.length; i++) { | |
| 973 var name = names[i]; | |
| 974 var desc = GetOwnPropertyJS(obj, name); | |
| 975 if (IsDataDescriptor(desc) && desc.isWritable()) return false; | |
| 976 if (desc.isConfigurable()) return false; | |
| 977 } | |
| 978 return true; | |
| 979 } | 952 } |
| 980 | 953 |
| 981 | 954 |
| 982 // ES5 section 15.2.3.13 | 955 // ES6 19.1.2.11 |
| 983 function ObjectIsExtensible(obj) { | 956 function ObjectIsExtensible(obj) { |
| 984 if (!IS_SPEC_OBJECT(obj)) return false; | 957 if (!IS_SPEC_OBJECT(obj)) return false; |
| 985 return %IsExtensible(obj); | 958 return %IsExtensible(obj); |
| 986 } | 959 } |
| 987 | 960 |
| 988 | 961 |
| 989 // ECMA-262, Edition 6, section 19.1.2.1 | 962 // ECMA-262, Edition 6, section 19.1.2.1 |
| 990 function ObjectAssign(target, sources) { | 963 function ObjectAssign(target, sources) { |
| 991 // TODO(bmeurer): Move this to toplevel. | 964 // TODO(bmeurer): Move this to toplevel. |
| 992 "use strict"; | 965 "use strict"; |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1561 to.ObjectToString = ObjectToString; | 1534 to.ObjectToString = ObjectToString; |
| 1562 }); | 1535 }); |
| 1563 | 1536 |
| 1564 %InstallToContext([ | 1537 %InstallToContext([ |
| 1565 "global_eval_fun", GlobalEval, | 1538 "global_eval_fun", GlobalEval, |
| 1566 "object_value_of", ObjectValueOf, | 1539 "object_value_of", ObjectValueOf, |
| 1567 "object_to_string", ObjectToString, | 1540 "object_to_string", ObjectToString, |
| 1568 ]); | 1541 ]); |
| 1569 | 1542 |
| 1570 }) | 1543 }) |
| OLD | NEW |