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