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