Update rive-cpp to 2.0 version
[platform/core/uifw/rive-tizen.git] / submodule / skia / src / sksl / ir / SkSLTypeReference.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_TYPEREFERENCE
9 #define SKSL_TYPEREFERENCE
10
11 #include "src/sksl/SkSLContext.h"
12 #include "src/sksl/ir/SkSLExpression.h"
13
14 namespace SkSL {
15
16 /**
17  * Represents an identifier referring to a type. This is an intermediate value: TypeReferences are
18  * always eventually replaced by Constructors in valid programs.
19  */
20 class TypeReference final : public Expression {
21 public:
22     inline static constexpr Kind kExpressionKind = Kind::kTypeReference;
23
24     TypeReference(const Context& context, Position pos, const Type* value)
25         : TypeReference(pos, value, context.fTypes.fInvalid.get()) {}
26
27     // Creates a reference to an SkSL type; uses the ErrorReporter to report errors.
28     static std::unique_ptr<TypeReference> Convert(const Context& context,
29                                                   Position pos,
30                                                   const Type* type);
31
32     // Creates a reference to an SkSL type; reports errors via ASSERT.
33     static std::unique_ptr<TypeReference> Make(const Context& context, Position pos,
34             const Type* type);
35
36     const Type& value() const {
37         return fValue;
38     }
39
40     bool hasProperty(Property property) const override {
41         return false;
42     }
43
44     std::string description() const override {
45         return std::string(this->value().name());
46     }
47
48     std::unique_ptr<Expression> clone(Position pos) const override {
49         return std::unique_ptr<Expression>(new TypeReference(pos, &this->value(), &this->type()));
50     }
51
52 private:
53     TypeReference(Position pos, const Type* value, const Type* type)
54         : INHERITED(pos, kExpressionKind, type)
55         , fValue(*value) {}
56
57     const Type& fValue;
58
59     using INHERITED = Expression;
60 };
61
62 }  // namespace SkSL
63
64 #endif