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

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

Issue 1083083004: Reland "Migrate error messages, part 2." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix for layout test 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/generator.js ('k') | src/harmony-typedarray.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 'use strict'; 5 'use strict';
6 6
7 // This file relies on the fact that the following declaration has been made 7 // This file relies on the fact that the following declaration has been made
8 // in runtime.js: 8 // in runtime.js:
9 // var $Array = global.Array; 9 // var $Array = global.Array;
10 10
11 // ------------------------------------------------------------------- 11 // -------------------------------------------------------------------
12 12
13 // ES6 draft 07-15-13, section 15.4.3.23 13 // ES6 draft 07-15-13, section 15.4.3.23
14 function ArrayFind(predicate /* thisArg */) { // length == 1 14 function ArrayFind(predicate /* thisArg */) { // length == 1
15 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.find"); 15 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.find");
16 16
17 var array = ToObject(this); 17 var array = ToObject(this);
18 var length = ToInteger(array.length); 18 var length = ToInteger(array.length);
19 19
20 if (!IS_SPEC_FUNCTION(predicate)) { 20 if (!IS_SPEC_FUNCTION(predicate)) {
21 throw MakeTypeError('called_non_callable', [predicate]); 21 throw MakeTypeError(kCalledNonCallable, predicate);
22 } 22 }
23 23
24 var thisArg; 24 var thisArg;
25 if (%_ArgumentsLength() > 1) { 25 if (%_ArgumentsLength() > 1) {
26 thisArg = %_Arguments(1); 26 thisArg = %_Arguments(1);
27 } 27 }
28 28
29 var needs_wrapper = false; 29 var needs_wrapper = false;
30 if (IS_NULL_OR_UNDEFINED(thisArg)) { 30 if (IS_NULL_OR_UNDEFINED(thisArg)) {
31 thisArg = %GetDefaultReceiver(predicate) || thisArg; 31 thisArg = %GetDefaultReceiver(predicate) || thisArg;
(...skipping 16 matching lines...) Expand all
48 48
49 49
50 // ES6 draft 07-15-13, section 15.4.3.24 50 // ES6 draft 07-15-13, section 15.4.3.24
51 function ArrayFindIndex(predicate /* thisArg */) { // length == 1 51 function ArrayFindIndex(predicate /* thisArg */) { // length == 1
52 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.findIndex"); 52 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.findIndex");
53 53
54 var array = ToObject(this); 54 var array = ToObject(this);
55 var length = ToInteger(array.length); 55 var length = ToInteger(array.length);
56 56
57 if (!IS_SPEC_FUNCTION(predicate)) { 57 if (!IS_SPEC_FUNCTION(predicate)) {
58 throw MakeTypeError('called_non_callable', [predicate]); 58 throw MakeTypeError(kCalledNonCallable, predicate);
59 } 59 }
60 60
61 var thisArg; 61 var thisArg;
62 if (%_ArgumentsLength() > 1) { 62 if (%_ArgumentsLength() > 1) {
63 thisArg = %_Arguments(1); 63 thisArg = %_Arguments(1);
64 } 64 }
65 65
66 var needs_wrapper = false; 66 var needs_wrapper = false;
67 if (IS_NULL_OR_UNDEFINED(thisArg)) { 67 if (IS_NULL_OR_UNDEFINED(thisArg)) {
68 thisArg = %GetDefaultReceiver(predicate) || thisArg; 68 thisArg = %GetDefaultReceiver(predicate) || thisArg;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 return array; 127 return array;
128 } 128 }
129 129
130 // ES6, draft 10-14-14, section 22.1.2.1 130 // ES6, draft 10-14-14, section 22.1.2.1
131 function ArrayFrom(arrayLike, mapfn, receiver) { 131 function ArrayFrom(arrayLike, mapfn, receiver) {
132 var items = ToObject(arrayLike); 132 var items = ToObject(arrayLike);
133 var mapping = !IS_UNDEFINED(mapfn); 133 var mapping = !IS_UNDEFINED(mapfn);
134 134
135 if (mapping) { 135 if (mapping) {
136 if (!IS_SPEC_FUNCTION(mapfn)) { 136 if (!IS_SPEC_FUNCTION(mapfn)) {
137 throw MakeTypeError('called_non_callable', [ mapfn ]); 137 throw MakeTypeError(kCalledNonCallable, mapfn);
138 } else if (IS_NULL_OR_UNDEFINED(receiver)) { 138 } else if (IS_NULL_OR_UNDEFINED(receiver)) {
139 receiver = %GetDefaultReceiver(mapfn) || receiver; 139 receiver = %GetDefaultReceiver(mapfn) || receiver;
140 } else if (!IS_SPEC_OBJECT(receiver) && %IsSloppyModeFunction(mapfn)) { 140 } else if (!IS_SPEC_OBJECT(receiver) && %IsSloppyModeFunction(mapfn)) {
141 receiver = ToObject(receiver); 141 receiver = ToObject(receiver);
142 } 142 }
143 } 143 }
144 144
145 var iterable = GetMethod(items, symbolIterator); 145 var iterable = GetMethod(items, symbolIterator);
146 var k; 146 var k;
147 var result; 147 var result;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 232
233 // Set up the non-enumerable functions on the Array prototype object. 233 // Set up the non-enumerable functions on the Array prototype object.
234 InstallFunctions($Array.prototype, DONT_ENUM, [ 234 InstallFunctions($Array.prototype, DONT_ENUM, [
235 "find", ArrayFind, 235 "find", ArrayFind,
236 "findIndex", ArrayFindIndex, 236 "findIndex", ArrayFindIndex,
237 "fill", ArrayFill 237 "fill", ArrayFill
238 ]); 238 ]);
239 } 239 }
240 240
241 HarmonyArrayExtendArrayPrototype(); 241 HarmonyArrayExtendArrayPrototype();
OLDNEW
« no previous file with comments | « src/generator.js ('k') | src/harmony-typedarray.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698