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 "exportAllDeclaration.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
24namespace ark::es2panda::ir {
25void ExportAllDeclaration::TransformChildren(const NodeTransformer &cb, std::string_view const transformationName)
26{
27    if (auto *transformedNode = cb(source_); source_ != transformedNode) {
28        source_->SetTransformedNode(transformationName, transformedNode);
29        source_ = transformedNode->AsStringLiteral();
30    }
31
32    if (exported_ != nullptr) {
33        if (auto *transformedNode = cb(exported_); exported_ != transformedNode) {
34            exported_->SetTransformedNode(transformationName, transformedNode);
35            exported_ = transformedNode->AsIdentifier();
36        }
37    }
38}
39
40void ExportAllDeclaration::Iterate(const NodeTraverser &cb) const
41{
42    cb(source_);
43
44    if (exported_ != nullptr) {
45        cb(exported_);
46    }
47}
48
49void ExportAllDeclaration::Dump(ir::AstDumper *dumper) const
50{
51    dumper->Add({{"type", "ExportAllDeclaration"}, {"source", source_}, {"exported", AstDumper::Nullish(exported_)}});
52}
53
54void ExportAllDeclaration::Dump(ir::SrcDumper *dumper) const
55{
56    dumper->Add("ExportAllDeclaration");
57}
58
59void ExportAllDeclaration::Compile(compiler::PandaGen *pg) const
60{
61    pg->GetAstCompiler()->Compile(this);
62}
63
64void ExportAllDeclaration::Compile(compiler::ETSGen *etsg) const
65{
66    etsg->GetAstCompiler()->Compile(this);
67}
68
69checker::Type *ExportAllDeclaration::Check(checker::TSChecker *checker)
70{
71    return checker->GetAnalyzer()->Check(this);
72}
73
74checker::Type *ExportAllDeclaration::Check(checker::ETSChecker *checker)
75{
76    return checker->GetAnalyzer()->Check(this);
77}
78}  // namespace ark::es2panda::ir
79