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 #include "tsImportEqualsDeclaration.h"
17 
18 #include "checker/TSchecker.h"
19 #include "compiler/core/ETSGen.h"
20 #include "compiler/core/pandagen.h"
21 #include "ir/astDump.h"
22 #include "ir/srcDump.h"
23 #include "ir/expression.h"
24 #include "ir/expressions/identifier.h"
25 
26 namespace ark::es2panda::ir {
TransformChildren(const NodeTransformer &cb, std::string_view transformationName)27 void TSImportEqualsDeclaration::TransformChildren(const NodeTransformer &cb, std::string_view transformationName)
28 {
29     if (auto *transformedNode = cb(id_); id_ != transformedNode) {
30         id_->SetTransformedNode(transformationName, transformedNode);
31         id_ = transformedNode->AsIdentifier();
32     }
33 
34     if (auto *transformedNode = cb(moduleReference_); moduleReference_ != transformedNode) {
35         moduleReference_->SetTransformedNode(transformationName, transformedNode);
36         moduleReference_ = transformedNode->AsExpression();
37     }
38 }
39 
Iterate(const NodeTraverser &cb) const40 void TSImportEqualsDeclaration::Iterate(const NodeTraverser &cb) const
41 {
42     cb(id_);
43     cb(moduleReference_);
44 }
45 
Dump(ir::AstDumper *dumper) const46 void TSImportEqualsDeclaration::Dump(ir::AstDumper *dumper) const
47 {
48     dumper->Add({{"type", "TSImportEqualsDeclaration"},
49                  {"id", id_},
50                  {"moduleReference", moduleReference_},
51                  {"isExport", isExport_}});
52 }
53 
Dump(ir::SrcDumper *dumper) const54 void TSImportEqualsDeclaration::Dump(ir::SrcDumper *dumper) const
55 {
56     dumper->Add("TSImportEqualsDeclaration");
57 }
58 
Compile([[maybe_unused]] compiler::PandaGen *pg) const59 void TSImportEqualsDeclaration::Compile([[maybe_unused]] compiler::PandaGen *pg) const
60 {
61     pg->GetAstCompiler()->Compile(this);
62 }
Compile(compiler::ETSGen *etsg) const63 void TSImportEqualsDeclaration::Compile(compiler::ETSGen *etsg) const
64 {
65     etsg->GetAstCompiler()->Compile(this);
66 }
67 
Check([[maybe_unused]] checker::TSChecker *checker)68 checker::Type *TSImportEqualsDeclaration::Check([[maybe_unused]] checker::TSChecker *checker)
69 {
70     return checker->GetAnalyzer()->Check(this);
71 }
72 
Check([[maybe_unused]] checker::ETSChecker *checker)73 checker::Type *TSImportEqualsDeclaration::Check([[maybe_unused]] checker::ETSChecker *checker)
74 {
75     return checker->GetAnalyzer()->Check(this);
76 }
77 }  // namespace ark::es2panda::ir
78