Commit 2c315f12 by Zhenyao Mo

Style violation cleanup for IntermTraverse.cpp

Per suggested by kbr in https://codereview.appspot.com/14366043/, we clean up the stype violation in a separate CL. BUG= TEST=no behavioral change TBR=kbr@chromium.org Review URL: https://codereview.appspot.com/14371043
parent d34a0d1b
...@@ -23,271 +23,231 @@ ...@@ -23,271 +23,231 @@
// //
// Traversal functions for terminals are straighforward.... // Traversal functions for terminals are straighforward....
// //
void TIntermSymbol::traverse(TIntermTraverser* it) void TIntermSymbol::traverse(TIntermTraverser *it)
{ {
it->visitSymbol(this); it->visitSymbol(this);
} }
void TIntermConstantUnion::traverse(TIntermTraverser* it) void TIntermConstantUnion::traverse(TIntermTraverser *it)
{ {
it->visitConstantUnion(this); it->visitConstantUnion(this);
} }
// //
// Traverse a binary node. // Traverse a binary node.
// //
void TIntermBinary::traverse(TIntermTraverser* it) void TIntermBinary::traverse(TIntermTraverser *it)
{ {
bool visit = true; bool visit = true;
// //
// visit the node before children if pre-visiting. // visit the node before children if pre-visiting.
// //
if(it->preVisit) if (it->preVisit)
{ visit = it->visitBinary(PreVisit, this);
visit = it->visitBinary(PreVisit, this);
} //
// Visit the children, in the right order.
// //
// Visit the children, in the right order. if (visit)
// {
if(visit) it->incrementDepth();
{
it->incrementDepth(); if (it->rightToLeft)
{
if(it->rightToLeft) if (right)
{ right->traverse(it);
if(right)
{ if (it->inVisit)
right->traverse(it); visit = it->visitBinary(InVisit, this);
}
if (visit && left)
if(it->inVisit) left->traverse(it);
{ }
visit = it->visitBinary(InVisit, this); else
} {
if (left)
if(visit && left) left->traverse(it);
{
left->traverse(it); if (it->inVisit)
} visit = it->visitBinary(InVisit, this);
}
else if (visit && right)
{ right->traverse(it);
if(left) }
{
left->traverse(it); it->decrementDepth();
} }
if(it->inVisit) //
{ // Visit the node after the children, if requested and the traversal
visit = it->visitBinary(InVisit, this); // hasn't been cancelled yet.
} //
if (visit && it->postVisit)
if(visit && right) it->visitBinary(PostVisit, this);
{
right->traverse(it);
}
}
it->decrementDepth();
}
//
// Visit the node after the children, if requested and the traversal
// hasn't been cancelled yet.
//
if(visit && it->postVisit)
{
it->visitBinary(PostVisit, this);
}
} }
// //
// Traverse a unary node. Same comments in binary node apply here. // Traverse a unary node. Same comments in binary node apply here.
// //
void TIntermUnary::traverse(TIntermTraverser* it) void TIntermUnary::traverse(TIntermTraverser *it)
{ {
bool visit = true; bool visit = true;
if (it->preVisit) if (it->preVisit)
visit = it->visitUnary(PreVisit, this); visit = it->visitUnary(PreVisit, this);
if (visit) { if (visit) {
it->incrementDepth(); it->incrementDepth();
operand->traverse(it); operand->traverse(it);
it->decrementDepth(); it->decrementDepth();
} }
if (visit && it->postVisit) if (visit && it->postVisit)
it->visitUnary(PostVisit, this); it->visitUnary(PostVisit, this);
} }
// //
// Traverse an aggregate node. Same comments in binary node apply here. // Traverse an aggregate node. Same comments in binary node apply here.
// //
void TIntermAggregate::traverse(TIntermTraverser* it) void TIntermAggregate::traverse(TIntermTraverser *it)
{ {
bool visit = true; bool visit = true;
if(it->preVisit) if (it->preVisit)
{ visit = it->visitAggregate(PreVisit, this);
visit = it->visitAggregate(PreVisit, this);
} if (visit)
{
if(visit) it->incrementDepth();
{
it->incrementDepth(); if (it->rightToLeft)
{
if(it->rightToLeft) for (TIntermSequence::reverse_iterator sit = sequence.rbegin(); sit != sequence.rend(); sit++)
{ {
for(TIntermSequence::reverse_iterator sit = sequence.rbegin(); sit != sequence.rend(); sit++) (*sit)->traverse(it);
{
(*sit)->traverse(it); if (visit && it->inVisit)
{
if(visit && it->inVisit) if (*sit != sequence.front())
{ visit = it->visitAggregate(InVisit, this);
if(*sit != sequence.front()) }
{ }
visit = it->visitAggregate(InVisit, this); }
} else
} {
} for (TIntermSequence::iterator sit = sequence.begin(); sit != sequence.end(); sit++)
} {
else (*sit)->traverse(it);
{
for(TIntermSequence::iterator sit = sequence.begin(); sit != sequence.end(); sit++) if (visit && it->inVisit)
{ {
(*sit)->traverse(it); if (*sit != sequence.back())
visit = it->visitAggregate(InVisit, this);
if(visit && it->inVisit) }
{ }
if(*sit != sequence.back()) }
{
visit = it->visitAggregate(InVisit, this); it->decrementDepth();
} }
}
} if (visit && it->postVisit)
} it->visitAggregate(PostVisit, this);
it->decrementDepth();
}
if(visit && it->postVisit)
{
it->visitAggregate(PostVisit, this);
}
} }
// //
// Traverse a selection node. Same comments in binary node apply here. // Traverse a selection node. Same comments in binary node apply here.
// //
void TIntermSelection::traverse(TIntermTraverser* it) void TIntermSelection::traverse(TIntermTraverser *it)
{ {
bool visit = true; bool visit = true;
if (it->preVisit) if (it->preVisit)
visit = it->visitSelection(PreVisit, this); visit = it->visitSelection(PreVisit, this);
if (visit) { if (visit) {
it->incrementDepth(); it->incrementDepth();
if (it->rightToLeft) { if (it->rightToLeft) {
if (falseBlock) if (falseBlock)
falseBlock->traverse(it); falseBlock->traverse(it);
if (trueBlock) if (trueBlock)
trueBlock->traverse(it); trueBlock->traverse(it);
condition->traverse(it); condition->traverse(it);
} else { } else {
condition->traverse(it); condition->traverse(it);
if (trueBlock) if (trueBlock)
trueBlock->traverse(it); trueBlock->traverse(it);
if (falseBlock) if (falseBlock)
falseBlock->traverse(it); falseBlock->traverse(it);
} }
it->decrementDepth(); it->decrementDepth();
} }
if (visit && it->postVisit) if (visit && it->postVisit)
it->visitSelection(PostVisit, this); it->visitSelection(PostVisit, this);
} }
// //
// Traverse a loop node. Same comments in binary node apply here. // Traverse a loop node. Same comments in binary node apply here.
// //
void TIntermLoop::traverse(TIntermTraverser* it) void TIntermLoop::traverse(TIntermTraverser *it)
{ {
bool visit = true; bool visit = true;
if(it->preVisit) if (it->preVisit)
{ visit = it->visitLoop(PreVisit, this);
visit = it->visitLoop(PreVisit, this);
} if (visit)
{
if(visit) it->incrementDepth();
{
it->incrementDepth(); if (it->rightToLeft)
{
if(it->rightToLeft) if (expr)
{ expr->traverse(it);
if(expr)
{ if (body)
expr->traverse(it); body->traverse(it);
}
if (cond)
if(body) cond->traverse(it);
{ }
body->traverse(it); else
} {
if (cond)
if(cond) cond->traverse(it);
{
cond->traverse(it); if (body)
} body->traverse(it);
}
else if (expr)
{ expr->traverse(it);
if(cond) }
{
cond->traverse(it); it->decrementDepth();
} }
if(body) if (visit && it->postVisit)
{ it->visitLoop(PostVisit, this);
body->traverse(it);
}
if(expr)
{
expr->traverse(it);
}
}
it->decrementDepth();
}
if(visit && it->postVisit)
{
it->visitLoop(PostVisit, this);
}
} }
// //
// Traverse a branch node. Same comments in binary node apply here. // Traverse a branch node. Same comments in binary node apply here.
// //
void TIntermBranch::traverse(TIntermTraverser* it) void TIntermBranch::traverse(TIntermTraverser *it)
{ {
bool visit = true; bool visit = true;
if (it->preVisit) if (it->preVisit)
visit = it->visitBranch(PreVisit, this); visit = it->visitBranch(PreVisit, this);
if (visit && expression) { if (visit && expression) {
it->incrementDepth(); it->incrementDepth();
expression->traverse(it); expression->traverse(it);
it->decrementDepth(); it->decrementDepth();
} }
if (visit && it->postVisit) if (visit && it->postVisit)
it->visitBranch(PostVisit, this); it->visitBranch(PostVisit, this);
} }
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