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

Side by Side Diff: src/array.js

Issue 7044054: Fix Array.prototype.{reduce,reduceRight} to pass undefined as receiver (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments Created 9 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/parser.h » ('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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 i++; 1245 i++;
1246 break find_initial; 1246 break find_initial;
1247 } 1247 }
1248 } 1248 }
1249 throw MakeTypeError('reduce_no_initial', []); 1249 throw MakeTypeError('reduce_no_initial', []);
1250 } 1250 }
1251 1251
1252 for (; i < length; i++) { 1252 for (; i < length; i++) {
1253 var element = this[i]; 1253 var element = this[i];
1254 if (!IS_UNDEFINED(element) || i in this) { 1254 if (!IS_UNDEFINED(element) || i in this) {
1255 current = callback.call(null, current, element, i, this); 1255 current = callback.call(void 0, current, element, i, this);
1256 } 1256 }
1257 } 1257 }
1258 return current; 1258 return current;
1259 } 1259 }
1260 1260
1261 function ArrayReduceRight(callback, current) { 1261 function ArrayReduceRight(callback, current) {
1262 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { 1262 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) {
1263 throw MakeTypeError("called_on_null_or_undefined", 1263 throw MakeTypeError("called_on_null_or_undefined",
1264 ["Array.prototype.reduceRight"]); 1264 ["Array.prototype.reduceRight"]);
1265 } 1265 }
(...skipping 10 matching lines...) Expand all
1276 i--; 1276 i--;
1277 break find_initial; 1277 break find_initial;
1278 } 1278 }
1279 } 1279 }
1280 throw MakeTypeError('reduce_no_initial', []); 1280 throw MakeTypeError('reduce_no_initial', []);
1281 } 1281 }
1282 1282
1283 for (; i >= 0; i--) { 1283 for (; i >= 0; i--) {
1284 var element = this[i]; 1284 var element = this[i];
1285 if (!IS_UNDEFINED(element) || i in this) { 1285 if (!IS_UNDEFINED(element) || i in this) {
1286 current = callback.call(null, current, element, i, this); 1286 current = callback.call(void 0, current, element, i, this);
1287 } 1287 }
1288 } 1288 }
1289 return current; 1289 return current;
1290 } 1290 }
1291 1291
1292 // ES5, 15.4.3.2 1292 // ES5, 15.4.3.2
1293 function ArrayIsArray(obj) { 1293 function ArrayIsArray(obj) {
1294 return IS_ARRAY(obj); 1294 return IS_ARRAY(obj);
1295 } 1295 }
1296 1296
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1359 InternalArray.prototype.join = getFunction("join", ArrayJoin); 1359 InternalArray.prototype.join = getFunction("join", ArrayJoin);
1360 InternalArray.prototype.pop = getFunction("pop", ArrayPop); 1360 InternalArray.prototype.pop = getFunction("pop", ArrayPop);
1361 InternalArray.prototype.push = getFunction("push", ArrayPush); 1361 InternalArray.prototype.push = getFunction("push", ArrayPush);
1362 InternalArray.prototype.toString = function() { 1362 InternalArray.prototype.toString = function() {
1363 return "Internal Array, length " + this.length; 1363 return "Internal Array, length " + this.length;
1364 }; 1364 };
1365 } 1365 }
1366 1366
1367 1367
1368 SetupArray(); 1368 SetupArray();
OLDNEW
« no previous file with comments | « no previous file | src/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698