/* * Copyright 2016 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #ifndef SKSL_DOSTATEMENT #define SKSL_DOSTATEMENT #include "include/private/SkSLStatement.h" #include "src/sksl/ir/SkSLExpression.h" namespace SkSL { /** * A 'do' statement. */ class DoStatement final : public Statement { public: inline static constexpr Kind kStatementKind = Kind::kDo; DoStatement(int line, std::unique_ptr statement, std::unique_ptr test) : INHERITED(line, kStatementKind) , fStatement(std::move(statement)) , fTest(std::move(test)) {} // Creates an SkSL do-while loop; uses the ErrorReporter to report errors. static std::unique_ptr Convert(const Context& context, std::unique_ptr stmt, std::unique_ptr test); // Creates an SkSL do-while loop; reports errors via ASSERT. static std::unique_ptr Make(const Context& context, std::unique_ptr stmt, std::unique_ptr test); std::unique_ptr& statement() { return fStatement; } const std::unique_ptr& statement() const { return fStatement; } std::unique_ptr& test() { return fTest; } const std::unique_ptr& test() const { return fTest; } std::unique_ptr clone() const override; String description() const override; private: std::unique_ptr fStatement; std::unique_ptr fTest; using INHERITED = Statement; }; } // namespace SkSL #endif