OLD | NEW |
(Empty) | |
| 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 */ |
| 7 |
| 8 #ifndef SKSL_ASTIFSTATEMENT |
| 9 #define SKSL_ASTIFSTATEMENT |
| 10 |
| 11 #include "SkSLASTStatement.h" |
| 12 |
| 13 namespace SkSL { |
| 14 |
| 15 /** |
| 16 * An 'if' statement. |
| 17 */ |
| 18 struct ASTIfStatement : public ASTStatement { |
| 19 ASTIfStatement(Position position, std::unique_ptr<ASTExpression> test, |
| 20 std::unique_ptr<ASTStatement> ifTrue, std::unique_ptr<ASTStat
ement> ifFalse) |
| 21 : INHERITED(position, kIf_Kind) |
| 22 , fTest(std::move(test)) |
| 23 , fIfTrue(std::move(ifTrue)) |
| 24 , fIfFalse(std::move(ifFalse)) {} |
| 25 |
| 26 std::string description() const override { |
| 27 std::string result("if ("); |
| 28 result += fTest->description(); |
| 29 result += ") "; |
| 30 result += fIfTrue->description(); |
| 31 if (fIfFalse) { |
| 32 result += " else "; |
| 33 result += fIfFalse->description(); |
| 34 } |
| 35 return result; |
| 36 } |
| 37 |
| 38 const std::unique_ptr<ASTExpression> fTest; |
| 39 const std::unique_ptr<ASTStatement> fIfTrue; |
| 40 const std::unique_ptr<ASTStatement> fIfFalse; |
| 41 |
| 42 typedef ASTStatement INHERITED; |
| 43 }; |
| 44 |
| 45 } // namespace |
| 46 |
| 47 #endif |
OLD | NEW |