SkSLExpressionStatement.h 935 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. #ifndef SKSL_EXPRESSIONSTATEMENT
  8. #define SKSL_EXPRESSIONSTATEMENT
  9. #include "src/sksl/ir/SkSLExpression.h"
  10. #include "src/sksl/ir/SkSLStatement.h"
  11. namespace SkSL {
  12. /**
  13. * A lone expression being used as a statement.
  14. */
  15. struct ExpressionStatement : public Statement {
  16. ExpressionStatement(std::unique_ptr<Expression> expression)
  17. : INHERITED(expression->fOffset, kExpression_Kind)
  18. , fExpression(std::move(expression)) {}
  19. std::unique_ptr<Statement> clone() const override {
  20. return std::unique_ptr<Statement>(new ExpressionStatement(fExpression->clone()));
  21. }
  22. String description() const override {
  23. return fExpression->description() + ";";
  24. }
  25. std::unique_ptr<Expression> fExpression;
  26. typedef Statement INHERITED;
  27. };
  28. } // namespace
  29. #endif