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

Side by Side Diff: src/harmony-array.js

Issue 1100673002: Wrap harmony implementations in functions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 | « src/bootstrapper.cc ('k') | src/harmony-array-includes.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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() {
6
5 'use strict'; 7 'use strict';
6 8
7 // This file relies on the fact that the following declaration has been made 9 %CheckIsBootstrapping();
8 // in runtime.js: 10
9 // var $Array = global.Array; 11 var GlobalArray = global.Array;
12 var GlobalSymbol = global.Symbol;
10 13
11 // ------------------------------------------------------------------- 14 // -------------------------------------------------------------------
12 15
13 // ES6 draft 07-15-13, section 15.4.3.23 16 // ES6 draft 07-15-13, section 15.4.3.23
14 function ArrayFind(predicate /* thisArg */) { // length == 1 17 function ArrayFind(predicate /* thisArg */) { // length == 1
15 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.find"); 18 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.find");
16 19
17 var array = ToObject(this); 20 var array = ToObject(this);
18 var length = ToInteger(array.length); 21 var length = ToInteger(array.length);
19 22
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 var array = %IsConstructor(constructor) ? new constructor(length) : []; 204 var array = %IsConstructor(constructor) ? new constructor(length) : [];
202 for (var i = 0; i < length; i++) { 205 for (var i = 0; i < length; i++) {
203 %AddElement(array, i, %_Arguments(i), NONE); 206 %AddElement(array, i, %_Arguments(i), NONE);
204 } 207 }
205 array.length = length; 208 array.length = length;
206 return array; 209 return array;
207 } 210 }
208 211
209 // ------------------------------------------------------------------- 212 // -------------------------------------------------------------------
210 213
211 function HarmonyArrayExtendSymbolPrototype() { 214 InstallConstants(GlobalSymbol, [
212 %CheckIsBootstrapping(); 215 // TODO(dslomov, caitp): Move to symbol.js when shipping
216 "isConcatSpreadable", symbolIsConcatSpreadable
217 ]);
213 218
214 InstallConstants(global.Symbol, [ 219 %FunctionSetLength(ArrayFrom, 1);
215 // TODO(dslomov, caitp): Move to symbol.js when shipping
216 "isConcatSpreadable", symbolIsConcatSpreadable
217 ]);
218 }
219 220
220 HarmonyArrayExtendSymbolPrototype(); 221 // Set up non-enumerable functions on the Array object.
222 InstallFunctions(GlobalArray, DONT_ENUM, [
223 "from", ArrayFrom,
224 "of", ArrayOf
225 ]);
221 226
222 function HarmonyArrayExtendArrayPrototype() { 227 // Set up the non-enumerable functions on the Array prototype object.
223 %CheckIsBootstrapping(); 228 InstallFunctions(GlobalArray.prototype, DONT_ENUM, [
229 "find", ArrayFind,
230 "findIndex", ArrayFindIndex,
231 "fill", ArrayFill
232 ]);
224 233
225 %FunctionSetLength(ArrayFrom, 1); 234 })();
226
227 // Set up non-enumerable functions on the Array object.
228 InstallFunctions($Array, DONT_ENUM, [
229 "from", ArrayFrom,
230 "of", ArrayOf
231 ]);
232
233 // Set up the non-enumerable functions on the Array prototype object.
234 InstallFunctions($Array.prototype, DONT_ENUM, [
235 "find", ArrayFind,
236 "findIndex", ArrayFindIndex,
237 "fill", ArrayFill
238 ]);
239 }
240
241 HarmonyArrayExtendArrayPrototype();
OLDNEW
« no previous file with comments | « src/bootstrapper.cc ('k') | src/harmony-array-includes.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698