OLD | NEW |
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 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
992 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { | 992 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { |
993 throw MakeTypeError("called_on_null_or_undefined", | 993 throw MakeTypeError("called_on_null_or_undefined", |
994 ["Array.prototype.filter"]); | 994 ["Array.prototype.filter"]); |
995 } | 995 } |
996 | 996 |
997 if (!IS_FUNCTION(f)) { | 997 if (!IS_FUNCTION(f)) { |
998 throw MakeTypeError('called_non_callable', [ f ]); | 998 throw MakeTypeError('called_non_callable', [ f ]); |
999 } | 999 } |
1000 // Pull out the length so that modifications to the length in the | 1000 // Pull out the length so that modifications to the length in the |
1001 // loop will not affect the looping. | 1001 // loop will not affect the looping. |
1002 var length = this.length; | 1002 var length = ToUint32(this.length); |
1003 var result = []; | 1003 var result = []; |
1004 var result_length = 0; | 1004 var result_length = 0; |
1005 for (var i = 0; i < length; i++) { | 1005 for (var i = 0; i < length; i++) { |
1006 var current = this[i]; | 1006 var current = this[i]; |
1007 if (!IS_UNDEFINED(current) || i in this) { | 1007 if (!IS_UNDEFINED(current) || i in this) { |
1008 if (f.call(receiver, current, i, this)) { | 1008 if (f.call(receiver, current, i, this)) { |
1009 result[result_length++] = current; | 1009 result[result_length++] = current; |
1010 } | 1010 } |
1011 } | 1011 } |
1012 } | 1012 } |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1229 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { | 1229 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { |
1230 throw MakeTypeError("called_on_null_or_undefined", | 1230 throw MakeTypeError("called_on_null_or_undefined", |
1231 ["Array.prototype.reduce"]); | 1231 ["Array.prototype.reduce"]); |
1232 } | 1232 } |
1233 | 1233 |
1234 if (!IS_FUNCTION(callback)) { | 1234 if (!IS_FUNCTION(callback)) { |
1235 throw MakeTypeError('called_non_callable', [callback]); | 1235 throw MakeTypeError('called_non_callable', [callback]); |
1236 } | 1236 } |
1237 // Pull out the length so that modifications to the length in the | 1237 // Pull out the length so that modifications to the length in the |
1238 // loop will not affect the looping. | 1238 // loop will not affect the looping. |
1239 var length = this.length; | 1239 var length = ToUint32(this.length); |
1240 var i = 0; | 1240 var i = 0; |
1241 | 1241 |
1242 find_initial: if (%_ArgumentsLength() < 2) { | 1242 find_initial: if (%_ArgumentsLength() < 2) { |
1243 for (; i < length; i++) { | 1243 for (; i < length; i++) { |
1244 current = this[i]; | 1244 current = this[i]; |
1245 if (!IS_UNDEFINED(current) || i in this) { | 1245 if (!IS_UNDEFINED(current) || i in this) { |
1246 i++; | 1246 i++; |
1247 break find_initial; | 1247 break find_initial; |
1248 } | 1248 } |
1249 } | 1249 } |
(...skipping 11 matching lines...) Expand all Loading... |
1261 | 1261 |
1262 function ArrayReduceRight(callback, current) { | 1262 function ArrayReduceRight(callback, current) { |
1263 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { | 1263 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { |
1264 throw MakeTypeError("called_on_null_or_undefined", | 1264 throw MakeTypeError("called_on_null_or_undefined", |
1265 ["Array.prototype.reduceRight"]); | 1265 ["Array.prototype.reduceRight"]); |
1266 } | 1266 } |
1267 | 1267 |
1268 if (!IS_FUNCTION(callback)) { | 1268 if (!IS_FUNCTION(callback)) { |
1269 throw MakeTypeError('called_non_callable', [callback]); | 1269 throw MakeTypeError('called_non_callable', [callback]); |
1270 } | 1270 } |
1271 var i = this.length - 1; | 1271 var i = ToUint32(this.length) - 1; |
1272 | 1272 |
1273 find_initial: if (%_ArgumentsLength() < 2) { | 1273 find_initial: if (%_ArgumentsLength() < 2) { |
1274 for (; i >= 0; i--) { | 1274 for (; i >= 0; i--) { |
1275 current = this[i]; | 1275 current = this[i]; |
1276 if (!IS_UNDEFINED(current) || i in this) { | 1276 if (!IS_UNDEFINED(current) || i in this) { |
1277 i--; | 1277 i--; |
1278 break find_initial; | 1278 break find_initial; |
1279 } | 1279 } |
1280 } | 1280 } |
1281 throw MakeTypeError('reduce_no_initial', []); | 1281 throw MakeTypeError('reduce_no_initial', []); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1360 InternalArray.prototype.join = getFunction("join", ArrayJoin); | 1360 InternalArray.prototype.join = getFunction("join", ArrayJoin); |
1361 InternalArray.prototype.pop = getFunction("pop", ArrayPop); | 1361 InternalArray.prototype.pop = getFunction("pop", ArrayPop); |
1362 InternalArray.prototype.push = getFunction("push", ArrayPush); | 1362 InternalArray.prototype.push = getFunction("push", ArrayPush); |
1363 InternalArray.prototype.toString = function() { | 1363 InternalArray.prototype.toString = function() { |
1364 return "Internal Array, length " + this.length; | 1364 return "Internal Array, length " + this.length; |
1365 }; | 1365 }; |
1366 } | 1366 } |
1367 | 1367 |
1368 | 1368 |
1369 SetupArray(); | 1369 SetupArray(); |
OLD | NEW |