blob: 868c6c9baef14a849cf5e2d1b4f233d32be23070 [file] [log] [blame]
Ethan Nicholas91164d12019-05-15 15:29:54 -04001/*
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
Ethan Nicholas91164d12019-05-15 15:29:54 -040011#include "src/sksl/SkSLExternalValue.h"
Mike Kleinfe0aeb32019-05-20 10:55:11 -050012#include "src/sksl/ir/SkSLExpression.h"
Ethan Nicholas91164d12019-05-15 15:29:54 -040013
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
Ethan Nicholas2a099da2020-01-02 14:40:54 -050024 bool hasProperty(Property property) const override {
25 return property == Property::kSideEffects;
Ethan Nicholas91164d12019-05-15 15:29:54 -040026 }
27
Ethan Nicholas2dd272b2020-05-27 12:21:42 -040028 int nodeCount() const override {
29 return 1;
30 }
31
Ethan Nicholas91164d12019-05-15 15:29:54 -040032 String description() const override {
33 return String(fValue->fName);
34 }
Ethan Nicholas91164d12019-05-15 15:29:54 -040035
36 std::unique_ptr<Expression> clone() const override {
37 return std::unique_ptr<Expression>(new ExternalValueReference(fOffset, fValue));
38 }
39
40 ExternalValue* fValue;
41
42 typedef Expression INHERITED;
43};
44
45} // namespace
46
47#endif