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 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 var spreadable = O[isConcatSpreadableSymbol]; | 710 var spreadable = O[isConcatSpreadableSymbol]; |
711 if (IS_UNDEFINED(spreadable)) return IS_ARRAY(O); | 711 if (IS_UNDEFINED(spreadable)) return IS_ARRAY(O); |
712 return ToBoolean(spreadable); | 712 return ToBoolean(spreadable); |
713 } | 713 } |
714 | 714 |
715 | 715 |
716 // ECMA-262, section 8.6.2.6, page 28. | 716 // ECMA-262, section 8.6.2.6, page 28. |
717 function DefaultNumber(x) { | 717 function DefaultNumber(x) { |
718 var valueOf = x.valueOf; | 718 var valueOf = x.valueOf; |
719 if (IS_CALLABLE(valueOf)) { | 719 if (IS_CALLABLE(valueOf)) { |
720 var v = %_CallFunction(x, valueOf); | 720 var v = %_Call(valueOf, x); |
721 if (IS_SYMBOL(v)) throw MakeTypeError(kSymbolToNumber); | 721 if (IS_SYMBOL(v)) throw MakeTypeError(kSymbolToNumber); |
722 if (IS_SIMD_VALUE(x)) throw MakeTypeError(kSimdToNumber); | 722 if (IS_SIMD_VALUE(x)) throw MakeTypeError(kSimdToNumber); |
723 if (IsPrimitive(v)) return v; | 723 if (IsPrimitive(v)) return v; |
724 } | 724 } |
725 var toString = x.toString; | 725 var toString = x.toString; |
726 if (IS_CALLABLE(toString)) { | 726 if (IS_CALLABLE(toString)) { |
727 var s = %_CallFunction(x, toString); | 727 var s = %_Call(toString, x); |
728 if (IsPrimitive(s)) return s; | 728 if (IsPrimitive(s)) return s; |
729 } | 729 } |
730 throw MakeTypeError(kCannotConvertToPrimitive); | 730 throw MakeTypeError(kCannotConvertToPrimitive); |
731 } | 731 } |
732 | 732 |
733 // ECMA-262, section 8.6.2.6, page 28. | 733 // ECMA-262, section 8.6.2.6, page 28. |
734 function DefaultString(x) { | 734 function DefaultString(x) { |
735 if (!IS_SYMBOL_WRAPPER(x)) { | 735 if (!IS_SYMBOL_WRAPPER(x)) { |
736 if (IS_SYMBOL(x)) throw MakeTypeError(kSymbolToString); | 736 if (IS_SYMBOL(x)) throw MakeTypeError(kSymbolToString); |
737 var toString = x.toString; | 737 var toString = x.toString; |
738 if (IS_CALLABLE(toString)) { | 738 if (IS_CALLABLE(toString)) { |
739 var s = %_CallFunction(x, toString); | 739 var s = %_Call(toString, x); |
740 if (IsPrimitive(s)) return s; | 740 if (IsPrimitive(s)) return s; |
741 } | 741 } |
742 | 742 |
743 var valueOf = x.valueOf; | 743 var valueOf = x.valueOf; |
744 if (IS_CALLABLE(valueOf)) { | 744 if (IS_CALLABLE(valueOf)) { |
745 var v = %_CallFunction(x, valueOf); | 745 var v = %_Call(valueOf, x); |
746 if (IsPrimitive(v)) return v; | 746 if (IsPrimitive(v)) return v; |
747 } | 747 } |
748 } | 748 } |
749 throw MakeTypeError(kCannotConvertToPrimitive); | 749 throw MakeTypeError(kCannotConvertToPrimitive); |
750 } | 750 } |
751 | 751 |
752 function ToPositiveInteger(x, rangeErrorIndex) { | 752 function ToPositiveInteger(x, rangeErrorIndex) { |
753 var i = TO_INTEGER_MAP_MINUS_ZERO(x); | 753 var i = TO_INTEGER_MAP_MINUS_ZERO(x); |
754 if (i < 0) throw MakeRangeError(rangeErrorIndex); | 754 if (i < 0) throw MakeRangeError(rangeErrorIndex); |
755 return i; | 755 return i; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 | 830 |
831 utils.Export(function(to) { | 831 utils.Export(function(to) { |
832 to.ToBoolean = ToBoolean; | 832 to.ToBoolean = ToBoolean; |
833 to.ToLength = ToLength; | 833 to.ToLength = ToLength; |
834 to.ToNumber = ToNumber; | 834 to.ToNumber = ToNumber; |
835 to.ToPrimitive = ToPrimitive; | 835 to.ToPrimitive = ToPrimitive; |
836 to.ToString = ToString; | 836 to.ToString = ToString; |
837 }); | 837 }); |
838 | 838 |
839 }) | 839 }) |
OLD | NEW |