本文整理汇总了C++中TIntermSelection::setLine方法的典型用法代码示例。如果您正苦于以下问题:C++ TIntermSelection::setLine方法的具体用法?C++ TIntermSelection::setLine怎么用?C++ TIntermSelection::setLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TIntermSelection
的用法示例。
在下文中一共展示了TIntermSelection::setLine方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TIntermSelection
//
// For "?:" test nodes. There are three children; a condition,
// a true path, and a false path. The two paths are specified
// as separate parameters.
//
// Returns the selection node created, or 0 if one could not be.
//
TIntermTyped *TIntermediate::addSelection(
TIntermTyped *cond, TIntermTyped *trueBlock, TIntermTyped *falseBlock,
const TSourceLoc &line)
{
if (!cond || !trueBlock || !falseBlock ||
trueBlock->getType() != falseBlock->getType())
{
return NULL;
}
//
// See if all the operands are constant, then fold it otherwise not.
//
if (cond->getAsConstantUnion() &&
trueBlock->getAsConstantUnion() &&
falseBlock->getAsConstantUnion())
{
if (cond->getAsConstantUnion()->getBConst(0))
return trueBlock;
else
return falseBlock;
}
//
// Make a selection node.
//
TIntermSelection *node = new TIntermSelection(
cond, trueBlock, falseBlock, trueBlock->getType());
node->getTypePointer()->setQualifier(EvqTemporary);
node->setLine(line);
return node;
}
示例2: TIntermSelection
//
// For "?:" test nodes. There are three children; a condition,
// a true path, and a false path. The two paths are specified
// as separate parameters.
//
// Returns the selection node created, or one of trueBlock and falseBlock if the expression could be folded.
//
TIntermTyped *TIntermediate::addSelection(TIntermTyped *cond, TIntermTyped *trueBlock, TIntermTyped *falseBlock,
const TSourceLoc &line)
{
// Right now it's safe to fold ternary operators only when all operands
// are constant. If only the condition is constant, it's theoretically
// possible to fold the ternary operator, but that requires making sure
// that the node returned from here won't be treated as a constant
// expression in case the node that gets eliminated was not a constant
// expression.
if (cond->getAsConstantUnion() &&
trueBlock->getAsConstantUnion() &&
falseBlock->getAsConstantUnion())
{
if (cond->getAsConstantUnion()->getBConst(0))
return trueBlock;
else
return falseBlock;
}
//
// Make a selection node.
//
TIntermSelection *node = new TIntermSelection(cond, trueBlock, falseBlock, trueBlock->getType());
node->getTypePointer()->setQualifier(EvqTemporary);
node->setLine(line);
return node;
}
示例3: setAggregateOperator
//
// For "if" test nodes. There are three children; a condition,
// a true path, and a false path. The two paths are in the
// nodePair.
//
// Returns the selection node created.
//
TIntermNode *TIntermediate::addSelection(
TIntermTyped *cond, TIntermNodePair nodePair, const TSourceLoc &line)
{
//
// For compile time constant selections, prune the code and
// test now.
//
if (cond->getAsTyped() && cond->getAsTyped()->getAsConstantUnion())
{
if (cond->getAsConstantUnion()->getBConst(0) == true)
{
return nodePair.node1 ? setAggregateOperator(
nodePair.node1, EOpSequence, nodePair.node1->getLine()) : NULL;
}
else
{
return nodePair.node2 ? setAggregateOperator(
nodePair.node2, EOpSequence, nodePair.node2->getLine()) : NULL;
}
}
TIntermSelection *node = new TIntermSelection(
cond, nodePair.node1, nodePair.node2);
node->setLine(line);
return node;
}
示例4: addSelection
//
// For "?:" test nodes. There are three children; a condition,
// a true path, and a false path. The two paths are specified
// as separate parameters.
//
// Returns the selection node created, or 0 if one could not be.
//
TIntermTyped* TIntermediate::addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, TSourceLoc line)
{
//
// Get compatible types.
//
TIntermTyped* child = addConversion(EOpSequence, trueBlock->getType(), falseBlock);
if (child)
falseBlock = child;
else {
child = addConversion(EOpSequence, falseBlock->getType(), trueBlock);
if (child)
trueBlock = child;
else
return 0;
}
//
// See if all the operands are constant, then fold it otherwise not.
//
if (cond->getAsConstantUnion() && trueBlock->getAsConstantUnion() && falseBlock->getAsConstantUnion()) {
if (cond->getAsConstantUnion()->getUnionArrayPointer()->getBConst())
return trueBlock;
else
return falseBlock;
}
//
// Make a selection node.
//
TIntermSelection* node = new TIntermSelection(cond, trueBlock, falseBlock, trueBlock->getType());
node->setLine(line);
return node;
}
示例5: ir_add_selection
// For "if" test nodes. There are three children; a condition,
// a true path, and a false path. The two paths are in the
// nodePair.
TIntermNode* ir_add_selection(TIntermTyped* cond, TIntermNodePair nodePair, TSourceLoc line, TInfoSink& infoSink)
{
// Convert float/int to bool
if ( cond->getBasicType() != EbtBool)
{
cond = ir_add_conversion (EOpConstructBool,
TType (EbtBool, cond->getPrecision(), cond->getQualifier(), cond->getColsCount(), cond->getRowsCount(), cond->isMatrix(), cond->isArray()),
cond, infoSink);
}
TIntermSelection* node = new TIntermSelection(cond, nodePair.node1, nodePair.node2);
node->setLine(line);
return node;
}
示例6: ir_add_selection
// For "if" test nodes. There are three children; a condition,
// a true path, and a false path. The two paths are in the
// nodePair.
TIntermNode* ir_add_selection(TIntermTyped* cond, TIntermNodePair nodePair, TSourceLoc line, TInfoSink& infoSink)
{
// Convert float/int to bool
switch ( cond->getBasicType() )
{
case EbtFloat:
case EbtInt:
cond = ir_add_conversion (EOpConstructBool,
TType (EbtBool, cond->getPrecision(), cond->getQualifier(), cond->getNominalSize(), cond->isMatrix(), cond->isArray()),
cond, infoSink);
break;
default:
// Do nothing
break;
}
TIntermSelection* node = new TIntermSelection(cond, nodePair.node1, nodePair.node2);
node->setLine(line);
return node;
}