本文整理汇总了C++中TIntermSelection类的典型用法代码示例。如果您正苦于以下问题:C++ TIntermSelection类的具体用法?C++ TIntermSelection怎么用?C++ TIntermSelection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TIntermSelection类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: 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;
}
开发者ID:AOSC-Dev,项目名称:Pale-Moon,代码行数:35,代码来源:Intermediate.cpp
示例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 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;
}
开发者ID:AOSC-Dev,项目名称:Pale-Moon,代码行数:41,代码来源:Intermediate.cpp
示例3: addConversion
//
// 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;
}
开发者ID:Aetherdyne,项目名称:glintercept,代码行数:42,代码来源:Intermediate.cpp
示例4: 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;
}
开发者ID:kizmo,项目名称:angle,代码行数:35,代码来源:Intermediate.cpp
示例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;
}
开发者ID:Groovounet,项目名称:hlsl2glslfork,代码行数:18,代码来源:Intermediate.cpp
示例6: TIntermSelection
//
// 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, TSourceLoc line)
{
//
// For compile time constant selections, prune the code and
// test now.
//
if (cond->getAsTyped() && cond->getAsTyped()->getAsConstantUnion()) {
if (cond->getAsTyped()->getAsConstantUnion()->getUnionArrayPointer()->getBConst())
return nodePair.node1;
else
return nodePair.node2;
}
TIntermSelection* node = new TIntermSelection(cond, nodePair.node1, nodePair.node2);
node->setLine(line);
return node;
}
开发者ID:Aetherdyne,项目名称:glintercept,代码行数:26,代码来源:Intermediate.cpp
示例7: 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;
}
开发者ID:jjiezheng,项目名称:hlsl2glslfork,代码行数:24,代码来源:Intermediate.cpp
示例8: switch
bool ElseBlockRewriter::visitAggregate(Visit visit, TIntermAggregate *node)
{
switch (node->getOp())
{
case EOpSequence:
{
for (size_t statementIndex = 0; statementIndex != node->getSequence().size(); statementIndex++)
{
TIntermNode *statement = node->getSequence()[statementIndex];
TIntermSelection *selection = statement->getAsSelectionNode();
if (selection && selection->getFalseBlock() != NULL)
{
node->getSequence()[statementIndex] = rewriteSelection(selection);
delete selection;
}
}
}
break;
default: break;
}
return true;
}
开发者ID:0x163mL,项目名称:phantomjs,代码行数:24,代码来源:RewriteElseBlocks.cpp
注:本文中的TIntermSelection类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论