1 /* 2 * Copyright 2018 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 #include "src/sksl/ir/SkSLVariableReference.h" 9 10 #include "src/sksl/ir/SkSLConstructor.h" 11 #include "src/sksl/ir/SkSLLiteral.h" 12 #include "src/sksl/ir/SkSLSetting.h" 13 #include "src/sksl/ir/SkSLVariable.h" 14 15 namespace SkSL { 16 VariableReference(int line,const Variable * variable,RefKind refKind)17VariableReference::VariableReference(int line, const Variable* variable, RefKind refKind) 18 : INHERITED(line, kExpressionKind, &variable->type()) 19 , fVariable(variable) 20 , fRefKind(refKind) { 21 SkASSERT(this->variable()); 22 } 23 hasProperty(Property property) const24bool VariableReference::hasProperty(Property property) const { 25 switch (property) { 26 case Property::kSideEffects: return false; 27 case Property::kContainsRTAdjust: return this->variable()->name() == "sk_RTAdjust"; 28 default: 29 SkASSERT(false); 30 return false; 31 } 32 } 33 isConstantOrUniform() const34bool VariableReference::isConstantOrUniform() const { 35 return (this->variable()->modifiers().fFlags & Modifiers::kUniform_Flag) != 0; 36 } 37 description() const38String VariableReference::description() const { 39 return String(this->variable()->name()); 40 } 41 setRefKind(RefKind refKind)42void VariableReference::setRefKind(RefKind refKind) { 43 fRefKind = refKind; 44 } 45 setVariable(const Variable * variable)46void VariableReference::setVariable(const Variable* variable) { 47 fVariable = variable; 48 } 49 50 } // namespace SkSL 51