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 // This file relies on the fact that the following declarations have been made | 5 // This file relies on the fact that the following declarations have been made |
6 // in runtime.js: | 6 // in runtime.js: |
7 // var $Object = global.Object; | 7 // var $Object = global.Object; |
8 // var $Boolean = global.Boolean; | 8 // var $Boolean = global.Boolean; |
9 // var $Number = global.Number; | 9 // var $Number = global.Number; |
10 // var $Function = global.Function; | 10 // var $Function = global.Function; |
(...skipping 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
918 if (should_throw) { | 918 if (should_throw) { |
919 throw MakeTypeError("redefine_disallowed", [p]); | 919 throw MakeTypeError("redefine_disallowed", [p]); |
920 } else { | 920 } else { |
921 return false; | 921 return false; |
922 } | 922 } |
923 } | 923 } |
924 return true; | 924 return true; |
925 } | 925 } |
926 | 926 |
927 // Step 4 - Special handling for array index. | 927 // Step 4 - Special handling for array index. |
928 var index = ToUint32(p); | 928 if (typeof p !== "symbol") { |
Dmitry Lomov (no reviews)
2014/08/11 17:58:51
!IS_SYMBOL(p) is how we typically do it
| |
929 var emit_splice = false; | 929 var index = ToUint32(p); |
930 if (ToString(index) == p && index != 4294967295) { | 930 var emit_splice = false; |
931 var length = obj.length; | 931 if (ToString(index) == p && index != 4294967295) { |
932 if (index >= length && %IsObserved(obj)) { | 932 var length = obj.length; |
933 emit_splice = true; | 933 if (index >= length && %IsObserved(obj)) { |
934 BeginPerformSplice(obj); | 934 emit_splice = true; |
935 BeginPerformSplice(obj); | |
936 } | |
937 | |
938 var length_desc = GetOwnPropertyJS(obj, "length"); | |
939 if ((index >= length && !length_desc.isWritable()) || | |
940 !DefineObjectProperty(obj, p, desc, true)) { | |
941 if (emit_splice) | |
942 EndPerformSplice(obj); | |
943 if (should_throw) { | |
944 throw MakeTypeError("define_disallowed", [p]); | |
945 } else { | |
946 return false; | |
947 } | |
948 } | |
949 if (index >= length) { | |
950 obj.length = index + 1; | |
951 } | |
952 if (emit_splice) { | |
953 EndPerformSplice(obj); | |
954 EnqueueSpliceRecord(obj, length, [], index + 1 - length); | |
955 } | |
956 return true; | |
935 } | 957 } |
936 | |
937 var length_desc = GetOwnPropertyJS(obj, "length"); | |
938 if ((index >= length && !length_desc.isWritable()) || | |
939 !DefineObjectProperty(obj, p, desc, true)) { | |
940 if (emit_splice) | |
941 EndPerformSplice(obj); | |
942 if (should_throw) { | |
943 throw MakeTypeError("define_disallowed", [p]); | |
944 } else { | |
945 return false; | |
946 } | |
947 } | |
948 if (index >= length) { | |
949 obj.length = index + 1; | |
950 } | |
951 if (emit_splice) { | |
952 EndPerformSplice(obj); | |
953 EnqueueSpliceRecord(obj, length, [], index + 1 - length); | |
954 } | |
955 return true; | |
956 } | 958 } |
957 | 959 |
958 // Step 5 - Fallback to default implementation. | 960 // Step 5 - Fallback to default implementation. |
959 return DefineObjectProperty(obj, p, desc, should_throw); | 961 return DefineObjectProperty(obj, p, desc, should_throw); |
960 } | 962 } |
961 | 963 |
962 | 964 |
963 // ES5 section 8.12.9, ES5 section 15.4.5.1 and Harmony proxies. | 965 // ES5 section 8.12.9, ES5 section 15.4.5.1 and Harmony proxies. |
964 function DefineOwnProperty(obj, p, desc, should_throw) { | 966 function DefineOwnProperty(obj, p, desc, should_throw) { |
965 if (%IsJSProxy(obj)) { | 967 if (%IsJSProxy(obj)) { |
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1899 } | 1901 } |
1900 if (!IS_SPEC_FUNCTION(method)) { | 1902 if (!IS_SPEC_FUNCTION(method)) { |
1901 throw MakeTypeError('not_iterable', [obj]); | 1903 throw MakeTypeError('not_iterable', [obj]); |
1902 } | 1904 } |
1903 var iterator = %_CallFunction(obj, method); | 1905 var iterator = %_CallFunction(obj, method); |
1904 if (!IS_SPEC_OBJECT(iterator)) { | 1906 if (!IS_SPEC_OBJECT(iterator)) { |
1905 throw MakeTypeError('not_an_iterator', [iterator]); | 1907 throw MakeTypeError('not_an_iterator', [iterator]); |
1906 } | 1908 } |
1907 return iterator; | 1909 return iterator; |
1908 } | 1910 } |
OLD | NEW |