Line data Source code
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 0 : struct ASTReturnStatement : public ASTStatement {
19 : // expression may be null
20 0 : ASTReturnStatement(Position position, std::unique_ptr<ASTExpression> expression)
21 0 : : INHERITED(position, kReturn_Kind)
22 0 : , fExpression(std::move(expression)) {}
23 :
24 0 : String description() const override {
25 0 : String result("return");
26 0 : if (fExpression) {
27 0 : result += " " + fExpression->description();
28 : }
29 0 : return result + ";";
30 : }
31 :
32 : const std::unique_ptr<ASTExpression> fExpression;
33 :
34 : typedef ASTStatement INHERITED;
35 : };
36 :
37 : } // namespace
38 :
39 : #endif
|