Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkSLReturnStatement.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_RETURNSTATEMENT
9#define SKSL_RETURNSTATEMENT
10
13
14namespace SkSL {
15
16/**
17 * A 'return' statement.
18 */
19class ReturnStatement final : public Statement {
20public:
21 inline static constexpr Kind kIRNodeKind = Kind::kReturn;
22
23 ReturnStatement(Position pos, std::unique_ptr<Expression> expression)
25 , fExpression(std::move(expression)) {}
26
27 static std::unique_ptr<Statement> Make(Position pos, std::unique_ptr<Expression> expression) {
28 return std::make_unique<ReturnStatement>(pos, std::move(expression));
29 }
30
31 std::unique_ptr<Expression>& expression() {
32 return fExpression;
33 }
34
35 const std::unique_ptr<Expression>& expression() const {
36 return fExpression;
37 }
38
39 void setExpression(std::unique_ptr<Expression> expr) {
40 fExpression = std::move(expr);
41 }
42
43 std::string description() const override {
44 if (this->expression()) {
45 return "return " + this->expression()->description() + ";";
46 } else {
47 return "return;";
48 }
49 }
50
51private:
52 std::unique_ptr<Expression> fExpression;
53
54 using INHERITED = Statement;
55};
56
57} // namespace SkSL
58
59#endif
SkPoint pos
static std::unique_ptr< Statement > Make(Position pos, std::unique_ptr< Expression > expression)
std::string description() const override
void setExpression(std::unique_ptr< Expression > expr)
const std::unique_ptr< Expression > & expression() const
ReturnStatement(Position pos, std::unique_ptr< Expression > expression)
static constexpr Kind kIRNodeKind
std::unique_ptr< Expression > & expression()
StatementKind
Definition SkSLIRNode.h:43
Definition ref_ptr.h:256