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#ifndef ES2PANDA_IR_STATEMENT_BREAK_STATEMENT_H
17#define ES2PANDA_IR_STATEMENT_BREAK_STATEMENT_H
18
19#include "ir/statement.h"
20
21namespace ark::es2panda::checker {
22class ETSAnalyzer;
23}  // namespace ark::es2panda::checker
24
25namespace ark::es2panda::compiler {
26class ETSCompiler;
27}  // namespace ark::es2panda::compiler
28
29namespace ark::es2panda::ir {
30class Identifier;
31
32class BreakStatement : public Statement {
33public:
34    ~BreakStatement() override = default;
35
36    NO_COPY_SEMANTIC(BreakStatement);
37    NO_MOVE_SEMANTIC(BreakStatement);
38
39    explicit BreakStatement() : Statement(AstNodeType::BREAK_STATEMENT) {}
40    explicit BreakStatement(Identifier *ident) : Statement(AstNodeType::BREAK_STATEMENT), ident_(ident) {}
41
42    [[nodiscard]] const Identifier *Ident() const noexcept
43    {
44        return ident_;
45    }
46
47    Identifier *Ident() noexcept
48    {
49        return ident_;
50    }
51
52    [[nodiscard]] const ir::AstNode *Target() const noexcept
53    {
54        return target_;
55    }
56
57    void SetTarget(ir::AstNode const *target) noexcept
58    {
59        target_ = target;
60    }
61
62    void TransformChildren(const NodeTransformer &cb, std::string_view transformationName) override;
63    void Iterate(const NodeTraverser &cb) const override;
64    void Dump(ir::AstDumper *dumper) const override;
65    void Dump(ir::SrcDumper *dumper) const override;
66    void Compile([[maybe_unused]] compiler::PandaGen *pg) const override;
67    void Compile([[maybe_unused]] compiler::ETSGen *etsg) const override;
68    checker::Type *Check([[maybe_unused]] checker::TSChecker *checker) override;
69    checker::Type *Check([[maybe_unused]] checker::ETSChecker *checker) override;
70
71    void Accept(ASTVisitorT *v) override
72    {
73        v->Accept(this);
74    }
75
76private:
77    Identifier *ident_ {};
78    const ir::AstNode *target_ {};
79};
80}  // namespace ark::es2panda::ir
81
82#endif
83