Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkSLDoStatement.h
Go to the documentation of this file.
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_DOSTATEMENT
9#define SKSL_DOSTATEMENT
10
15
16#include <memory>
17#include <string>
18#include <utility>
19
20namespace SkSL {
21
22class Context;
23
24/**
25 * A 'do' statement.
26 */
27class DoStatement final : public Statement {
28public:
29 inline static constexpr Kind kIRNodeKind = Kind::kDo;
30
31 DoStatement(Position pos, std::unique_ptr<Statement> statement,
32 std::unique_ptr<Expression> test)
34 , fStatement(std::move(statement))
35 , fTest(std::move(test)) {}
36
37 // Creates an SkSL do-while loop; uses the ErrorReporter to report errors.
38 static std::unique_ptr<Statement> Convert(const Context& context,
40 std::unique_ptr<Statement> stmt,
41 std::unique_ptr<Expression> test);
42
43 // Creates an SkSL do-while loop; reports errors via ASSERT.
44 static std::unique_ptr<Statement> Make(const Context& context,
46 std::unique_ptr<Statement> stmt,
47 std::unique_ptr<Expression> test);
48
49 std::unique_ptr<Statement>& statement() {
50 return fStatement;
51 }
52
53 const std::unique_ptr<Statement>& statement() const {
54 return fStatement;
55 }
56
57 std::unique_ptr<Expression>& test() {
58 return fTest;
59 }
60
61 const std::unique_ptr<Expression>& test() const {
62 return fTest;
63 }
64
65 std::string description() const override;
66
67private:
68 std::unique_ptr<Statement> fStatement;
69 std::unique_ptr<Expression> fTest;
70
71 using INHERITED = Statement;
72};
73
74} // namespace SkSL
75
76#endif
SkPoint pos
static constexpr Kind kIRNodeKind
const std::unique_ptr< Statement > & statement() const
std::unique_ptr< Expression > & test()
const std::unique_ptr< Expression > & test() const
DoStatement(Position pos, std::unique_ptr< Statement > statement, std::unique_ptr< Expression > test)
static std::unique_ptr< Statement > Make(const Context &context, Position pos, std::unique_ptr< Statement > stmt, std::unique_ptr< Expression > test)
static std::unique_ptr< Statement > Convert(const Context &context, Position pos, std::unique_ptr< Statement > stmt, std::unique_ptr< Expression > test)
std::string description() const override
std::unique_ptr< Statement > & statement()
StatementKind
Definition SkSLIRNode.h:43
Definition ref_ptr.h:256