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_EXPRESSIONSTATEMENT
9 #define SKSL_EXPRESSIONSTATEMENT
10 
11 #include "SkSLExpression.h"
12 #include "SkSLStatement.h"
13 
14 namespace SkSL {
15 
16 /**
17  * A lone expression being used as a statement.
18  */
19 struct ExpressionStatement : public Statement {
ExpressionStatementExpressionStatement20     ExpressionStatement(std::unique_ptr<Expression> expression)
21     : INHERITED(expression->fOffset, kExpression_Kind)
22     , fExpression(std::move(expression)) {}
23 
cloneExpressionStatement24     std::unique_ptr<Statement> clone() const override {
25         return std::unique_ptr<Statement>(new ExpressionStatement(fExpression->clone()));
26     }
27 
descriptionExpressionStatement28     String description() const override {
29         return fExpression->description() + ";";
30     }
31 
32     std::unique_ptr<Expression> fExpression;
33 
34     typedef Statement INHERITED;
35 };
36 
37 } // namespace
38 
39 #endif
40