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) { |
| 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 } |
| 1186 $innerArrayFilter = InnerArrayFilter; | |
| 1187 | |
| 1188 function ArrayFilter(f, receiver) { | |
| 1189 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.filter"); | |
| 1190 | |
| 1191 // Pull out the length so that modifications to the length in the | |
| 1192 // loop will not affect the looping and side effects are visible. | |
| 1193 var array = $toObject(this); | |
| 1194 var length = $toUint32(array.length); | |
| 1195 | |
| 1196 return InnerArrayFilter(f, receiver, array, length); | |
| 1197 } | |
| 1188 | 1198 |
| 1189 function InnerArrayForEach(f, receiver, array, length) { | 1199 function InnerArrayForEach(f, receiver, array, length) { |
| 1190 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); | 1200 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); |
| 1191 var needs_wrapper = false; | 1201 var needs_wrapper = false; |
| 1192 if (IS_NULL(receiver)) { | 1202 if (IS_NULL(receiver)) { |
| 1193 if (%IsSloppyModeFunction(f)) receiver = UNDEFINED; | 1203 if (%IsSloppyModeFunction(f)) receiver = UNDEFINED; |
| 1194 } else if (!IS_UNDEFINED(receiver)) { | 1204 } else if (!IS_UNDEFINED(receiver)) { |
| 1195 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); | 1205 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); |
| 1196 } | 1206 } |
| 1197 | 1207 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 1212 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.forEach"); | 1222 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.forEach"); |
| 1213 | 1223 |
| 1214 // Pull out the length so that modifications to the length in the | 1224 // Pull out the length so that modifications to the length in the |
| 1215 // loop will not affect the looping and side effects are visible. | 1225 // loop will not affect the looping and side effects are visible. |
| 1216 var array = $toObject(this); | 1226 var array = $toObject(this); |
| 1217 var length = TO_UINT32(array.length); | 1227 var length = TO_UINT32(array.length); |
| 1218 InnerArrayForEach(f, receiver, array, length); | 1228 InnerArrayForEach(f, receiver, array, length); |
| 1219 } | 1229 } |
| 1220 | 1230 |
| 1221 | 1231 |
| 1222 // Executes the function once for each element present in the | 1232 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); | 1233 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); |
| 1233 var needs_wrapper = false; | 1234 var needs_wrapper = false; |
| 1234 if (IS_NULL(receiver)) { | 1235 if (IS_NULL(receiver)) { |
| 1235 if (%IsSloppyModeFunction(f)) receiver = UNDEFINED; | 1236 if (%IsSloppyModeFunction(f)) receiver = UNDEFINED; |
| 1236 } else if (!IS_UNDEFINED(receiver)) { | 1237 } else if (!IS_UNDEFINED(receiver)) { |
| 1237 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); | 1238 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); |
| 1238 } | 1239 } |
| 1239 | 1240 |
| 1240 var is_array = IS_ARRAY(array); | 1241 var is_array = IS_ARRAY(array); |
| 1241 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); | 1242 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); |
| 1242 for (var i = 0; i < length; i++) { | 1243 for (var i = 0; i < length; i++) { |
| 1243 if (HAS_INDEX(array, i, is_array)) { | 1244 if (HAS_INDEX(array, i, is_array)) { |
| 1244 var element = array[i]; | 1245 var element = array[i]; |
| 1245 // Prepare break slots for debugger step in. | 1246 // Prepare break slots for debugger step in. |
| 1246 if (stepping) %DebugPrepareStepInIfStepping(f); | 1247 if (stepping) %DebugPrepareStepInIfStepping(f); |
| 1247 var new_receiver = needs_wrapper ? $toObject(receiver) : receiver; | 1248 var new_receiver = needs_wrapper ? $toObject(receiver) : receiver; |
| 1248 if (%_CallFunction(new_receiver, element, i, array, f)) return true; | 1249 if (%_CallFunction(new_receiver, element, i, array, f)) return true; |
| 1249 } | 1250 } |
| 1250 } | 1251 } |
| 1251 return false; | 1252 return false; |
| 1252 } | 1253 } |
| 1254 $innerArraySome = InnerArraySome; | |
|
arv (Not doing code reviews)
2015/05/18 22:54:23
Can you put all of these at the end?
dehrenberg
2015/05/19 00:13:45
Done.
| |
| 1255 | |
| 1256 | |
| 1257 // Executes the function once for each element present in the | |
| 1258 // array until it finds one where callback returns true. | |
| 1259 function ArraySome(f, receiver) { | |
| 1260 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.some"); | |
| 1261 | |
| 1262 // Pull out the length so that modifications to the length in the | |
| 1263 // loop will not affect the looping and side effects are visible. | |
| 1264 var array = $toObject(this); | |
| 1265 var length = TO_UINT32(array.length); | |
| 1266 return InnerArraySome(f, receiver, array, length); | |
| 1267 } | |
| 1253 | 1268 |
| 1254 | 1269 |
| 1255 function InnerArrayEvery(f, receiver, array, length) { | 1270 function InnerArrayEvery(f, receiver, array, length) { |
| 1256 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); | 1271 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); |
| 1257 var needs_wrapper = false; | 1272 var needs_wrapper = false; |
| 1258 if (IS_NULL(receiver)) { | 1273 if (IS_NULL(receiver)) { |
| 1259 if (%IsSloppyModeFunction(f)) receiver = UNDEFINED; | 1274 if (%IsSloppyModeFunction(f)) receiver = UNDEFINED; |
| 1260 } else if (!IS_UNDEFINED(receiver)) { | 1275 } else if (!IS_UNDEFINED(receiver)) { |
| 1261 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); | 1276 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); |
| 1262 } | 1277 } |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1279 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.every"); | 1294 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.every"); |
| 1280 | 1295 |
| 1281 // Pull out the length so that modifications to the length in the | 1296 // Pull out the length so that modifications to the length in the |
| 1282 // loop will not affect the looping and side effects are visible. | 1297 // loop will not affect the looping and side effects are visible. |
| 1283 var array = $toObject(this); | 1298 var array = $toObject(this); |
| 1284 var length = TO_UINT32(array.length); | 1299 var length = TO_UINT32(array.length); |
| 1285 return InnerArrayEvery(f, receiver, array, length); | 1300 return InnerArrayEvery(f, receiver, array, length); |
| 1286 } | 1301 } |
| 1287 | 1302 |
| 1288 | 1303 |
| 1289 function ArrayMap(f, receiver) { | 1304 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); | 1305 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); |
| 1298 var needs_wrapper = false; | 1306 var needs_wrapper = false; |
| 1299 if (IS_NULL(receiver)) { | 1307 if (IS_NULL(receiver)) { |
| 1300 if (%IsSloppyModeFunction(f)) receiver = UNDEFINED; | 1308 if (%IsSloppyModeFunction(f)) receiver = UNDEFINED; |
| 1301 } else if (!IS_UNDEFINED(receiver)) { | 1309 } else if (!IS_UNDEFINED(receiver)) { |
| 1302 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); | 1310 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); |
| 1303 } | 1311 } |
| 1304 | 1312 |
| 1305 var result = new GlobalArray(); | 1313 var result = new GlobalArray(); |
| 1306 var accumulator = new InternalArray(length); | 1314 var accumulator = new InternalArray(length); |
| 1307 var is_array = IS_ARRAY(array); | 1315 var is_array = IS_ARRAY(array); |
| 1308 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); | 1316 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); |
| 1309 for (var i = 0; i < length; i++) { | 1317 for (var i = 0; i < length; i++) { |
| 1310 if (HAS_INDEX(array, i, is_array)) { | 1318 if (HAS_INDEX(array, i, is_array)) { |
| 1311 var element = array[i]; | 1319 var element = array[i]; |
| 1312 // Prepare break slots for debugger step in. | 1320 // Prepare break slots for debugger step in. |
| 1313 if (stepping) %DebugPrepareStepInIfStepping(f); | 1321 if (stepping) %DebugPrepareStepInIfStepping(f); |
| 1314 var new_receiver = needs_wrapper ? $toObject(receiver) : receiver; | 1322 var new_receiver = needs_wrapper ? $toObject(receiver) : receiver; |
| 1315 accumulator[i] = %_CallFunction(new_receiver, element, i, array, f); | 1323 accumulator[i] = %_CallFunction(new_receiver, element, i, array, f); |
| 1316 } | 1324 } |
| 1317 } | 1325 } |
| 1318 %MoveArrayContents(accumulator, result); | 1326 %MoveArrayContents(accumulator, result); |
| 1319 return result; | 1327 return result; |
| 1320 } | 1328 } |
| 1329 $innerArrayMap = InnerArrayMap; | |
| 1330 | |
| 1331 | |
| 1332 function ArrayMap(f, receiver) { | |
| 1333 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.map"); | |
| 1334 | |
| 1335 // Pull out the length so that modifications to the length in the | |
| 1336 // loop will not affect the looping and side effects are visible. | |
| 1337 var array = $toObject(this); | |
| 1338 var length = TO_UINT32(array.length); | |
| 1339 return InnerArrayMap(f, receiver, array, length); | |
| 1340 } | |
| 1321 | 1341 |
| 1322 | 1342 |
| 1323 function ArrayIndexOf(element, index) { | 1343 function ArrayIndexOf(element, index) { |
| 1324 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.indexOf"); | 1344 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.indexOf"); |
| 1325 | 1345 |
| 1326 var length = TO_UINT32(this.length); | 1346 var length = TO_UINT32(this.length); |
| 1327 if (length == 0) return -1; | 1347 if (length == 0) return -1; |
| 1328 if (IS_UNDEFINED(index)) { | 1348 if (IS_UNDEFINED(index)) { |
| 1329 index = 0; | 1349 index = 0; |
| 1330 } else { | 1350 } else { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1423 } | 1443 } |
| 1424 for (var i = max; i >= min; i--) { | 1444 for (var i = max; i >= min; i--) { |
| 1425 if (IS_UNDEFINED(this[i]) && i in this) { | 1445 if (IS_UNDEFINED(this[i]) && i in this) { |
| 1426 return i; | 1446 return i; |
| 1427 } | 1447 } |
| 1428 } | 1448 } |
| 1429 return -1; | 1449 return -1; |
| 1430 } | 1450 } |
| 1431 | 1451 |
| 1432 | 1452 |
| 1433 function ArrayReduce(callback, current) { | 1453 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)) { | 1454 if (!IS_SPEC_FUNCTION(callback)) { |
| 1442 throw MakeTypeError(kCalledNonCallable, callback); | 1455 throw MakeTypeError(kCalledNonCallable, callback); |
| 1443 } | 1456 } |
| 1444 | 1457 |
| 1445 var is_array = IS_ARRAY(array); | 1458 var is_array = IS_ARRAY(array); |
| 1446 var i = 0; | 1459 var i = 0; |
| 1447 find_initial: if (%_ArgumentsLength() < 2) { | 1460 find_initial: if (argumentsLength < 2) { |
| 1448 for (; i < length; i++) { | 1461 for (; i < length; i++) { |
| 1449 if (HAS_INDEX(array, i, is_array)) { | 1462 if (HAS_INDEX(array, i, is_array)) { |
| 1450 current = array[i++]; | 1463 current = array[i++]; |
| 1451 break find_initial; | 1464 break find_initial; |
| 1452 } | 1465 } |
| 1453 } | 1466 } |
| 1454 throw MakeTypeError(kReduceNoInitial); | 1467 throw MakeTypeError(kReduceNoInitial); |
| 1455 } | 1468 } |
| 1456 | 1469 |
| 1457 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(callback); | 1470 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(callback); |
| 1458 for (; i < length; i++) { | 1471 for (; i < length; i++) { |
| 1459 if (HAS_INDEX(array, i, is_array)) { | 1472 if (HAS_INDEX(array, i, is_array)) { |
| 1460 var element = array[i]; | 1473 var element = array[i]; |
| 1461 // Prepare break slots for debugger step in. | 1474 // Prepare break slots for debugger step in. |
| 1462 if (stepping) %DebugPrepareStepInIfStepping(callback); | 1475 if (stepping) %DebugPrepareStepInIfStepping(callback); |
| 1463 current = %_CallFunction(UNDEFINED, current, element, i, array, callback); | 1476 current = %_CallFunction(UNDEFINED, current, element, i, array, callback); |
| 1464 } | 1477 } |
| 1465 } | 1478 } |
| 1466 return current; | 1479 return current; |
| 1467 } | 1480 } |
| 1481 $innerArrayReduce = InnerArrayReduce; | |
| 1468 | 1482 |
| 1469 | 1483 |
| 1470 function ArrayReduceRight(callback, current) { | 1484 function ArrayReduce(callback, current) { |
| 1471 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reduceRight"); | 1485 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reduce"); |
| 1472 | 1486 |
| 1473 // Pull out the length so that side effects are visible before the | 1487 // Pull out the length so that modifications to the length in the |
| 1474 // callback function is checked. | 1488 // loop will not affect the looping and side effects are visible. |
| 1475 var array = $toObject(this); | 1489 var array = $toObject(this); |
| 1476 var length = $toUint32(array.length); | 1490 var length = $toUint32(array.length); |
| 1491 return InnerArrayReduce(callback, current, array, length, | |
| 1492 %_ArgumentsLength()); | |
| 1493 } | |
| 1477 | 1494 |
| 1495 | |
| 1496 function InnerArrayReduceRight(callback, current, array, length, | |
| 1497 argumentsLength) { | |
| 1478 if (!IS_SPEC_FUNCTION(callback)) { | 1498 if (!IS_SPEC_FUNCTION(callback)) { |
| 1479 throw MakeTypeError(kCalledNonCallable, callback); | 1499 throw MakeTypeError(kCalledNonCallable, callback); |
| 1480 } | 1500 } |
| 1481 | 1501 |
| 1482 var is_array = IS_ARRAY(array); | 1502 var is_array = IS_ARRAY(array); |
| 1483 var i = length - 1; | 1503 var i = length - 1; |
| 1484 find_initial: if (%_ArgumentsLength() < 2) { | 1504 find_initial: if (argumentsLength < 2) { |
| 1485 for (; i >= 0; i--) { | 1505 for (; i >= 0; i--) { |
| 1486 if (HAS_INDEX(array, i, is_array)) { | 1506 if (HAS_INDEX(array, i, is_array)) { |
| 1487 current = array[i--]; | 1507 current = array[i--]; |
| 1488 break find_initial; | 1508 break find_initial; |
| 1489 } | 1509 } |
| 1490 } | 1510 } |
| 1491 throw MakeTypeError(kReduceNoInitial); | 1511 throw MakeTypeError(kReduceNoInitial); |
| 1492 } | 1512 } |
| 1493 | 1513 |
| 1494 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(callback); | 1514 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(callback); |
| 1495 for (; i >= 0; i--) { | 1515 for (; i >= 0; i--) { |
| 1496 if (HAS_INDEX(array, i, is_array)) { | 1516 if (HAS_INDEX(array, i, is_array)) { |
| 1497 var element = array[i]; | 1517 var element = array[i]; |
| 1498 // Prepare break slots for debugger step in. | 1518 // Prepare break slots for debugger step in. |
| 1499 if (stepping) %DebugPrepareStepInIfStepping(callback); | 1519 if (stepping) %DebugPrepareStepInIfStepping(callback); |
| 1500 current = %_CallFunction(UNDEFINED, current, element, i, array, callback); | 1520 current = %_CallFunction(UNDEFINED, current, element, i, array, callback); |
| 1501 } | 1521 } |
| 1502 } | 1522 } |
| 1503 return current; | 1523 return current; |
| 1504 } | 1524 } |
| 1525 $innerArrayReduceRight = InnerArrayReduceRight; | |
| 1526 | |
| 1527 | |
| 1528 function ArrayReduceRight(callback, current) { | |
| 1529 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reduceRight"); | |
| 1530 | |
| 1531 // Pull out the length so that side effects are visible before the | |
| 1532 // callback function is checked. | |
| 1533 var array = $toObject(this); | |
| 1534 var length = $toUint32(array.length); | |
| 1535 return InnerArrayReduceRight(callback, current, array, length, | |
| 1536 %_ArgumentsLength()); | |
| 1537 } | |
| 1505 | 1538 |
| 1506 // ES5, 15.4.3.2 | 1539 // ES5, 15.4.3.2 |
| 1507 function ArrayIsArray(obj) { | 1540 function ArrayIsArray(obj) { |
| 1508 return IS_ARRAY(obj); | 1541 return IS_ARRAY(obj); |
| 1509 } | 1542 } |
| 1510 | 1543 |
| 1511 | 1544 |
| 1512 // ------------------------------------------------------------------- | 1545 // ------------------------------------------------------------------- |
| 1513 | 1546 |
| 1514 // Set up non-enumerable constructor property on the Array.prototype | 1547 // Set up non-enumerable constructor property on the Array.prototype |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1602 $arrayJoin = ArrayJoin; | 1635 $arrayJoin = ArrayJoin; |
| 1603 $arrayPush = ArrayPush; | 1636 $arrayPush = ArrayPush; |
| 1604 $arrayPop = ArrayPop; | 1637 $arrayPop = ArrayPop; |
| 1605 $arrayShift = ArrayShift; | 1638 $arrayShift = ArrayShift; |
| 1606 $arraySlice = ArraySlice; | 1639 $arraySlice = ArraySlice; |
| 1607 $arraySplice = ArraySplice; | 1640 $arraySplice = ArraySplice; |
| 1608 $arrayUnshift = ArrayUnshift; | 1641 $arrayUnshift = ArrayUnshift; |
| 1609 | 1642 |
| 1610 $innerArrayForEach = InnerArrayForEach; | 1643 $innerArrayForEach = InnerArrayForEach; |
| 1611 $innerArrayEvery = InnerArrayEvery; | 1644 $innerArrayEvery = InnerArrayEvery; |
| 1612 | 1645 |
|
arv (Not doing code reviews)
2015/05/18 22:54:23
should go here
dehrenberg
2015/05/19 00:13:45
Done.
| |
| 1613 }); | 1646 }); |
| OLD | NEW |