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 14 namespace SkSL { 15 16 /** 17 * Represents an identifier referring to an ExternalValue. 18 */ 19 struct ExternalValueReference : public Expression { ExternalValueReferenceExternalValueReference20 ExternalValueReference(int offset, ExternalValue* ev) 21 : INHERITED(offset, kExternalValue_Kind, ev->type()) 22 , fValue(ev) {} 23 hasSideEffectsExternalValueReference24 bool hasSideEffects() const override { 25 return true; 26 } 27 descriptionExternalValueReference28 String description() const override { 29 return String(fValue->fName); 30 } 31 cloneExternalValueReference32 std::unique_ptr<Expression> clone() const override { 33 return std::unique_ptr<Expression>(new ExternalValueReference(fOffset, fValue)); 34 } 35 36 ExternalValue* fValue; 37 38 typedef Expression INHERITED; 39 }; 40 41 } // namespace 42 43 #endif 44