| 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 |
| 11 // ------------------------------------------------------------------- | 11 // ------------------------------------------------------------------- |
| 12 // Imports | 12 // Imports |
| 13 | 13 |
| 14 var FLAG_harmony_species; | |
| 15 var GetIterator; | 14 var GetIterator; |
| 16 var GetMethod; | 15 var GetMethod; |
| 17 var GlobalArray = global.Array; | 16 var GlobalArray = global.Array; |
| 18 var InternalArray = utils.InternalArray; | 17 var InternalArray = utils.InternalArray; |
| 19 var InternalPackedArray = utils.InternalPackedArray; | 18 var InternalPackedArray = utils.InternalPackedArray; |
| 20 var MakeTypeError; | 19 var MakeTypeError; |
| 21 var MaxSimple; | 20 var MaxSimple; |
| 22 var MinSimple; | 21 var MinSimple; |
| 23 var ObjectHasOwnProperty; | 22 var ObjectHasOwnProperty; |
| 24 var ObjectToString = utils.ImportNow("object_to_string"); | 23 var ObjectToString = utils.ImportNow("object_to_string"); |
| 25 var iteratorSymbol = utils.ImportNow("iterator_symbol"); | 24 var iteratorSymbol = utils.ImportNow("iterator_symbol"); |
| 25 var speciesSymbol = utils.ImportNow("species_symbol"); |
| 26 var unscopablesSymbol = utils.ImportNow("unscopables_symbol"); | 26 var unscopablesSymbol = utils.ImportNow("unscopables_symbol"); |
| 27 | 27 |
| 28 utils.Import(function(from) { | 28 utils.Import(function(from) { |
| 29 GetIterator = from.GetIterator; | 29 GetIterator = from.GetIterator; |
| 30 GetMethod = from.GetMethod; | 30 GetMethod = from.GetMethod; |
| 31 MakeTypeError = from.MakeTypeError; | 31 MakeTypeError = from.MakeTypeError; |
| 32 MaxSimple = from.MaxSimple; | 32 MaxSimple = from.MaxSimple; |
| 33 MinSimple = from.MinSimple; | 33 MinSimple = from.MinSimple; |
| 34 ObjectHasOwnProperty = from.ObjectHasOwnProperty; | 34 ObjectHasOwnProperty = from.ObjectHasOwnProperty; |
| 35 }); | 35 }); |
| 36 | 36 |
| 37 utils.ImportFromExperimental(function(from) { | |
| 38 FLAG_harmony_species = from.FLAG_harmony_species; | |
| 39 }); | |
| 40 | |
| 41 // ------------------------------------------------------------------- | 37 // ------------------------------------------------------------------- |
| 42 | 38 |
| 43 | 39 |
| 44 function ArraySpeciesCreate(array, length) { | 40 function ArraySpeciesCreate(array, length) { |
| 45 var constructor; | |
| 46 | |
| 47 length = INVERT_NEG_ZERO(length); | 41 length = INVERT_NEG_ZERO(length); |
| 48 | 42 var constructor = %ArraySpeciesConstructor(array); |
| 49 if (FLAG_harmony_species) { | |
| 50 constructor = %ArraySpeciesConstructor(array); | |
| 51 } else { | |
| 52 constructor = GlobalArray; | |
| 53 } | |
| 54 return new constructor(length); | 43 return new constructor(length); |
| 55 } | 44 } |
| 56 | 45 |
| 57 | 46 |
| 58 function KeySortCompare(a, b) { | 47 function KeySortCompare(a, b) { |
| 59 return a - b; | 48 return a - b; |
| 60 } | 49 } |
| 61 | 50 |
| 62 function GetSortedArrayKeys(array, indices) { | 51 function GetSortedArrayKeys(array, indices) { |
| 63 if (IS_NUMBER(indices)) { | 52 if (IS_NUMBER(indices)) { |
| (...skipping 1571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1635 var constructor = this; | 1624 var constructor = this; |
| 1636 // TODO: Implement IsConstructor (ES6 section 7.2.5) | 1625 // TODO: Implement IsConstructor (ES6 section 7.2.5) |
| 1637 var array = %IsConstructor(constructor) ? new constructor(length) : []; | 1626 var array = %IsConstructor(constructor) ? new constructor(length) : []; |
| 1638 for (var i = 0; i < length; i++) { | 1627 for (var i = 0; i < length; i++) { |
| 1639 %CreateDataProperty(array, i, args[i]); | 1628 %CreateDataProperty(array, i, args[i]); |
| 1640 } | 1629 } |
| 1641 array.length = length; | 1630 array.length = length; |
| 1642 return array; | 1631 return array; |
| 1643 } | 1632 } |
| 1644 | 1633 |
| 1634 |
| 1635 function ArraySpecies() { |
| 1636 return this; |
| 1637 } |
| 1638 |
| 1639 |
| 1645 // ------------------------------------------------------------------- | 1640 // ------------------------------------------------------------------- |
| 1646 | 1641 |
| 1647 // Set up non-enumerable constructor property on the Array.prototype | 1642 // Set up non-enumerable constructor property on the Array.prototype |
| 1648 // object. | 1643 // object. |
| 1649 %AddNamedProperty(GlobalArray.prototype, "constructor", GlobalArray, | 1644 %AddNamedProperty(GlobalArray.prototype, "constructor", GlobalArray, |
| 1650 DONT_ENUM); | 1645 DONT_ENUM); |
| 1651 | 1646 |
| 1652 // Set up unscopable properties on the Array.prototype object. | 1647 // Set up unscopable properties on the Array.prototype object. |
| 1653 var unscopables = { | 1648 var unscopables = { |
| 1654 __proto__: null, | 1649 __proto__: null, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1710 "lastIndexOf", getFunction("lastIndexOf", ArrayLastIndexOf, 1), | 1705 "lastIndexOf", getFunction("lastIndexOf", ArrayLastIndexOf, 1), |
| 1711 "reduce", getFunction("reduce", ArrayReduce, 1), | 1706 "reduce", getFunction("reduce", ArrayReduce, 1), |
| 1712 "reduceRight", getFunction("reduceRight", ArrayReduceRight, 1), | 1707 "reduceRight", getFunction("reduceRight", ArrayReduceRight, 1), |
| 1713 "copyWithin", getFunction("copyWithin", ArrayCopyWithin, 2), | 1708 "copyWithin", getFunction("copyWithin", ArrayCopyWithin, 2), |
| 1714 "find", getFunction("find", ArrayFind, 1), | 1709 "find", getFunction("find", ArrayFind, 1), |
| 1715 "findIndex", getFunction("findIndex", ArrayFindIndex, 1), | 1710 "findIndex", getFunction("findIndex", ArrayFindIndex, 1), |
| 1716 "fill", getFunction("fill", ArrayFill, 1), | 1711 "fill", getFunction("fill", ArrayFill, 1), |
| 1717 "includes", getFunction("includes", ArrayIncludes, 1), | 1712 "includes", getFunction("includes", ArrayIncludes, 1), |
| 1718 ]); | 1713 ]); |
| 1719 | 1714 |
| 1715 utils.InstallGetter(GlobalArray, speciesSymbol, ArraySpecies); |
| 1716 |
| 1720 %FinishArrayPrototypeSetup(GlobalArray.prototype); | 1717 %FinishArrayPrototypeSetup(GlobalArray.prototype); |
| 1721 | 1718 |
| 1722 // The internal Array prototype doesn't need to be fancy, since it's never | 1719 // The internal Array prototype doesn't need to be fancy, since it's never |
| 1723 // exposed to user code. | 1720 // exposed to user code. |
| 1724 // Adding only the functions that are actually used. | 1721 // Adding only the functions that are actually used. |
| 1725 utils.SetUpLockedPrototype(InternalArray, GlobalArray(), [ | 1722 utils.SetUpLockedPrototype(InternalArray, GlobalArray(), [ |
| 1726 "indexOf", getFunction("indexOf", ArrayIndexOf), | 1723 "indexOf", getFunction("indexOf", ArrayIndexOf), |
| 1727 "join", getFunction("join", ArrayJoin), | 1724 "join", getFunction("join", ArrayJoin), |
| 1728 "pop", getFunction("pop", ArrayPop), | 1725 "pop", getFunction("pop", ArrayPop), |
| 1729 "push", getFunction("push", ArrayPush), | 1726 "push", getFunction("push", ArrayPush), |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1781 %InstallToContext([ | 1778 %InstallToContext([ |
| 1782 "array_pop", ArrayPop, | 1779 "array_pop", ArrayPop, |
| 1783 "array_push", ArrayPush, | 1780 "array_push", ArrayPush, |
| 1784 "array_shift", ArrayShift, | 1781 "array_shift", ArrayShift, |
| 1785 "array_splice", ArraySplice, | 1782 "array_splice", ArraySplice, |
| 1786 "array_slice", ArraySlice, | 1783 "array_slice", ArraySlice, |
| 1787 "array_unshift", ArrayUnshift, | 1784 "array_unshift", ArrayUnshift, |
| 1788 ]); | 1785 ]); |
| 1789 | 1786 |
| 1790 }); | 1787 }); |
| OLD | NEW |