Chromium Code Reviews| 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, extrasUtils) { | 5 (function(global, utils, extrasUtils) { |
| 6 | 6 |
| 7 "use strict"; | 7 "use strict"; |
| 8 | 8 |
| 9 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); |
| 10 | 10 |
| (...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1042 } | 1042 } |
| 1043 } | 1043 } |
| 1044 }; | 1044 }; |
| 1045 | 1045 |
| 1046 // Copy elements in the range 0..length from obj's prototype chain | 1046 // Copy elements in the range 0..length from obj's prototype chain |
| 1047 // to obj itself, if obj has holes. Return one more than the maximal index | 1047 // to obj itself, if obj has holes. Return one more than the maximal index |
| 1048 // of a prototype property. | 1048 // of a prototype property. |
| 1049 var CopyFromPrototype = function CopyFromPrototype(obj, length) { | 1049 var CopyFromPrototype = function CopyFromPrototype(obj, length) { |
| 1050 var max = 0; | 1050 var max = 0; |
| 1051 for (var proto = %_GetPrototype(obj); proto; proto = %_GetPrototype(proto)) { | 1051 for (var proto = %_GetPrototype(obj); proto; proto = %_GetPrototype(proto)) { |
| 1052 var indices = %GetArrayKeys(proto, length); | 1052 var indices = IS_PROXY(proto) ? length : %GetArrayKeys(proto, length); |
|
Camillo Bruni
2016/03/29 11:34:57
aah quelle elegance!
| |
| 1053 if (IS_NUMBER(indices)) { | 1053 if (IS_NUMBER(indices)) { |
| 1054 // It's an interval. | 1054 // It's an interval. |
| 1055 var proto_length = indices; | 1055 var proto_length = indices; |
| 1056 for (var i = 0; i < proto_length; i++) { | 1056 for (var i = 0; i < proto_length; i++) { |
| 1057 if (!HAS_OWN_PROPERTY(obj, i) && HAS_OWN_PROPERTY(proto, i)) { | 1057 if (!HAS_OWN_PROPERTY(obj, i) && HAS_OWN_PROPERTY(proto, i)) { |
| 1058 obj[i] = proto[i]; | 1058 obj[i] = proto[i]; |
| 1059 if (i >= max) { max = i + 1; } | 1059 if (i >= max) { max = i + 1; } |
| 1060 } | 1060 } |
| 1061 } | 1061 } |
| 1062 } else { | 1062 } else { |
| 1063 for (var i = 0; i < indices.length; i++) { | 1063 for (var i = 0; i < indices.length; i++) { |
| 1064 var index = indices[i]; | 1064 var index = indices[i]; |
| 1065 if (!HAS_OWN_PROPERTY(obj, index) && HAS_OWN_PROPERTY(proto, index)) { | 1065 if (!HAS_OWN_PROPERTY(obj, index) && HAS_OWN_PROPERTY(proto, index)) { |
| 1066 obj[index] = proto[index]; | 1066 obj[index] = proto[index]; |
| 1067 if (index >= max) { max = index + 1; } | 1067 if (index >= max) { max = index + 1; } |
| 1068 } | 1068 } |
| 1069 } | 1069 } |
| 1070 } | 1070 } |
| 1071 } | 1071 } |
| 1072 return max; | 1072 return max; |
| 1073 }; | 1073 }; |
| 1074 | 1074 |
| 1075 // Set a value of "undefined" on all indices in the range from..to | 1075 // Set a value of "undefined" on all indices in the range from..to |
| 1076 // where a prototype of obj has an element. I.e., shadow all prototype | 1076 // where a prototype of obj has an element. I.e., shadow all prototype |
| 1077 // elements in that range. | 1077 // elements in that range. |
| 1078 var ShadowPrototypeElements = function(obj, from, to) { | 1078 var ShadowPrototypeElements = function(obj, from, to) { |
| 1079 for (var proto = %_GetPrototype(obj); proto; proto = %_GetPrototype(proto)) { | 1079 for (var proto = %_GetPrototype(obj); proto; proto = %_GetPrototype(proto)) { |
| 1080 var indices = %GetArrayKeys(proto, to); | 1080 var indices = IS_PROXY(proto) ? to : %GetArrayKeys(proto, to); |
| 1081 if (IS_NUMBER(indices)) { | 1081 if (IS_NUMBER(indices)) { |
| 1082 // It's an interval. | 1082 // It's an interval. |
| 1083 var proto_length = indices; | 1083 var proto_length = indices; |
| 1084 for (var i = from; i < proto_length; i++) { | 1084 for (var i = from; i < proto_length; i++) { |
| 1085 if (HAS_OWN_PROPERTY(proto, i)) { | 1085 if (HAS_OWN_PROPERTY(proto, i)) { |
| 1086 obj[i] = UNDEFINED; | 1086 obj[i] = UNDEFINED; |
| 1087 } | 1087 } |
| 1088 } | 1088 } |
| 1089 } else { | 1089 } else { |
| 1090 for (var i = 0; i < indices.length; i++) { | 1090 for (var i = 0; i < indices.length; i++) { |
| (...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1955 %InstallToContext([ | 1955 %InstallToContext([ |
| 1956 "array_pop", ArrayPop, | 1956 "array_pop", ArrayPop, |
| 1957 "array_push", ArrayPush, | 1957 "array_push", ArrayPush, |
| 1958 "array_shift", ArrayShift, | 1958 "array_shift", ArrayShift, |
| 1959 "array_splice", ArraySplice, | 1959 "array_splice", ArraySplice, |
| 1960 "array_slice", ArraySlice, | 1960 "array_slice", ArraySlice, |
| 1961 "array_unshift", ArrayUnshift, | 1961 "array_unshift", ArrayUnshift, |
| 1962 ]); | 1962 ]); |
| 1963 | 1963 |
| 1964 }); | 1964 }); |
| OLD | NEW |