| 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 var $arrayConcat; | 5 var $arrayConcat; |
| 6 var $arrayJoin; | 6 var $arrayJoin; |
| 7 var $arrayPush; | 7 var $arrayPush; |
| 8 var $arrayPop; | 8 var $arrayPop; |
| 9 var $arrayShift; | 9 var $arrayShift; |
| 10 var $arraySlice; | 10 var $arraySlice; |
| 11 var $arraySplice; | 11 var $arraySplice; |
| 12 var $arrayUnshift; | 12 var $arrayUnshift; |
| 13 var $innerArrayForEach; | 13 var $innerArrayForEach; |
| 14 var $innerArrayEvery; | 14 var $innerArrayEvery; |
| 15 var $innerArrayFilter; | |
| 16 var $innerArrayMap; | |
| 17 var $innerArrayReduce; | |
| 18 var $innerArrayReduceRight; | |
| 19 var $innerArraySome; | |
| 20 | 15 |
| 21 (function(global, shared, exports) { | 16 (function(global, shared, exports) { |
| 22 | 17 |
| 23 "use strict"; | 18 "use strict"; |
| 24 | 19 |
| 25 %CheckIsBootstrapping(); | 20 %CheckIsBootstrapping(); |
| 26 | 21 |
| 27 // ------------------------------------------------------------------- | 22 // ------------------------------------------------------------------- |
| 28 // Imports | 23 // Imports |
| 29 | 24 |
| (...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1148 ShadowPrototypeElements(this, num_non_undefined, max_prototype_element); | 1143 ShadowPrototypeElements(this, num_non_undefined, max_prototype_element); |
| 1149 } | 1144 } |
| 1150 | 1145 |
| 1151 return this; | 1146 return this; |
| 1152 } | 1147 } |
| 1153 | 1148 |
| 1154 | 1149 |
| 1155 // The following functions cannot be made efficient on sparse arrays while | 1150 // The following functions cannot be made efficient on sparse arrays while |
| 1156 // preserving the semantics, since the calls to the receiver function can add | 1151 // preserving the semantics, since the calls to the receiver function can add |
| 1157 // or delete elements from the array. | 1152 // or delete elements from the array. |
| 1158 function InnerArrayFilter(f, receiver, array, length) { | 1153 function ArrayFilter(f, receiver) { |
| 1154 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.filter"); |
| 1155 |
| 1156 // Pull out the length so that modifications to the length in the |
| 1157 // loop will not affect the looping and side effects are visible. |
| 1158 var array = $toObject(this); |
| 1159 var length = $toUint32(array.length); |
| 1160 |
| 1159 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); | 1161 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); |
| 1160 var needs_wrapper = false; | 1162 var needs_wrapper = false; |
| 1161 if (IS_NULL(receiver)) { | 1163 if (IS_NULL(receiver)) { |
| 1162 if (%IsSloppyModeFunction(f)) receiver = UNDEFINED; | 1164 if (%IsSloppyModeFunction(f)) receiver = UNDEFINED; |
| 1163 } else if (!IS_UNDEFINED(receiver)) { | 1165 } else if (!IS_UNDEFINED(receiver)) { |
| 1164 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); | 1166 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); |
| 1165 } | 1167 } |
| 1166 | 1168 |
| 1167 var result = new GlobalArray(); | 1169 var result = new GlobalArray(); |
| 1168 var accumulator = new InternalArray(); | 1170 var accumulator = new InternalArray(); |
| 1169 var accumulator_length = 0; | 1171 var accumulator_length = 0; |
| 1170 var is_array = IS_ARRAY(array); | 1172 var is_array = IS_ARRAY(array); |
| 1171 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); | 1173 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); |
| 1172 for (var i = 0; i < length; i++) { | 1174 for (var i = 0; i < length; i++) { |
| 1173 if (HAS_INDEX(array, i, is_array)) { | 1175 if (HAS_INDEX(array, i, is_array)) { |
| 1174 var element = array[i]; | 1176 var element = array[i]; |
| 1175 // Prepare break slots for debugger step in. | 1177 // Prepare break slots for debugger step in. |
| 1176 if (stepping) %DebugPrepareStepInIfStepping(f); | 1178 if (stepping) %DebugPrepareStepInIfStepping(f); |
| 1177 var new_receiver = needs_wrapper ? $toObject(receiver) : receiver; | 1179 var new_receiver = needs_wrapper ? $toObject(receiver) : receiver; |
| 1178 if (%_CallFunction(new_receiver, element, i, array, f)) { | 1180 if (%_CallFunction(new_receiver, element, i, array, f)) { |
| 1179 accumulator[accumulator_length++] = element; | 1181 accumulator[accumulator_length++] = element; |
| 1180 } | 1182 } |
| 1181 } | 1183 } |
| 1182 } | 1184 } |
| 1183 %MoveArrayContents(accumulator, result); | 1185 %MoveArrayContents(accumulator, result); |
| 1184 return result; | 1186 return result; |
| 1185 } | 1187 } |
| 1186 | 1188 |
| 1187 function ArrayFilter(f, receiver) { | |
| 1188 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.filter"); | |
| 1189 | |
| 1190 // Pull out the length so that modifications to the length in the | |
| 1191 // loop will not affect the looping and side effects are visible. | |
| 1192 var array = $toObject(this); | |
| 1193 var length = $toUint32(array.length); | |
| 1194 | |
| 1195 return InnerArrayFilter(f, receiver, array, length); | |
| 1196 } | |
| 1197 | |
| 1198 function InnerArrayForEach(f, receiver, array, length) { | 1189 function InnerArrayForEach(f, receiver, array, length) { |
| 1199 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); | 1190 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); |
| 1200 var needs_wrapper = false; | 1191 var needs_wrapper = false; |
| 1201 if (IS_NULL(receiver)) { | 1192 if (IS_NULL(receiver)) { |
| 1202 if (%IsSloppyModeFunction(f)) receiver = UNDEFINED; | 1193 if (%IsSloppyModeFunction(f)) receiver = UNDEFINED; |
| 1203 } else if (!IS_UNDEFINED(receiver)) { | 1194 } else if (!IS_UNDEFINED(receiver)) { |
| 1204 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); | 1195 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); |
| 1205 } | 1196 } |
| 1206 | 1197 |
| 1207 var is_array = IS_ARRAY(array); | 1198 var is_array = IS_ARRAY(array); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1221 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.forEach"); | 1212 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.forEach"); |
| 1222 | 1213 |
| 1223 // Pull out the length so that modifications to the length in the | 1214 // Pull out the length so that modifications to the length in the |
| 1224 // loop will not affect the looping and side effects are visible. | 1215 // loop will not affect the looping and side effects are visible. |
| 1225 var array = $toObject(this); | 1216 var array = $toObject(this); |
| 1226 var length = TO_UINT32(array.length); | 1217 var length = TO_UINT32(array.length); |
| 1227 InnerArrayForEach(f, receiver, array, length); | 1218 InnerArrayForEach(f, receiver, array, length); |
| 1228 } | 1219 } |
| 1229 | 1220 |
| 1230 | 1221 |
| 1231 function InnerArraySome(f, receiver, array, length) { | 1222 // Executes the function once for each element present in the |
| 1223 // array until it finds one where callback returns true. |
| 1224 function ArraySome(f, receiver) { |
| 1225 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.some"); |
| 1226 |
| 1227 // Pull out the length so that modifications to the length in the |
| 1228 // loop will not affect the looping and side effects are visible. |
| 1229 var array = $toObject(this); |
| 1230 var length = TO_UINT32(array.length); |
| 1231 |
| 1232 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); | 1232 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); |
| 1233 var needs_wrapper = false; | 1233 var needs_wrapper = false; |
| 1234 if (IS_NULL(receiver)) { | 1234 if (IS_NULL(receiver)) { |
| 1235 if (%IsSloppyModeFunction(f)) receiver = UNDEFINED; | 1235 if (%IsSloppyModeFunction(f)) receiver = UNDEFINED; |
| 1236 } else if (!IS_UNDEFINED(receiver)) { | 1236 } else if (!IS_UNDEFINED(receiver)) { |
| 1237 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); | 1237 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); |
| 1238 } | 1238 } |
| 1239 | 1239 |
| 1240 var is_array = IS_ARRAY(array); | 1240 var is_array = IS_ARRAY(array); |
| 1241 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); | 1241 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); |
| 1242 for (var i = 0; i < length; i++) { | 1242 for (var i = 0; i < length; i++) { |
| 1243 if (HAS_INDEX(array, i, is_array)) { | 1243 if (HAS_INDEX(array, i, is_array)) { |
| 1244 var element = array[i]; | 1244 var element = array[i]; |
| 1245 // Prepare break slots for debugger step in. | 1245 // Prepare break slots for debugger step in. |
| 1246 if (stepping) %DebugPrepareStepInIfStepping(f); | 1246 if (stepping) %DebugPrepareStepInIfStepping(f); |
| 1247 var new_receiver = needs_wrapper ? $toObject(receiver) : receiver; | 1247 var new_receiver = needs_wrapper ? $toObject(receiver) : receiver; |
| 1248 if (%_CallFunction(new_receiver, element, i, array, f)) return true; | 1248 if (%_CallFunction(new_receiver, element, i, array, f)) return true; |
| 1249 } | 1249 } |
| 1250 } | 1250 } |
| 1251 return false; | 1251 return false; |
| 1252 } | 1252 } |
| 1253 | 1253 |
| 1254 | 1254 |
| 1255 // Executes the function once for each element present in the | |
| 1256 // array until it finds one where callback returns true. | |
| 1257 function ArraySome(f, receiver) { | |
| 1258 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.some"); | |
| 1259 | |
| 1260 // Pull out the length so that modifications to the length in the | |
| 1261 // loop will not affect the looping and side effects are visible. | |
| 1262 var array = $toObject(this); | |
| 1263 var length = TO_UINT32(array.length); | |
| 1264 return InnerArraySome(f, receiver, array, length); | |
| 1265 } | |
| 1266 | |
| 1267 | |
| 1268 function InnerArrayEvery(f, receiver, array, length) { | 1255 function InnerArrayEvery(f, receiver, array, length) { |
| 1269 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); | 1256 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); |
| 1270 var needs_wrapper = false; | 1257 var needs_wrapper = false; |
| 1271 if (IS_NULL(receiver)) { | 1258 if (IS_NULL(receiver)) { |
| 1272 if (%IsSloppyModeFunction(f)) receiver = UNDEFINED; | 1259 if (%IsSloppyModeFunction(f)) receiver = UNDEFINED; |
| 1273 } else if (!IS_UNDEFINED(receiver)) { | 1260 } else if (!IS_UNDEFINED(receiver)) { |
| 1274 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); | 1261 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); |
| 1275 } | 1262 } |
| 1276 | 1263 |
| 1277 var is_array = IS_ARRAY(array); | 1264 var is_array = IS_ARRAY(array); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1292 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.every"); | 1279 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.every"); |
| 1293 | 1280 |
| 1294 // Pull out the length so that modifications to the length in the | 1281 // Pull out the length so that modifications to the length in the |
| 1295 // loop will not affect the looping and side effects are visible. | 1282 // loop will not affect the looping and side effects are visible. |
| 1296 var array = $toObject(this); | 1283 var array = $toObject(this); |
| 1297 var length = TO_UINT32(array.length); | 1284 var length = TO_UINT32(array.length); |
| 1298 return InnerArrayEvery(f, receiver, array, length); | 1285 return InnerArrayEvery(f, receiver, array, length); |
| 1299 } | 1286 } |
| 1300 | 1287 |
| 1301 | 1288 |
| 1302 function InnerArrayMap(f, receiver, array, length) { | 1289 function ArrayMap(f, receiver) { |
| 1290 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.map"); |
| 1291 |
| 1292 // Pull out the length so that modifications to the length in the |
| 1293 // loop will not affect the looping and side effects are visible. |
| 1294 var array = $toObject(this); |
| 1295 var length = TO_UINT32(array.length); |
| 1296 |
| 1303 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); | 1297 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); |
| 1304 var needs_wrapper = false; | 1298 var needs_wrapper = false; |
| 1305 if (IS_NULL(receiver)) { | 1299 if (IS_NULL(receiver)) { |
| 1306 if (%IsSloppyModeFunction(f)) receiver = UNDEFINED; | 1300 if (%IsSloppyModeFunction(f)) receiver = UNDEFINED; |
| 1307 } else if (!IS_UNDEFINED(receiver)) { | 1301 } else if (!IS_UNDEFINED(receiver)) { |
| 1308 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); | 1302 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); |
| 1309 } | 1303 } |
| 1310 | 1304 |
| 1311 var result = new GlobalArray(); | 1305 var result = new GlobalArray(); |
| 1312 var accumulator = new InternalArray(length); | 1306 var accumulator = new InternalArray(length); |
| 1313 var is_array = IS_ARRAY(array); | 1307 var is_array = IS_ARRAY(array); |
| 1314 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); | 1308 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); |
| 1315 for (var i = 0; i < length; i++) { | 1309 for (var i = 0; i < length; i++) { |
| 1316 if (HAS_INDEX(array, i, is_array)) { | 1310 if (HAS_INDEX(array, i, is_array)) { |
| 1317 var element = array[i]; | 1311 var element = array[i]; |
| 1318 // Prepare break slots for debugger step in. | 1312 // Prepare break slots for debugger step in. |
| 1319 if (stepping) %DebugPrepareStepInIfStepping(f); | 1313 if (stepping) %DebugPrepareStepInIfStepping(f); |
| 1320 var new_receiver = needs_wrapper ? $toObject(receiver) : receiver; | 1314 var new_receiver = needs_wrapper ? $toObject(receiver) : receiver; |
| 1321 accumulator[i] = %_CallFunction(new_receiver, element, i, array, f); | 1315 accumulator[i] = %_CallFunction(new_receiver, element, i, array, f); |
| 1322 } | 1316 } |
| 1323 } | 1317 } |
| 1324 %MoveArrayContents(accumulator, result); | 1318 %MoveArrayContents(accumulator, result); |
| 1325 return result; | 1319 return result; |
| 1326 } | 1320 } |
| 1327 | 1321 |
| 1328 | 1322 |
| 1329 function ArrayMap(f, receiver) { | |
| 1330 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.map"); | |
| 1331 | |
| 1332 // Pull out the length so that modifications to the length in the | |
| 1333 // loop will not affect the looping and side effects are visible. | |
| 1334 var array = $toObject(this); | |
| 1335 var length = TO_UINT32(array.length); | |
| 1336 return InnerArrayMap(f, receiver, array, length); | |
| 1337 } | |
| 1338 | |
| 1339 | |
| 1340 function ArrayIndexOf(element, index) { | 1323 function ArrayIndexOf(element, index) { |
| 1341 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.indexOf"); | 1324 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.indexOf"); |
| 1342 | 1325 |
| 1343 var length = TO_UINT32(this.length); | 1326 var length = TO_UINT32(this.length); |
| 1344 if (length == 0) return -1; | 1327 if (length == 0) return -1; |
| 1345 if (IS_UNDEFINED(index)) { | 1328 if (IS_UNDEFINED(index)) { |
| 1346 index = 0; | 1329 index = 0; |
| 1347 } else { | 1330 } else { |
| 1348 index = TO_INTEGER(index); | 1331 index = TO_INTEGER(index); |
| 1349 // If index is negative, index from the end of the array. | 1332 // If index is negative, index from the end of the array. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1440 } | 1423 } |
| 1441 for (var i = max; i >= min; i--) { | 1424 for (var i = max; i >= min; i--) { |
| 1442 if (IS_UNDEFINED(this[i]) && i in this) { | 1425 if (IS_UNDEFINED(this[i]) && i in this) { |
| 1443 return i; | 1426 return i; |
| 1444 } | 1427 } |
| 1445 } | 1428 } |
| 1446 return -1; | 1429 return -1; |
| 1447 } | 1430 } |
| 1448 | 1431 |
| 1449 | 1432 |
| 1450 function InnerArrayReduce(callback, current, array, length, argumentsLength) { | 1433 function ArrayReduce(callback, current) { |
| 1434 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reduce"); |
| 1435 |
| 1436 // Pull out the length so that modifications to the length in the |
| 1437 // loop will not affect the looping and side effects are visible. |
| 1438 var array = $toObject(this); |
| 1439 var length = $toUint32(array.length); |
| 1440 |
| 1451 if (!IS_SPEC_FUNCTION(callback)) { | 1441 if (!IS_SPEC_FUNCTION(callback)) { |
| 1452 throw MakeTypeError(kCalledNonCallable, callback); | 1442 throw MakeTypeError(kCalledNonCallable, callback); |
| 1453 } | 1443 } |
| 1454 | 1444 |
| 1455 var is_array = IS_ARRAY(array); | 1445 var is_array = IS_ARRAY(array); |
| 1456 var i = 0; | 1446 var i = 0; |
| 1457 find_initial: if (argumentsLength < 2) { | 1447 find_initial: if (%_ArgumentsLength() < 2) { |
| 1458 for (; i < length; i++) { | 1448 for (; i < length; i++) { |
| 1459 if (HAS_INDEX(array, i, is_array)) { | 1449 if (HAS_INDEX(array, i, is_array)) { |
| 1460 current = array[i++]; | 1450 current = array[i++]; |
| 1461 break find_initial; | 1451 break find_initial; |
| 1462 } | 1452 } |
| 1463 } | 1453 } |
| 1464 throw MakeTypeError(kReduceNoInitial); | 1454 throw MakeTypeError(kReduceNoInitial); |
| 1465 } | 1455 } |
| 1466 | 1456 |
| 1467 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(callback); | 1457 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(callback); |
| 1468 for (; i < length; i++) { | 1458 for (; i < length; i++) { |
| 1469 if (HAS_INDEX(array, i, is_array)) { | 1459 if (HAS_INDEX(array, i, is_array)) { |
| 1470 var element = array[i]; | 1460 var element = array[i]; |
| 1471 // Prepare break slots for debugger step in. | 1461 // Prepare break slots for debugger step in. |
| 1472 if (stepping) %DebugPrepareStepInIfStepping(callback); | 1462 if (stepping) %DebugPrepareStepInIfStepping(callback); |
| 1473 current = %_CallFunction(UNDEFINED, current, element, i, array, callback); | 1463 current = %_CallFunction(UNDEFINED, current, element, i, array, callback); |
| 1474 } | 1464 } |
| 1475 } | 1465 } |
| 1476 return current; | 1466 return current; |
| 1477 } | 1467 } |
| 1478 | 1468 |
| 1479 | 1469 |
| 1480 function ArrayReduce(callback, current) { | 1470 function ArrayReduceRight(callback, current) { |
| 1481 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reduce"); | 1471 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reduceRight"); |
| 1482 | 1472 |
| 1483 // Pull out the length so that modifications to the length in the | 1473 // Pull out the length so that side effects are visible before the |
| 1484 // loop will not affect the looping and side effects are visible. | 1474 // callback function is checked. |
| 1485 var array = $toObject(this); | 1475 var array = $toObject(this); |
| 1486 var length = $toUint32(array.length); | 1476 var length = $toUint32(array.length); |
| 1487 return InnerArrayReduce(callback, current, array, length, | |
| 1488 %_ArgumentsLength()); | |
| 1489 } | |
| 1490 | 1477 |
| 1491 | |
| 1492 function InnerArrayReduceRight(callback, current, array, length, | |
| 1493 argumentsLength) { | |
| 1494 if (!IS_SPEC_FUNCTION(callback)) { | 1478 if (!IS_SPEC_FUNCTION(callback)) { |
| 1495 throw MakeTypeError(kCalledNonCallable, callback); | 1479 throw MakeTypeError(kCalledNonCallable, callback); |
| 1496 } | 1480 } |
| 1497 | 1481 |
| 1498 var is_array = IS_ARRAY(array); | 1482 var is_array = IS_ARRAY(array); |
| 1499 var i = length - 1; | 1483 var i = length - 1; |
| 1500 find_initial: if (argumentsLength < 2) { | 1484 find_initial: if (%_ArgumentsLength() < 2) { |
| 1501 for (; i >= 0; i--) { | 1485 for (; i >= 0; i--) { |
| 1502 if (HAS_INDEX(array, i, is_array)) { | 1486 if (HAS_INDEX(array, i, is_array)) { |
| 1503 current = array[i--]; | 1487 current = array[i--]; |
| 1504 break find_initial; | 1488 break find_initial; |
| 1505 } | 1489 } |
| 1506 } | 1490 } |
| 1507 throw MakeTypeError(kReduceNoInitial); | 1491 throw MakeTypeError(kReduceNoInitial); |
| 1508 } | 1492 } |
| 1509 | 1493 |
| 1510 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(callback); | 1494 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(callback); |
| 1511 for (; i >= 0; i--) { | 1495 for (; i >= 0; i--) { |
| 1512 if (HAS_INDEX(array, i, is_array)) { | 1496 if (HAS_INDEX(array, i, is_array)) { |
| 1513 var element = array[i]; | 1497 var element = array[i]; |
| 1514 // Prepare break slots for debugger step in. | 1498 // Prepare break slots for debugger step in. |
| 1515 if (stepping) %DebugPrepareStepInIfStepping(callback); | 1499 if (stepping) %DebugPrepareStepInIfStepping(callback); |
| 1516 current = %_CallFunction(UNDEFINED, current, element, i, array, callback); | 1500 current = %_CallFunction(UNDEFINED, current, element, i, array, callback); |
| 1517 } | 1501 } |
| 1518 } | 1502 } |
| 1519 return current; | 1503 return current; |
| 1520 } | 1504 } |
| 1521 | 1505 |
| 1522 | |
| 1523 function ArrayReduceRight(callback, current) { | |
| 1524 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reduceRight"); | |
| 1525 | |
| 1526 // Pull out the length so that side effects are visible before the | |
| 1527 // callback function is checked. | |
| 1528 var array = $toObject(this); | |
| 1529 var length = $toUint32(array.length); | |
| 1530 return InnerArrayReduceRight(callback, current, array, length, | |
| 1531 %_ArgumentsLength()); | |
| 1532 } | |
| 1533 | |
| 1534 // ES5, 15.4.3.2 | 1506 // ES5, 15.4.3.2 |
| 1535 function ArrayIsArray(obj) { | 1507 function ArrayIsArray(obj) { |
| 1536 return IS_ARRAY(obj); | 1508 return IS_ARRAY(obj); |
| 1537 } | 1509 } |
| 1538 | 1510 |
| 1539 | 1511 |
| 1540 // ------------------------------------------------------------------- | 1512 // ------------------------------------------------------------------- |
| 1541 | 1513 |
| 1542 // Set up non-enumerable constructor property on the Array.prototype | 1514 // Set up non-enumerable constructor property on the Array.prototype |
| 1543 // object. | 1515 // object. |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1628 | 1600 |
| 1629 $arrayConcat = ArrayConcatJS; | 1601 $arrayConcat = ArrayConcatJS; |
| 1630 $arrayJoin = ArrayJoin; | 1602 $arrayJoin = ArrayJoin; |
| 1631 $arrayPush = ArrayPush; | 1603 $arrayPush = ArrayPush; |
| 1632 $arrayPop = ArrayPop; | 1604 $arrayPop = ArrayPop; |
| 1633 $arrayShift = ArrayShift; | 1605 $arrayShift = ArrayShift; |
| 1634 $arraySlice = ArraySlice; | 1606 $arraySlice = ArraySlice; |
| 1635 $arraySplice = ArraySplice; | 1607 $arraySplice = ArraySplice; |
| 1636 $arrayUnshift = ArrayUnshift; | 1608 $arrayUnshift = ArrayUnshift; |
| 1637 | 1609 |
| 1610 $innerArrayForEach = InnerArrayForEach; |
| 1638 $innerArrayEvery = InnerArrayEvery; | 1611 $innerArrayEvery = InnerArrayEvery; |
| 1639 $innerArrayFilter = InnerArrayFilter; | |
| 1640 $innerArrayForEach = InnerArrayForEach; | |
| 1641 $innerArrayMap = InnerArrayMap; | |
| 1642 $innerArrayReduce = InnerArrayReduce; | |
| 1643 $innerArrayReduceRight = InnerArrayReduceRight; | |
| 1644 $innerArraySome = InnerArraySome; | |
| 1645 | 1612 |
| 1646 }); | 1613 }); |
| OLD | NEW |