blob: ed24d4a153fa6c09407d5e6c1b33c6204194fdca [file] [log] [blame]
ethannicholasb3058bd2016-07-01 08:22:01 -07001/*
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
13namespace SkSL {
14
15/**
16 * A 'return' statement.
17 */
18struct 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 Nicholas9e1138d2016-11-21 10:39:35 -050024 SkString description() const override {
25 SkString result("return");
ethannicholasb3058bd2016-07-01 08:22:01 -070026 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