Update rive-cpp to 2.0 version
[platform/core/uifw/rive-tizen.git] / submodule / skia / src / sksl / ir / SkSLPostfixExpression.cpp
1 /*
2  * Copyright 2021 Google LLC
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 #include "src/sksl/ir/SkSLPostfixExpression.h"
9
10 #include "include/sksl/SkSLErrorReporter.h"
11 #include "src/sksl/SkSLAnalysis.h"
12 #include "src/sksl/SkSLContext.h"
13 #include "src/sksl/ir/SkSLVariableReference.h"
14
15 namespace SkSL {
16
17 std::unique_ptr<Expression> PostfixExpression::Convert(const Context& context, Position pos,
18         std::unique_ptr<Expression> base, Operator op) {
19     const Type& baseType = base->type();
20     if (!baseType.isNumber()) {
21         context.fErrors->error(pos, "'" + std::string(op.tightOperatorName()) +
22                 "' cannot operate on '" + baseType.displayName() + "'");
23         return nullptr;
24     }
25     if (!Analysis::UpdateVariableRefKind(base.get(), VariableRefKind::kReadWrite,
26                                          context.fErrors)) {
27         return nullptr;
28     }
29     return PostfixExpression::Make(context, pos, std::move(base), op);
30 }
31
32 std::unique_ptr<Expression> PostfixExpression::Make(const Context& context, Position pos,
33         std::unique_ptr<Expression> base, Operator op) {
34     SkASSERT(base->type().isNumber());
35     SkASSERT(Analysis::IsAssignable(*base));
36     return std::make_unique<PostfixExpression>(pos, std::move(base), op);
37 }
38
39 }  // namespace SkSL