Update rive-cpp to 2.0 version
[platform/core/uifw/rive-tizen.git] / submodule / skia / src / sksl / ir / SkSLPostfixExpression.h
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
11 #include "include/sksl/SkSLOperator.h"
12 #include "src/sksl/ir/SkSLExpression.h"
13
14 namespace SkSL {
15
16 /**
17  * An expression modified by a unary operator appearing after it, such as 'i++'.
18  */
19 class PostfixExpression final : public Expression {
20 public:
21     inline static constexpr Kind kExpressionKind = Kind::kPostfix;
22
23     PostfixExpression(Position pos, std::unique_ptr<Expression> operand, Operator op)
24         : INHERITED(pos, kExpressionKind, &operand->type())
25         , fOperand(std::move(operand))
26         , fOperator(op) {}
27
28     // Creates an SkSL postfix expression; uses the ErrorReporter to report errors.
29     static std::unique_ptr<Expression> Convert(const Context& context,
30                                                Position pos,
31                                                std::unique_ptr<Expression> base,
32                                                Operator op);
33
34     // Creates an SkSL postfix expression; reports errors via ASSERT.
35     static std::unique_ptr<Expression> Make(const Context& context,
36                                             Position pos,
37                                             std::unique_ptr<Expression> base,
38                                             Operator op);
39
40     Operator getOperator() const {
41         return fOperator;
42     }
43
44     std::unique_ptr<Expression>& operand() {
45         return fOperand;
46     }
47
48     const std::unique_ptr<Expression>& operand() const {
49         return fOperand;
50     }
51
52     bool hasProperty(Property property) const override {
53         return (property == Property::kSideEffects) ||
54                this->operand()->hasProperty(property);
55     }
56
57     std::unique_ptr<Expression> clone(Position pos) const override {
58         return std::make_unique<PostfixExpression>(pos, this->operand()->clone(),
59                                                    this->getOperator());
60     }
61
62     std::string description() const override {
63         return this->operand()->description() + this->getOperator().operatorName();
64     }
65
66 private:
67     std::unique_ptr<Expression> fOperand;
68     Operator fOperator;
69
70     using INHERITED = Expression;
71 };
72
73 }  // namespace SkSL
74
75 #endif