• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021-2025 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 #include "tsNullKeyword.h"
17 
18 #include "compiler/core/ETSGen.h"
19 #include "compiler/core/pandagen.h"
20 #include "ir/astDump.h"
21 #include "ir/srcDump.h"
22 #include "checker/TSchecker.h"
23 
24 namespace ark::es2panda::ir {
TransformChildren(const NodeTransformer & cb,std::string_view const transformationName)25 void TSNullKeyword::TransformChildren([[maybe_unused]] const NodeTransformer &cb,
26                                       [[maybe_unused]] std::string_view const transformationName)
27 {
28     for (auto *&it : VectorIterationGuard(Annotations())) {
29         if (auto *transformedNode = cb(it); it != transformedNode) {
30             it->SetTransformedNode(transformationName, transformedNode);
31             it = transformedNode->AsAnnotationUsage();
32         }
33     }
34 }
35 
Iterate(const NodeTraverser & cb) const36 void TSNullKeyword::Iterate([[maybe_unused]] const NodeTraverser &cb) const
37 {
38     for (auto *it : VectorIterationGuard(Annotations())) {
39         cb(it);
40     }
41 }
42 
Dump(ir::AstDumper * dumper) const43 void TSNullKeyword::Dump(ir::AstDumper *dumper) const
44 {
45     dumper->Add({{"type", "TSNullKeyword"}, {"annotations", AstDumper::Optional(Annotations())}});
46 }
47 
Dump(ir::SrcDumper * dumper) const48 void TSNullKeyword::Dump(ir::SrcDumper *dumper) const
49 {
50     for (auto *anno : Annotations()) {
51         anno->Dump(dumper);
52     }
53     dumper->Add("TSNullKeyword");
54 }
55 
Compile(compiler::PandaGen * pg) const56 void TSNullKeyword::Compile([[maybe_unused]] compiler::PandaGen *pg) const
57 {
58     pg->GetAstCompiler()->Compile(this);
59 }
Compile(compiler::ETSGen * etsg) const60 void TSNullKeyword::Compile(compiler::ETSGen *etsg) const
61 {
62     etsg->GetAstCompiler()->Compile(this);
63 }
64 
Check(checker::TSChecker * checker)65 checker::Type *TSNullKeyword::Check([[maybe_unused]] checker::TSChecker *checker)
66 {
67     return checker->GetAnalyzer()->Check(this);
68 }
69 
GetType(checker::TSChecker * checker)70 checker::Type *TSNullKeyword::GetType([[maybe_unused]] checker::TSChecker *checker)
71 {
72     return checker->GlobalNullType();
73 }
74 
Check(checker::ETSChecker * checker)75 checker::VerifiedType TSNullKeyword::Check([[maybe_unused]] checker::ETSChecker *checker)
76 {
77     return {this, checker->GetAnalyzer()->Check(this)};
78 }
79 }  // namespace ark::es2panda::ir
80