• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
ASTReturnStatementASTReturnStatement20     ASTReturnStatement(Position position, std::unique_ptr<ASTExpression> expression)
21     : INHERITED(position, kReturn_Kind)
22     , fExpression(std::move(expression)) {}
23 
descriptionASTReturnStatement24     String description() const override {
25         String result("return");
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
40