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 1521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1532 var f = jsBuiltin; | 1532 var f = jsBuiltin; |
1533 if (specialFunctions.hasOwnProperty(name)) { | 1533 if (specialFunctions.hasOwnProperty(name)) { |
1534 f = specialFunctions[name]; | 1534 f = specialFunctions[name]; |
1535 } | 1535 } |
1536 if (!IS_UNDEFINED(len)) { | 1536 if (!IS_UNDEFINED(len)) { |
1537 %FunctionSetLength(f, len); | 1537 %FunctionSetLength(f, len); |
1538 } | 1538 } |
1539 return f; | 1539 return f; |
1540 }; | 1540 }; |
1541 | 1541 |
| 1542 var ArrayValues = getFunction("values", null, 0); |
| 1543 |
1542 // Set up non-enumerable functions of the Array.prototype object and | 1544 // Set up non-enumerable functions of the Array.prototype object and |
1543 // set their names. | 1545 // set their names. |
1544 // Manipulate the length of some of the functions to meet | 1546 // Manipulate the length of some of the functions to meet |
1545 // expectations set by ECMA-262 or Mozilla. | 1547 // expectations set by ECMA-262 or Mozilla. |
1546 utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [ | 1548 utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [ |
1547 "toString", getFunction("toString", ArrayToString), | 1549 "toString", getFunction("toString", ArrayToString), |
1548 "toLocaleString", getFunction("toLocaleString", ArrayToLocaleString), | 1550 "toLocaleString", getFunction("toLocaleString", ArrayToLocaleString), |
1549 "join", getFunction("join", ArrayJoin), | 1551 "join", getFunction("join", ArrayJoin), |
1550 "pop", getFunction("pop", ArrayPop), | 1552 "pop", getFunction("pop", ArrayPop), |
1551 "push", getFunction("push", ArrayPush, 1), | 1553 "push", getFunction("push", ArrayPush, 1), |
1552 "reverse", getFunction("reverse", ArrayReverse), | 1554 "reverse", getFunction("reverse", ArrayReverse), |
1553 "shift", getFunction("shift", ArrayShift), | 1555 "shift", getFunction("shift", ArrayShift), |
1554 "unshift", getFunction("unshift", ArrayUnshift, 1), | 1556 "unshift", getFunction("unshift", ArrayUnshift, 1), |
1555 "slice", getFunction("slice", ArraySlice, 2), | 1557 "slice", getFunction("slice", ArraySlice, 2), |
1556 "splice", getFunction("splice", ArraySplice, 2), | 1558 "splice", getFunction("splice", ArraySplice, 2), |
1557 "sort", getFunction("sort", ArraySort), | 1559 "sort", getFunction("sort", ArraySort), |
1558 "filter", getFunction("filter", ArrayFilter, 1), | 1560 "filter", getFunction("filter", ArrayFilter, 1), |
1559 "forEach", getFunction("forEach", ArrayForEach, 1), | 1561 "forEach", getFunction("forEach", ArrayForEach, 1), |
1560 "some", getFunction("some", ArraySome, 1), | 1562 "some", getFunction("some", ArraySome, 1), |
1561 "every", getFunction("every", ArrayEvery, 1), | 1563 "every", getFunction("every", ArrayEvery, 1), |
1562 "map", getFunction("map", ArrayMap, 1), | 1564 "map", getFunction("map", ArrayMap, 1), |
1563 "indexOf", getFunction("indexOf", null, 1), | 1565 "indexOf", getFunction("indexOf", null, 1), |
1564 "lastIndexOf", getFunction("lastIndexOf", ArrayLastIndexOf, 1), | 1566 "lastIndexOf", getFunction("lastIndexOf", ArrayLastIndexOf, 1), |
1565 "reduce", getFunction("reduce", ArrayReduce, 1), | 1567 "reduce", getFunction("reduce", ArrayReduce, 1), |
1566 "reduceRight", getFunction("reduceRight", ArrayReduceRight, 1), | 1568 "reduceRight", getFunction("reduceRight", ArrayReduceRight, 1), |
1567 "copyWithin", getFunction("copyWithin", ArrayCopyWithin, 2), | 1569 "copyWithin", getFunction("copyWithin", ArrayCopyWithin, 2), |
1568 "find", getFunction("find", ArrayFind, 1), | 1570 "find", getFunction("find", ArrayFind, 1), |
1569 "findIndex", getFunction("findIndex", ArrayFindIndex, 1), | 1571 "findIndex", getFunction("findIndex", ArrayFindIndex, 1), |
1570 "fill", getFunction("fill", ArrayFill, 1), | 1572 "fill", getFunction("fill", ArrayFill, 1), |
1571 "includes", getFunction("includes", null, 1) | 1573 "includes", getFunction("includes", null, 1), |
| 1574 "keys", getFunction("keys", null, 0), |
| 1575 "entries", getFunction("entries", null, 0), |
| 1576 iteratorSymbol, ArrayValues |
1572 ]); | 1577 ]); |
1573 | 1578 |
| 1579 %FunctionSetName(ArrayValues, "values"); |
| 1580 |
1574 utils.InstallGetter(GlobalArray, speciesSymbol, ArraySpecies); | 1581 utils.InstallGetter(GlobalArray, speciesSymbol, ArraySpecies); |
1575 | 1582 |
1576 %FinishArrayPrototypeSetup(GlobalArray.prototype); | 1583 %FinishArrayPrototypeSetup(GlobalArray.prototype); |
1577 | 1584 |
1578 // The internal Array prototype doesn't need to be fancy, since it's never | 1585 // The internal Array prototype doesn't need to be fancy, since it's never |
1579 // exposed to user code. | 1586 // exposed to user code. |
1580 // Adding only the functions that are actually used. | 1587 // Adding only the functions that are actually used. |
1581 utils.SetUpLockedPrototype(InternalArray, GlobalArray(), [ | 1588 utils.SetUpLockedPrototype(InternalArray, GlobalArray(), [ |
1582 "indexOf", getFunction("indexOf", null), | 1589 "indexOf", getFunction("indexOf", null), |
1583 "join", getFunction("join", ArrayJoin), | 1590 "join", getFunction("join", ArrayJoin), |
(...skipping 23 matching lines...) Expand all Loading... |
1607 ]); | 1614 ]); |
1608 | 1615 |
1609 // ------------------------------------------------------------------- | 1616 // ------------------------------------------------------------------- |
1610 // Exports | 1617 // Exports |
1611 | 1618 |
1612 utils.Export(function(to) { | 1619 utils.Export(function(to) { |
1613 to.ArrayFrom = ArrayFrom; | 1620 to.ArrayFrom = ArrayFrom; |
1614 to.ArrayJoin = ArrayJoin; | 1621 to.ArrayJoin = ArrayJoin; |
1615 to.ArrayPush = ArrayPush; | 1622 to.ArrayPush = ArrayPush; |
1616 to.ArrayToString = ArrayToString; | 1623 to.ArrayToString = ArrayToString; |
| 1624 to.ArrayValues = ArrayValues; |
1617 to.InnerArrayCopyWithin = InnerArrayCopyWithin; | 1625 to.InnerArrayCopyWithin = InnerArrayCopyWithin; |
1618 to.InnerArrayEvery = InnerArrayEvery; | 1626 to.InnerArrayEvery = InnerArrayEvery; |
1619 to.InnerArrayFill = InnerArrayFill; | 1627 to.InnerArrayFill = InnerArrayFill; |
1620 to.InnerArrayFilter = InnerArrayFilter; | 1628 to.InnerArrayFilter = InnerArrayFilter; |
1621 to.InnerArrayFind = InnerArrayFind; | 1629 to.InnerArrayFind = InnerArrayFind; |
1622 to.InnerArrayFindIndex = InnerArrayFindIndex; | 1630 to.InnerArrayFindIndex = InnerArrayFindIndex; |
1623 to.InnerArrayForEach = InnerArrayForEach; | 1631 to.InnerArrayForEach = InnerArrayForEach; |
1624 to.InnerArrayJoin = InnerArrayJoin; | 1632 to.InnerArrayJoin = InnerArrayJoin; |
1625 to.InnerArrayLastIndexOf = InnerArrayLastIndexOf; | 1633 to.InnerArrayLastIndexOf = InnerArrayLastIndexOf; |
1626 to.InnerArrayReduce = InnerArrayReduce; | 1634 to.InnerArrayReduce = InnerArrayReduce; |
1627 to.InnerArrayReduceRight = InnerArrayReduceRight; | 1635 to.InnerArrayReduceRight = InnerArrayReduceRight; |
1628 to.InnerArraySome = InnerArraySome; | 1636 to.InnerArraySome = InnerArraySome; |
1629 to.InnerArraySort = InnerArraySort; | 1637 to.InnerArraySort = InnerArraySort; |
1630 to.InnerArrayToLocaleString = InnerArrayToLocaleString; | 1638 to.InnerArrayToLocaleString = InnerArrayToLocaleString; |
1631 to.PackedArrayReverse = PackedArrayReverse; | 1639 to.PackedArrayReverse = PackedArrayReverse; |
1632 }); | 1640 }); |
1633 | 1641 |
1634 %InstallToContext([ | 1642 %InstallToContext([ |
1635 "array_pop", ArrayPop, | 1643 "array_pop", ArrayPop, |
1636 "array_push", ArrayPush, | 1644 "array_push", ArrayPush, |
1637 "array_shift", ArrayShift, | 1645 "array_shift", ArrayShift, |
1638 "array_splice", ArraySplice, | 1646 "array_splice", ArraySplice, |
1639 "array_slice", ArraySlice, | 1647 "array_slice", ArraySlice, |
1640 "array_unshift", ArrayUnshift, | 1648 "array_unshift", ArrayUnshift, |
| 1649 "array_values_iterator", ArrayValues, |
1641 ]); | 1650 ]); |
1642 | 1651 |
1643 }); | 1652 }); |
OLD | NEW |