Make isNamelessStruct a member of TType
This will be needed outside of InitializeVariables when removing
unreferenced variables is added. Named struct type declarations
cannot be pruned as easily as they might be referenced later.
BUG=angleproject:2166
TEST=angle_unittests
Change-Id: If1462abe67e62ae19bde97de3c8f3d15e99ae9ea
Reviewed-on: https://chromium-review.googlesource.com/771790
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/InitializeVariables.cpp b/src/compiler/translator/InitializeVariables.cpp
index f90e06f..51f2cc2 100644
--- a/src/compiler/translator/InitializeVariables.cpp
+++ b/src/compiler/translator/InitializeVariables.cpp
@@ -20,11 +20,6 @@
namespace
{
-bool IsNamelessStruct(const TIntermTyped *node)
-{
- return (node->getBasicType() == EbtStruct && node->getType().getStruct()->name() == "");
-}
-
void AddArrayZeroInitSequence(const TIntermTyped *initializedNode,
TIntermSequence *initSequenceOut);
@@ -55,7 +50,7 @@
{
// Structs can't be defined inside structs, so the type of a struct field can't be a
// nameless struct.
- ASSERT(!IsNamelessStruct(element));
+ ASSERT(!element->getType().isNamelessStruct());
initSequenceOut->push_back(CreateZeroInitAssignment(element));
}
}
@@ -159,7 +154,7 @@
mShaderVersion == 100;
// Nameless struct constructors can't be referred to, so they also need to be
// initialized one element at a time.
- if (arrayConstructorUnavailable || IsNamelessStruct(symbol))
+ if (arrayConstructorUnavailable || symbol->getType().isNamelessStruct())
{
// SimplifyLoopConditions should have been run so the parent node of this node
// should not be a loop.
@@ -195,7 +190,7 @@
AddArrayZeroInitSequence(initializedSymbol, initCode);
}
else if (initializedSymbol->getType().isStructureContainingArrays() ||
- IsNamelessStruct(initializedSymbol))
+ initializedSymbol->getType().isNamelessStruct())
{
AddStructZeroInitSequence(initializedSymbol, initCode);
}