dan sinclair | b8b0c21 | 2022-10-20 22:45:50 +0000 | [diff] [blame] | 1 | // 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 sinclair | 99181d8 | 2023-07-20 01:14:15 +0000 | [diff] [blame] | 15 | #ifndef SRC_TINT_LANG_WGSL_AST_BREAK_IF_STATEMENT_H_ |
| 16 | #define SRC_TINT_LANG_WGSL_AST_BREAK_IF_STATEMENT_H_ |
dan sinclair | b8b0c21 | 2022-10-20 22:45:50 +0000 | [diff] [blame] | 17 | |
| 18 | #include <utility> |
| 19 | |
dan sinclair | 99181d8 | 2023-07-20 01:14:15 +0000 | [diff] [blame] | 20 | #include "src/tint/lang/wgsl/ast/block_statement.h" |
| 21 | #include "src/tint/lang/wgsl/ast/expression.h" |
dan sinclair | b8b0c21 | 2022-10-20 22:45:50 +0000 | [diff] [blame] | 22 | |
| 23 | namespace tint::ast { |
| 24 | |
dan sinclair | 3a1b799 | 2022-10-24 17:49:20 +0000 | [diff] [blame] | 25 | /// A break-if statement |
dan sinclair | 12fa303 | 2023-04-19 23:52:33 +0000 | [diff] [blame] | 26 | class BreakIfStatement final : public utils::Castable<BreakIfStatement, Statement> { |
dan sinclair | b8b0c21 | 2022-10-20 22:45:50 +0000 | [diff] [blame] | 27 | 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 Clayton | 9a56b25 | 2023-03-15 14:09:40 +0000 | [diff] [blame] | 35 | /// Destructor |
dan sinclair | b8b0c21 | 2022-10-20 22:45:50 +0000 | [diff] [blame] | 36 | ~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 sinclair | 99181d8 | 2023-07-20 01:14:15 +0000 | [diff] [blame] | 49 | #endif // SRC_TINT_LANG_WGSL_AST_BREAK_IF_STATEMENT_H_ |