Home | History | Annotate | Download | only in src

Lines Matching refs:array

30 // const $Array = global.Array;
36 var visited_arrays = new $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) {
71 function SparseJoin(array, len, convert) {
72 var keys = GetSortedArrayKeys(array, %GetArrayKeys(array, len));
76 var elements = new $Array(keys_length);
82 var e = array[key];
100 function Join(array, length, separator, convert) {
103 var is_array = IS_ARRAY(array);
106 // If the array is cyclic, return the empty string for already
108 if (!%PushIfAbsent(visited_arrays, array)) return '';
113 if (UseSparseVariant(array, length, is_array) && (separator.length == 0)) {
114 return SparseJoin(array, length, convert);
119 var e = array[0];
120 if (!IS_UNDEFINED(e) || (0 in array)) {
126 // Construct an array for the elements.
132 elements = new $Array(length);
134 var e = array[i];
135 if (!IS_UNDEFINED(e) || (i in array)) {
141 elements = new $Array(length << 1);
143 var e = array[i];
145 if (!IS_UNDEFINED(e) || (i in array)) {
153 // Make sure to pop the visited array no matter what happens.
182 // special array operations to handle sparse arrays in a sensible fashion.
183 function SmartSlice(array, start_i, del_count, len, deleted_elements) {
184 // Move deleted elements to a new array (the return value from splice).
185 // Intervals array can contain keys and intervals. See comment in Concat.
186 var intervals = %GetArrayKeys(array, start_i + del_count);
201 var current = array[j];
202 if (!IS_UNDEFINED(current) || j in array) {
213 var current = array[key];
214 if (!IS_UNDEFINED(current) || key in array) {
225 // special array operations to handle sparse arrays in a sensible fashion.
226 function SmartMove(array, start_i, del_count, len, num_additional_args) {
227 // Move data to new array.
228 var new_array = new $Array(len - del_count + num_additional_args);
229 var intervals = %GetArrayKeys(array, len);
240 var current = array[j];
241 if (!IS_UNDEFINED(current) || j in array) {
252 var current = array[j];
253 if (!IS_UNDEFINED(current) || j in array) {
264 var current = array[key];
265 if (!IS_UNDEFINED(current) || key in array) {
273 var current = array[key];
274 if (!IS_UNDEFINED(current) || key in array) {
281 // Move contents of new_array into this array
282 %MoveArrayContents(new_array, array);
287 // because the receiver is not an array (so we have no choice) or because we
289 function SimpleSlice(array, start_i, del_count, len, deleted_elements) {
295 var current = array[index];
296 if (!IS_UNDEFINED(current) || index in array)
302 function SimpleMove(array, start_i, del_count, len, num_additional_args) {
305 // to the right position in the resulting array.
313 var current = array[from_index];
314 if (!IS_UNDEFINED(current) || from_index in array) {
315 array[to_index] = current;
317 delete array[to_index];
327 var current = array[from_index];
328 if (!IS_UNDEFINED(current) || from_index in array) {
329 array[to_index] = current;
331 delete array[to_index];
335 delete array[i - 1];
347 throw new $TypeError('Array.prototype.toString is not generic');
355 throw new $TypeError('Array.prototype.toString is not generic');
372 // Removes the last element from the array and returns it. See
388 // Appends the arguments to the end of the array and returns the new
389 // length of the array. See ECMA-262, section 15.4.4.7.
404 var arrays = new $Array(1 + arg_count);
415 function SparseReverse(array, len) {
416 var keys = GetSortedArrayKeys(array, %GetArrayKeys(array, len));
437 var current_i = array[low];
438 if (!IS_UNDEFINED(current_i) || low in array) {
439 var current_j = array[high];
440 if (!IS_UNDEFINED(current_j) || high in array) {
441 array[low] = current_j;
442 array[high] = current_i;
444 array[high] = current_i;
445 delete array[low];
448 var current_j = array[high];
449 if (!IS_UNDEFINED(current_j) || high in array) {
450 array[low] = current_j;
451 delete array[high];
612 // array then the simple version is going to be faster, because it
613 // doesn't touch most of the array.
628 // Insert the arguments into the resulting array in
803 // in the beginning of the array. Write undefineds and holes at the end
815 // array with indices <= first_undefined or > last_defined.
834 // If there were any undefineds in the entire array, first_undefined
865 // the prototype chain on non-Array objects.
877 // There were indexed accessors in the array. Move array holes and
897 // or delete elements from the array.
934 // array until it finds one where callback returns true.
975 var result = new $Array(length);
992 // If index is negative, index from the end of the array.
994 // If index is still negative, search the entire array.
997 // Lookup through the array.
1014 // If index is negative, index from end of the array.
1016 // If index is still negative, do not search the array.
1020 // Lookup through the array.
1103 // Setup non-enumerable constructor property on the Array.prototype
1105 %SetProperty($Array.prototype, "constructor", $Array, DONT_ENUM);
1107 // Setup non-enumerable functions on the Array object.
1108 InstallFunctions($Array, DONT_ENUM, $Array(
1112 // Setup non-enumerable functions of the Array.prototype object and
1114 InstallFunctionsOnHiddenPrototype($Array.prototype, DONT_ENUM, $Array(