1 /**
2  * Copyright (c) 2021-2024 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_CONTEXT_CLASS_PRIVATE_CONTEXT_H
17 #define ES2PANDA_PARSER_CONTEXT_CLASS_PRIVATE_CONTEXT_H
18 
19 #include <macros.h>
20 #include "util/enumbitops.h"
21 #include "util/ustring.h"
22 
23 #include <vector>
24 
25 namespace ark::es2panda::ir {
26 class ClassElement;
27 class Identifier;
28 }  // namespace ark::es2panda::ir
29 
30 namespace ark::es2panda::parser {
31 class ClassPrivateContext {
32 public:
33     explicit ClassPrivateContext() = default;
ClassPrivateContext(ClassPrivateContext *current)34     explicit ClassPrivateContext(ClassPrivateContext *current) : prev_(current) {}
35     DEFAULT_COPY_SEMANTIC(ClassPrivateContext);
36     DEFAULT_MOVE_SEMANTIC(ClassPrivateContext);
37     ~ClassPrivateContext() = default;
38 
39     bool AddElement(const ir::ClassElement *elem);
40     bool FindElement(const ir::Identifier *elem) const;
41 
Elements()42     const std::vector<const ir::ClassElement *> &Elements()
43     {
44         return elements_;
45     }
46 
Prev() const47     ClassPrivateContext *Prev() const
48     {
49         return prev_;
50     }
51 
52 private:
53     ClassPrivateContext *prev_ {};
54     std::vector<const ir::ClassElement *> elements_;
55 };
56 }  // namespace ark::es2panda::parser
57 
58 #endif
59