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 int nodeCount() const override {
25 return 1 + fExpression->nodeCount();
26 }
27
28 std::unique_ptr<Statement> clone() const override {
29 return std::unique_ptr<Statement>(new ExpressionStatement(fExpression->clone()));
30 }
31
32 String description() const override {
33 return fExpression->description() + ";";
34 }
35
36 std::unique_ptr<Expression> fExpression;
37
38 typedef Statement INHERITED;
39};
40
41} // namespace SkSL
42
43#endif
44