#include "compiler/translator/tree_ops/RemoveUnreferencedVariables.h"
#include "common/hash_containers.h"
#include "compiler/translator/SymbolTable.h"
#include "compiler/translator/tree_util/IntermTraverse.h"
namespace sh
{
namespace
{
class CollectVariableRefCountsTraverser : public TIntermTraverser
{ … };
CollectVariableRefCountsTraverser::CollectVariableRefCountsTraverser()
: … { … }
void CollectVariableRefCountsTraverser::incrementStructTypeRefCount(const TType &type)
{ … }
void CollectVariableRefCountsTraverser::visitSymbol(TIntermSymbol *node)
{ … }
bool CollectVariableRefCountsTraverser::visitAggregate(Visit visit, TIntermAggregate *node)
{ … }
void CollectVariableRefCountsTraverser::visitFunctionPrototype(TIntermFunctionPrototype *node)
{ … }
class RemoveUnreferencedVariablesTraverser : public TIntermTraverser
{ … };
RemoveUnreferencedVariablesTraverser::RemoveUnreferencedVariablesTraverser(
CollectVariableRefCountsTraverser::RefCountMap *symbolIdRefCounts,
CollectVariableRefCountsTraverser::RefCountMap *structIdRefCounts,
TSymbolTable *symbolTable)
: … { … }
void RemoveUnreferencedVariablesTraverser::decrementStructTypeRefCount(const TType &type)
{ … }
void RemoveUnreferencedVariablesTraverser::removeVariableDeclaration(TIntermDeclaration *node,
TIntermTyped *declarator)
{ … }
bool RemoveUnreferencedVariablesTraverser::visitDeclaration(Visit visit, TIntermDeclaration *node)
{ … }
void RemoveUnreferencedVariablesTraverser::visitSymbol(TIntermSymbol *node)
{ … }
bool RemoveUnreferencedVariablesTraverser::visitAggregate(Visit visit, TIntermAggregate *node)
{ … }
void RemoveUnreferencedVariablesTraverser::traverseBlock(TIntermBlock *node)
{ … }
void RemoveUnreferencedVariablesTraverser::traverseLoop(TIntermLoop *node)
{ … }
}
bool RemoveUnreferencedVariables(TCompiler *compiler, TIntermBlock *root, TSymbolTable *symbolTable)
{ … }
}