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 ...@@ -20,11 +20,6 @@ namespace sh
namespace namespace
{ {
bool IsNamelessStruct(const TIntermTyped *node)
{
return (node->getBasicType() == EbtStruct && node->getType().getStruct()->name() == "");
}
void AddArrayZeroInitSequence(const TIntermTyped *initializedNode, void AddArrayZeroInitSequence(const TIntermTyped *initializedNode,
TIntermSequence *initSequenceOut); TIntermSequence *initSequenceOut);
...@@ -55,7 +50,7 @@ void AddStructZeroInitSequence(const TIntermTyped *initializedNode, ...@@ -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 // Structs can't be defined inside structs, so the type of a struct field can't be a
// nameless struct. // nameless struct.
ASSERT(!IsNamelessStruct(element)); ASSERT(!element->getType().isNamelessStruct());
initSequenceOut->push_back(CreateZeroInitAssignment(element)); initSequenceOut->push_back(CreateZeroInitAssignment(element));
} }
} }
...@@ -159,7 +154,7 @@ class InitializeLocalsTraverser : public TIntermTraverser ...@@ -159,7 +154,7 @@ class InitializeLocalsTraverser : public TIntermTraverser
mShaderVersion == 100; mShaderVersion == 100;
// Nameless struct constructors can't be referred to, so they also need to be // Nameless struct constructors can't be referred to, so they also need to be
// initialized one element at a time. // 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 // SimplifyLoopConditions should have been run so the parent node of this node
// should not be a loop. // should not be a loop.
...@@ -195,7 +190,7 @@ TIntermSequence *CreateInitCode(const TIntermTyped *initializedSymbol) ...@@ -195,7 +190,7 @@ TIntermSequence *CreateInitCode(const TIntermTyped *initializedSymbol)
AddArrayZeroInitSequence(initializedSymbol, initCode); AddArrayZeroInitSequence(initializedSymbol, initCode);
} }
else if (initializedSymbol->getType().isStructureContainingArrays() || else if (initializedSymbol->getType().isStructureContainingArrays() ||
IsNamelessStruct(initializedSymbol)) initializedSymbol->getType().isNamelessStruct())
{ {
AddStructZeroInitSequence(initializedSymbol, initCode); AddStructZeroInitSequence(initializedSymbol, initCode);
} }
......
...@@ -467,6 +467,8 @@ class TType ...@@ -467,6 +467,8 @@ class TType
// deepest field (nesting2.field1.position). // deepest field (nesting2.field1.position).
int getDeepestStructNesting() const { return structure ? structure->deepestNesting() : 0; } int getDeepestStructNesting() const { return structure ? structure->deepestNesting() : 0; }
bool isNamelessStruct() const { return structure && structure->name() == ""; }
bool isStructureContainingArrays() const bool isStructureContainingArrays() const
{ {
return structure ? structure->containsArrays() : false; 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