| 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 1358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1369 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.findIndex"); | 1369 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.findIndex"); |
| 1370 | 1370 |
| 1371 var array = TO_OBJECT(this); | 1371 var array = TO_OBJECT(this); |
| 1372 var length = TO_INTEGER(array.length); | 1372 var length = TO_INTEGER(array.length); |
| 1373 | 1373 |
| 1374 return InnerArrayFindIndex(predicate, thisArg, array, length); | 1374 return InnerArrayFindIndex(predicate, thisArg, array, length); |
| 1375 } | 1375 } |
| 1376 | 1376 |
| 1377 | 1377 |
| 1378 // ES6, draft 04-05-14, section 22.1.3.6 | 1378 // ES6, draft 04-05-14, section 22.1.3.6 |
| 1379 function InnerArrayFill(value, start, end, array, length) { | 1379 function ArrayFill(value, start, end) { |
| 1380 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.fill"); |
| 1381 |
| 1382 var array = TO_OBJECT(this); |
| 1383 var length = TO_LENGTH(array.length); |
| 1384 |
| 1380 var i = IS_UNDEFINED(start) ? 0 : TO_INTEGER(start); | 1385 var i = IS_UNDEFINED(start) ? 0 : TO_INTEGER(start); |
| 1381 var end = IS_UNDEFINED(end) ? length : TO_INTEGER(end); | 1386 var end = IS_UNDEFINED(end) ? length : TO_INTEGER(end); |
| 1382 | 1387 |
| 1383 if (i < 0) { | 1388 if (i < 0) { |
| 1384 i += length; | 1389 i += length; |
| 1385 if (i < 0) i = 0; | 1390 if (i < 0) i = 0; |
| 1386 } else { | 1391 } else { |
| 1387 if (i > length) i = length; | 1392 if (i > length) i = length; |
| 1388 } | 1393 } |
| 1389 | 1394 |
| 1390 if (end < 0) { | 1395 if (end < 0) { |
| 1391 end += length; | 1396 end += length; |
| 1392 if (end < 0) end = 0; | 1397 if (end < 0) end = 0; |
| 1393 } else { | 1398 } else { |
| 1394 if (end > length) end = length; | 1399 if (end > length) end = length; |
| 1395 } | 1400 } |
| 1396 | 1401 |
| 1397 if ((end - i) > 0 && %object_is_frozen(array)) { | 1402 if ((end - i) > 0 && %object_is_frozen(array)) { |
| 1398 throw %make_type_error(kArrayFunctionsOnFrozen); | 1403 throw %make_type_error(kArrayFunctionsOnFrozen); |
| 1399 } | 1404 } |
| 1400 | 1405 |
| 1401 for (; i < end; i++) | 1406 for (; i < end; i++) |
| 1402 array[i] = value; | 1407 array[i] = value; |
| 1403 return array; | 1408 return array; |
| 1404 } | 1409 } |
| 1405 | 1410 |
| 1406 | 1411 |
| 1407 // ES6, draft 04-05-14, section 22.1.3.6 | |
| 1408 function ArrayFill(value, start, end) { | |
| 1409 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.fill"); | |
| 1410 | |
| 1411 var array = TO_OBJECT(this); | |
| 1412 var length = TO_LENGTH(array.length); | |
| 1413 | |
| 1414 return InnerArrayFill(value, start, end, array, length); | |
| 1415 } | |
| 1416 | |
| 1417 | |
| 1418 // ES6, draft 10-14-14, section 22.1.2.1 | 1412 // ES6, draft 10-14-14, section 22.1.2.1 |
| 1419 function ArrayFrom(arrayLike, mapfn, receiver) { | 1413 function ArrayFrom(arrayLike, mapfn, receiver) { |
| 1420 var items = TO_OBJECT(arrayLike); | 1414 var items = TO_OBJECT(arrayLike); |
| 1421 var mapping = !IS_UNDEFINED(mapfn); | 1415 var mapping = !IS_UNDEFINED(mapfn); |
| 1422 | 1416 |
| 1423 if (mapping) { | 1417 if (mapping) { |
| 1424 if (!IS_CALLABLE(mapfn)) { | 1418 if (!IS_CALLABLE(mapfn)) { |
| 1425 throw %make_type_error(kCalledNonCallable, mapfn); | 1419 throw %make_type_error(kCalledNonCallable, mapfn); |
| 1426 } | 1420 } |
| 1427 } | 1421 } |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1611 // ------------------------------------------------------------------- | 1605 // ------------------------------------------------------------------- |
| 1612 // Exports | 1606 // Exports |
| 1613 | 1607 |
| 1614 utils.Export(function(to) { | 1608 utils.Export(function(to) { |
| 1615 to.ArrayFrom = ArrayFrom; | 1609 to.ArrayFrom = ArrayFrom; |
| 1616 to.ArrayJoin = ArrayJoin; | 1610 to.ArrayJoin = ArrayJoin; |
| 1617 to.ArrayPush = ArrayPush; | 1611 to.ArrayPush = ArrayPush; |
| 1618 to.ArrayToString = ArrayToString; | 1612 to.ArrayToString = ArrayToString; |
| 1619 to.ArrayValues = IteratorFunctions.values, | 1613 to.ArrayValues = IteratorFunctions.values, |
| 1620 to.InnerArrayEvery = InnerArrayEvery; | 1614 to.InnerArrayEvery = InnerArrayEvery; |
| 1621 to.InnerArrayFill = InnerArrayFill; | |
| 1622 to.InnerArrayFilter = InnerArrayFilter; | 1615 to.InnerArrayFilter = InnerArrayFilter; |
| 1623 to.InnerArrayFind = InnerArrayFind; | 1616 to.InnerArrayFind = InnerArrayFind; |
| 1624 to.InnerArrayFindIndex = InnerArrayFindIndex; | 1617 to.InnerArrayFindIndex = InnerArrayFindIndex; |
| 1625 to.InnerArrayForEach = InnerArrayForEach; | 1618 to.InnerArrayForEach = InnerArrayForEach; |
| 1626 to.InnerArrayJoin = InnerArrayJoin; | 1619 to.InnerArrayJoin = InnerArrayJoin; |
| 1627 to.InnerArrayReduce = InnerArrayReduce; | 1620 to.InnerArrayReduce = InnerArrayReduce; |
| 1628 to.InnerArrayReduceRight = InnerArrayReduceRight; | 1621 to.InnerArrayReduceRight = InnerArrayReduceRight; |
| 1629 to.InnerArraySome = InnerArraySome; | 1622 to.InnerArraySome = InnerArraySome; |
| 1630 to.InnerArraySort = InnerArraySort; | 1623 to.InnerArraySort = InnerArraySort; |
| 1631 to.InnerArrayToLocaleString = InnerArrayToLocaleString; | 1624 to.InnerArrayToLocaleString = InnerArrayToLocaleString; |
| 1632 to.PackedArrayReverse = PackedArrayReverse; | 1625 to.PackedArrayReverse = PackedArrayReverse; |
| 1633 }); | 1626 }); |
| 1634 | 1627 |
| 1635 %InstallToContext([ | 1628 %InstallToContext([ |
| 1636 "array_entries_iterator", IteratorFunctions.entries, | 1629 "array_entries_iterator", IteratorFunctions.entries, |
| 1637 "array_for_each_iterator", IteratorFunctions.forEach, | 1630 "array_for_each_iterator", IteratorFunctions.forEach, |
| 1638 "array_keys_iterator", IteratorFunctions.keys, | 1631 "array_keys_iterator", IteratorFunctions.keys, |
| 1639 "array_pop", ArrayPop, | 1632 "array_pop", ArrayPop, |
| 1640 "array_push", ArrayPush, | 1633 "array_push", ArrayPush, |
| 1641 "array_shift", ArrayShift, | 1634 "array_shift", ArrayShift, |
| 1642 "array_splice", ArraySplice, | 1635 "array_splice", ArraySplice, |
| 1643 "array_slice", ArraySlice, | 1636 "array_slice", ArraySlice, |
| 1644 "array_unshift", ArrayUnshift, | 1637 "array_unshift", ArrayUnshift, |
| 1645 "array_values_iterator", IteratorFunctions.values, | 1638 "array_values_iterator", IteratorFunctions.values, |
| 1646 ]); | 1639 ]); |
| 1647 | 1640 |
| 1648 }); | 1641 }); |
| OLD | NEW |