• 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_TS_PROPERTY_SIGNATURE_H
17 #define ES2PANDA_PARSER_INCLUDE_AST_TS_PROPERTY_SIGNATURE_H
18 
19 #include "ir/expression.h"
20 
21 namespace panda::es2panda::ir {
22 class TypeNode;
23 
24 class TSPropertySignature : public AnnotatedAstNode {
25 public:
26     TSPropertySignature() = delete;
27     ~TSPropertySignature() override = default;
28 
29     NO_COPY_SEMANTIC(TSPropertySignature);
30     NO_MOVE_SEMANTIC(TSPropertySignature);
31 
TSPropertySignature(Expression * key,TypeNode * typeAnnotation,bool computed,bool optional,bool readonly)32     explicit TSPropertySignature(Expression *key, TypeNode *typeAnnotation, bool computed, bool optional, bool readonly)
33         : AnnotatedAstNode(AstNodeType::TS_PROPERTY_SIGNATURE, typeAnnotation),
34           key_(key),
35           computed_(computed),
36           optional_(optional),
37           readonly_(readonly)
38     {
39     }
40 
Key()41     [[nodiscard]] const Expression *Key() const noexcept
42     {
43         return key_;
44     }
45 
Key()46     [[nodiscard]] Expression *Key() noexcept
47     {
48         return key_;
49     }
50 
Computed()51     [[nodiscard]] bool Computed() const noexcept
52     {
53         return computed_;
54     }
55 
Optional()56     [[nodiscard]] bool Optional() const noexcept
57     {
58         return optional_;
59     }
60 
Readonly()61     [[nodiscard]] bool Readonly() const noexcept
62     {
63         return readonly_;
64     }
65 
66     // NOLINTNEXTLINE(google-default-arguments)
67     [[nodiscard]] TSPropertySignature *Clone(ArenaAllocator *allocator, AstNode *parent = nullptr) override;
68 
69     void TransformChildren(const NodeTransformer &cb) override;
70     void Iterate(const NodeTraverser &cb) const override;
71 
72     void Dump(ir::AstDumper *dumper) const override;
73     void Dump(ir::SrcDumper *dumper) const override;
74     void Compile(compiler::PandaGen *pg) const override;
75     void Compile(compiler::ETSGen *etsg) const override;
76     checker::Type *Check(checker::TSChecker *checker) override;
77     checker::Type *Check(checker::ETSChecker *checker) override;
78 
Accept(ASTVisitorT * v)79     void Accept(ASTVisitorT *v) override
80     {
81         v->Accept(this);
82     }
83 
84 private:
85     Expression *key_;
86     bool computed_;
87     bool optional_;
88     bool readonly_;
89 };
90 }  // namespace panda::es2panda::ir
91 
92 #endif
93