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_SEM_FOR_LOOP_STATEMENT_H_ 16 #define SRC_SEM_FOR_LOOP_STATEMENT_H_ 17 18 #include "src/sem/statement.h" 19 20 namespace tint { 21 namespace ast { 22 class ForLoopStatement; 23 } // namespace ast 24 namespace sem { 25 class Expression; 26 } // namespace sem 27 } // namespace tint 28 29 namespace tint { 30 namespace sem { 31 32 /// Holds semantic information about a for-loop statement 33 class ForLoopStatement : public Castable<ForLoopStatement, CompoundStatement> { 34 public: 35 /// Constructor 36 /// @param declaration the AST node for this for-loop statement 37 /// @param parent the owning statement 38 /// @param function the owning function 39 ForLoopStatement(const ast::ForLoopStatement* declaration, 40 const CompoundStatement* parent, 41 const sem::Function* function); 42 43 /// Destructor 44 ~ForLoopStatement() override; 45 46 /// @returns the AST node 47 const ast::ForLoopStatement* Declaration() const; 48 49 /// @returns the for-loop condition expression Condition()50 const Expression* Condition() const { return condition_; } 51 52 /// Sets the for-loop condition expression 53 /// @param condition the for-loop condition expression SetCondition(const Expression * condition)54 void SetCondition(const Expression* condition) { condition_ = condition; } 55 56 private: 57 const Expression* condition_ = nullptr; 58 }; 59 60 } // namespace sem 61 } // namespace tint 62 63 #endif // SRC_SEM_FOR_LOOP_STATEMENT_H_ 64