• 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_FUNCTION_TYPE_H
17 #define ES2PANDA_IR_TS_FUNCTION_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 TSFunctionType : public TypeNode {
39 public:
TSFunctionType(binder::Scope * scope,ArenaVector<Expression * > && params,TSTypeParameterDeclaration * typeParams,Expression * returnType)40     explicit TSFunctionType(binder::Scope *scope, ArenaVector<Expression *> &&params,
41                             TSTypeParameterDeclaration *typeParams, Expression *returnType)
42         : TypeNode(AstNodeType::TS_FUNCTION_TYPE),
43           scope_(scope),
44           params_(std::move(params)),
45           typeParams_(typeParams),
46           returnType_(returnType)
47     {
48     }
49 
Scope()50     binder::Scope *Scope() const
51     {
52         return scope_;
53     }
54 
TypeParams()55     const TSTypeParameterDeclaration *TypeParams() const
56     {
57         return typeParams_;
58     }
59 
Params()60     const ArenaVector<Expression *> &Params() const
61     {
62         return params_;
63     }
64 
ReturnTypeAnnotation()65     const Expression *ReturnTypeAnnotation() const
66     {
67         return returnType_;
68     }
69 
70     void Iterate(const NodeTraverser &cb) const override;
71     void Dump(ir::AstDumper *dumper) const override;
72     void Compile([[maybe_unused]] compiler::PandaGen *pg) const override;
73     checker::Type *Check(checker::Checker *checker) const override;
74     checker::Type *GetType(checker::Checker *checker) const override;
75     void UpdateSelf(const NodeUpdater &cb, binder::Binder *binder) override;
76 
77 private:
78     binder::Scope *scope_;
79     ArenaVector<Expression *> params_;
80     TSTypeParameterDeclaration *typeParams_;
81     Expression *returnType_;
82 };
83 }  // namespace panda::es2panda::ir
84 
85 #endif
86