dan sinclair | 49d1a2d | 2022-06-16 12:01:27 +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 | |
| 15 | #ifndef SRC_TINT_AST_WHILE_STATEMENT_H_ |
| 16 | #define SRC_TINT_AST_WHILE_STATEMENT_H_ |
| 17 | |
| 18 | #include "src/tint/ast/block_statement.h" |
| 19 | |
| 20 | namespace tint::ast { |
| 21 | |
| 22 | class Expression; |
| 23 | |
| 24 | /// A while loop statement |
| 25 | class WhileStatement final : public Castable<WhileStatement, Statement> { |
| 26 | public: |
| 27 | /// Constructor |
Ben Clayton | 4a92a3c | 2022-07-18 20:50:02 +0000 | [diff] [blame] | 28 | /// @param pid the identifier of the program that owns this node |
| 29 | /// @param nid the unique node identifier |
dan sinclair | 49d1a2d | 2022-06-16 12:01:27 +0000 | [diff] [blame] | 30 | /// @param source the for loop statement source |
| 31 | /// @param condition the optional loop condition expression |
| 32 | /// @param body the loop body |
Ben Clayton | 4a92a3c | 2022-07-18 20:50:02 +0000 | [diff] [blame] | 33 | WhileStatement(ProgramID pid, |
| 34 | NodeID nid, |
| 35 | const Source& source, |
dan sinclair | 49d1a2d | 2022-06-16 12:01:27 +0000 | [diff] [blame] | 36 | const Expression* condition, |
| 37 | const BlockStatement* body); |
| 38 | /// Move constructor |
| 39 | WhileStatement(WhileStatement&&); |
| 40 | ~WhileStatement() override; |
| 41 | |
| 42 | /// Clones this node and all transitive child nodes using the `CloneContext` |
| 43 | /// `ctx`. |
| 44 | /// @param ctx the clone context |
| 45 | /// @return the newly cloned node |
| 46 | const WhileStatement* Clone(CloneContext* ctx) const override; |
| 47 | |
| 48 | /// The condition expression |
| 49 | const Expression* const condition; |
| 50 | |
| 51 | /// The loop body block |
| 52 | const BlockStatement* const body; |
| 53 | }; |
| 54 | |
| 55 | } // namespace tint::ast |
| 56 | |
| 57 | #endif // SRC_TINT_AST_WHILE_STATEMENT_H_ |