1cb93a386Sopenharmony_ci/* 2cb93a386Sopenharmony_ci * Copyright 2018 Google Inc. 3cb93a386Sopenharmony_ci * 4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be 5cb93a386Sopenharmony_ci * found in the LICENSE file. 6cb93a386Sopenharmony_ci */ 7cb93a386Sopenharmony_ci 8cb93a386Sopenharmony_ci#include "src/sksl/ir/SkSLVariableReference.h" 9cb93a386Sopenharmony_ci 10cb93a386Sopenharmony_ci#include "src/sksl/ir/SkSLConstructor.h" 11cb93a386Sopenharmony_ci#include "src/sksl/ir/SkSLLiteral.h" 12cb93a386Sopenharmony_ci#include "src/sksl/ir/SkSLSetting.h" 13cb93a386Sopenharmony_ci#include "src/sksl/ir/SkSLVariable.h" 14cb93a386Sopenharmony_ci 15cb93a386Sopenharmony_cinamespace SkSL { 16cb93a386Sopenharmony_ci 17cb93a386Sopenharmony_ciVariableReference::VariableReference(int line, const Variable* variable, RefKind refKind) 18cb93a386Sopenharmony_ci : INHERITED(line, kExpressionKind, &variable->type()) 19cb93a386Sopenharmony_ci , fVariable(variable) 20cb93a386Sopenharmony_ci , fRefKind(refKind) { 21cb93a386Sopenharmony_ci SkASSERT(this->variable()); 22cb93a386Sopenharmony_ci} 23cb93a386Sopenharmony_ci 24cb93a386Sopenharmony_cibool VariableReference::hasProperty(Property property) const { 25cb93a386Sopenharmony_ci switch (property) { 26cb93a386Sopenharmony_ci case Property::kSideEffects: return false; 27cb93a386Sopenharmony_ci case Property::kContainsRTAdjust: return this->variable()->name() == "sk_RTAdjust"; 28cb93a386Sopenharmony_ci default: 29cb93a386Sopenharmony_ci SkASSERT(false); 30cb93a386Sopenharmony_ci return false; 31cb93a386Sopenharmony_ci } 32cb93a386Sopenharmony_ci} 33cb93a386Sopenharmony_ci 34cb93a386Sopenharmony_cibool VariableReference::isConstantOrUniform() const { 35cb93a386Sopenharmony_ci return (this->variable()->modifiers().fFlags & Modifiers::kUniform_Flag) != 0; 36cb93a386Sopenharmony_ci} 37cb93a386Sopenharmony_ci 38cb93a386Sopenharmony_ciString VariableReference::description() const { 39cb93a386Sopenharmony_ci return String(this->variable()->name()); 40cb93a386Sopenharmony_ci} 41cb93a386Sopenharmony_ci 42cb93a386Sopenharmony_civoid VariableReference::setRefKind(RefKind refKind) { 43cb93a386Sopenharmony_ci fRefKind = refKind; 44cb93a386Sopenharmony_ci} 45cb93a386Sopenharmony_ci 46cb93a386Sopenharmony_civoid VariableReference::setVariable(const Variable* variable) { 47cb93a386Sopenharmony_ci fVariable = variable; 48cb93a386Sopenharmony_ci} 49cb93a386Sopenharmony_ci 50cb93a386Sopenharmony_ci} // namespace SkSL 51