• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2024 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_NAMED_TYPE_H
17 #define ES2PANDA_IR_NAMED_TYPE_H
18 
19 #include "ir/typeNode.h"
20 
21 namespace ark::es2panda::ir {
22 class Identifier;
23 class TSTypeParameterInstantiation;
24 
25 class NamedType : public TypeNode {
26 public:
NamedType(Identifier * name)27     explicit NamedType(Identifier *name) : TypeNode(AstNodeType::NAMED_TYPE), name_(name) {}
28 
Name()29     const Identifier *Name() const
30     {
31         return name_;
32     }
33 
TypeParams()34     const TSTypeParameterInstantiation *TypeParams() const
35     {
36         return typeParams_;
37     }
38 
IsNullable()39     bool IsNullable() const
40     {
41         return nullable_;
42     }
43 
SetNullable(bool nullable)44     void SetNullable(bool nullable)
45     {
46         nullable_ = nullable;
47     }
48 
SetNext(NamedType * next)49     void SetNext(NamedType *next)
50     {
51         next_ = next;
52     }
53 
SetTypeParams(TSTypeParameterInstantiation * typeParams)54     void SetTypeParams(TSTypeParameterInstantiation *typeParams)
55     {
56         typeParams_ = typeParams;
57     }
58 
59     void TransformChildren(const NodeTransformer &cb, std::string_view transformationName) override;
60     void Iterate(const NodeTraverser &cb) const override;
61     void Dump(AstDumper *dumper) const override;
62     void Dump(ir::SrcDumper *dumper) const override;
63     void Compile(compiler::PandaGen *pg) const override;
64     void Compile(compiler::ETSGen *etsg) const override;
65 
66     checker::Type *Check(checker::TSChecker *checker) override;
67     checker::Type *Check(checker::ETSChecker *checker) override;
68 
Accept(ASTVisitorT * v)69     void Accept(ASTVisitorT *v) override
70     {
71         v->Accept(this);
72     }
73 
74 private:
75     Identifier *name_;
76     TSTypeParameterInstantiation *typeParams_ {};
77     NamedType *next_ {};
78     bool nullable_ {};
79 };
80 }  // namespace ark::es2panda::ir
81 
82 #endif
83