| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SKSL_FORSTATEMENT | 8 #ifndef SKSL_FORSTATEMENT |
| 9 #define SKSL_FORSTATEMENT | 9 #define SKSL_FORSTATEMENT |
| 10 | 10 |
| 11 #include "SkSLExpression.h" | 11 #include "SkSLExpression.h" |
| 12 #include "SkSLStatement.h" | 12 #include "SkSLStatement.h" |
| 13 #include "SkSLSymbolTable.h" | |
| 14 | 13 |
| 15 namespace SkSL { | 14 namespace SkSL { |
| 16 | 15 |
| 17 /** | 16 /** |
| 18 * A 'for' statement. | 17 * A 'for' statement. |
| 19 */ | 18 */ |
| 20 struct ForStatement : public Statement { | 19 struct ForStatement : public Statement { |
| 21 ForStatement(Position position, std::unique_ptr<Statement> initializer, | 20 ForStatement(Position position, std::unique_ptr<Statement> initializer, |
| 22 std::unique_ptr<Expression> test, std::unique_ptr<Expression> n
ext, | 21 std::unique_ptr<Expression> test, std::unique_ptr<Expression> n
ext, |
| 23 std::unique_ptr<Statement> statement, std::shared_ptr<SymbolTab
le> symbols) | 22 std::unique_ptr<Statement> statement) |
| 24 : INHERITED(position, kFor_Kind) | 23 : INHERITED(position, kFor_Kind) |
| 25 , fInitializer(std::move(initializer)) | 24 , fInitializer(std::move(initializer)) |
| 26 , fTest(std::move(test)) | 25 , fTest(std::move(test)) |
| 27 , fNext(std::move(next)) | 26 , fNext(std::move(next)) |
| 28 , fStatement(std::move(statement)) | 27 , fStatement(std::move(statement)) {} |
| 29 , fSymbols(symbols) {} | |
| 30 | 28 |
| 31 std::string description() const override { | 29 std::string description() const override { |
| 32 std::string result = "for ("; | 30 std::string result = "for ("; |
| 33 if (fInitializer) { | 31 if (fInitializer) { |
| 34 result += fInitializer->description(); | 32 result += fInitializer->description(); |
| 35 } | 33 } |
| 36 result += " "; | 34 result += " "; |
| 37 if (fTest) { | 35 if (fTest) { |
| 38 result += fTest->description(); | 36 result += fTest->description(); |
| 39 } | 37 } |
| 40 result += "; "; | 38 result += "; "; |
| 41 if (fNext) { | 39 if (fNext) { |
| 42 result += fNext->description(); | 40 result += fNext->description(); |
| 43 } | 41 } |
| 44 result += ") " + fStatement->description(); | 42 result += ") " + fStatement->description(); |
| 45 return result; | 43 return result; |
| 46 } | 44 } |
| 47 | 45 |
| 48 const std::unique_ptr<Statement> fInitializer; | 46 const std::unique_ptr<Statement> fInitializer; |
| 49 const std::unique_ptr<Expression> fTest; | 47 const std::unique_ptr<Expression> fTest; |
| 50 const std::unique_ptr<Expression> fNext; | 48 const std::unique_ptr<Expression> fNext; |
| 51 const std::unique_ptr<Statement> fStatement; | 49 const std::unique_ptr<Statement> fStatement; |
| 52 const std::shared_ptr<SymbolTable> fSymbols; | |
| 53 | 50 |
| 54 typedef Statement INHERITED; | 51 typedef Statement INHERITED; |
| 55 }; | 52 }; |
| 56 | 53 |
| 57 } // namespace | 54 } // namespace |
| 58 | 55 |
| 59 #endif | 56 #endif |
| OLD | NEW |