1/*
2 * Copyright (c) 2021-2023 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_OP_H
17#define ECMASCRIPT_IC_IC_COMPARE_OP_H
18
19#include "ecmascript/js_function.h"
20#include "ecmascript/js_thread.h"
21#include "ecmascript/object_factory.h"
22
23namespace panda::ecmascript {
24enum 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
50class CompareOp {
51public:
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 LessWithIC(JSThread *thread, JSTaggedValue left,
66        JSTaggedValue right, CompareOpType operationType);
67
68    static JSTaggedValue LessEqWithIC(JSThread *thread, JSTaggedValue left,
69        JSTaggedValue right, CompareOpType operationType);
70
71    static JSTaggedValue GreaterWithIC(JSThread *thread, JSTaggedValue left,
72        JSTaggedValue right, CompareOpType operationType);
73
74    static JSTaggedValue GreaterEqWithIC(JSThread *thread, JSTaggedValue left,
75        JSTaggedValue right, CompareOpType operationType);
76};
77}   // namespace panda::ecmascript
78#endif  // ECMASCRIPT_IC_IC_COMPARE_OP_H