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 // This file relies on the fact that the following declarations have been made | 5 // This file relies on the fact that the following declarations have been made |
6 // in runtime.js: | 6 // in runtime.js: |
7 // var $Object = global.Object; | 7 // var $Object = global.Object; |
8 // var $Boolean = global.Boolean; | 8 // var $Boolean = global.Boolean; |
9 // var $Number = global.Number; | 9 // var $Number = global.Number; |
10 // var $Function = global.Function; | 10 // var $Function = global.Function; |
(...skipping 1520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1531 // Get the value of this number in case it's an object. | 1531 // Get the value of this number in case it's an object. |
1532 number = %_ValueOf(this); | 1532 number = %_ValueOf(this); |
1533 } | 1533 } |
1534 // Fast case: Convert number in radix 10. | 1534 // Fast case: Convert number in radix 10. |
1535 if (IS_UNDEFINED(radix) || radix === 10) { | 1535 if (IS_UNDEFINED(radix) || radix === 10) { |
1536 return %_NumberToString(number); | 1536 return %_NumberToString(number); |
1537 } | 1537 } |
1538 | 1538 |
1539 // Convert the radix to an integer and check the range. | 1539 // Convert the radix to an integer and check the range. |
1540 radix = TO_INTEGER(radix); | 1540 radix = TO_INTEGER(radix); |
1541 if (radix < 2 || radix > 36) { | 1541 if (radix < 2 || radix > 36) throw MakeRangeError(kToRadixFormatRange); |
1542 throw new $RangeError('toString() radix argument must be between 2 and 36'); | |
1543 } | |
1544 // Convert the number to a string in the given radix. | 1542 // Convert the number to a string in the given radix. |
1545 return %NumberToRadixString(number, radix); | 1543 return %NumberToRadixString(number, radix); |
1546 } | 1544 } |
1547 | 1545 |
1548 | 1546 |
1549 // ECMA-262 section 15.7.4.3 | 1547 // ECMA-262 section 15.7.4.3 |
1550 function NumberToLocaleString() { | 1548 function NumberToLocaleString() { |
1551 return %_CallFunction(this, NumberToStringJS); | 1549 return %_CallFunction(this, NumberToStringJS); |
1552 } | 1550 } |
1553 | 1551 |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1894 } | 1892 } |
1895 if (!IS_SPEC_FUNCTION(method)) { | 1893 if (!IS_SPEC_FUNCTION(method)) { |
1896 throw MakeTypeError(kNotIterable, obj); | 1894 throw MakeTypeError(kNotIterable, obj); |
1897 } | 1895 } |
1898 var iterator = %_CallFunction(obj, method); | 1896 var iterator = %_CallFunction(obj, method); |
1899 if (!IS_SPEC_OBJECT(iterator)) { | 1897 if (!IS_SPEC_OBJECT(iterator)) { |
1900 throw MakeTypeError(kNotAnIterator, iterator); | 1898 throw MakeTypeError(kNotAnIterator, iterator); |
1901 } | 1899 } |
1902 return iterator; | 1900 return iterator; |
1903 } | 1901 } |
OLD | NEW |