• 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_IR_TS_CONSTRUCTOR_TYPE_H
17 #define ES2PANDA_IR_TS_CONSTRUCTOR_TYPE_H
18 
19 #include <ir/typeNode.h>
20 
21 namespace panda::es2panda::binder {
22 class Scope;
23 }  // namespace panda::es2panda::binder
24 
25 namespace panda::es2panda::compiler {
26 class PandaGen;
27 }  // namespace panda::es2panda::compiler
28 
29 namespace panda::es2panda::checker {
30 class Checker;
31 class Type;
32 }  // namespace panda::es2panda::checker
33 
34 namespace panda::es2panda::ir {
35 
36 class TSTypeParameterDeclaration;
37 
38 class TSConstructorType : public TypeNode {
39 public:
TSConstructorType(binder::Scope * scope,ArenaVector<Expression * > && params,TSTypeParameterDeclaration * typeParams,Expression * returnType,bool abstract)40     explicit TSConstructorType(binder::Scope *scope, ArenaVector<Expression *> &&params,
41                                TSTypeParameterDeclaration *typeParams, Expression *returnType, bool abstract)
42         : TypeNode(AstNodeType::TS_CONSTRUCTOR_TYPE),
43           scope_(scope),
44           params_(std::move(params)),
45           typeParams_(typeParams),
46           returnType_(returnType),
47           abstract_(abstract)
48     {
49     }
50 
Scope()51     binder::Scope *Scope() const
52     {
53         return scope_;
54     }
55 
TypeParams()56     const TSTypeParameterDeclaration *TypeParams() const
57     {
58         return typeParams_;
59     }
60 
Params()61     const ArenaVector<Expression *> &Params() const
62     {
63         return params_;
64     }
65 
ReturnType()66     const Expression *ReturnType() const
67     {
68         return returnType_;
69     }
70 
Abstract()71     bool Abstract() const
72     {
73         return abstract_;
74     }
75 
76     void Iterate(const NodeTraverser &cb) const override;
77     void Dump(ir::AstDumper *dumper) const override;
78     void Compile([[maybe_unused]] compiler::PandaGen *pg) const override;
79     checker::Type *Check(checker::Checker *checker) const override;
80     checker::Type *GetType(checker::Checker *checker) const override;
81     void UpdateSelf(const NodeUpdater &cb, binder::Binder *binder) override;
82 
83 private:
84     binder::Scope *scope_;
85     ArenaVector<Expression *> params_;
86     TSTypeParameterDeclaration *typeParams_;
87     Expression *returnType_;
88     bool abstract_;
89 };
90 }  // namespace panda::es2panda::ir
91 
92 #endif
93