1/*
2 * Copyright 2019 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#ifndef SKSL_EXTERNALVALUEREFERENCE
9#define SKSL_EXTERNALVALUEREFERENCE
10
11#include "src/sksl/SkSLExternalValue.h"
12#include "src/sksl/ir/SkSLExpression.h"
13
14namespace SkSL {
15
16/**
17 * Represents an identifier referring to an ExternalValue.
18 */
19struct ExternalValueReference : public Expression {
20 ExternalValueReference(int offset, ExternalValue* ev)
21 : INHERITED(offset, kExternalValue_Kind, ev->type())
22 , fValue(ev) {}
23
24 bool hasProperty(Property property) const override {
25 return property == Property::kSideEffects;
26 }
27
28#ifdef SK_DEBUG
29 String description() const override {
30 return String(fValue->fName);
31 }
32#endif
33
34 std::unique_ptr<Expression> clone() const override {
35 return std::unique_ptr<Expression>(new ExternalValueReference(fOffset, fValue));
36 }
37
38 ExternalValue* fValue;
39
40 typedef Expression INHERITED;
41};
42
43} // namespace
44
45#endif
46