• 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_IC_IC_COMPARE_H
17 #define ECMASCRIPT_IC_IC_COMPARE_H
18 
19 #include "ecmascript/js_function.h"
20 #include "ecmascript/js_thread.h"
21 #include "ecmascript/object_factory.h"
22 
23 namespace panda::ecmascript {
24 enum class CompareOpType {
25     NUMBER_NUMBER,
26     NUMBER_STRING,
27     NUMBER_BOOLEAN,
28     NUMBER_OBJ,
29     STRING_STRING,
30     STRING_NUMBER,
31     STRING_BOOLEAN,
32     STRING_OBJ,
33     BOOLEAN_BOOLEAN,
34     BOOLEAN_NUMBER,
35     BOOLEAN_STRING,
36     BOOLEAN_OBJ,
37     OBJ_OBJ,
38     OBJ_NUMBER,
39     OBJ_STRING,
40     OBJ_BOOLEAN,
41     SYMBOL_SYMBOL,
42     NULL_NULL,
43     NULL_UNDEFINED,
44     UNDEFINED_UNDEFINED,
45     UNDEFINED_NULL,
46     UNDEFINED_BLLEAN,
47     OTHER,
48 };
49 
50 class CompareOp {
51 public:
52 
53     CompareOp() = default;
54     ~CompareOp() = default;
55 
56     static JSTaggedValue EqualWithIC(JSThread* thread, JSTaggedValue left,
57         JSTaggedValue right, CompareOpType operationType);
58 
59     static JSTaggedValue NotEqualWithIC(JSThread *thread, JSTaggedValue left,
60         JSTaggedValue right, CompareOpType operationType);
61 
62     static ComparisonResult Compare(JSThread *thread, JSTaggedValue left,
63         JSTaggedValue right, CompareOpType operationType);
64 
65     static JSTaggedValue LessDynWithIC(JSThread *thread, JSTaggedValue left,
66         JSTaggedValue right, CompareOpType operationType);
67 
68     static JSTaggedValue LessEqDynWithIC(JSThread *thread, JSTaggedValue left,
69         JSTaggedValue right, CompareOpType operationType);
70 
71     static JSTaggedValue GreaterDynWithIC(JSThread *thread, JSTaggedValue left,
72         JSTaggedValue right, CompareOpType operationType);
73 
74     static JSTaggedValue GreaterEqDynWithIC(JSThread *thread, JSTaggedValue left,
75         JSTaggedValue right, CompareOpType operationType);
76 };
77 }   // namespace panda::ecmascript
78 #endif  // ECMASCRIPT_IC_IC_COMPAREOP_H