| 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 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1099 return -1; | 1099 return -1; |
| 1100 } | 1100 } |
| 1101 for (var i = max; i >= min; i--) { | 1101 for (var i = max; i >= min; i--) { |
| 1102 if (IS_UNDEFINED(array[i]) && i in array) { | 1102 if (IS_UNDEFINED(array[i]) && i in array) { |
| 1103 return i; | 1103 return i; |
| 1104 } | 1104 } |
| 1105 } | 1105 } |
| 1106 return -1; | 1106 return -1; |
| 1107 } | 1107 } |
| 1108 | 1108 |
| 1109 function InnerArrayReduceRight(callback, current, array, length, | |
| 1110 argumentsLength) { | |
| 1111 if (!IS_CALLABLE(callback)) { | |
| 1112 throw %make_type_error(kCalledNonCallable, callback); | |
| 1113 } | |
| 1114 | |
| 1115 var i = length - 1; | |
| 1116 find_initial: if (argumentsLength < 2) { | |
| 1117 for (; i >= 0; i--) { | |
| 1118 if (i in array) { | |
| 1119 current = array[i--]; | |
| 1120 break find_initial; | |
| 1121 } | |
| 1122 } | |
| 1123 throw %make_type_error(kReduceNoInitial); | |
| 1124 } | |
| 1125 | |
| 1126 for (; i >= 0; i--) { | |
| 1127 if (i in array) { | |
| 1128 var element = array[i]; | |
| 1129 current = callback(current, element, i, array); | |
| 1130 } | |
| 1131 } | |
| 1132 return current; | |
| 1133 } | |
| 1134 | |
| 1135 | |
| 1136 function ArrayReduceRight(callback, current) { | |
| 1137 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reduceRight"); | |
| 1138 | |
| 1139 // Pull out the length so that side effects are visible before the | |
| 1140 // callback function is checked. | |
| 1141 var array = TO_OBJECT(this); | |
| 1142 var length = TO_LENGTH(array.length); | |
| 1143 return InnerArrayReduceRight(callback, current, array, length, | |
| 1144 arguments.length); | |
| 1145 } | |
| 1146 | |
| 1147 | |
| 1148 // ES#sec-array.prototype.copywithin | 1109 // ES#sec-array.prototype.copywithin |
| 1149 // (Array.prototype.copyWithin ( target, start [ , end ] ) | 1110 // (Array.prototype.copyWithin ( target, start [ , end ] ) |
| 1150 function ArrayCopyWithin(target, start, end) { | 1111 function ArrayCopyWithin(target, start, end) { |
| 1151 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.copyWithin"); | 1112 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.copyWithin"); |
| 1152 | 1113 |
| 1153 var array = TO_OBJECT(this); | 1114 var array = TO_OBJECT(this); |
| 1154 var length = TO_LENGTH(array.length); | 1115 var length = TO_LENGTH(array.length); |
| 1155 | 1116 |
| 1156 target = TO_INTEGER(target); | 1117 target = TO_INTEGER(target); |
| 1157 var to; | 1118 var to; |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1418 "reverse", getFunction("reverse", ArrayReverse), | 1379 "reverse", getFunction("reverse", ArrayReverse), |
| 1419 "shift", getFunction("shift", ArrayShift), | 1380 "shift", getFunction("shift", ArrayShift), |
| 1420 "unshift", getFunction("unshift", ArrayUnshift, 1), | 1381 "unshift", getFunction("unshift", ArrayUnshift, 1), |
| 1421 "slice", getFunction("slice", ArraySlice, 2), | 1382 "slice", getFunction("slice", ArraySlice, 2), |
| 1422 "splice", getFunction("splice", ArraySplice, 2), | 1383 "splice", getFunction("splice", ArraySplice, 2), |
| 1423 "sort", getFunction("sort", ArraySort), | 1384 "sort", getFunction("sort", ArraySort), |
| 1424 "filter", getFunction("filter", ArrayFilter, 1), | 1385 "filter", getFunction("filter", ArrayFilter, 1), |
| 1425 "map", getFunction("map", ArrayMap, 1), | 1386 "map", getFunction("map", ArrayMap, 1), |
| 1426 "indexOf", getFunction("indexOf", null, 1), | 1387 "indexOf", getFunction("indexOf", null, 1), |
| 1427 "lastIndexOf", getFunction("lastIndexOf", ArrayLastIndexOf, 1), | 1388 "lastIndexOf", getFunction("lastIndexOf", ArrayLastIndexOf, 1), |
| 1428 "reduceRight", getFunction("reduceRight", ArrayReduceRight, 1), | |
| 1429 "copyWithin", getFunction("copyWithin", ArrayCopyWithin, 2), | 1389 "copyWithin", getFunction("copyWithin", ArrayCopyWithin, 2), |
| 1430 "find", getFunction("find", ArrayFind, 1), | 1390 "find", getFunction("find", ArrayFind, 1), |
| 1431 "findIndex", getFunction("findIndex", ArrayFindIndex, 1), | 1391 "findIndex", getFunction("findIndex", ArrayFindIndex, 1), |
| 1432 "fill", getFunction("fill", ArrayFill, 1), | 1392 "fill", getFunction("fill", ArrayFill, 1), |
| 1433 "includes", getFunction("includes", null, 1), | 1393 "includes", getFunction("includes", null, 1), |
| 1434 "entries", IteratorFunctions.entries, | 1394 "entries", IteratorFunctions.entries, |
| 1435 "keys", IteratorFunctions.keys, | 1395 "keys", IteratorFunctions.keys, |
| 1436 iteratorSymbol, IteratorFunctions.values | 1396 iteratorSymbol, IteratorFunctions.values |
| 1437 ]); | 1397 ]); |
| 1438 | 1398 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1477 utils.Export(function(to) { | 1437 utils.Export(function(to) { |
| 1478 to.ArrayFrom = ArrayFrom; | 1438 to.ArrayFrom = ArrayFrom; |
| 1479 to.ArrayJoin = ArrayJoin; | 1439 to.ArrayJoin = ArrayJoin; |
| 1480 to.ArrayPush = ArrayPush; | 1440 to.ArrayPush = ArrayPush; |
| 1481 to.ArrayToString = ArrayToString; | 1441 to.ArrayToString = ArrayToString; |
| 1482 to.ArrayValues = IteratorFunctions.values, | 1442 to.ArrayValues = IteratorFunctions.values, |
| 1483 to.InnerArrayFilter = InnerArrayFilter; | 1443 to.InnerArrayFilter = InnerArrayFilter; |
| 1484 to.InnerArrayFind = InnerArrayFind; | 1444 to.InnerArrayFind = InnerArrayFind; |
| 1485 to.InnerArrayFindIndex = InnerArrayFindIndex; | 1445 to.InnerArrayFindIndex = InnerArrayFindIndex; |
| 1486 to.InnerArrayJoin = InnerArrayJoin; | 1446 to.InnerArrayJoin = InnerArrayJoin; |
| 1487 to.InnerArrayReduceRight = InnerArrayReduceRight; | |
| 1488 to.InnerArraySort = InnerArraySort; | 1447 to.InnerArraySort = InnerArraySort; |
| 1489 to.InnerArrayToLocaleString = InnerArrayToLocaleString; | 1448 to.InnerArrayToLocaleString = InnerArrayToLocaleString; |
| 1490 to.PackedArrayReverse = PackedArrayReverse; | 1449 to.PackedArrayReverse = PackedArrayReverse; |
| 1491 }); | 1450 }); |
| 1492 | 1451 |
| 1493 %InstallToContext([ | 1452 %InstallToContext([ |
| 1494 "array_entries_iterator", IteratorFunctions.entries, | 1453 "array_entries_iterator", IteratorFunctions.entries, |
| 1495 "array_keys_iterator", IteratorFunctions.keys, | 1454 "array_keys_iterator", IteratorFunctions.keys, |
| 1496 "array_pop", ArrayPop, | 1455 "array_pop", ArrayPop, |
| 1497 "array_push", ArrayPush, | 1456 "array_push", ArrayPush, |
| 1498 "array_shift", ArrayShift, | 1457 "array_shift", ArrayShift, |
| 1499 "array_splice", ArraySplice, | 1458 "array_splice", ArraySplice, |
| 1500 "array_slice", ArraySlice, | 1459 "array_slice", ArraySlice, |
| 1501 "array_unshift", ArrayUnshift, | 1460 "array_unshift", ArrayUnshift, |
| 1502 "array_values_iterator", IteratorFunctions.values, | 1461 "array_values_iterator", IteratorFunctions.values, |
| 1503 ]); | 1462 ]); |
| 1504 | 1463 |
| 1505 }); | 1464 }); |
| OLD | NEW |