• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021-2025 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_IR_TS_ENUM_MEMBER_H
17 #define ES2PANDA_IR_TS_ENUM_MEMBER_H
18 
19 #include "ir/statement.h"
20 #include "ir/jsDocAllowed.h"
21 
22 namespace ark::es2panda::ir {
23 class Expression;
24 
25 class TSEnumMember : public Statement {
26 public:
TSEnumMember(Expression * key,Expression * init)27     explicit TSEnumMember(Expression *key, Expression *init)
28         : Statement(AstNodeType::TS_ENUM_MEMBER), key_(key), init_(init)
29     {
30     }
31 
TSEnumMember(Expression * key,Expression * init,bool isGenerated)32     explicit TSEnumMember(Expression *key, Expression *init, bool isGenerated)
33         : Statement(AstNodeType::TS_ENUM_MEMBER), key_(key), init_(init), isGenerated_(isGenerated)
34     {
35     }
36 
Key()37     const Expression *Key() const
38     {
39         return key_;
40     }
41 
Key()42     Expression *Key()
43     {
44         return key_;
45     }
46 
Init()47     const Expression *Init() const
48     {
49         return init_;
50     }
51 
Init()52     Expression *Init()
53     {
54         return init_;
55     }
56 
IsGenerated()57     bool IsGenerated() const
58     {
59         return isGenerated_;
60     }
61 
62     [[nodiscard]] util::StringView Name() const;
63 
64     void TransformChildren(const NodeTransformer &cb, std::string_view transformationName) override;
65     void Iterate(const NodeTraverser &cb) const override;
66     void Dump(ir::AstDumper *dumper) const override;
67     void Dump(ir::SrcDumper *dumper) const override;
68     void Compile(compiler::PandaGen *pg) const override;
69     void Compile(compiler::ETSGen *etsg) const override;
70     checker::Type *Check(checker::TSChecker *checker) override;
71     checker::VerifiedType Check(checker::ETSChecker *checker) override;
72 
Accept(ASTVisitorT * v)73     void Accept(ASTVisitorT *v) override
74     {
75         v->Accept(this);
76     }
77 
78 private:
79     Expression *key_;
80     Expression *init_;
81     bool isGenerated_ {false};
82 };
83 }  // namespace ark::es2panda::ir
84 
85 #endif
86