Lines Matching refs:Array
30 // var $Array = global.Array;
39 // Gets a sorted array of array keys. Useful for operations on sparse
41 function GetSortedArrayKeys(array, intervals) {
50 var e = array[j];
51 if (!IS_UNDEFINED(e) || j in array) {
58 var e = array[key];
59 if (!IS_UNDEFINED(e) || key in array) {
70 function SparseJoinWithSeparator(array, len, convert, separator) {
71 var keys = GetSortedArrayKeys(array, %GetArrayKeys(array, len));
78 var e = array[key];
90 function SparseJoin(array, len, convert) {
91 var keys = GetSortedArrayKeys(array, %GetArrayKeys(array, len));
101 var e = array[key];
119 function Join(array, length, separator, convert) {
122 var is_array = IS_ARRAY(array);
125 // If the array is cyclic, return the empty string for already
127 if (!%PushIfAbsent(visited_arrays, array)) return '';
132 if (UseSparseVariant(array, length, is_array)) {
134 return SparseJoin(array, length, convert);
136 return SparseJoinWithSeparator(array, length, convert, separator);
142 var e = array[0];
147 // Construct an array for the elements.
154 var e = array[i];
166 if (!IS_NUMBER(array[0])) {
168 var e = array[i];
174 var e = array[i];
188 // Make sure to remove the last element of the visited array no
217 // special array operations to handle sparse arrays in a sensible fashion.
218 function SmartSlice(array, start_i, del_count, len, deleted_elements) {
219 // Move deleted elements to a new array (the return value from splice).
220 // Intervals array can contain keys and intervals. See comment in Concat.
221 var intervals = %GetArrayKeys(array, start_i + del_count);
236 var current = array[j];
237 if (!IS_UNDEFINED(current) || j in array) {
248 var current = array[key];
249 if (!IS_UNDEFINED(current) || key in array) {
260 // special array operations to handle sparse arrays in a sensible fashion.
261 function SmartMove(array, start_i, del_count, len, num_additional_args) {
262 // Move data to new array.
264 var intervals = %GetArrayKeys(array, len);
275 var current = array[j];
276 if (!IS_UNDEFINED(current) || j in array) {
287 var current = array[j];
288 if (!IS_UNDEFINED(current) || j in array) {
299 var current = array[key];
300 if (!IS_UNDEFINED(current) || key in array) {
308 var current = array[key];
309 if (!IS_UNDEFINED(current) || key in array) {
316 // Move contents of new_array into this array
317 %MoveArrayContents(new_array, array);
322 // because the receiver is not an array (so we have no choice) or because we
324 function SimpleSlice(array, start_i, del_count, len, deleted_elements) {
330 var current = array[index];
331 if (!IS_UNDEFINED(current) || index in array) {
338 function SimpleMove(array, start_i, del_count, len, num_additional_args) {
341 // to the right position in the resulting array.
349 var current = array[from_index];
350 if (!IS_UNDEFINED(current) || from_index in array) {
351 array[to_index] = current;
353 delete array[to_index];
363 var current = array[from_index];
364 if (!IS_UNDEFINED(current) || from_index in array) {
365 array[to_index] = current;
367 delete array[to_index];
371 delete array[i - 1];
382 var array;
389 array = this;
391 array = ToObject(this);
392 func = array.join;
395 return %_CallFunction(array, ObjectToString);
397 return %_CallFunction(array, func);
402 var array = ToObject(this);
403 var arrayLen = array.length;
406 return Join(array, len, ',', ConvertToLocaleString);
413 ["Array.prototype.join"]);
429 // Removes the last element from the array and returns it. See
434 ["Array.prototype.pop"]);
450 // Appends the arguments to the end of the array and returns the new
451 // length of the array. See ECMA-262, section 15.4.4.7.
455 ["Array.prototype.push"]);
471 ["Array.prototype.concat"]);
486 function SparseReverse(array, len) {
487 var keys = GetSortedArrayKeys(array, %GetArrayKeys(array, len));
508 var current_i = array[low];
509 if (!IS_UNDEFINED(current_i) || low in array) {
510 var current_j = array[high];
511 array) {
512 array[low] = current_j;
513 array[high] = current_i;
515 array[high] = current_i;
516 delete array[low];
519 var current_j = array[high];
520 if (!IS_UNDEFINED(current_j) || high in array) {
521 array[low] = current_j;
522 delete array[high];
532 ["Array.prototype.reverse"]);
568 ["Array.prototype.shift"]);
595 ["Array.prototype.unshift"]);
620 ["Array.prototype.slice"]);
664 ["Array.prototype.splice"]);
706 // array then the simple version is going to be faster, because it
707 // doesn't touch most of the array.
722 // Insert the arguments into the resulting array in
740 ["Array.prototype.sort"]);
912 // in the beginning of the array. Write undefineds and holes at the end
924 // array with indices <= first_undefined or > last_defined.
943 // If there were any undefineds in the entire array, first_undefined
974 // the prototype chain on non-Array objects.
986 // There were indexed accessors in the array. Move array holes and
1006 // or delete elements from the array.
1010 ["Array.prototype.filter"]);
1015 var array = ToObject(this);
1016 var length = ToUint32(array.length);
1027 var result = new $Array();
1031 if (i in array) {
1032 var element = array[i];
1033 if (%_CallFunction(receiver, element, i, array, f)) {
1046 ["Array.prototype.forEach"]);
1051 var array = ToObject(this);
1052 var length = TO_UINT32(array.length);
1064 array) {
1065 var element = array[i];
1066 %_CallFunction(receiver, element, i, array, f);
1073 // array until it finds one where callback returns true.
1077 ["Array.prototype.some"]);
1082 var array = ToObject(this);
1083 var length = TO_UINT32(array.length);
1095 if (i in array) {
1096 var element = array[i];
1097 if (%_CallFunction(receiver, element, i, array, f)) return true;
1107 ["Array.prototype.every"]);
1112 var array = ToObject(this);
1113 var length = TO_UINT32(array.length);
1125 if (i in array) {
1126 var element = array[i];
1127 if (!%_CallFunction(receiver, element, i, array, f)) return false;
1136 ["Array.prototype.map"]);
1141 var array = ToObject(this);
1142 var length = TO_UINT32(array.length);
1153 var result = new $Array();
1156 if (i in array) {
1157 var element = array[i];
1158 accumulator[i] = %_CallFunction(receiver, element, i, array, f);
1169 ["Array.prototype.indexOf"]);
1178 // If index is negative, index from the end of the array.
1181 // If index is still negative, search the entire array.
1211 // Lookup through the array.
1218 // Lookup through the array.
1231 ["Array.prototype.lastIndexOf"]);
1240 // If index is negative, index from end of the array.
1242 // If index is still negative, do not search the array.
1270 // Lookup through the array.
1289 ["Array.prototype.reduce"]);
1294 var array = ToObject(this);
1295 var length = ToUint32(array.length);
1304 current = array[i];
1305 if (!IS_UNDEFINED(current) || i in array) {
1315 if (i in array) {
1316 var element = array[i];
1317 current = %_CallFunction(receiver, current, element, i, array, callback);
1326 ["Array.prototype.reduceRight"]);
1331 var array = ToObject(this);
1332 var length = ToUint32(array.length);
1341 current = array[i];
1342 if (!IS_UNDEFINED(current) || i in array) {
1352 if (i in array) {
1353 var element = array[i];
1354 current = %_CallFunction(receiver, current, element, i, array, callback);
1369 // Set up non-enumerable constructor property on the Array.prototype
1371 %SetProperty($Array.prototype, "constructor", $Array, DONT_ENUM);
1373 // Set up non-enumerable functions on the Array object.
1374 InstallFunctions($Array, DONT_ENUM, $Array(
1391 // Set up non-enumerable functions of the Array.prototype object and
1395 InstallFunctions($Array.prototype, DONT_ENUM, $Array(
1419 %FinishArrayPrototypeSetup($Array.prototype);
1421 // The internal Array prototype doesn't need to be fancy, since it's never
1424 SetUpLockedPrototype(InternalArray, $Array(), $Array(