Commit 858ff481 by Olli Etuaho Committed by Commit Bot

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/771790Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 10137d59
......@@ -20,11 +20,6 @@ namespace sh
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 @@ void AddStructZeroInitSequence(const TIntermTyped *initializedNode,
{
// 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 @@ class InitializeLocalsTraverser : public TIntermTraverser
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 @@ TIntermSequence *CreateInitCode(const TIntermTyped *initializedSymbol)
AddArrayZeroInitSequence(initializedSymbol, initCode);
}
else if (initializedSymbol->getType().isStructureContainingArrays() ||
IsNamelessStruct(initializedSymbol))
initializedSymbol->getType().isNamelessStruct())
{
AddStructZeroInitSequence(initializedSymbol, initCode);
}
......
......@@ -467,6 +467,8 @@ class TType
// deepest field (nesting2.field1.position).
int getDeepestStructNesting() const { return structure ? structure->deepestNesting() : 0; }
bool isNamelessStruct() const { return structure && structure->name() == ""; }
bool isStructureContainingArrays() const
{
return structure ? structure->containsArrays() : false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment