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 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 var valueOf = x.valueOf; | 665 var valueOf = x.valueOf; |
666 if (IS_SPEC_FUNCTION(valueOf)) { | 666 if (IS_SPEC_FUNCTION(valueOf)) { |
667 var v = %_CallFunction(x, valueOf); | 667 var v = %_CallFunction(x, valueOf); |
668 if (%IsPrimitive(v)) return v; | 668 if (%IsPrimitive(v)) return v; |
669 } | 669 } |
670 } | 670 } |
671 throw %MakeTypeError('cannot_convert_to_primitive', []); | 671 throw %MakeTypeError('cannot_convert_to_primitive', []); |
672 } | 672 } |
673 | 673 |
674 function ToPositiveInteger(x, rangeErrorName) { | 674 function ToPositiveInteger(x, rangeErrorName) { |
675 var i = TO_INTEGER(x); | 675 var i = TO_INTEGER_MAP_MINUS_ZERO(x); |
676 if (i < 0) throw MakeRangeError(rangeErrorName); | 676 if (i < 0) throw MakeRangeError(rangeErrorName); |
677 return i; | 677 return i; |
678 } | 678 } |
679 | 679 |
680 | 680 |
681 // NOTE: Setting the prototype for Array must take place as early as | 681 // NOTE: Setting the prototype for Array must take place as early as |
682 // possible due to code generation for array literals. When | 682 // possible due to code generation for array literals. When |
683 // generating code for a array literal a boilerplate array is created | 683 // generating code for a array literal a boilerplate array is created |
684 // that is cloned when running the code. It is essential that the | 684 // that is cloned when running the code. It is essential that the |
685 // boilerplate gets the right prototype. | 685 // boilerplate gets the right prototype. |
686 %FunctionSetPrototype($Array, new $Array(0)); | 686 %FunctionSetPrototype($Array, new $Array(0)); |
OLD | NEW |