1 /* 2 * Copyright (c) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef ECMASCRIPT_BUILTINS_BUILTINS_MATH_H 17 #define ECMASCRIPT_BUILTINS_BUILTINS_MATH_H 18 19 #include "ecmascript/base/builtins_base.h" 20 21 namespace panda::ecmascript::builtins { 22 class BuiltinsMath : public base::BuiltinsBase { 23 public: 24 // 20.2.1.1 25 static constexpr double E = 2.718281828459045; 26 // 20.2.1.2 27 static constexpr double LN10 = 2.302585092994046; 28 // 20.2.1.3 29 static constexpr double LN2 = 0.6931471805599453; 30 // 20.2.1.4 31 static constexpr double LOG10E = 0.4342944819032518; 32 // 20.2.1.5 33 static constexpr double LOG2E = 1.4426950408889634; 34 // 20.2.1.6 35 static constexpr double PI = 3.141592653589793; 36 // 20.2.1.7 37 static constexpr double SQRT1_2 = 0.7071067811865476; 38 // 20.2.1.8 39 static constexpr double SQRT2 = 1.4142135623730951; 40 // 20.2.2.1 41 static JSTaggedValue Abs(EcmaRuntimeCallInfo *argv); 42 // 20.2.2.2 43 static JSTaggedValue Acos(EcmaRuntimeCallInfo *argv); 44 // 20.2.2.3 45 static JSTaggedValue Acosh(EcmaRuntimeCallInfo *argv); 46 // 20.2.2.4 47 static JSTaggedValue Asin(EcmaRuntimeCallInfo *argv); 48 // 20.2.2.5 49 static JSTaggedValue Asinh(EcmaRuntimeCallInfo *argv); 50 // 20.2.2.6 51 static JSTaggedValue Atan(EcmaRuntimeCallInfo *argv); 52 // 20.2.2.7 53 static JSTaggedValue Atanh(EcmaRuntimeCallInfo *argv); 54 // 20.2.2.8 55 static JSTaggedValue Atan2(EcmaRuntimeCallInfo *argv); 56 // 20.2.2.9 57 static JSTaggedValue Cbrt(EcmaRuntimeCallInfo *argv); 58 // 20.2.2.10 59 static JSTaggedValue Ceil(EcmaRuntimeCallInfo *argv); 60 // 20.2.2.11 61 static JSTaggedValue Clz32(EcmaRuntimeCallInfo *argv); 62 // 20.2.2.12 63 static JSTaggedValue Cos(EcmaRuntimeCallInfo *argv); 64 // 20.2.2.13 65 static JSTaggedValue Cosh(EcmaRuntimeCallInfo *argv); 66 // 20.2.2.14 67 static JSTaggedValue Exp(EcmaRuntimeCallInfo *argv); 68 // 20.2.2.15 69 static JSTaggedValue Expm1(EcmaRuntimeCallInfo *argv); 70 // 20.2.2.16 71 static JSTaggedValue Floor(EcmaRuntimeCallInfo *argv); 72 // 20.2.2.17 73 static JSTaggedValue Fround(EcmaRuntimeCallInfo *argv); 74 // 20.2.2.18 75 static JSTaggedValue Hypot(EcmaRuntimeCallInfo *argv); 76 // 20.2.2.19 77 static JSTaggedValue Imul(EcmaRuntimeCallInfo *argv); 78 // 20.2.2.20 79 static JSTaggedValue Log(EcmaRuntimeCallInfo *argv); 80 // 20.2.2.21 81 static JSTaggedValue Log1p(EcmaRuntimeCallInfo *argv); 82 // 20.2.2.22 83 static JSTaggedValue Log10(EcmaRuntimeCallInfo *argv); 84 // 20.2.2.23 85 static JSTaggedValue Log2(EcmaRuntimeCallInfo *argv); 86 // 20.2.2.24 87 static JSTaggedValue Max(EcmaRuntimeCallInfo *argv); 88 // 20.2.2.25 89 static JSTaggedValue Min(EcmaRuntimeCallInfo *argv); 90 // 20.2.2.26 91 static JSTaggedValue Pow(EcmaRuntimeCallInfo *argv); 92 // 20.2.2.27 93 static JSTaggedValue Random(EcmaRuntimeCallInfo *argv); 94 // 20.2.2.28 95 static JSTaggedValue Round(EcmaRuntimeCallInfo *argv); 96 // 20.2.2.29 97 static JSTaggedValue Sign(EcmaRuntimeCallInfo *argv); 98 // 20.2.2.30 99 static JSTaggedValue Sin(EcmaRuntimeCallInfo *argv); 100 // 20.2.2.31 101 static JSTaggedValue Sinh(EcmaRuntimeCallInfo *argv); 102 // 20.2.2.32 103 static JSTaggedValue Sqrt(EcmaRuntimeCallInfo *argv); 104 // 20.2.2.33 105 static JSTaggedValue Tan(EcmaRuntimeCallInfo *argv); 106 // 20.2.2.34 107 static JSTaggedValue Tanh(EcmaRuntimeCallInfo *argv); 108 // 20.2.2.35 109 static JSTaggedValue Trunc(EcmaRuntimeCallInfo *argv); 110 }; 111 } // namespace panda::ecmascript::builtins 112 #endif // ECMASCRIPT_BUILTINS_BUILTINS_MATH_H 113