OLD | NEW |
---|---|
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
Jakob Kummerow
2012/04/16 08:08:56
2012
| |
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 |
11 // with the distribution. | 11 // with the distribution. |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
458 var n = TO_UINT32(this.length); | 458 var n = TO_UINT32(this.length); |
459 var m = %_ArgumentsLength(); | 459 var m = %_ArgumentsLength(); |
460 for (var i = 0; i < m; i++) { | 460 for (var i = 0; i < m; i++) { |
461 this[i+n] = %_Arguments(i); | 461 this[i+n] = %_Arguments(i); |
462 } | 462 } |
463 this.length = n + m; | 463 this.length = n + m; |
464 return this.length; | 464 return this.length; |
465 } | 465 } |
466 | 466 |
467 | 467 |
468 // Returns an array containing the array elements of the object followed | |
469 // by the array elements of each argument in order. See ECMA-262, | |
470 // section 15.4.4.7. | |
468 function ArrayConcat(arg1) { // length == 1 | 471 function ArrayConcat(arg1) { // length == 1 |
469 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { | 472 if (IS_NULL_OR_UNDEFINED(this) && !IS_UNDETECTABLE(this)) { |
470 throw MakeTypeError("called_on_null_or_undefined", | 473 throw MakeTypeError("called_on_null_or_undefined", |
471 ["Array.prototype.concat"]); | 474 ["Array.prototype.concat"]); |
472 } | 475 } |
473 | 476 |
477 var array = ToObject(this); | |
474 var arg_count = %_ArgumentsLength(); | 478 var arg_count = %_ArgumentsLength(); |
475 var arrays = new InternalArray(1 + arg_count); | 479 var arrays = new InternalArray(1 + arg_count); |
476 arrays[0] = this; | 480 arrays[0] = array; |
477 for (var i = 0; i < arg_count; i++) { | 481 for (var i = 0; i < arg_count; i++) { |
478 arrays[i + 1] = %_Arguments(i); | 482 arrays[i + 1] = %_Arguments(i); |
479 } | 483 } |
480 | 484 |
481 return %ArrayConcat(arrays); | 485 return %ArrayConcat(arrays); |
482 } | 486 } |
483 | 487 |
484 | 488 |
485 // For implementing reverse() on large, sparse arrays. | 489 // For implementing reverse() on large, sparse arrays. |
486 function SparseReverse(array, len) { | 490 function SparseReverse(array, len) { |
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1418 // exposed to user code. | 1422 // exposed to user code. |
1419 // Adding only the functions that are actually used. | 1423 // Adding only the functions that are actually used. |
1420 SetUpLockedPrototype(InternalArray, $Array(), $Array( | 1424 SetUpLockedPrototype(InternalArray, $Array(), $Array( |
1421 "join", getFunction("join", ArrayJoin), | 1425 "join", getFunction("join", ArrayJoin), |
1422 "pop", getFunction("pop", ArrayPop), | 1426 "pop", getFunction("pop", ArrayPop), |
1423 "push", getFunction("push", ArrayPush) | 1427 "push", getFunction("push", ArrayPush) |
1424 )); | 1428 )); |
1425 } | 1429 } |
1426 | 1430 |
1427 SetUpArray(); | 1431 SetUpArray(); |
OLD | NEW |