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 15namespace SkSL { 16 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 24bool 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 34bool VariableReference::isConstantOrUniform() const { 35 return (this->variable()->modifiers().fFlags & Modifiers::kUniform_Flag) != 0; 36} 37 38String VariableReference::description() const { 39 return String(this->variable()->name()); 40} 41 42void VariableReference::setRefKind(RefKind refKind) { 43 fRefKind = refKind; 44} 45 46void VariableReference::setVariable(const Variable* variable) { 47 fVariable = variable; 48} 49 50} // namespace SkSL 51