ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
Ethan Nicholas | 0df1b04 | 2017-03-31 13:56:23 -0400 | [diff] [blame] | 7 | |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 8 | #ifndef SKSL_WHILESTATEMENT |
| 9 | #define SKSL_WHILESTATEMENT |
| 10 | |
| 11 | #include "SkSLExpression.h" |
| 12 | #include "SkSLStatement.h" |
| 13 | |
| 14 | namespace SkSL { |
| 15 | |
| 16 | /** |
| 17 | * A 'while' loop. |
| 18 | */ |
| 19 | struct WhileStatement : public Statement { |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 20 | WhileStatement(int offset, std::unique_ptr<Expression> test, |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 21 | std::unique_ptr<Statement> statement) |
Ethan Nicholas | 5b5f096 | 2017-09-11 13:50:14 -0700 | [diff] [blame] | 22 | : INHERITED(offset, kWhile_Kind) |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 23 | , fTest(std::move(test)) |
| 24 | , fStatement(std::move(statement)) {} |
| 25 | |
Ethan Nicholas | 0054311 | 2018-07-31 09:44:36 -0400 | [diff] [blame] | 26 | std::unique_ptr<Statement> clone() const override { |
| 27 | return std::unique_ptr<Statement>(new WhileStatement(fOffset, fTest->clone(), |
| 28 | fStatement->clone())); |
| 29 | } |
| 30 | |
Ethan Nicholas | 0df1b04 | 2017-03-31 13:56:23 -0400 | [diff] [blame] | 31 | String description() const override { |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 32 | return "while (" + fTest->description() + ") " + fStatement->description(); |
| 33 | } |
| 34 | |
Ethan Nicholas | 86a4340 | 2017-01-19 13:32:00 -0500 | [diff] [blame] | 35 | std::unique_ptr<Expression> fTest; |
Ethan Nicholas | cb67096 | 2017-04-20 19:31:52 -0400 | [diff] [blame] | 36 | std::unique_ptr<Statement> fStatement; |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 37 | |
| 38 | typedef Statement INHERITED; |
| 39 | }; |
| 40 | |
| 41 | } // namespace |
| 42 | |
| 43 | #endif |