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 $arrayPush; | 6 var $arrayPush; |
7 var $arrayPop; | 7 var $arrayPop; |
8 var $arrayShift; | 8 var $arrayShift; |
9 var $arraySlice; | 9 var $arraySlice; |
10 var $arraySplice; | 10 var $arraySplice; |
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1225 } | 1225 } |
1226 return accumulator; | 1226 return accumulator; |
1227 } | 1227 } |
1228 | 1228 |
1229 function ArrayFilter(f, receiver) { | 1229 function ArrayFilter(f, receiver) { |
1230 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.filter"); | 1230 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.filter"); |
1231 | 1231 |
1232 // Pull out the length so that modifications to the length in the | 1232 // Pull out the length so that modifications to the length in the |
1233 // loop will not affect the looping and side effects are visible. | 1233 // loop will not affect the looping and side effects are visible. |
1234 var array = TO_OBJECT(this); | 1234 var array = TO_OBJECT(this); |
1235 var length = $toUint32(array.length); | 1235 var length = TO_UINT32(array.length); |
1236 var accumulator = InnerArrayFilter(f, receiver, array, length); | 1236 var accumulator = InnerArrayFilter(f, receiver, array, length); |
1237 var result = new GlobalArray(); | 1237 var result = new GlobalArray(); |
1238 %MoveArrayContents(accumulator, result); | 1238 %MoveArrayContents(accumulator, result); |
1239 return result; | 1239 return result; |
1240 } | 1240 } |
1241 | 1241 |
1242 function InnerArrayForEach(f, receiver, array, length) { | 1242 function InnerArrayForEach(f, receiver, array, length) { |
1243 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); | 1243 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); |
1244 var needs_wrapper = false; | 1244 var needs_wrapper = false; |
1245 if (IS_NULL(receiver)) { | 1245 if (IS_NULL(receiver)) { |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1536 return current; | 1536 return current; |
1537 } | 1537 } |
1538 | 1538 |
1539 | 1539 |
1540 function ArrayReduce(callback, current) { | 1540 function ArrayReduce(callback, current) { |
1541 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reduce"); | 1541 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reduce"); |
1542 | 1542 |
1543 // Pull out the length so that modifications to the length in the | 1543 // Pull out the length so that modifications to the length in the |
1544 // loop will not affect the looping and side effects are visible. | 1544 // loop will not affect the looping and side effects are visible. |
1545 var array = TO_OBJECT(this); | 1545 var array = TO_OBJECT(this); |
1546 var length = $toUint32(array.length); | 1546 var length = TO_UINT32(array.length); |
1547 return InnerArrayReduce(callback, current, array, length, | 1547 return InnerArrayReduce(callback, current, array, length, |
1548 %_ArgumentsLength()); | 1548 %_ArgumentsLength()); |
1549 } | 1549 } |
1550 | 1550 |
1551 | 1551 |
1552 function InnerArrayReduceRight(callback, current, array, length, | 1552 function InnerArrayReduceRight(callback, current, array, length, |
1553 argumentsLength) { | 1553 argumentsLength) { |
1554 if (!IS_SPEC_FUNCTION(callback)) { | 1554 if (!IS_SPEC_FUNCTION(callback)) { |
1555 throw MakeTypeError(kCalledNonCallable, callback); | 1555 throw MakeTypeError(kCalledNonCallable, callback); |
1556 } | 1556 } |
(...skipping 22 matching lines...) Expand all Loading... |
1579 return current; | 1579 return current; |
1580 } | 1580 } |
1581 | 1581 |
1582 | 1582 |
1583 function ArrayReduceRight(callback, current) { | 1583 function ArrayReduceRight(callback, current) { |
1584 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reduceRight"); | 1584 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reduceRight"); |
1585 | 1585 |
1586 // Pull out the length so that side effects are visible before the | 1586 // Pull out the length so that side effects are visible before the |
1587 // callback function is checked. | 1587 // callback function is checked. |
1588 var array = TO_OBJECT(this); | 1588 var array = TO_OBJECT(this); |
1589 var length = $toUint32(array.length); | 1589 var length = TO_UINT32(array.length); |
1590 return InnerArrayReduceRight(callback, current, array, length, | 1590 return InnerArrayReduceRight(callback, current, array, length, |
1591 %_ArgumentsLength()); | 1591 %_ArgumentsLength()); |
1592 } | 1592 } |
1593 | 1593 |
1594 // ES5, 15.4.3.2 | 1594 // ES5, 15.4.3.2 |
1595 function ArrayIsArray(obj) { | 1595 function ArrayIsArray(obj) { |
1596 return IS_ARRAY(obj); | 1596 return IS_ARRAY(obj); |
1597 } | 1597 } |
1598 | 1598 |
1599 | 1599 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1710 | 1710 |
1711 $arrayConcat = ArrayConcatJS; | 1711 $arrayConcat = ArrayConcatJS; |
1712 $arrayPush = ArrayPush; | 1712 $arrayPush = ArrayPush; |
1713 $arrayPop = ArrayPop; | 1713 $arrayPop = ArrayPop; |
1714 $arrayShift = ArrayShift; | 1714 $arrayShift = ArrayShift; |
1715 $arraySlice = ArraySlice; | 1715 $arraySlice = ArraySlice; |
1716 $arraySplice = ArraySplice; | 1716 $arraySplice = ArraySplice; |
1717 $arrayUnshift = ArrayUnshift; | 1717 $arrayUnshift = ArrayUnshift; |
1718 | 1718 |
1719 }); | 1719 }); |
OLD | NEW |