Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 if (!IS_NUMBER(x)) x = NonNumberToNumber(x); | 206 if (!IS_NUMBER(x)) x = NonNumberToNumber(x); |
| 207 return %_MathSqrt(x); | 207 return %_MathSqrt(x); |
| 208 } | 208 } |
| 209 | 209 |
| 210 // ECMA 262 - 15.8.2.18 | 210 // ECMA 262 - 15.8.2.18 |
| 211 function MathTan(x) { | 211 function MathTan(x) { |
| 212 if (!IS_NUMBER(x)) x = NonNumberToNumber(x); | 212 if (!IS_NUMBER(x)) x = NonNumberToNumber(x); |
| 213 return %_MathTan(x); | 213 return %_MathTan(x); |
| 214 } | 214 } |
| 215 | 215 |
| 216 // Non-standard extension. | |
| 217 function MathImul(x, y) { | |
| 218 if (!IS_NUMBER(x)) x = NonNumberToNumber(x); | |
| 219 if (!IS_NUMBER(y)) y = NonNumberToNumber(y); | |
| 220 return %NumberImul(x, y); | |
|
Sven Panne
2013/04/29 06:36:00
I think the right way to implement this would be r
| |
| 221 } | |
| 222 | |
| 216 | 223 |
| 217 // ------------------------------------------------------------------- | 224 // ------------------------------------------------------------------- |
| 218 | 225 |
| 219 function SetUpMath() { | 226 function SetUpMath() { |
| 220 %CheckIsBootstrapping(); | 227 %CheckIsBootstrapping(); |
| 221 | 228 |
| 222 %SetPrototype($Math, $Object.prototype); | 229 %SetPrototype($Math, $Object.prototype); |
| 223 %SetProperty(global, "Math", $Math, DONT_ENUM); | 230 %SetProperty(global, "Math", $Math, DONT_ENUM); |
| 224 %FunctionSetInstanceClassName(MathConstructor, 'Math'); | 231 %FunctionSetInstanceClassName(MathConstructor, 'Math'); |
| 225 | 232 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 276 "exp", MathExp, | 283 "exp", MathExp, |
| 277 "floor", MathFloor, | 284 "floor", MathFloor, |
| 278 "log", MathLog, | 285 "log", MathLog, |
| 279 "round", MathRound, | 286 "round", MathRound, |
| 280 "sin", MathSin, | 287 "sin", MathSin, |
| 281 "sqrt", MathSqrt, | 288 "sqrt", MathSqrt, |
| 282 "tan", MathTan, | 289 "tan", MathTan, |
| 283 "atan2", MathAtan2, | 290 "atan2", MathAtan2, |
| 284 "pow", MathPow, | 291 "pow", MathPow, |
| 285 "max", MathMax, | 292 "max", MathMax, |
| 286 "min", MathMin | 293 "min", MathMin, |
| 294 "imul", MathImul | |
| 287 )); | 295 )); |
| 288 } | 296 } |
| 289 | 297 |
| 290 SetUpMath(); | 298 SetUpMath(); |
| OLD | NEW |