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 "use strict"; | 5 "use strict"; |
6 | 6 |
7 // This file relies on the fact that the following declarations have been made | 7 // This file relies on the fact that the following declarations have been made |
8 // in runtime.js: | 8 // in runtime.js: |
9 // var $Array = global.Array; | 9 // var $Array = global.Array; |
10 | 10 |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 %MoveArrayContents(new_array, array); | 277 %MoveArrayContents(new_array, array); |
278 } | 278 } |
279 | 279 |
280 | 280 |
281 // This is part of the old simple-minded splice. We are using it either | 281 // This is part of the old simple-minded splice. We are using it either |
282 // because the receiver is not an array (so we have no choice) or because we | 282 // because the receiver is not an array (so we have no choice) or because we |
283 // know we are not deleting or moving a lot of elements. | 283 // know we are not deleting or moving a lot of elements. |
284 function SimpleSlice(array, start_i, del_count, len, deleted_elements) { | 284 function SimpleSlice(array, start_i, del_count, len, deleted_elements) { |
285 for (var i = 0; i < del_count; i++) { | 285 for (var i = 0; i < del_count; i++) { |
286 var index = start_i + i; | 286 var index = start_i + i; |
287 // The spec could also be interpreted such that %HasOwnProperty | 287 if (index in array) { |
288 // would be the appropriate test. We follow KJS in consulting the | 288 var current = array[index]; |
289 // prototype. | |
290 var current = array[index]; | |
291 if (!IS_UNDEFINED(current) || index in array) { | |
292 // The spec requires [[DefineOwnProperty]] here, %AddElement is close | 289 // The spec requires [[DefineOwnProperty]] here, %AddElement is close |
293 // enough (in that it ignores the prototype). | 290 // enough (in that it ignores the prototype). |
294 %AddElement(deleted_elements, i, current, NONE); | 291 %AddElement(deleted_elements, i, current, NONE); |
295 } | 292 } |
296 } | 293 } |
297 } | 294 } |
298 | 295 |
299 | 296 |
300 function SimpleMove(array, start_i, del_count, len, num_additional_args) { | 297 function SimpleMove(array, start_i, del_count, len, num_additional_args) { |
301 if (num_additional_args !== del_count) { | 298 if (num_additional_args !== del_count) { |
(...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1567 )); | 1564 )); |
1568 | 1565 |
1569 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( | 1566 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( |
1570 "join", getFunction("join", ArrayJoin), | 1567 "join", getFunction("join", ArrayJoin), |
1571 "pop", getFunction("pop", ArrayPop), | 1568 "pop", getFunction("pop", ArrayPop), |
1572 "push", getFunction("push", ArrayPush) | 1569 "push", getFunction("push", ArrayPush) |
1573 )); | 1570 )); |
1574 } | 1571 } |
1575 | 1572 |
1576 SetUpArray(); | 1573 SetUpArray(); |
OLD | NEW |