Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: src/array.js

Issue 291153005: Consistently say 'own' property (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add new files Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/api.cc ('k') | src/bootstrapper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 %MoveArrayContents(new_array, array); 264 %MoveArrayContents(new_array, array);
265 } 265 }
266 266
267 267
268 // This is part of the old simple-minded splice. We are using it either 268 // This is part of the old simple-minded splice. We are using it either
269 // because the receiver is not an array (so we have no choice) or because we 269 // because the receiver is not an array (so we have no choice) or because we
270 // know we are not deleting or moving a lot of elements. 270 // know we are not deleting or moving a lot of elements.
271 function SimpleSlice(array, start_i, del_count, len, deleted_elements) { 271 function SimpleSlice(array, start_i, del_count, len, deleted_elements) {
272 for (var i = 0; i < del_count; i++) { 272 for (var i = 0; i < del_count; i++) {
273 var index = start_i + i; 273 var index = start_i + i;
274 // The spec could also be interpreted such that %HasLocalProperty 274 // The spec could also be interpreted such that %HasOwnProperty
275 // would be the appropriate test. We follow KJS in consulting the 275 // would be the appropriate test. We follow KJS in consulting the
276 // prototype. 276 // prototype.
277 var current = array[index]; 277 var current = array[index];
278 if (!IS_UNDEFINED(current) || index in array) { 278 if (!IS_UNDEFINED(current) || index in array) {
279 deleted_elements[i] = current; 279 deleted_elements[i] = current;
280 } 280 }
281 } 281 }
282 } 282 }
283 283
284 284
285 function SimpleMove(array, start_i, del_count, len, num_additional_args) { 285 function SimpleMove(array, start_i, del_count, len, num_additional_args) {
286 if (num_additional_args !== del_count) { 286 if (num_additional_args !== del_count) {
287 // Move the existing elements after the elements to be deleted 287 // Move the existing elements after the elements to be deleted
288 // to the right position in the resulting array. 288 // to the right position in the resulting array.
289 if (num_additional_args > del_count) { 289 if (num_additional_args > del_count) {
290 for (var i = len - del_count; i > start_i; i--) { 290 for (var i = len - del_count; i > start_i; i--) {
291 var from_index = i + del_count - 1; 291 var from_index = i + del_count - 1;
292 var to_index = i + num_additional_args - 1; 292 var to_index = i + num_additional_args - 1;
293 // The spec could also be interpreted such that 293 // The spec could also be interpreted such that
294 // %HasLocalProperty would be the appropriate test. We follow 294 // %HasOwnProperty would be the appropriate test. We follow
295 // KJS in consulting the prototype. 295 // KJS in consulting the prototype.
296 var current = array[from_index]; 296 var current = array[from_index];
297 if (!IS_UNDEFINED(current) || from_index in array) { 297 if (!IS_UNDEFINED(current) || from_index in array) {
298 array[to_index] = current; 298 array[to_index] = current;
299 } else { 299 } else {
300 delete array[to_index]; 300 delete array[to_index];
301 } 301 }
302 } 302 }
303 } else { 303 } else {
304 for (var i = start_i; i < len - del_count; i++) { 304 for (var i = start_i; i < len - del_count; i++) {
305 var from_index = i + del_count; 305 var from_index = i + del_count;
306 var to_index = i + num_additional_args; 306 var to_index = i + num_additional_args;
307 // The spec could also be interpreted such that 307 // The spec could also be interpreted such that
308 // %HasLocalProperty would be the appropriate test. We follow 308 // %HasOwnProperty would be the appropriate test. We follow
309 // KJS in consulting the prototype. 309 // KJS in consulting the prototype.
310 var current = array[from_index]; 310 var current = array[from_index];
311 if (!IS_UNDEFINED(current) || from_index in array) { 311 if (!IS_UNDEFINED(current) || from_index in array) {
312 array[to_index] = current; 312 array[to_index] = current;
313 } else { 313 } else {
314 delete array[to_index]; 314 delete array[to_index];
315 } 315 }
316 } 316 }
317 for (var i = len; i > len - del_count + num_additional_args; i--) { 317 for (var i = len; i > len - del_count + num_additional_args; i--) {
318 delete array[i - 1]; 318 delete array[i - 1];
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 1068
1069 var length = TO_UINT32(this.length); 1069 var length = TO_UINT32(this.length);
1070 if (length < 2) return this; 1070 if (length < 2) return this;
1071 1071
1072 var is_array = IS_ARRAY(this); 1072 var is_array = IS_ARRAY(this);
1073 var max_prototype_element; 1073 var max_prototype_element;
1074 if (!is_array) { 1074 if (!is_array) {
1075 // For compatibility with JSC, we also sort elements inherited from 1075 // For compatibility with JSC, we also sort elements inherited from
1076 // the prototype chain on non-Array objects. 1076 // the prototype chain on non-Array objects.
1077 // We do this by copying them to this object and sorting only 1077 // We do this by copying them to this object and sorting only
1078 // local elements. This is not very efficient, but sorting with 1078 // own elements. This is not very efficient, but sorting with
1079 // inherited elements happens very, very rarely, if at all. 1079 // inherited elements happens very, very rarely, if at all.
1080 // The specification allows "implementation dependent" behavior 1080 // The specification allows "implementation dependent" behavior
1081 // if an element on the prototype chain has an element that 1081 // if an element on the prototype chain has an element that
1082 // might interact with sorting. 1082 // might interact with sorting.
1083 max_prototype_element = CopyFromPrototype(this, length); 1083 max_prototype_element = CopyFromPrototype(this, length);
1084 } 1084 }
1085 1085
1086 // %RemoveArrayHoles returns -1 if fast removal is not supported. 1086 // %RemoveArrayHoles returns -1 if fast removal is not supported.
1087 var num_non_undefined = %RemoveArrayHoles(this, length); 1087 var num_non_undefined = %RemoveArrayHoles(this, length);
1088 1088
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 )); 1525 ));
1526 1526
1527 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( 1527 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array(
1528 "join", getFunction("join", ArrayJoin), 1528 "join", getFunction("join", ArrayJoin),
1529 "pop", getFunction("pop", ArrayPop), 1529 "pop", getFunction("pop", ArrayPop),
1530 "push", getFunction("push", ArrayPush) 1530 "push", getFunction("push", ArrayPush)
1531 )); 1531 ));
1532 } 1532 }
1533 1533
1534 SetUpArray(); 1534 SetUpArray();
OLDNEW
« no previous file with comments | « src/api.cc ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698