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 23 matching lines...) Expand all Loading... |
34 */ | 34 */ |
35 | 35 |
36 | 36 |
37 function ToPositiveInteger(x, rangeErrorIndex) { | 37 function ToPositiveInteger(x, rangeErrorIndex) { |
38 var i = TO_INTEGER(x) + 0; | 38 var i = TO_INTEGER(x) + 0; |
39 if (i < 0) throw %make_range_error(rangeErrorIndex); | 39 if (i < 0) throw %make_range_error(rangeErrorIndex); |
40 return i; | 40 return i; |
41 } | 41 } |
42 | 42 |
43 | 43 |
| 44 function ToIndex(x, rangeErrorIndex) { |
| 45 var i = TO_INTEGER(x) + 0; |
| 46 if (i < 0 || i > kMaxSafeInteger) throw %make_range_error(rangeErrorIndex); |
| 47 return i; |
| 48 } |
| 49 |
| 50 |
44 function MaxSimple(a, b) { | 51 function MaxSimple(a, b) { |
45 return a > b ? a : b; | 52 return a > b ? a : b; |
46 } | 53 } |
47 | 54 |
48 | 55 |
49 function MinSimple(a, b) { | 56 function MinSimple(a, b) { |
50 return a > b ? b : a; | 57 return a > b ? b : a; |
51 } | 58 } |
52 | 59 |
53 | 60 |
(...skipping 29 matching lines...) Expand all Loading... |
83 // boilerplate gets the right prototype. | 90 // boilerplate gets the right prototype. |
84 %FunctionSetPrototype(GlobalArray, new GlobalArray(0)); | 91 %FunctionSetPrototype(GlobalArray, new GlobalArray(0)); |
85 | 92 |
86 // ---------------------------------------------------------------------------- | 93 // ---------------------------------------------------------------------------- |
87 // Exports | 94 // Exports |
88 | 95 |
89 utils.Export(function(to) { | 96 utils.Export(function(to) { |
90 to.MaxSimple = MaxSimple; | 97 to.MaxSimple = MaxSimple; |
91 to.MinSimple = MinSimple; | 98 to.MinSimple = MinSimple; |
92 to.ToPositiveInteger = ToPositiveInteger; | 99 to.ToPositiveInteger = ToPositiveInteger; |
| 100 to.ToIndex = ToIndex; |
93 to.SpeciesConstructor = SpeciesConstructor; | 101 to.SpeciesConstructor = SpeciesConstructor; |
94 }); | 102 }); |
95 | 103 |
96 }) | 104 }) |
OLD | NEW |