Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkSLPostfixExpression.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_POSTFIXEXPRESSION
9#define SKSL_POSTFIXEXPRESSION
10
15
16#include <memory>
17#include <string>
18#include <utility>
19
20namespace SkSL {
21
22class Context;
23
24/**
25 * An expression modified by a unary operator appearing after it, such as 'i++'.
26 */
27class PostfixExpression final : public Expression {
28public:
29 inline static constexpr Kind kIRNodeKind = Kind::kPostfix;
30
31 PostfixExpression(Position pos, std::unique_ptr<Expression> operand, Operator op)
33 , fOperand(std::move(operand))
34 , fOperator(op) {}
35
36 // Creates an SkSL postfix expression; uses the ErrorReporter to report errors.
37 static std::unique_ptr<Expression> Convert(const Context& context,
39 std::unique_ptr<Expression> base,
40 Operator op);
41
42 // Creates an SkSL postfix expression; reports errors via ASSERT.
43 static std::unique_ptr<Expression> Make(const Context& context,
45 std::unique_ptr<Expression> base,
46 Operator op);
47
49 return fOperator;
50 }
51
52 std::unique_ptr<Expression>& operand() {
53 return fOperand;
54 }
55
56 const std::unique_ptr<Expression>& operand() const {
57 return fOperand;
58 }
59
60 std::unique_ptr<Expression> clone(Position pos) const override {
61 return std::make_unique<PostfixExpression>(pos, this->operand()->clone(),
62 this->getOperator());
63 }
64
65 std::string description(OperatorPrecedence parentPrecedence) const override;
66
67private:
68 std::unique_ptr<Expression> fOperand;
69 Operator fOperator;
70
71 using INHERITED = Expression;
72};
73
74} // namespace SkSL
75
76#endif
SkPoint pos
virtual const Type & type() const
std::unique_ptr< Expression > clone() const
std::string description() const final
const std::unique_ptr< Expression > & operand() const
static std::unique_ptr< Expression > Make(const Context &context, Position pos, std::unique_ptr< Expression > base, Operator op)
static std::unique_ptr< Expression > Convert(const Context &context, Position pos, std::unique_ptr< Expression > base, Operator op)
PostfixExpression(Position pos, std::unique_ptr< Expression > operand, Operator op)
std::unique_ptr< Expression > clone(Position pos) const override
static constexpr Kind kIRNodeKind
std::unique_ptr< Expression > & operand()
OperatorPrecedence
ExpressionKind
Definition SkSLIRNode.h:62
Definition ref_ptr.h:256