xref: /aosp_15_r20/external/skia/src/sksl/ir/SkSLVariableReference.cpp (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
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/SkSLVariable.h"
11 
12 namespace SkSL {
13 
VariableReference(Position pos,const Variable * variable,RefKind refKind)14 VariableReference::VariableReference(Position pos, const Variable* variable, RefKind refKind)
15     : INHERITED(pos, kIRNodeKind, &variable->type())
16     , fVariable(variable)
17     , fRefKind(refKind) {
18     SkASSERT(this->variable());
19 }
20 
description(OperatorPrecedence) const21 std::string VariableReference::description(OperatorPrecedence) const {
22     return std::string(this->variable()->name());
23 }
24 
setRefKind(RefKind refKind)25 void VariableReference::setRefKind(RefKind refKind) {
26     fRefKind = refKind;
27 }
28 
setVariable(const Variable * variable)29 void VariableReference::setVariable(const Variable* variable) {
30     fVariable = variable;
31 }
32 
33 }  // namespace SkSL
34