OLD | NEW |
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 (function(global, utils) { | 5 (function(global, utils) { |
6 | 6 |
7 "use strict"; | 7 "use strict"; |
8 | 8 |
9 %CheckIsBootstrapping(); | 9 %CheckIsBootstrapping(); |
10 | 10 |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 function ArrayToLocaleString() { | 404 function ArrayToLocaleString() { |
405 var array = TO_OBJECT(this); | 405 var array = TO_OBJECT(this); |
406 var arrayLen = array.length; | 406 var arrayLen = array.length; |
407 return InnerArrayToLocaleString(array, arrayLen); | 407 return InnerArrayToLocaleString(array, arrayLen); |
408 } | 408 } |
409 | 409 |
410 | 410 |
411 function InnerArrayJoin(separator, array, length) { | 411 function InnerArrayJoin(separator, array, length) { |
412 if (IS_UNDEFINED(separator)) { | 412 if (IS_UNDEFINED(separator)) { |
413 separator = ','; | 413 separator = ','; |
414 } else if (!IS_STRING(separator)) { | 414 } else { |
415 separator = $nonStringToString(separator); | 415 separator = TO_STRING(separator); |
416 } | 416 } |
417 | 417 |
418 var result = %_FastOneByteArrayJoin(array, separator); | 418 var result = %_FastOneByteArrayJoin(array, separator); |
419 if (!IS_UNDEFINED(result)) return result; | 419 if (!IS_UNDEFINED(result)) return result; |
420 | 420 |
421 // Fast case for one-element arrays. | 421 // Fast case for one-element arrays. |
422 if (length === 1) { | 422 if (length === 1) { |
423 var e = array[0]; | 423 var e = array[0]; |
424 if (IS_STRING(e)) return e; | |
425 if (IS_NULL_OR_UNDEFINED(e)) return ''; | 424 if (IS_NULL_OR_UNDEFINED(e)) return ''; |
426 return $nonStringToString(e); | 425 return TO_STRING(e); |
427 } | 426 } |
428 | 427 |
429 return Join(array, length, separator, ConvertToString); | 428 return Join(array, length, separator, ConvertToString); |
430 } | 429 } |
431 | 430 |
432 | 431 |
433 function ArrayJoin(separator) { | 432 function ArrayJoin(separator) { |
434 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.join"); | 433 CHECK_OBJECT_COERCIBLE(this, "Array.prototype.join"); |
435 | 434 |
436 var array = TO_OBJECT(this); | 435 var array = TO_OBJECT(this); |
(...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1658 %InstallToContext([ | 1657 %InstallToContext([ |
1659 "array_pop", ArrayPop, | 1658 "array_pop", ArrayPop, |
1660 "array_push", ArrayPush, | 1659 "array_push", ArrayPush, |
1661 "array_shift", ArrayShift, | 1660 "array_shift", ArrayShift, |
1662 "array_splice", ArraySplice, | 1661 "array_splice", ArraySplice, |
1663 "array_slice", ArraySlice, | 1662 "array_slice", ArraySlice, |
1664 "array_unshift", ArrayUnshift, | 1663 "array_unshift", ArrayUnshift, |
1665 ]); | 1664 ]); |
1666 | 1665 |
1667 }); | 1666 }); |
OLD | NEW |