Change VariableReference::fVariable to a pointer
We will soon be re-targeting variable references, and this is going to
be much easier (and cheaper) than replacing the entire VariableReference
itself.
Change-Id: I8febc44a1c06e99251153f038a4f5f693cd30231
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319344
Reviewed-by: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/src/sksl/SkSLInliner.cpp b/src/sksl/SkSLInliner.cpp
index f197481..8d15999 100644
--- a/src/sksl/SkSLInliner.cpp
+++ b/src/sksl/SkSLInliner.cpp
@@ -375,9 +375,9 @@
return expression.clone();
case Expression::Kind::kVariableReference: {
const VariableReference& v = expression.as<VariableReference>();
- auto found = varMap->find(&v.fVariable);
+ auto found = varMap->find(v.fVariable);
if (found != varMap->end()) {
- return std::make_unique<VariableReference>(offset, *found->second, v.fRefKind);
+ return std::make_unique<VariableReference>(offset, found->second, v.fRefKind);
}
return v.clone();
}
@@ -618,7 +618,7 @@
const Variable* var = makeInlineVar(String(function.fDeclaration.fName),
&function.fDeclaration.fReturnType,
Modifiers{}, &noInitialValue);
- resultExpr.fInnerVariable = std::make_unique<VariableReference>(offset, *var);
+ resultExpr.fInnerVariable = std::make_unique<VariableReference>(offset, var);
}
// Create variables in the extra statements to hold the arguments, and assign the arguments to
@@ -632,7 +632,7 @@
// or it's written to within the function.
if ((param->fModifiers.fFlags & Modifiers::kOut_Flag) ||
!Analysis::StatementWritesToVariable(*function.fBody, *param)) {
- varMap[param] = &arguments[i]->as<VariableReference>().fVariable;
+ varMap[param] = arguments[i]->as<VariableReference>().fVariable;
continue;
}
}
@@ -669,12 +669,12 @@
if (p->fModifiers.fFlags & Modifiers::kOut_Flag) {
SkASSERT(varMap.find(p) != varMap.end());
if (arguments[i]->is<VariableReference>() &&
- &arguments[i]->as<VariableReference>().fVariable == varMap[p]) {
+ arguments[i]->as<VariableReference>().fVariable == varMap[p]) {
// We didn't create a temporary for this parameter, so there's nothing to copy back
// out.
continue;
}
- auto varRef = std::make_unique<VariableReference>(offset, *varMap[p]);
+ auto varRef = std::make_unique<VariableReference>(offset, varMap[p]);
inlinedBody.push_back(std::make_unique<ExpressionStatement>(
std::make_unique<BinaryExpression>(offset,
arguments[i]->clone(),