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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 } | 374 } |
375 } | 375 } |
376 } | 376 } |
377 } | 377 } |
378 | 378 |
379 | 379 |
380 // ------------------------------------------------------------------- | 380 // ------------------------------------------------------------------- |
381 | 381 |
382 | 382 |
383 function ArrayToString() { | 383 function ArrayToString() { |
384 if (!IS_ARRAY(this)) { | 384 var array; |
385 throw new $TypeError('Array.prototype.toString is not generic'); | 385 var func; |
| 386 if (IS_ARRAY(this)) { |
| 387 func = this.join; |
| 388 if (func === ArrayJoin) { |
| 389 return Join(this, this.length, ',', ConvertToString); |
| 390 } |
| 391 array = this; |
| 392 } else { |
| 393 array = ToObject(this); |
| 394 func = array.join; |
386 } | 395 } |
387 return Join(this, this.length, ',', ConvertToString); | 396 if (!IS_SPEC_FUNCTION(func)) { |
| 397 return %_CallFunction(array, ObjectToString); |
| 398 } |
| 399 return %_CallFunction(array, func); |
388 } | 400 } |
389 | 401 |
390 | 402 |
391 function ArrayToLocaleString() { | 403 function ArrayToLocaleString() { |
392 if (!IS_ARRAY(this)) { | 404 if (!IS_ARRAY(this)) { |
393 throw new $TypeError('Array.prototype.toString is not generic'); | 405 throw new $TypeError('Array.prototype.toString is not generic'); |
394 } | 406 } |
395 return Join(this, this.length, ',', ConvertToLocaleString); | 407 return Join(this, this.length, ',', ConvertToLocaleString); |
396 } | 408 } |
397 | 409 |
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1372 // exposed to user code. | 1384 // exposed to user code. |
1373 // Adding only the functions that are actually used. | 1385 // Adding only the functions that are actually used. |
1374 SetUpLockedPrototype(InternalArray, $Array(), $Array( | 1386 SetUpLockedPrototype(InternalArray, $Array(), $Array( |
1375 "join", getFunction("join", ArrayJoin), | 1387 "join", getFunction("join", ArrayJoin), |
1376 "pop", getFunction("pop", ArrayPop), | 1388 "pop", getFunction("pop", ArrayPop), |
1377 "push", getFunction("push", ArrayPush) | 1389 "push", getFunction("push", ArrayPush) |
1378 )); | 1390 )); |
1379 } | 1391 } |
1380 | 1392 |
1381 SetUpArray(); | 1393 SetUpArray(); |
OLD | NEW |