1 /** 2 * Copyright (c) 2021-2022 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 "tsModuleBlock.h" 17 18 #include "varbinder/scope.h" 19 #include "checker/TSchecker.h" 20 #include "compiler/core/ETSGen.h" 21 #include "compiler/core/pandagen.h" 22 #include "ir/astDump.h" 23 #include "ir/srcDump.h" 24 25 namespace panda::es2panda::ir { TransformChildren(const NodeTransformer & cb)26void TSModuleBlock::TransformChildren(const NodeTransformer &cb) 27 { 28 for (auto *&it : statements_) { 29 it = cb(it)->AsStatement(); 30 } 31 } 32 Iterate(const NodeTraverser & cb) const33void TSModuleBlock::Iterate(const NodeTraverser &cb) const 34 { 35 for (auto *it : statements_) { 36 cb(it); 37 } 38 } 39 Dump(ir::AstDumper * dumper) const40void TSModuleBlock::Dump(ir::AstDumper *dumper) const 41 { 42 dumper->Add({{"type", "TSModuleBlock"}, {"body", statements_}}); 43 } 44 Dump(ir::SrcDumper * dumper) const45void TSModuleBlock::Dump(ir::SrcDumper *dumper) const 46 { 47 dumper->Add("TSModuleBlock"); 48 } 49 Compile(compiler::PandaGen * pg) const50void TSModuleBlock::Compile([[maybe_unused]] compiler::PandaGen *pg) const 51 { 52 pg->GetAstCompiler()->Compile(this); 53 } Compile(compiler::ETSGen * etsg) const54void TSModuleBlock::Compile(compiler::ETSGen *etsg) const 55 { 56 etsg->GetAstCompiler()->Compile(this); 57 } 58 Check(checker::TSChecker * checker)59checker::Type *TSModuleBlock::Check([[maybe_unused]] checker::TSChecker *checker) 60 { 61 return checker->GetAnalyzer()->Check(this); 62 } 63 Check(checker::ETSChecker * checker)64checker::Type *TSModuleBlock::Check([[maybe_unused]] checker::ETSChecker *checker) 65 { 66 return checker->GetAnalyzer()->Check(this); 67 } 68 } // namespace panda::es2panda::ir 69