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 | */ |
| 7 | |
| 8 | #ifndef SKSL_ASTRETURNSTATEMENT |
| 9 | #define SKSL_ASTRETURNSTATEMENT |
| 10 | |
| 11 | #include "SkSLASTStatement.h" |
| 12 | |
| 13 | namespace SkSL { |
| 14 | |
| 15 | /** |
| 16 | * A 'return' statement. |
| 17 | */ |
| 18 | struct ASTReturnStatement : public ASTStatement { |
| 19 | // expression may be null |
| 20 | ASTReturnStatement(Position position, std::unique_ptr<ASTExpression> expression) |
| 21 | : INHERITED(position, kReturn_Kind) |
| 22 | , fExpression(std::move(expression)) {} |
| 23 | |
Ethan Nicholas | 9e1138d | 2016-11-21 10:39:35 -0500 | [diff] [blame^] | 24 | SkString description() const override { |
| 25 | SkString result("return"); |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 26 | if (fExpression) { |
| 27 | result += " " + fExpression->description(); |
| 28 | } |
| 29 | return result + ";"; |
| 30 | } |
| 31 | |
| 32 | const std::unique_ptr<ASTExpression> fExpression; |
| 33 | |
| 34 | typedef ASTStatement INHERITED; |
| 35 | }; |
| 36 | |
| 37 | } // namespace |
| 38 | |
| 39 | #endif |