SkSLWhileStatement.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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_WHILESTATEMENT
  8. #define SKSL_WHILESTATEMENT
  9. #include "src/sksl/ir/SkSLExpression.h"
  10. #include "src/sksl/ir/SkSLStatement.h"
  11. namespace SkSL {
  12. /**
  13. * A 'while' loop.
  14. */
  15. struct WhileStatement : public Statement {
  16. WhileStatement(int offset, std::unique_ptr<Expression> test,
  17. std::unique_ptr<Statement> statement)
  18. : INHERITED(offset, kWhile_Kind)
  19. , fTest(std::move(test))
  20. , fStatement(std::move(statement)) {}
  21. std::unique_ptr<Statement> clone() const override {
  22. return std::unique_ptr<Statement>(new WhileStatement(fOffset, fTest->clone(),
  23. fStatement->clone()));
  24. }
  25. String description() const override {
  26. return "while (" + fTest->description() + ") " + fStatement->description();
  27. }
  28. std::unique_ptr<Expression> fTest;
  29. std::unique_ptr<Statement> fStatement;
  30. typedef Statement INHERITED;
  31. };
  32. } // namespace
  33. #endif