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