Commit 999f0ff6 by maxvujovic@gmail.com

Removed static destructors in DependencyGraphBuilder.

Review URL: https://codereview.appspot.com/6296079/ git-svn-id: https://angleproject.googlecode.com/svn/trunk@1154 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 646ea1ec
......@@ -6,12 +6,6 @@
#include "compiler/depgraph/DependencyGraphBuilder.h"
TDependencyGraphBuilder::TLeftmostSymbolMaintainer::TSubtreePlaceholder
TDependencyGraphBuilder::TLeftmostSymbolMaintainer::kLeftSubtree;
TDependencyGraphBuilder::TLeftmostSymbolMaintainer::TSubtreePlaceholder
TDependencyGraphBuilder::TLeftmostSymbolMaintainer::kRightSubtree;
void TDependencyGraphBuilder::build(TIntermNode* node, TDependencyGraph* graph)
{
TDependencyGraphBuilder builder(graph);
......@@ -91,8 +85,7 @@ void TDependencyGraphBuilder::visitSymbol(TIntermSymbol* intermSymbol)
// If this symbol is the current leftmost symbol under an assignment, replace the previous
// leftmost symbol with this symbol.
if (!mLeftmostSymbols.empty() && mLeftmostSymbols.top() !=
&TLeftmostSymbolMaintainer::kRightSubtree) {
if (!mLeftmostSymbols.empty() && mLeftmostSymbols.top() != &mRightSubtree) {
mLeftmostSymbols.pop();
mLeftmostSymbols.push(symbol);
}
......@@ -123,18 +116,18 @@ void TDependencyGraphBuilder::visitAssignment(TIntermBinary* intermAssignment)
TNodeSetMaintainer nodeSetMaintainer(this);
{
TLeftmostSymbolMaintainer leftmostSymbolMaintainer(this, TLeftmostSymbolMaintainer::kLeftSubtree);
TLeftmostSymbolMaintainer leftmostSymbolMaintainer(this, mLeftSubtree);
intermLeft->traverse(this);
leftmostSymbol = mLeftmostSymbols.top();
// After traversing the left subtree of this assignment, we should have found a real
// leftmost symbol, and the leftmost symbol should not be a placeholder.
ASSERT(leftmostSymbol != &TLeftmostSymbolMaintainer::kLeftSubtree);
ASSERT(leftmostSymbol != &TLeftmostSymbolMaintainer::kRightSubtree);
ASSERT(leftmostSymbol != &mLeftSubtree);
ASSERT(leftmostSymbol != &mRightSubtree);
}
if (TIntermTyped* intermRight = intermAssignment->getRight()) {
TLeftmostSymbolMaintainer leftmostSymbolMaintainer(this, TLeftmostSymbolMaintainer::kRightSubtree);
TLeftmostSymbolMaintainer leftmostSymbolMaintainer(this, mRightSubtree);
intermRight->traverse(this);
}
......@@ -164,7 +157,7 @@ void TDependencyGraphBuilder::visitLogicalOp(TIntermBinary* intermLogicalOp)
}
if (TIntermTyped* intermRight = intermLogicalOp->getRight()) {
TLeftmostSymbolMaintainer leftmostSymbolMaintainer(this, TLeftmostSymbolMaintainer::kRightSubtree);
TLeftmostSymbolMaintainer leftmostSymbolMaintainer(this, mRightSubtree);
intermRight->traverse(this);
}
}
......@@ -175,7 +168,7 @@ void TDependencyGraphBuilder::visitBinaryChildren(TIntermBinary* intermBinary)
intermLeft->traverse(this);
if (TIntermTyped* intermRight = intermBinary->getRight()) {
TLeftmostSymbolMaintainer leftmostSymbolMaintainer(this, TLeftmostSymbolMaintainer::kRightSubtree);
TLeftmostSymbolMaintainer leftmostSymbolMaintainer(this, mRightSubtree);
intermRight->traverse(this);
}
}
......
......@@ -135,15 +135,7 @@ private:
//
class TLeftmostSymbolMaintainer {
public:
class TSubtreePlaceholder : public TGraphSymbol {
public:
TSubtreePlaceholder() : TGraphSymbol(NULL) {}
};
static TSubtreePlaceholder kLeftSubtree;
static TSubtreePlaceholder kRightSubtree;
TLeftmostSymbolMaintainer(TDependencyGraphBuilder* factory, TSubtreePlaceholder& subtree)
TLeftmostSymbolMaintainer(TDependencyGraphBuilder* factory, TGraphSymbol& subtree)
: leftmostSymbols(factory->mLeftmostSymbols)
{
needsPlaceholderSymbol = leftmostSymbols.empty() || leftmostSymbols.top() != &subtree;
......@@ -164,6 +156,8 @@ private:
TDependencyGraphBuilder(TDependencyGraph* graph)
: TIntermTraverser(true, false, false)
, mLeftSubtree(NULL)
, mRightSubtree(NULL)
, mGraph(graph) {}
void build(TIntermNode* intermNode) { intermNode->traverse(this); }
......@@ -176,6 +170,9 @@ private:
void visitFunctionCall(TIntermAggregate* intermFunctionCall);
void visitAggregateChildren(TIntermAggregate*);
TGraphSymbol mLeftSubtree;
TGraphSymbol mRightSubtree;
TDependencyGraph* mGraph;
TNodeSetStack mNodeSets;
TSymbolStack mLeftmostSymbols;
......
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