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 GetIterator; | 14 var GetIterator; |
15 var GetMethod; | 15 var GetMethod; |
16 var GlobalArray = global.Array; | 16 var GlobalArray = global.Array; |
17 var InternalArray = utils.InternalArray; | 17 var InternalArray = utils.InternalArray; |
18 var InternalPackedArray = utils.InternalPackedArray; | 18 var InternalPackedArray = utils.InternalPackedArray; |
19 var MaxSimple; | 19 var MaxSimple; |
20 var MinSimple; | 20 var MinSimple; |
21 var ObjectHasOwnProperty; | 21 var ObjectHasOwnProperty; |
22 var ObjectToString = utils.ImportNow("object_to_string"); | 22 var ObjectToString = utils.ImportNow("object_to_string"); |
23 var iteratorSymbol = utils.ImportNow("iterator_symbol"); | 23 var iteratorSymbol = utils.ImportNow("iterator_symbol"); |
24 var speciesSymbol = utils.ImportNow("species_symbol"); | |
25 var unscopablesSymbol = utils.ImportNow("unscopables_symbol"); | 24 var unscopablesSymbol = utils.ImportNow("unscopables_symbol"); |
26 | 25 |
27 utils.Import(function(from) { | 26 utils.Import(function(from) { |
28 GetIterator = from.GetIterator; | 27 GetIterator = from.GetIterator; |
29 GetMethod = from.GetMethod; | 28 GetMethod = from.GetMethod; |
30 MaxSimple = from.MaxSimple; | 29 MaxSimple = from.MaxSimple; |
31 MinSimple = from.MinSimple; | 30 MinSimple = from.MinSimple; |
32 ObjectHasOwnProperty = from.ObjectHasOwnProperty; | 31 ObjectHasOwnProperty = from.ObjectHasOwnProperty; |
33 }); | 32 }); |
34 | 33 |
(...skipping 1448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1483 var constructor = this; | 1482 var constructor = this; |
1484 // TODO: Implement IsConstructor (ES6 section 7.2.5) | 1483 // TODO: Implement IsConstructor (ES6 section 7.2.5) |
1485 var array = %IsConstructor(constructor) ? new constructor(length) : []; | 1484 var array = %IsConstructor(constructor) ? new constructor(length) : []; |
1486 for (var i = 0; i < length; i++) { | 1485 for (var i = 0; i < length; i++) { |
1487 %CreateDataProperty(array, i, args[i]); | 1486 %CreateDataProperty(array, i, args[i]); |
1488 } | 1487 } |
1489 array.length = length; | 1488 array.length = length; |
1490 return array; | 1489 return array; |
1491 } | 1490 } |
1492 | 1491 |
1493 | |
1494 function ArraySpecies() { | |
1495 return this; | |
1496 } | |
1497 | |
1498 | |
1499 // ------------------------------------------------------------------- | 1492 // ------------------------------------------------------------------- |
1500 | 1493 |
1501 // Set up non-enumerable constructor property on the Array.prototype | 1494 // Set up non-enumerable constructor property on the Array.prototype |
1502 // object. | 1495 // object. |
1503 %AddNamedProperty(GlobalArray.prototype, "constructor", GlobalArray, | 1496 %AddNamedProperty(GlobalArray.prototype, "constructor", GlobalArray, |
1504 DONT_ENUM); | 1497 DONT_ENUM); |
1505 | 1498 |
1506 // Set up unscopable properties on the Array.prototype object. | 1499 // Set up unscopable properties on the Array.prototype object. |
1507 var unscopables = { | 1500 var unscopables = { |
1508 __proto__: null, | 1501 __proto__: null, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1571 "findIndex", getFunction("findIndex", ArrayFindIndex, 1), | 1564 "findIndex", getFunction("findIndex", ArrayFindIndex, 1), |
1572 "fill", getFunction("fill", ArrayFill, 1), | 1565 "fill", getFunction("fill", ArrayFill, 1), |
1573 "includes", getFunction("includes", null, 1), | 1566 "includes", getFunction("includes", null, 1), |
1574 "keys", getFunction("keys", null, 0), | 1567 "keys", getFunction("keys", null, 0), |
1575 "entries", getFunction("entries", null, 0), | 1568 "entries", getFunction("entries", null, 0), |
1576 iteratorSymbol, ArrayValues | 1569 iteratorSymbol, ArrayValues |
1577 ]); | 1570 ]); |
1578 | 1571 |
1579 %FunctionSetName(ArrayValues, "values"); | 1572 %FunctionSetName(ArrayValues, "values"); |
1580 | 1573 |
1581 utils.InstallGetter(GlobalArray, speciesSymbol, ArraySpecies); | |
1582 | |
1583 %FinishArrayPrototypeSetup(GlobalArray.prototype); | 1574 %FinishArrayPrototypeSetup(GlobalArray.prototype); |
1584 | 1575 |
1585 // The internal Array prototype doesn't need to be fancy, since it's never | 1576 // The internal Array prototype doesn't need to be fancy, since it's never |
1586 // exposed to user code. | 1577 // exposed to user code. |
1587 // Adding only the functions that are actually used. | 1578 // Adding only the functions that are actually used. |
1588 utils.SetUpLockedPrototype(InternalArray, GlobalArray(), [ | 1579 utils.SetUpLockedPrototype(InternalArray, GlobalArray(), [ |
1589 "indexOf", getFunction("indexOf", null), | 1580 "indexOf", getFunction("indexOf", null), |
1590 "join", getFunction("join", ArrayJoin), | 1581 "join", getFunction("join", ArrayJoin), |
1591 "pop", getFunction("pop", ArrayPop), | 1582 "pop", getFunction("pop", ArrayPop), |
1592 "push", getFunction("push", ArrayPush), | 1583 "push", getFunction("push", ArrayPush), |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1643 "array_pop", ArrayPop, | 1634 "array_pop", ArrayPop, |
1644 "array_push", ArrayPush, | 1635 "array_push", ArrayPush, |
1645 "array_shift", ArrayShift, | 1636 "array_shift", ArrayShift, |
1646 "array_splice", ArraySplice, | 1637 "array_splice", ArraySplice, |
1647 "array_slice", ArraySlice, | 1638 "array_slice", ArraySlice, |
1648 "array_unshift", ArrayUnshift, | 1639 "array_unshift", ArrayUnshift, |
1649 "array_values_iterator", ArrayValues, | 1640 "array_values_iterator", ArrayValues, |
1650 ]); | 1641 ]); |
1651 | 1642 |
1652 }); | 1643 }); |
OLD | NEW |