blob: c986e9097ad2c7694b19b0beacddb3f072c03e7d [file] [log] [blame]
dan sinclairb8b0c212022-10-20 22:45:50 +00001// Copyright 2022 The Tint Authors.
2//
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
dan sinclair99181d82023-07-20 01:14:15 +000015#ifndef SRC_TINT_LANG_WGSL_AST_BREAK_IF_STATEMENT_H_
16#define SRC_TINT_LANG_WGSL_AST_BREAK_IF_STATEMENT_H_
dan sinclairb8b0c212022-10-20 22:45:50 +000017
18#include <utility>
19
dan sinclair99181d82023-07-20 01:14:15 +000020#include "src/tint/lang/wgsl/ast/block_statement.h"
21#include "src/tint/lang/wgsl/ast/expression.h"
dan sinclairb8b0c212022-10-20 22:45:50 +000022
23namespace tint::ast {
24
dan sinclair3a1b7992022-10-24 17:49:20 +000025/// A break-if statement
dan sinclair12fa3032023-04-19 23:52:33 +000026class BreakIfStatement final : public utils::Castable<BreakIfStatement, Statement> {
dan sinclairb8b0c212022-10-20 22:45:50 +000027 public:
28 /// Constructor
29 /// @param pid the identifier of the program that owns this node
30 /// @param nid the unique node identifier
31 /// @param src the source of this node
32 /// @param condition the if condition
33 BreakIfStatement(ProgramID pid, NodeID nid, const Source& src, const Expression* condition);
34
Ben Clayton9a56b252023-03-15 14:09:40 +000035 /// Destructor
dan sinclairb8b0c212022-10-20 22:45:50 +000036 ~BreakIfStatement() override;
37
38 /// Clones this node and all transitive child nodes using the `CloneContext` `ctx`.
39 /// @param ctx the clone context
40 /// @return the newly cloned node
41 const BreakIfStatement* Clone(CloneContext* ctx) const override;
42
43 /// The if condition or nullptr if none set
44 const Expression* const condition;
45};
46
47} // namespace tint::ast
48
dan sinclair99181d82023-07-20 01:14:15 +000049#endif // SRC_TINT_LANG_WGSL_AST_BREAK_IF_STATEMENT_H_