• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 union Float64Union {
23     double d;
24     uint64_t u64;
25 };
26 class BuiltinsMath : public base::BuiltinsBase {
27 public:
28     // 20.2.1.1
29     static constexpr double E = 2.718281828459045;
30     // 20.2.1.2
31     static constexpr double LN10 = 2.302585092994046;
32     // 20.2.1.3
33     static constexpr double LN2 = 0.6931471805599453;
34     // 20.2.1.4
35     static constexpr double LOG10E = 0.4342944819032518;
36     // 20.2.1.5
37     static constexpr double LOG2E = 1.4426950408889634;
38     // 20.2.1.6
39     static constexpr double PI = 3.141592653589793;
40     // 20.2.1.7
41     static constexpr double SQRT1_2 = 0.7071067811865476;
42     // 20.2.1.8
43     static constexpr double SQRT2 = 1.4142135623730951;
44     // 20.2.2.1
45     static JSTaggedValue Abs(EcmaRuntimeCallInfo *argv);
46     // 20.2.2.2
47     static JSTaggedValue Acos(EcmaRuntimeCallInfo *argv);
48     // 20.2.2.3
49     static JSTaggedValue Acosh(EcmaRuntimeCallInfo *argv);
50     // 20.2.2.4
51     static JSTaggedValue Asin(EcmaRuntimeCallInfo *argv);
52     // 20.2.2.5
53     static JSTaggedValue Asinh(EcmaRuntimeCallInfo *argv);
54     // 20.2.2.6
55     static JSTaggedValue Atan(EcmaRuntimeCallInfo *argv);
56     // 20.2.2.7
57     static JSTaggedValue Atanh(EcmaRuntimeCallInfo *argv);
58     // 20.2.2.8
59     static JSTaggedValue Atan2(EcmaRuntimeCallInfo *argv);
60     // 20.2.2.9
61     static JSTaggedValue Cbrt(EcmaRuntimeCallInfo *argv);
62     // 20.2.2.10
63     static JSTaggedValue Ceil(EcmaRuntimeCallInfo *argv);
64     // 20.2.2.11
65     static JSTaggedValue Clz32(EcmaRuntimeCallInfo *argv);
66     // 20.2.2.12
67     static JSTaggedValue Cos(EcmaRuntimeCallInfo *argv);
68     // 20.2.2.13
69     static JSTaggedValue Cosh(EcmaRuntimeCallInfo *argv);
70     // 20.2.2.14
71     static JSTaggedValue Exp(EcmaRuntimeCallInfo *argv);
72     // 20.2.2.15
73     static JSTaggedValue Expm1(EcmaRuntimeCallInfo *argv);
74     // 20.2.2.16
75     static JSTaggedValue Floor(EcmaRuntimeCallInfo *argv);
76     // 20.2.2.17
77     static JSTaggedValue Fround(EcmaRuntimeCallInfo *argv);
78     // 20.2.2.18
79     static JSTaggedValue Hypot(EcmaRuntimeCallInfo *argv);
80     // 20.2.2.19
81     static JSTaggedValue Imul(EcmaRuntimeCallInfo *argv);
82     // 20.2.2.20
83     static JSTaggedValue Log(EcmaRuntimeCallInfo *argv);
84     // 20.2.2.21
85     static JSTaggedValue Log1p(EcmaRuntimeCallInfo *argv);
86     // 20.2.2.22
87     static JSTaggedValue Log10(EcmaRuntimeCallInfo *argv);
88     // 20.2.2.23
89     static JSTaggedValue Log2(EcmaRuntimeCallInfo *argv);
90     // 20.2.2.24
91     static JSTaggedValue Max(EcmaRuntimeCallInfo *argv);
92     // 20.2.2.25
93     static JSTaggedValue Min(EcmaRuntimeCallInfo *argv);
94     // 20.2.2.26
95     static JSTaggedValue Pow(EcmaRuntimeCallInfo *argv);
96     // 20.2.2.27
97     static JSTaggedValue Random(EcmaRuntimeCallInfo *argv);
98     // 20.2.2.28
99     static JSTaggedValue Round(EcmaRuntimeCallInfo *argv);
100     // 20.2.2.29
101     static JSTaggedValue Sign(EcmaRuntimeCallInfo *argv);
102     // 20.2.2.30
103     static JSTaggedValue Sin(EcmaRuntimeCallInfo *argv);
104     // 20.2.2.31
105     static JSTaggedValue Sinh(EcmaRuntimeCallInfo *argv);
106     // 20.2.2.32
107     static JSTaggedValue Sqrt(EcmaRuntimeCallInfo *argv);
108     // 20.2.2.33
109     static JSTaggedValue Tan(EcmaRuntimeCallInfo *argv);
110     // 20.2.2.34
111     static JSTaggedValue Tanh(EcmaRuntimeCallInfo *argv);
112     // 20.2.2.35
113     static JSTaggedValue Trunc(EcmaRuntimeCallInfo *argv);
114 };
115 }  // namespace panda::ecmascript::builtins
116 #endif  // ECMASCRIPT_BUILTINS_BUILTINS_MATH_H
117