Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkSLExpressionStatement.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_EXPRESSIONSTATEMENT
9#define SKSL_EXPRESSIONSTATEMENT
10
14
15#include <memory>
16#include <string>
17#include <utility>
18
19namespace SkSL {
20
21class Context;
22
23/**
24 * A lone expression being used as a statement.
25 */
26class ExpressionStatement final : public Statement {
27public:
28 inline static constexpr Kind kIRNodeKind = Kind::kExpression;
29
30 ExpressionStatement(std::unique_ptr<Expression> expression)
32 , fExpression(std::move(expression)) {}
33
34 // Creates an SkSL expression-statement; reports errors via ErrorReporter.
35 static std::unique_ptr<Statement> Convert(const Context& context,
36 std::unique_ptr<Expression> expr);
37
38 // Creates an SkSL expression-statement; reports errors via assertion.
39 static std::unique_ptr<Statement> Make(const Context& context,
40 std::unique_ptr<Expression> expr);
41
42 const std::unique_ptr<Expression>& expression() const {
43 return fExpression;
44 }
45
46 std::unique_ptr<Expression>& expression() {
47 return fExpression;
48 }
49
50 std::string description() const override;
51
52private:
53 std::unique_ptr<Expression> fExpression;
54
55 using INHERITED = Statement;
56};
57
58} // namespace SkSL
59
60#endif
std::string description() const override
std::unique_ptr< Expression > & expression()
static std::unique_ptr< Statement > Convert(const Context &context, std::unique_ptr< Expression > expr)
ExpressionStatement(std::unique_ptr< Expression > expression)
static std::unique_ptr< Statement > Make(const Context &context, std::unique_ptr< Expression > expr)
static constexpr Kind kIRNodeKind
const std::unique_ptr< Expression > & expression() const
Position fPosition
Definition SkSLIRNode.h:109
StatementKind
Definition SkSLIRNode.h:43
Definition ref_ptr.h:256