moved SkSL VarDeclarations data into IRNode
Change-Id: I03bdef43c79bc3c997f9a9a6aa8fbb1a7194943a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/326437
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
diff --git a/src/sksl/SkSLCompiler.cpp b/src/sksl/SkSLCompiler.cpp
index 1bde5dc..ee29937 100644
--- a/src/sksl/SkSLCompiler.cpp
+++ b/src/sksl/SkSLCompiler.cpp
@@ -371,9 +371,10 @@
break;
}
case ProgramElement::Kind::kGlobalVar: {
- const Variable* var = element->as<GlobalVarDeclaration>().fDecl->fVar;
- SkASSERT(var->isBuiltin());
- intrinsics->insertOrDie(var->name(), std::move(element));
+ const GlobalVarDeclaration& global = element->as<GlobalVarDeclaration>();
+ const Variable& var = global.declaration()->as<VarDeclaration>().var();
+ SkASSERT(var.isBuiltin());
+ intrinsics->insertOrDie(var.name(), std::move(element));
break;
}
case ProgramElement::Kind::kInterfaceBlock: {
@@ -515,8 +516,8 @@
Statement* stmt = node.statement()->get();
if (stmt->is<VarDeclaration>()) {
VarDeclaration& vd = stmt->as<VarDeclaration>();
- if (vd.fValue) {
- definitions->set(vd.fVar, &vd.fValue);
+ if (vd.value()) {
+ definitions->set(&vd.var(), &vd.value());
}
}
}
@@ -570,7 +571,7 @@
if (node.isStatement()) {
const Statement* s = node.statement()->get();
if (s->is<VarDeclaration>()) {
- result[s->as<VarDeclaration>().fVar] = nullptr;
+ result[&s->as<VarDeclaration>().var()] = nullptr;
}
}
}
@@ -1284,12 +1285,12 @@
switch (stmt->kind()) {
case Statement::Kind::kVarDeclaration: {
const auto& varDecl = stmt->as<VarDeclaration>();
- if (varDecl.fVar->dead() &&
- (!varDecl.fValue ||
- !varDecl.fValue->hasSideEffects())) {
- if (varDecl.fValue) {
+ if (varDecl.var().dead() &&
+ (!varDecl.value() ||
+ !varDecl.value()->hasSideEffects())) {
+ if (varDecl.value()) {
SkASSERT((*iter)->statement()->get() == stmt);
- if (!b.tryRemoveExpressionBefore(iter, varDecl.fValue.get())) {
+ if (!b.tryRemoveExpressionBefore(iter, varDecl.value().get())) {
*outNeedsRescan = true;
}
}
@@ -1616,8 +1617,10 @@
if (!element->is<GlobalVarDeclaration>()) {
return false;
}
- const auto& varDecl = element->as<GlobalVarDeclaration>();
- bool dead = varDecl.fDecl->fVar->dead();
+ const auto& global = element->as<GlobalVarDeclaration>();
+ const auto& varDecl =
+ global.declaration()->as<VarDeclaration>();
+ bool dead = varDecl.var().dead();
madeChanges |= dead;
return dead;
}),