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 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1263 | 1263 |
1264 // Pull out the length so that side effects are visible before the | 1264 // Pull out the length so that side effects are visible before the |
1265 // callback function is checked. | 1265 // callback function is checked. |
1266 var array = TO_OBJECT(this); | 1266 var array = TO_OBJECT(this); |
1267 var length = TO_LENGTH(array.length); | 1267 var length = TO_LENGTH(array.length); |
1268 return InnerArrayReduceRight(callback, current, array, length, | 1268 return InnerArrayReduceRight(callback, current, array, length, |
1269 arguments.length); | 1269 arguments.length); |
1270 } | 1270 } |
1271 | 1271 |
1272 | 1272 |
1273 function InnerArrayCopyWithin(target, start, end, array, length) { | 1273 // ES6 draft 03-17-15, section 22.1.3.3 |
| 1274 function ArrayCopyWithin(target, start, end) { |
| 1275 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.copyWithin"); |
| 1276 |
| 1277 var array = TO_OBJECT(this); |
| 1278 var length = TO_LENGTH(array.length); |
| 1279 |
1274 target = TO_INTEGER(target); | 1280 target = TO_INTEGER(target); |
1275 var to; | 1281 var to; |
1276 if (target < 0) { | 1282 if (target < 0) { |
1277 to = MaxSimple(length + target, 0); | 1283 to = MaxSimple(length + target, 0); |
1278 } else { | 1284 } else { |
1279 to = MinSimple(target, length); | 1285 to = MinSimple(target, length); |
1280 } | 1286 } |
1281 | 1287 |
1282 start = TO_INTEGER(start); | 1288 start = TO_INTEGER(start); |
1283 var from; | 1289 var from; |
(...skipping 27 matching lines...) Expand all Loading... |
1311 } | 1317 } |
1312 from = from + direction; | 1318 from = from + direction; |
1313 to = to + direction; | 1319 to = to + direction; |
1314 count--; | 1320 count--; |
1315 } | 1321 } |
1316 | 1322 |
1317 return array; | 1323 return array; |
1318 } | 1324 } |
1319 | 1325 |
1320 | 1326 |
1321 // ES6 draft 03-17-15, section 22.1.3.3 | |
1322 function ArrayCopyWithin(target, start, end) { | |
1323 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.copyWithin"); | |
1324 | |
1325 var array = TO_OBJECT(this); | |
1326 var length = TO_LENGTH(array.length); | |
1327 | |
1328 return InnerArrayCopyWithin(target, start, end, array, length); | |
1329 } | |
1330 | |
1331 | |
1332 function InnerArrayFind(predicate, thisArg, array, length) { | 1327 function InnerArrayFind(predicate, thisArg, array, length) { |
1333 if (!IS_CALLABLE(predicate)) { | 1328 if (!IS_CALLABLE(predicate)) { |
1334 throw %make_type_error(kCalledNonCallable, predicate); | 1329 throw %make_type_error(kCalledNonCallable, predicate); |
1335 } | 1330 } |
1336 | 1331 |
1337 for (var i = 0; i < length; i++) { | 1332 for (var i = 0; i < length; i++) { |
1338 var element = array[i]; | 1333 var element = array[i]; |
1339 if (%_Call(predicate, thisArg, element, i, array)) { | 1334 if (%_Call(predicate, thisArg, element, i, array)) { |
1340 return element; | 1335 return element; |
1341 } | 1336 } |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1608 | 1603 |
1609 // ------------------------------------------------------------------- | 1604 // ------------------------------------------------------------------- |
1610 // Exports | 1605 // Exports |
1611 | 1606 |
1612 utils.Export(function(to) { | 1607 utils.Export(function(to) { |
1613 to.ArrayFrom = ArrayFrom; | 1608 to.ArrayFrom = ArrayFrom; |
1614 to.ArrayJoin = ArrayJoin; | 1609 to.ArrayJoin = ArrayJoin; |
1615 to.ArrayPush = ArrayPush; | 1610 to.ArrayPush = ArrayPush; |
1616 to.ArrayToString = ArrayToString; | 1611 to.ArrayToString = ArrayToString; |
1617 to.ArrayValues = ArrayValues; | 1612 to.ArrayValues = ArrayValues; |
1618 to.InnerArrayCopyWithin = InnerArrayCopyWithin; | |
1619 to.InnerArrayEvery = InnerArrayEvery; | 1613 to.InnerArrayEvery = InnerArrayEvery; |
1620 to.InnerArrayFill = InnerArrayFill; | 1614 to.InnerArrayFill = InnerArrayFill; |
1621 to.InnerArrayFilter = InnerArrayFilter; | 1615 to.InnerArrayFilter = InnerArrayFilter; |
1622 to.InnerArrayFind = InnerArrayFind; | 1616 to.InnerArrayFind = InnerArrayFind; |
1623 to.InnerArrayFindIndex = InnerArrayFindIndex; | 1617 to.InnerArrayFindIndex = InnerArrayFindIndex; |
1624 to.InnerArrayForEach = InnerArrayForEach; | 1618 to.InnerArrayForEach = InnerArrayForEach; |
1625 to.InnerArrayJoin = InnerArrayJoin; | 1619 to.InnerArrayJoin = InnerArrayJoin; |
1626 to.InnerArrayLastIndexOf = InnerArrayLastIndexOf; | 1620 to.InnerArrayLastIndexOf = InnerArrayLastIndexOf; |
1627 to.InnerArrayReduce = InnerArrayReduce; | 1621 to.InnerArrayReduce = InnerArrayReduce; |
1628 to.InnerArrayReduceRight = InnerArrayReduceRight; | 1622 to.InnerArrayReduceRight = InnerArrayReduceRight; |
1629 to.InnerArraySome = InnerArraySome; | 1623 to.InnerArraySome = InnerArraySome; |
1630 to.InnerArraySort = InnerArraySort; | 1624 to.InnerArraySort = InnerArraySort; |
1631 to.InnerArrayToLocaleString = InnerArrayToLocaleString; | 1625 to.InnerArrayToLocaleString = InnerArrayToLocaleString; |
1632 to.PackedArrayReverse = PackedArrayReverse; | 1626 to.PackedArrayReverse = PackedArrayReverse; |
1633 }); | 1627 }); |
1634 | 1628 |
1635 %InstallToContext([ | 1629 %InstallToContext([ |
1636 "array_pop", ArrayPop, | 1630 "array_pop", ArrayPop, |
1637 "array_push", ArrayPush, | 1631 "array_push", ArrayPush, |
1638 "array_shift", ArrayShift, | 1632 "array_shift", ArrayShift, |
1639 "array_splice", ArraySplice, | 1633 "array_splice", ArraySplice, |
1640 "array_slice", ArraySlice, | 1634 "array_slice", ArraySlice, |
1641 "array_unshift", ArrayUnshift, | 1635 "array_unshift", ArrayUnshift, |
1642 "array_values_iterator", ArrayValues, | 1636 "array_values_iterator", ArrayValues, |
1643 ]); | 1637 ]); |
1644 | 1638 |
1645 }); | 1639 }); |
OLD | NEW |