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 ES2PANDA_PARSER_CORE_CHECKER_CONTEXT_H
17 #define ES2PANDA_PARSER_CORE_CHECKER_CONTEXT_H
18
19 #include <macros.h>
20 #include <util/enumbitops.h>
21
22 #include <vector>
23
24 namespace panda::es2panda::checker {
25 enum class CheckerStatus {
26 NO_OPTS = 0,
27 FORCE_TUPLE = 1 << 0,
28 IN_CONST_CONTEXT = 1 << 1,
29 KEEP_LITERAL_TYPE = 1 << 2,
30 IN_PARAMETER = 1 << 3,
31 };
32
DEFINE_BITOPS(CheckerStatus)33 DEFINE_BITOPS(CheckerStatus)
34
35 class CheckerContext {
36 public:
37 explicit CheckerContext(CheckerStatus newStatus) : status_(newStatus) {}
38
39 const CheckerStatus &Status() const
40 {
41 return status_;
42 }
43
44 CheckerStatus &Status()
45 {
46 return status_;
47 }
48
49 DEFAULT_COPY_SEMANTIC(CheckerContext);
50 DEFAULT_MOVE_SEMANTIC(CheckerContext);
51 ~CheckerContext() = default;
52
53 private:
54 CheckerStatus status_;
55 };
56 } // namespace panda::es2panda::checker
57
58 #endif
59