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

Side by Side Diff: src/array.js

Issue 1095573002: Revert of Migrate error messages, part 2. (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 | « 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 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 // preserving the semantics, since the calls to the receiver function can add 1135 // preserving the semantics, since the calls to the receiver function can add
1136 // or delete elements from the array. 1136 // or delete elements from the array.
1137 function ArrayFilter(f, receiver) { 1137 function ArrayFilter(f, receiver) {
1138 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.filter"); 1138 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.filter");
1139 1139
1140 // Pull out the length so that modifications to the length in the 1140 // Pull out the length so that modifications to the length in the
1141 // loop will not affect the looping and side effects are visible. 1141 // loop will not affect the looping and side effects are visible.
1142 var array = ToObject(this); 1142 var array = ToObject(this);
1143 var length = ToUint32(array.length); 1143 var length = ToUint32(array.length);
1144 1144
1145 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); 1145 if (!IS_SPEC_FUNCTION(f)) {
1146 throw MakeTypeError('called_non_callable', [ f ]);
1147 }
1146 var needs_wrapper = false; 1148 var needs_wrapper = false;
1147 if (IS_NULL_OR_UNDEFINED(receiver)) { 1149 if (IS_NULL_OR_UNDEFINED(receiver)) {
1148 receiver = %GetDefaultReceiver(f) || receiver; 1150 receiver = %GetDefaultReceiver(f) || receiver;
1149 } else { 1151 } else {
1150 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); 1152 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver);
1151 } 1153 }
1152 1154
1153 var result = new $Array(); 1155 var result = new $Array();
1154 var accumulator = new InternalArray(); 1156 var accumulator = new InternalArray();
1155 var accumulator_length = 0; 1157 var accumulator_length = 0;
(...skipping 16 matching lines...) Expand all
1172 1174
1173 1175
1174 function ArrayForEach(f, receiver) { 1176 function ArrayForEach(f, receiver) {
1175 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.forEach"); 1177 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.forEach");
1176 1178
1177 // Pull out the length so that modifications to the length in the 1179 // Pull out the length so that modifications to the length in the
1178 // loop will not affect the looping and side effects are visible. 1180 // loop will not affect the looping and side effects are visible.
1179 var array = ToObject(this); 1181 var array = ToObject(this);
1180 var length = TO_UINT32(array.length); 1182 var length = TO_UINT32(array.length);
1181 1183
1182 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); 1184 if (!IS_SPEC_FUNCTION(f)) {
1185 throw MakeTypeError('called_non_callable', [ f ]);
1186 }
1183 var needs_wrapper = false; 1187 var needs_wrapper = false;
1184 if (IS_NULL_OR_UNDEFINED(receiver)) { 1188 if (IS_NULL_OR_UNDEFINED(receiver)) {
1185 receiver = %GetDefaultReceiver(f) || receiver; 1189 receiver = %GetDefaultReceiver(f) || receiver;
1186 } else { 1190 } else {
1187 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); 1191 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver);
1188 } 1192 }
1189 1193
1190 var is_array = IS_ARRAY(array); 1194 var is_array = IS_ARRAY(array);
1191 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); 1195 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f);
1192 for (var i = 0; i < length; i++) { 1196 for (var i = 0; i < length; i++) {
(...skipping 11 matching lines...) Expand all
1204 // Executes the function once for each element present in the 1208 // Executes the function once for each element present in the
1205 // array until it finds one where callback returns true. 1209 // array until it finds one where callback returns true.
1206 function ArraySome(f, receiver) { 1210 function ArraySome(f, receiver) {
1207 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.some"); 1211 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.some");
1208 1212
1209 // Pull out the length so that modifications to the length in the 1213 // Pull out the length so that modifications to the length in the
1210 // loop will not affect the looping and side effects are visible. 1214 // loop will not affect the looping and side effects are visible.
1211 var array = ToObject(this); 1215 var array = ToObject(this);
1212 var length = TO_UINT32(array.length); 1216 var length = TO_UINT32(array.length);
1213 1217
1214 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); 1218 if (!IS_SPEC_FUNCTION(f)) {
1219 throw MakeTypeError('called_non_callable', [ f ]);
1220 }
1215 var needs_wrapper = false; 1221 var needs_wrapper = false;
1216 if (IS_NULL_OR_UNDEFINED(receiver)) { 1222 if (IS_NULL_OR_UNDEFINED(receiver)) {
1217 receiver = %GetDefaultReceiver(f) || receiver; 1223 receiver = %GetDefaultReceiver(f) || receiver;
1218 } else { 1224 } else {
1219 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); 1225 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver);
1220 } 1226 }
1221 1227
1222 var is_array = IS_ARRAY(array); 1228 var is_array = IS_ARRAY(array);
1223 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); 1229 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f);
1224 for (var i = 0; i < length; i++) { 1230 for (var i = 0; i < length; i++) {
(...skipping 10 matching lines...) Expand all
1235 1241
1236 1242
1237 function ArrayEvery(f, receiver) { 1243 function ArrayEvery(f, receiver) {
1238 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.every"); 1244 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.every");
1239 1245
1240 // Pull out the length so that modifications to the length in the 1246 // Pull out the length so that modifications to the length in the
1241 // loop will not affect the looping and side effects are visible. 1247 // loop will not affect the looping and side effects are visible.
1242 var array = ToObject(this); 1248 var array = ToObject(this);
1243 var length = TO_UINT32(array.length); 1249 var length = TO_UINT32(array.length);
1244 1250
1245 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); 1251 if (!IS_SPEC_FUNCTION(f)) {
1252 throw MakeTypeError('called_non_callable', [ f ]);
1253 }
1246 var needs_wrapper = false; 1254 var needs_wrapper = false;
1247 if (IS_NULL_OR_UNDEFINED(receiver)) { 1255 if (IS_NULL_OR_UNDEFINED(receiver)) {
1248 receiver = %GetDefaultReceiver(f) || receiver; 1256 receiver = %GetDefaultReceiver(f) || receiver;
1249 } else { 1257 } else {
1250 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); 1258 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver);
1251 } 1259 }
1252 1260
1253 var is_array = IS_ARRAY(array); 1261 var is_array = IS_ARRAY(array);
1254 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f); 1262 var stepping = DEBUG_IS_ACTIVE && %DebugCallbackSupportsStepping(f);
1255 for (var i = 0; i < length; i++) { 1263 for (var i = 0; i < length; i++) {
1256 if (HAS_INDEX(array, i, is_array)) { 1264 if (HAS_INDEX(array, i, is_array)) {
1257 var element = array[i]; 1265 var element = array[i];
1258 // Prepare break slots for debugger step in. 1266 // Prepare break slots for debugger step in.
1259 if (stepping) %DebugPrepareStepInIfStepping(f); 1267 if (stepping) %DebugPrepareStepInIfStepping(f);
1260 var new_receiver = needs_wrapper ? ToObject(receiver) : receiver; 1268 var new_receiver = needs_wrapper ? ToObject(receiver) : receiver;
1261 if (!%_CallFunction(new_receiver, element, i, array, f)) return false; 1269 if (!%_CallFunction(new_receiver, element, i, array, f)) return false;
1262 } 1270 }
1263 } 1271 }
1264 return true; 1272 return true;
1265 } 1273 }
1266 1274
1267 function ArrayMap(f, receiver) { 1275 function ArrayMap(f, receiver) {
1268 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.map"); 1276 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.map");
1269 1277
1270 // Pull out the length so that modifications to the length in the 1278 // Pull out the length so that modifications to the length in the
1271 // loop will not affect the looping and side effects are visible. 1279 // loop will not affect the looping and side effects are visible.
1272 var array = ToObject(this); 1280 var array = ToObject(this);
1273 var length = TO_UINT32(array.length); 1281 var length = TO_UINT32(array.length);
1274 1282
1275 if (!IS_SPEC_FUNCTION(f)) throw MakeTypeError(kCalledNonCallable, f); 1283 if (!IS_SPEC_FUNCTION(f)) {
1284 throw MakeTypeError('called_non_callable', [ f ]);
1285 }
1276 var needs_wrapper = false; 1286 var needs_wrapper = false;
1277 if (IS_NULL_OR_UNDEFINED(receiver)) { 1287 if (IS_NULL_OR_UNDEFINED(receiver)) {
1278 receiver = %GetDefaultReceiver(f) || receiver; 1288 receiver = %GetDefaultReceiver(f) || receiver;
1279 } else { 1289 } else {
1280 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver); 1290 needs_wrapper = SHOULD_CREATE_WRAPPER(f, receiver);
1281 } 1291 }
1282 1292
1283 var result = new $Array(); 1293 var result = new $Array();
1284 var accumulator = new InternalArray(length); 1294 var accumulator = new InternalArray(length);
1285 var is_array = IS_ARRAY(array); 1295 var is_array = IS_ARRAY(array);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 1420
1411 function ArrayReduce(callback, current) { 1421 function ArrayReduce(callback, current) {
1412 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reduce"); 1422 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reduce");
1413 1423
1414 // Pull out the length so that modifications to the length in the 1424 // Pull out the length so that modifications to the length in the
1415 // loop will not affect the looping and side effects are visible. 1425 // loop will not affect the looping and side effects are visible.
1416 var array = ToObject(this); 1426 var array = ToObject(this);
1417 var length = ToUint32(array.length); 1427 var length = ToUint32(array.length);
1418 1428
1419 if (!IS_SPEC_FUNCTION(callback)) { 1429 if (!IS_SPEC_FUNCTION(callback)) {
1420 throw MakeTypeError(kCalledNonCallable, callback); 1430 throw MakeTypeError('called_non_callable', [callback]);
1421 } 1431 }
1422 1432
1423 var is_array = IS_ARRAY(array); 1433 var is_array = IS_ARRAY(array);
1424 var i = 0; 1434 var i = 0;
1425 find_initial: if (%_ArgumentsLength() < 2) { 1435 find_initial: if (%_ArgumentsLength() < 2) {
1426 for (; i < length; i++) { 1436 for (; i < length; i++) {
1427 if (HAS_INDEX(array, i, is_array)) { 1437 if (HAS_INDEX(array, i, is_array)) {
1428 current = array[i++]; 1438 current = array[i++];
1429 break find_initial; 1439 break find_initial;
1430 } 1440 }
(...skipping 16 matching lines...) Expand all
1447 1457
1448 function ArrayReduceRight(callback, current) { 1458 function ArrayReduceRight(callback, current) {
1449 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reduceRight"); 1459 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reduceRight");
1450 1460
1451 // Pull out the length so that side effects are visible before the 1461 // Pull out the length so that side effects are visible before the
1452 // callback function is checked. 1462 // callback function is checked.
1453 var array = ToObject(this); 1463 var array = ToObject(this);
1454 var length = ToUint32(array.length); 1464 var length = ToUint32(array.length);
1455 1465
1456 if (!IS_SPEC_FUNCTION(callback)) { 1466 if (!IS_SPEC_FUNCTION(callback)) {
1457 throw MakeTypeError(kCalledNonCallable, callback); 1467 throw MakeTypeError('called_non_callable', [callback]);
1458 } 1468 }
1459 1469
1460 var is_array = IS_ARRAY(array); 1470 var is_array = IS_ARRAY(array);
1461 var i = length - 1; 1471 var i = length - 1;
1462 find_initial: if (%_ArgumentsLength() < 2) { 1472 find_initial: if (%_ArgumentsLength() < 2) {
1463 for (; i >= 0; i--) { 1473 for (; i >= 0; i--) {
1464 if (HAS_INDEX(array, i, is_array)) { 1474 if (HAS_INDEX(array, i, is_array)) {
1465 current = array[i--]; 1475 current = array[i--];
1466 break find_initial; 1476 break find_initial;
1467 } 1477 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1571 ]); 1581 ]);
1572 1582
1573 SetUpLockedPrototype(InternalPackedArray, $Array(), [ 1583 SetUpLockedPrototype(InternalPackedArray, $Array(), [
1574 "join", getFunction("join", ArrayJoin), 1584 "join", getFunction("join", ArrayJoin),
1575 "pop", getFunction("pop", ArrayPop), 1585 "pop", getFunction("pop", ArrayPop),
1576 "push", getFunction("push", ArrayPush) 1586 "push", getFunction("push", ArrayPush)
1577 ]); 1587 ]);
1578 } 1588 }
1579 1589
1580 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