OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | |
2 // Redistribution and use in source and binary forms, with or without | 1 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 2 // modification, are permitted provided that the following conditions are |
4 // met: | 3 // met: |
5 // | 4 // |
6 // * Redistributions of source code must retain the above copyright | 5 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 6 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 7 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 8 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 9 // disclaimer in the documentation and/or other materials provided |
11 // with the distribution. | 10 // with the distribution. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 76 |
78 // ECMA 262 - 15.8.2.6 | 77 // ECMA 262 - 15.8.2.6 |
79 function MathCeil(x) { | 78 function MathCeil(x) { |
80 if (!IS_NUMBER(x)) x = ToNumber(x); | 79 if (!IS_NUMBER(x)) x = ToNumber(x); |
81 return %Math_ceil(x); | 80 return %Math_ceil(x); |
82 } | 81 } |
83 | 82 |
84 // ECMA 262 - 15.8.2.7 | 83 // ECMA 262 - 15.8.2.7 |
85 function MathCos(x) { | 84 function MathCos(x) { |
86 if (!IS_NUMBER(x)) x = ToNumber(x); | 85 if (!IS_NUMBER(x)) x = ToNumber(x); |
87 return %_Math_cos(x); | 86 return %_MathCos(x); |
88 } | 87 } |
89 | 88 |
90 // ECMA 262 - 15.8.2.8 | 89 // ECMA 262 - 15.8.2.8 |
91 function MathExp(x) { | 90 function MathExp(x) { |
92 if (!IS_NUMBER(x)) x = ToNumber(x); | 91 if (!IS_NUMBER(x)) x = ToNumber(x); |
93 return %Math_exp(x); | 92 return %Math_exp(x); |
94 } | 93 } |
95 | 94 |
96 // ECMA 262 - 15.8.2.9 | 95 // ECMA 262 - 15.8.2.9 |
97 function MathFloor(x) { | 96 function MathFloor(x) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 // Smi or a heap number. | 151 // Smi or a heap number. |
153 if (n < r || (r === 0 && n === 0 && !%_IsSmi(n) && 1 / n < 0)) r = n; | 152 if (n < r || (r === 0 && n === 0 && !%_IsSmi(n) && 1 / n < 0)) r = n; |
154 } | 153 } |
155 return r; | 154 return r; |
156 } | 155 } |
157 | 156 |
158 // ECMA 262 - 15.8.2.13 | 157 // ECMA 262 - 15.8.2.13 |
159 function MathPow(x, y) { | 158 function MathPow(x, y) { |
160 if (!IS_NUMBER(x)) x = ToNumber(x); | 159 if (!IS_NUMBER(x)) x = ToNumber(x); |
161 if (!IS_NUMBER(y)) y = ToNumber(y); | 160 if (!IS_NUMBER(y)) y = ToNumber(y); |
162 return %_Math_pow(x, y); | 161 return %_MathPow(x, y); |
163 } | 162 } |
164 | 163 |
165 // ECMA 262 - 15.8.2.14 | 164 // ECMA 262 - 15.8.2.14 |
166 function MathRandom() { | 165 function MathRandom() { |
167 return %_RandomPositiveSmi() / 0x40000000; | 166 return %_RandomPositiveSmi() / 0x40000000; |
168 } | 167 } |
169 | 168 |
170 // ECMA 262 - 15.8.2.15 | 169 // ECMA 262 - 15.8.2.15 |
171 function MathRound(x) { | 170 function MathRound(x) { |
172 if (!IS_NUMBER(x)) x = ToNumber(x); | 171 if (!IS_NUMBER(x)) x = ToNumber(x); |
173 return %Math_round(x); | 172 return %Math_round(x); |
174 } | 173 } |
175 | 174 |
176 // ECMA 262 - 15.8.2.16 | 175 // ECMA 262 - 15.8.2.16 |
177 function MathSin(x) { | 176 function MathSin(x) { |
178 if (!IS_NUMBER(x)) x = ToNumber(x); | 177 if (!IS_NUMBER(x)) x = ToNumber(x); |
179 return %_Math_sin(x); | 178 return %_MathSin(x); |
180 } | 179 } |
181 | 180 |
182 // ECMA 262 - 15.8.2.17 | 181 // ECMA 262 - 15.8.2.17 |
183 function MathSqrt(x) { | 182 function MathSqrt(x) { |
184 if (!IS_NUMBER(x)) x = ToNumber(x); | 183 if (!IS_NUMBER(x)) x = ToNumber(x); |
185 return %_Math_sqrt(x); | 184 return %_MathSqrt(x); |
186 } | 185 } |
187 | 186 |
188 // ECMA 262 - 15.8.2.18 | 187 // ECMA 262 - 15.8.2.18 |
189 function MathTan(x) { | 188 function MathTan(x) { |
190 if (!IS_NUMBER(x)) x = ToNumber(x); | 189 if (!IS_NUMBER(x)) x = ToNumber(x); |
191 return %Math_tan(x); | 190 return %Math_tan(x); |
192 } | 191 } |
193 | 192 |
194 | 193 |
195 // ------------------------------------------------------------------- | 194 // ------------------------------------------------------------------- |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 "tan", MathTan, | 253 "tan", MathTan, |
255 "atan2", MathAtan2, | 254 "atan2", MathAtan2, |
256 "pow", MathPow, | 255 "pow", MathPow, |
257 "max", MathMax, | 256 "max", MathMax, |
258 "min", MathMin | 257 "min", MathMin |
259 )); | 258 )); |
260 }; | 259 }; |
261 | 260 |
262 | 261 |
263 SetupMath(); | 262 SetupMath(); |
OLD | NEW |