• 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 ES2PANDA_PARSER_INCLUDE_AST_CLASS_PROPERTY_H
17 #define ES2PANDA_PARSER_INCLUDE_AST_CLASS_PROPERTY_H
18 
19 #include <ir/statement.h>
20 
21 namespace panda::es2panda::compiler {
22 class PandaGen;
23 }  // namespace panda::es2panda::compiler
24 
25 namespace panda::es2panda::checker {
26 class Checker;
27 class Type;
28 }  // namespace panda::es2panda::checker
29 
30 namespace panda::es2panda::ir {
31 
32 class Expression;
33 
34 class ClassProperty : public Statement {
35 public:
ClassProperty(Expression * key,Expression * value,Expression * typeAnnotation,ModifierFlags modifiers,ArenaVector<Decorator * > && decorators,bool isComputed,bool definite)36     explicit ClassProperty(Expression *key, Expression *value, Expression *typeAnnotation, ModifierFlags modifiers,
37                            ArenaVector<Decorator *> &&decorators, bool isComputed, bool definite)
38         : Statement(AstNodeType::CLASS_PROPERTY),
39           key_(key),
40           value_(value),
41           typeAnnotation_(typeAnnotation),
42           modifiers_(modifiers),
43           decorators_(std::move(decorators)),
44           isComputed_(isComputed),
45           definite_(definite)
46     {
47     }
48 
Key()49     const Expression *Key() const
50     {
51         return key_;
52     }
53 
Value()54     const Expression *Value() const
55     {
56         return value_;
57     }
58 
TypeAnnotation()59     const Expression *TypeAnnotation() const
60     {
61         return typeAnnotation_;
62     }
63 
Modifiers()64     ModifierFlags Modifiers() const
65     {
66         return modifiers_;
67     }
68 
Decorators()69     const ArenaVector<Decorator *> &Decorators() const
70     {
71         return decorators_;
72     }
73 
IsComputed()74     bool IsComputed() const
75     {
76         return isComputed_;
77     }
78 
Definite()79     bool Definite() const
80     {
81         return definite_;
82     }
83 
84     void Iterate(const NodeTraverser &cb) const override;
85     void Dump(ir::AstDumper *dumper) const override;
86     void Compile([[maybe_unused]] compiler::PandaGen *pg) const override;
87     checker::Type *Check([[maybe_unused]] checker::Checker *checker) const override;
88     void UpdateSelf(const NodeUpdater &cb, binder::Binder *binder) override;
89 
90 private:
91     Expression *key_;
92     Expression *value_;
93     Expression *typeAnnotation_;
94     ModifierFlags modifiers_;
95     ArenaVector<Decorator *> decorators_;
96     bool isComputed_;
97     bool definite_;
98 };
99 
100 }  // namespace panda::es2panda::ir
101 
102 #endif
103