1/** 2 * Copyright (c) 2023-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 "ir/ets/etsReExportDeclaration.h" 17#include "ir/astDump.h" 18 19namespace ark::es2panda::ir { 20 21ETSReExportDeclaration::ETSReExportDeclaration(ETSImportDeclaration *etsImportDeclarations, 22 const std::vector<std::string> &userPaths, util::StringView programPath, 23 ArenaAllocator *allocator) 24 : Statement(AstNodeType::REEXPORT_STATEMENT), 25 etsImportDeclarations_(etsImportDeclarations), 26 userPaths_(allocator->Adapter()), 27 programPath_(programPath) 28{ 29 for (const auto &path : userPaths) { 30 userPaths_.emplace_back(util::UString(path, allocator).View()); 31 } 32} 33 34void ETSReExportDeclaration::TransformChildren(const NodeTransformer &cb, std::string_view const transformationName) 35{ 36 if (etsImportDeclarations_ != nullptr) { 37 if (auto *transformedNode = cb(etsImportDeclarations_); etsImportDeclarations_ != transformedNode) { 38 etsImportDeclarations_->SetTransformedNode(transformationName, transformedNode); 39 etsImportDeclarations_ = transformedNode->AsETSImportDeclaration(); 40 } 41 } 42} 43 44void ETSReExportDeclaration::Iterate(const NodeTraverser &cb) const 45{ 46 etsImportDeclarations_->Iterate(cb); 47} 48 49void ETSReExportDeclaration::Dump(ir::AstDumper *dumper) const 50{ 51 dumper->Add({{"type", "ETSReExportDeclaration"}, {"ets_import_declarations", etsImportDeclarations_}}); 52} 53 54} // namespace ark::es2panda::ir 55