Chromium Code Reviews| Index: src/js/array.js |
| diff --git a/src/js/array.js b/src/js/array.js |
| index fca75a3f65f85f32e3300f3669f056793fbf7973..c8b34e053dc5c209b40674781cb545597ee91160 100644 |
| --- a/src/js/array.js |
| +++ b/src/js/array.js |
| @@ -1520,11 +1520,15 @@ utils.InstallFunctions(GlobalArray, DONT_ENUM, [ |
| ]); |
| var specialFunctions = %SpecialArrayFunctions(); |
| +var specialExperimentalArrayFunctions = null; |
| function getFunction(name, jsBuiltin, len) { |
| var f = jsBuiltin; |
| if (specialFunctions.hasOwnProperty(name)) { |
| f = specialFunctions[name]; |
| + } else if (specialExperimentalArrayFunctions != null && |
| + specialExperimentalArrayFunctions.hasOwnProperty(name)) { |
| + f = specialExperimentalArrayFunctions[name]; |
| } |
| if (!IS_UNDEFINED(len)) { |
| %FunctionSetLength(f, len); |
| @@ -1551,7 +1555,6 @@ utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [ |
| "splice", getFunction("splice", ArraySplice, 2), |
| "sort", getFunction("sort", ArraySort), |
| "filter", getFunction("filter", ArrayFilter, 1), |
| - "forEach", getFunction("forEach", ArrayForEach, 1), |
| "some", getFunction("some", ArraySome, 1), |
| "every", getFunction("every", ArrayEvery, 1), |
| "map", getFunction("map", ArrayMap, 1), |
| @@ -1569,6 +1572,17 @@ utils.InstallFunctions(GlobalArray.prototype, DONT_ENUM, [ |
| iteratorSymbol, ArrayValues |
| ]); |
| +%FunctionRemovePrototype(ArrayForEach); |
| + |
| +var specialExperimentalArrayFunctions = null; |
| + |
| +function InstallExperimentalArrayFunctions() { |
| + specialExperimentalArrayFunctions = %SpecialExperimentalArrayFunctions(); |
|
Yang
2017/02/02 10:04:58
Can we have all of this in C++, in the bootstrappe
danno
2017/02/02 17:15:48
Done.
|
| + utils.InstallFunctions(global.Array.prototype, DONT_ENUM, [ |
| + "forEach", getFunction("forEach", ArrayForEach, 1), |
| + ], false); |
| +} |
| + |
| %FunctionSetName(ArrayValues, "values"); |
| %FinishArrayPrototypeSetup(GlobalArray.prototype); |
| @@ -1611,6 +1625,7 @@ utils.Export(function(to) { |
| to.ArrayFrom = ArrayFrom; |
| to.ArrayJoin = ArrayJoin; |
| to.ArrayPush = ArrayPush; |
| + to.InstallExperimentalArrayFunctions = InstallExperimentalArrayFunctions; |
| to.ArrayToString = ArrayToString; |
| to.ArrayValues = ArrayValues; |
| to.InnerArrayCopyWithin = InnerArrayCopyWithin; |