本文整理汇总了C++中TIntermTyped::traverse方法的典型用法代码示例。如果您正苦于以下问题:C++ TIntermTyped::traverse方法的具体用法?C++ TIntermTyped::traverse怎么用?C++ TIntermTyped::traverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TIntermTyped
的用法示例。
在下文中一共展示了TIntermTyped::traverse方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// Special case for matrix[idx1][idx2]: output as matrix[idx2][idx1]
static bool Check2DMatrixIndex (TGlslOutputTraverser* goit, std::stringstream& out, TIntermTyped* left, TIntermTyped* right)
{
if (left->isVector() && !left->isArray())
{
TIntermBinary* leftBin = left->getAsBinaryNode();
if (leftBin && (leftBin->getOp() == EOpIndexDirect || leftBin->getOp() == EOpIndexIndirect))
{
TIntermTyped* superLeft = leftBin->getLeft();
TIntermTyped* superRight = leftBin->getRight();
if (superLeft->isMatrix() && !superLeft->isArray())
{
superLeft->traverse (goit);
out << "[";
right->traverse(goit);
out << "][";
superRight->traverse(goit);
out << "]";
return true;
}
}
}
return false;
}
示例2: visitAssignment
void TDependencyGraphBuilder::visitAssignment(TIntermBinary* intermAssignment)
{
TIntermTyped* intermLeft = intermAssignment->getLeft();
if (!intermLeft)
return;
TGraphSymbol* leftmostSymbol = NULL;
{
TNodeSetMaintainer nodeSetMaintainer(this);
{
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 != &mLeftSubtree);
ASSERT(leftmostSymbol != &mRightSubtree);
}
if (TIntermTyped* intermRight = intermAssignment->getRight()) {
TLeftmostSymbolMaintainer leftmostSymbolMaintainer(this, mRightSubtree);
intermRight->traverse(this);
}
if (TParentNodeSet* assignmentNodes = mNodeSets.getTopSet())
connectMultipleNodesToSingleNode(assignmentNodes, leftmostSymbol);
}
// Push the leftmost symbol of this assignment into the current set of dependent symbols to
// represent the result of this assignment.
// An expression like "a = (b = c)" will yield a dependency graph like "c -> b -> a".
// This line essentially passes the leftmost symbol of the nested assignment ("b" in this
// example) back up to the earlier visitAssignment call for the outer assignment, which will
// create the connection "b -> a".
mNodeSets.insertIntoTopSet(leftmostSymbol);
}
示例3: traverseBinary
bool TGlslOutputTraverser::traverseBinary( bool preVisit, TIntermBinary *node, TIntermTraverser *it )
{
TString op = "??";
TGlslOutputTraverser* goit = static_cast<TGlslOutputTraverser*>(it);
GlslFunction *current = goit->current;
std::stringstream& out = current->getActiveOutput();
bool infix = true;
bool assign = false;
bool needsParens = true;
switch (node->getOp())
{
case EOpAssign: op = "="; infix = true; needsParens = false; break;
case EOpAddAssign: op = "+="; infix = true; needsParens = false; break;
case EOpSubAssign: op = "-="; infix = true; needsParens = false; break;
case EOpMulAssign: op = "*="; infix = true; needsParens = false; break;
case EOpVectorTimesMatrixAssign: op = "*="; infix = true; needsParens = false; break;
case EOpVectorTimesScalarAssign: op = "*="; infix = true; needsParens = false; break;
case EOpMatrixTimesScalarAssign: op = "*="; infix = true; needsParens = false; break;
case EOpMatrixTimesMatrixAssign: op = "*="; infix = true; needsParens = false; break;
case EOpDivAssign: op = "/="; infix = true; needsParens = false; break;
case EOpModAssign: op = "%="; infix = true; needsParens = false; break;
case EOpAndAssign: op = "&="; infix = true; needsParens = false; break;
case EOpInclusiveOrAssign: op = "|="; infix = true; needsParens = false; break;
case EOpExclusiveOrAssign: op = "^="; infix = true; needsParens = false; break;
case EOpLeftShiftAssign: op = "<<="; infix = true; needsParens = false; break;
case EOpRightShiftAssign: op = "??="; infix = true; needsParens = false; break;
case EOpIndexDirect:
{
TIntermTyped *left = node->getLeft();
TIntermTyped *right = node->getRight();
assert( left && right);
current->beginStatement();
if (Check2DMatrixIndex (goit, out, left, right))
return false;
if (left->isMatrix() && !left->isArray())
{
if (right->getAsConstant())
{
current->addLibFunction (EOpMatrixIndex);
out << "xll_matrixindex (";
left->traverse(goit);
out << ", ";
right->traverse(goit);
out << ")";
return false;
}
else
{
current->addLibFunction (EOpTranspose);
current->addLibFunction (EOpMatrixIndex);
current->addLibFunction (EOpMatrixIndexDynamic);
out << "xll_matrixindexdynamic (";
left->traverse(goit);
out << ", ";
right->traverse(goit);
out << ")";
return false;
}
}
left->traverse(goit);
// Special code for handling a vector component select (this improves readability)
if (left->isVector() && !left->isArray() && right->getAsConstant())
{
char swiz[] = "xyzw";
goit->visitConstantUnion = TGlslOutputTraverser::traverseImmediateConstant;
goit->generatingCode = false;
right->traverse(goit);
assert( goit->indexList.size() == 1);
assert( goit->indexList[0] < 4);
out << "." << swiz[goit->indexList[0]];
goit->indexList.clear();
goit->visitConstantUnion = TGlslOutputTraverser::traverseConstantUnion;
goit->generatingCode = true;
}
else
{
out << "[";
right->traverse(goit);
out << "]";
}
return false;
}
case EOpIndexIndirect:
{
TIntermTyped *left = node->getLeft();
TIntermTyped *right = node->getRight();
current->beginStatement();
if (Check2DMatrixIndex (goit, out, left, right))
return false;
if (left && right && left->isMatrix() && !left->isArray())
{
//.........这里部分代码省略.........