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 var $functionSourceString; | 5 var $functionSourceString; |
6 var $globalEval; | 6 var $globalEval; |
7 var $objectDefineArrayProperty; | 7 var $objectDefineOwnProperty; |
8 var $objectGetOwnPropertyDescriptor; | 8 var $objectGetOwnPropertyDescriptor; |
9 var $toCompletePropertyDescriptor; | 9 var $toCompletePropertyDescriptor; |
10 | 10 |
11 (function(global, utils) { | 11 (function(global, utils) { |
12 | 12 |
13 %CheckIsBootstrapping(); | 13 %CheckIsBootstrapping(); |
14 | 14 |
15 // ---------------------------------------------------------------------------- | 15 // ---------------------------------------------------------------------------- |
16 // Imports | 16 // Imports |
17 | 17 |
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 } | 889 } |
890 return true; | 890 return true; |
891 } | 891 } |
892 } | 892 } |
893 | 893 |
894 // Step 5 - Fallback to default implementation. | 894 // Step 5 - Fallback to default implementation. |
895 return DefineObjectProperty(obj, p, desc, should_throw); | 895 return DefineObjectProperty(obj, p, desc, should_throw); |
896 } | 896 } |
897 | 897 |
898 | 898 |
899 function DefineArrayPropertyFromAPI(obj, p, value) { | |
900 return DefineArrayProperty(obj, p, ToPropertyDescriptor({ | |
901 value: value, | |
902 configurable: true, | |
903 enumerable: true, | |
904 writable: true | |
905 }), | |
906 false); | |
907 } | |
908 | |
909 | |
910 // ES5 section 8.12.9, ES5 section 15.4.5.1 and Harmony proxies. | 899 // ES5 section 8.12.9, ES5 section 15.4.5.1 and Harmony proxies. |
911 function DefineOwnProperty(obj, p, desc, should_throw) { | 900 function DefineOwnProperty(obj, p, desc, should_throw) { |
912 if (%_IsJSProxy(obj)) { | 901 if (%_IsJSProxy(obj)) { |
913 // TODO(rossberg): adjust once there is a story for symbols vs proxies. | 902 // TODO(rossberg): adjust once there is a story for symbols vs proxies. |
914 if (IS_SYMBOL(p)) return false; | 903 if (IS_SYMBOL(p)) return false; |
915 | 904 |
916 var attributes = FromGenericPropertyDescriptor(desc); | 905 var attributes = FromGenericPropertyDescriptor(desc); |
917 return DefineProxyProperty(obj, p, attributes, should_throw); | 906 return DefineProxyProperty(obj, p, attributes, should_throw); |
918 } else if (IS_ARRAY(obj)) { | 907 } else if (IS_ARRAY(obj)) { |
919 return DefineArrayProperty(obj, p, desc, should_throw); | 908 return DefineArrayProperty(obj, p, desc, should_throw); |
920 } else { | 909 } else { |
921 return DefineObjectProperty(obj, p, desc, should_throw); | 910 return DefineObjectProperty(obj, p, desc, should_throw); |
922 } | 911 } |
923 } | 912 } |
924 | 913 |
925 | 914 |
| 915 function DefineOwnPropertyFromAPI(obj, p, value, desc) { |
| 916 return DefineOwnProperty(obj, p, ToPropertyDescriptor({ |
| 917 value: value, |
| 918 writable: desc[0], |
| 919 enumerable: desc[1], |
| 920 configurable: desc[2] |
| 921 }), |
| 922 false); |
| 923 } |
| 924 |
| 925 |
926 // ES6 section 19.1.2.9 | 926 // ES6 section 19.1.2.9 |
927 function ObjectGetPrototypeOf(obj) { | 927 function ObjectGetPrototypeOf(obj) { |
928 return %_GetPrototype(TO_OBJECT_INLINE(obj)); | 928 return %_GetPrototype(TO_OBJECT_INLINE(obj)); |
929 } | 929 } |
930 | 930 |
931 // ES6 section 19.1.2.19. | 931 // ES6 section 19.1.2.19. |
932 function ObjectSetPrototypeOf(obj, proto) { | 932 function ObjectSetPrototypeOf(obj, proto) { |
933 CHECK_OBJECT_COERCIBLE(obj, "Object.setPrototypeOf"); | 933 CHECK_OBJECT_COERCIBLE(obj, "Object.setPrototypeOf"); |
934 | 934 |
935 if (proto !== null && !IS_SPEC_OBJECT(proto)) { | 935 if (proto !== null && !IS_SPEC_OBJECT(proto)) { |
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1830 throw MakeTypeError(kNotAnIterator, iterator); | 1830 throw MakeTypeError(kNotAnIterator, iterator); |
1831 } | 1831 } |
1832 return iterator; | 1832 return iterator; |
1833 } | 1833 } |
1834 | 1834 |
1835 // ---------------------------------------------------------------------------- | 1835 // ---------------------------------------------------------------------------- |
1836 // Exports | 1836 // Exports |
1837 | 1837 |
1838 $functionSourceString = FunctionSourceString; | 1838 $functionSourceString = FunctionSourceString; |
1839 $globalEval = GlobalEval; | 1839 $globalEval = GlobalEval; |
1840 $objectDefineArrayProperty = DefineArrayPropertyFromAPI; | 1840 $objectDefineOwnProperty = DefineOwnPropertyFromAPI; |
1841 $objectGetOwnPropertyDescriptor = ObjectGetOwnPropertyDescriptor; | 1841 $objectGetOwnPropertyDescriptor = ObjectGetOwnPropertyDescriptor; |
1842 $toCompletePropertyDescriptor = ToCompletePropertyDescriptor; | 1842 $toCompletePropertyDescriptor = ToCompletePropertyDescriptor; |
1843 | 1843 |
1844 utils.ObjectDefineProperties = ObjectDefineProperties; | 1844 utils.ObjectDefineProperties = ObjectDefineProperties; |
1845 utils.ObjectDefineProperty = ObjectDefineProperty; | 1845 utils.ObjectDefineProperty = ObjectDefineProperty; |
1846 | 1846 |
1847 utils.Export(function(to) { | 1847 utils.Export(function(to) { |
1848 to.Delete = Delete; | 1848 to.Delete = Delete; |
1849 to.GetIterator = GetIterator; | 1849 to.GetIterator = GetIterator; |
1850 to.GetMethod = GetMethod; | 1850 to.GetMethod = GetMethod; |
1851 to.IsFinite = GlobalIsFinite; | 1851 to.IsFinite = GlobalIsFinite; |
1852 to.IsNaN = GlobalIsNaN; | 1852 to.IsNaN = GlobalIsNaN; |
1853 to.NewFunctionString = NewFunctionString; | 1853 to.NewFunctionString = NewFunctionString; |
1854 to.NumberIsNaN = NumberIsNaN; | 1854 to.NumberIsNaN = NumberIsNaN; |
1855 to.ObjectDefineProperty = ObjectDefineProperty; | 1855 to.ObjectDefineProperty = ObjectDefineProperty; |
1856 to.ObjectFreeze = ObjectFreezeJS; | 1856 to.ObjectFreeze = ObjectFreezeJS; |
1857 to.ObjectGetOwnPropertyKeys = ObjectGetOwnPropertyKeys; | 1857 to.ObjectGetOwnPropertyKeys = ObjectGetOwnPropertyKeys; |
1858 to.ObjectHasOwnProperty = ObjectHasOwnProperty; | 1858 to.ObjectHasOwnProperty = ObjectHasOwnProperty; |
1859 to.ObjectIsFrozen = ObjectIsFrozen; | 1859 to.ObjectIsFrozen = ObjectIsFrozen; |
1860 to.ObjectIsSealed = ObjectIsSealed; | 1860 to.ObjectIsSealed = ObjectIsSealed; |
1861 to.ObjectToString = ObjectToString; | 1861 to.ObjectToString = ObjectToString; |
1862 to.OwnPropertyKeys = OwnPropertyKeys; | 1862 to.OwnPropertyKeys = OwnPropertyKeys; |
1863 to.ToNameArray = ToNameArray; | 1863 to.ToNameArray = ToNameArray; |
1864 }); | 1864 }); |
1865 | 1865 |
1866 }) | 1866 }) |
OLD | NEW |