Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Side by Side Diff: src/array.js

Issue 1065863003: Use array literals instead of array constructor in native javascript. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase and fix Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/array-iterator.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "use strict"; 5 "use strict";
6 6
7 // This file relies on the fact that the following declarations have been made 7 // This file relies on the fact that the following declarations have been made
8 // in runtime.js: 8 // in runtime.js:
9 // var $Array = global.Array; 9 // var $Array = global.Array;
10 10
(...skipping 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after
1514 entries: true, 1514 entries: true,
1515 fill: true, 1515 fill: true,
1516 find: true, 1516 find: true,
1517 findIndex: true, 1517 findIndex: true,
1518 keys: true, 1518 keys: true,
1519 }; 1519 };
1520 %AddNamedProperty($Array.prototype, symbolUnscopables, unscopables, 1520 %AddNamedProperty($Array.prototype, symbolUnscopables, unscopables,
1521 DONT_ENUM | READ_ONLY); 1521 DONT_ENUM | READ_ONLY);
1522 1522
1523 // Set up non-enumerable functions on the Array object. 1523 // Set up non-enumerable functions on the Array object.
1524 InstallFunctions($Array, DONT_ENUM, $Array( 1524 InstallFunctions($Array, DONT_ENUM, [
1525 "isArray", ArrayIsArray 1525 "isArray", ArrayIsArray
1526 )); 1526 ]);
1527 1527
1528 var specialFunctions = %SpecialArrayFunctions(); 1528 var specialFunctions = %SpecialArrayFunctions();
1529 1529
1530 var getFunction = function(name, jsBuiltin, len) { 1530 var getFunction = function(name, jsBuiltin, len) {
1531 var f = jsBuiltin; 1531 var f = jsBuiltin;
1532 if (specialFunctions.hasOwnProperty(name)) { 1532 if (specialFunctions.hasOwnProperty(name)) {
1533 f = specialFunctions[name]; 1533 f = specialFunctions[name];
1534 } 1534 }
1535 if (!IS_UNDEFINED(len)) { 1535 if (!IS_UNDEFINED(len)) {
1536 %FunctionSetLength(f, len); 1536 %FunctionSetLength(f, len);
1537 } 1537 }
1538 return f; 1538 return f;
1539 }; 1539 };
1540 1540
1541 // Set up non-enumerable functions of the Array.prototype object and 1541 // Set up non-enumerable functions of the Array.prototype object and
1542 // set their names. 1542 // set their names.
1543 // Manipulate the length of some of the functions to meet 1543 // Manipulate the length of some of the functions to meet
1544 // expectations set by ECMA-262 or Mozilla. 1544 // expectations set by ECMA-262 or Mozilla.
1545 InstallFunctions($Array.prototype, DONT_ENUM, $Array( 1545 InstallFunctions($Array.prototype, DONT_ENUM, [
1546 "toString", getFunction("toString", ArrayToString), 1546 "toString", getFunction("toString", ArrayToString),
1547 "toLocaleString", getFunction("toLocaleString", ArrayToLocaleString), 1547 "toLocaleString", getFunction("toLocaleString", ArrayToLocaleString),
1548 "join", getFunction("join", ArrayJoin), 1548 "join", getFunction("join", ArrayJoin),
1549 "pop", getFunction("pop", ArrayPop), 1549 "pop", getFunction("pop", ArrayPop),
1550 "push", getFunction("push", ArrayPush, 1), 1550 "push", getFunction("push", ArrayPush, 1),
1551 "concat", getFunction("concat", ArrayConcatJS, 1), 1551 "concat", getFunction("concat", ArrayConcatJS, 1),
1552 "reverse", getFunction("reverse", ArrayReverse), 1552 "reverse", getFunction("reverse", ArrayReverse),
1553 "shift", getFunction("shift", ArrayShift), 1553 "shift", getFunction("shift", ArrayShift),
1554 "unshift", getFunction("unshift", ArrayUnshift, 1), 1554 "unshift", getFunction("unshift", ArrayUnshift, 1),
1555 "slice", getFunction("slice", ArraySlice, 2), 1555 "slice", getFunction("slice", ArraySlice, 2),
1556 "splice", getFunction("splice", ArraySplice, 2), 1556 "splice", getFunction("splice", ArraySplice, 2),
1557 "sort", getFunction("sort", ArraySort), 1557 "sort", getFunction("sort", ArraySort),
1558 "filter", getFunction("filter", ArrayFilter, 1), 1558 "filter", getFunction("filter", ArrayFilter, 1),
1559 "forEach", getFunction("forEach", ArrayForEach, 1), 1559 "forEach", getFunction("forEach", ArrayForEach, 1),
1560 "some", getFunction("some", ArraySome, 1), 1560 "some", getFunction("some", ArraySome, 1),
1561 "every", getFunction("every", ArrayEvery, 1), 1561 "every", getFunction("every", ArrayEvery, 1),
1562 "map", getFunction("map", ArrayMap, 1), 1562 "map", getFunction("map", ArrayMap, 1),
1563 "indexOf", getFunction("indexOf", ArrayIndexOf, 1), 1563 "indexOf", getFunction("indexOf", ArrayIndexOf, 1),
1564 "lastIndexOf", getFunction("lastIndexOf", ArrayLastIndexOf, 1), 1564 "lastIndexOf", getFunction("lastIndexOf", ArrayLastIndexOf, 1),
1565 "reduce", getFunction("reduce", ArrayReduce, 1), 1565 "reduce", getFunction("reduce", ArrayReduce, 1),
1566 "reduceRight", getFunction("reduceRight", ArrayReduceRight, 1) 1566 "reduceRight", getFunction("reduceRight", ArrayReduceRight, 1)
1567 )); 1567 ]);
1568 1568
1569 %FinishArrayPrototypeSetup($Array.prototype); 1569 %FinishArrayPrototypeSetup($Array.prototype);
1570 1570
1571 // The internal Array prototype doesn't need to be fancy, since it's never 1571 // The internal Array prototype doesn't need to be fancy, since it's never
1572 // exposed to user code. 1572 // exposed to user code.
1573 // Adding only the functions that are actually used. 1573 // Adding only the functions that are actually used.
1574 SetUpLockedPrototype(InternalArray, $Array(), $Array( 1574 SetUpLockedPrototype(InternalArray, $Array(), [
1575 "concat", getFunction("concat", ArrayConcatJS), 1575 "concat", getFunction("concat", ArrayConcatJS),
1576 "indexOf", getFunction("indexOf", ArrayIndexOf), 1576 "indexOf", getFunction("indexOf", ArrayIndexOf),
1577 "join", getFunction("join", ArrayJoin), 1577 "join", getFunction("join", ArrayJoin),
1578 "pop", getFunction("pop", ArrayPop), 1578 "pop", getFunction("pop", ArrayPop),
1579 "push", getFunction("push", ArrayPush), 1579 "push", getFunction("push", ArrayPush),
1580 "splice", getFunction("splice", ArraySplice) 1580 "splice", getFunction("splice", ArraySplice)
1581 )); 1581 ]);
1582 1582
1583 SetUpLockedPrototype(InternalPackedArray, $Array(), $Array( 1583 SetUpLockedPrototype(InternalPackedArray, $Array(), [
1584 "join", getFunction("join", ArrayJoin), 1584 "join", getFunction("join", ArrayJoin),
1585 "pop", getFunction("pop", ArrayPop), 1585 "pop", getFunction("pop", ArrayPop),
1586 "push", getFunction("push", ArrayPush) 1586 "push", getFunction("push", ArrayPush)
1587 )); 1587 ]);
1588 } 1588 }
1589 1589
1590 SetUpArray(); 1590 SetUpArray();
OLDNEW
« no previous file with comments | « no previous file | src/array-iterator.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698