• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2021 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_AST_FOR_LOOP_STATEMENT_H_
16 #define SRC_AST_FOR_LOOP_STATEMENT_H_
17 
18 #include "src/ast/block_statement.h"
19 
20 namespace tint {
21 namespace ast {
22 
23 class Expression;
24 
25 /// A for loop statement
26 class ForLoopStatement : public Castable<ForLoopStatement, Statement> {
27  public:
28   /// Constructor
29   /// @param program_id the identifier of the program that owns this node
30   /// @param source the for loop statement source
31   /// @param initializer the optional loop initializer statement
32   /// @param condition the optional loop condition expression
33   /// @param continuing the optional continuing statement
34   /// @param body the loop body
35   ForLoopStatement(ProgramID program_id,
36                    Source const& source,
37                    const Statement* initializer,
38                    const Expression* condition,
39                    const Statement* continuing,
40                    const BlockStatement* body);
41   /// Move constructor
42   ForLoopStatement(ForLoopStatement&&);
43   ~ForLoopStatement() override;
44 
45   /// Clones this node and all transitive child nodes using the `CloneContext`
46   /// `ctx`.
47   /// @param ctx the clone context
48   /// @return the newly cloned node
49   const ForLoopStatement* Clone(CloneContext* ctx) const override;
50 
51   /// The initializer statement
52   const Statement* const initializer;
53 
54   /// The condition expression
55   const Expression* const condition;
56 
57   /// The continuing statement
58   const Statement* const continuing;
59 
60   /// The loop body block
61   const BlockStatement* const body;
62 };
63 
64 }  // namespace ast
65 }  // namespace tint
66 
67 #endif  // SRC_AST_FOR_LOOP_STATEMENT_H_
68