| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 files contains runtime support implemented in JavaScript. | 5 // This files contains runtime support implemented in JavaScript. |
| 6 | 6 |
| 7 // CAUTION: Some of the functions specified in this file are called | 7 // CAUTION: Some of the functions specified in this file are called |
| 8 // directly from compiled code. These are the functions with names in | 8 // directly from compiled code. These are the functions with names in |
| 9 // ALL CAPS. The compiled code passes the first argument in 'this'. | 9 // ALL CAPS. The compiled code passes the first argument in 'this'. |
| 10 | 10 |
| (...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 | 745 |
| 746 | 746 |
| 747 /* ------------------------------------- | 747 /* ------------------------------------- |
| 748 - - - C o n v e r s i o n s - - - | 748 - - - C o n v e r s i o n s - - - |
| 749 ------------------------------------- | 749 ------------------------------------- |
| 750 */ | 750 */ |
| 751 | 751 |
| 752 // ECMA-262, section 9.1, page 30. Use null/undefined for no hint, | 752 // ECMA-262, section 9.1, page 30. Use null/undefined for no hint, |
| 753 // (1) for number hint, and (2) for string hint. | 753 // (1) for number hint, and (2) for string hint. |
| 754 function ToPrimitive(x, hint) { | 754 function ToPrimitive(x, hint) { |
| 755 // Fast case check. | |
| 756 if (IS_STRING(x)) return x; | |
| 757 // Normal behavior. | |
| 758 if (!IS_SPEC_OBJECT(x)) return x; | 755 if (!IS_SPEC_OBJECT(x)) return x; |
| 759 if (IS_SIMD_VALUE(x)) return x; | |
| 760 if (hint == NO_HINT) hint = (IS_DATE(x)) ? STRING_HINT : NUMBER_HINT; | 756 if (hint == NO_HINT) hint = (IS_DATE(x)) ? STRING_HINT : NUMBER_HINT; |
| 761 return (hint == NUMBER_HINT) ? DefaultNumber(x) : DefaultString(x); | 757 return (hint == NUMBER_HINT) ? DefaultNumber(x) : DefaultString(x); |
| 762 } | 758 } |
| 763 | 759 |
| 764 | 760 |
| 765 // ECMA-262, section 9.2, page 30 | 761 // ECMA-262, section 9.2, page 30 |
| 766 function ToBoolean(x) { | 762 function ToBoolean(x) { |
| 767 if (IS_BOOLEAN(x)) return x; | 763 if (IS_BOOLEAN(x)) return x; |
| 768 if (IS_STRING(x)) return x.length != 0; | 764 if (IS_STRING(x)) return x.length != 0; |
| 769 if (x == null) return false; | 765 if (x == null) return false; |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 $toInteger = ToInteger; | 973 $toInteger = ToInteger; |
| 978 $toLength = ToLength; | 974 $toLength = ToLength; |
| 979 $toName = ToName; | 975 $toName = ToName; |
| 980 $toNumber = ToNumber; | 976 $toNumber = ToNumber; |
| 981 $toPositiveInteger = ToPositiveInteger; | 977 $toPositiveInteger = ToPositiveInteger; |
| 982 $toPrimitive = ToPrimitive; | 978 $toPrimitive = ToPrimitive; |
| 983 $toString = ToString; | 979 $toString = ToString; |
| 984 $toUint32 = ToUint32; | 980 $toUint32 = ToUint32; |
| 985 | 981 |
| 986 }) | 982 }) |
| OLD | NEW |