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