ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 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 | |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 11 | #include "SkSLContext.h" |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 12 | #include "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 | struct TypeReference : public Expression { |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 21 | TypeReference(const Context& context, Position position, const Type& type) |
| 22 | : INHERITED(position, kTypeReference_Kind, *context.fInvalid_Type) |
| 23 | , fValue(type) {} |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 24 | |
Greg Daniel | 792d0f1 | 2016-11-20 14:53:35 +0000 | [diff] [blame^] | 25 | std::string description() const override { |
ethannicholas | ea4567c | 2016-10-17 11:24:37 -0700 | [diff] [blame] | 26 | return fValue.name(); |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 27 | } |
| 28 | |
ethannicholas | d598f79 | 2016-07-25 10:08:54 -0700 | [diff] [blame] | 29 | const Type& fValue; |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 30 | |
| 31 | typedef Expression INHERITED; |
| 32 | }; |
| 33 | |
| 34 | } // namespace |
| 35 | |
| 36 | #endif |