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