本文整理汇总了C++中TIntermNode类的典型用法代码示例。如果您正苦于以下问题:C++ TIntermNode类的具体用法?C++ TIntermNode怎么用?C++ TIntermNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TIntermNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TIntermLoop
//
// Create loop nodes.
//
TIntermNode* TIntermediate::addLoop(TIntermNode* body, TIntermTyped* test, TIntermTyped* terminal, bool testFirst, TSourceLoc line)
{
TIntermNode* node = new TIntermLoop(body, test, terminal, testFirst);
node->setLine(line);
return node;
}
示例2: nodeSetMaintainer
// Takes an expression like "f(x)" and creates a dependency graph like
// "x -> argument 0 -> function call".
void TDependencyGraphBuilder::visitFunctionCall(TIntermAggregate* intermFunctionCall)
{
TGraphFunctionCall* functionCall = mGraph->createFunctionCall(intermFunctionCall);
// Run through the function call arguments.
int argumentNumber = 0;
TIntermSequence& intermArguments = intermFunctionCall->getSequence();
for (TIntermSequence::const_iterator iter = intermArguments.begin();
iter != intermArguments.end();
++iter, ++argumentNumber)
{
TNodeSetMaintainer nodeSetMaintainer(this);
TIntermNode* intermArgument = *iter;
intermArgument->traverse(this);
if (TParentNodeSet* argumentNodes = mNodeSets.getTopSet()) {
TGraphArgument* argument = mGraph->createArgument(intermFunctionCall, argumentNumber);
connectMultipleNodesToSingleNode(argumentNodes, argument);
argument->addDependentNode(functionCall);
}
}
// Push the leftmost symbol of this function call into the current set of dependent symbols to
// represent the result of this function call.
// Thus, an expression like "y = f(x)" will yield a dependency graph like
// "x -> argument 0 -> function call -> y".
// This line essentially passes the function call node back up to an earlier visitAssignment
// call, which will create the connection "function call -> y".
mNodeSets.insertIntoTopSet(functionCall);
}
示例3: TIntermLoop
//
// Create loop nodes.
//
TIntermNode* TIntermediate::addLoop(TLoopType type, TIntermNode* init, TIntermTyped* cond, TIntermTyped* expr, TIntermNode* body, TSourceLoc line)
{
TIntermNode* node = new TIntermLoop(type, init, cond, expr, body);
node->setLine(line);
return node;
}
示例4: isChildofMain
bool isChildofMain(TIntermNode *node, TIntermNode *root)
{
TIntermNode *main = getFunctionBySignature(MAIN_FUNC_SIGNATURE, root);
if (!main) {
dbgPrint(DBGLVL_ERROR, "CodeTools - could not find main function\n");
exit(1);
}
TIntermAggregate *aggregate;
if (!(aggregate = main->getAsAggregate())) {
dbgPrint(DBGLVL_ERROR, "CodeTools - main is not Aggregate\n");
exit(1);
}
TIntermSequence sequence = aggregate->getSequence();
TIntermSequence::iterator sit;
for(sit = sequence.begin(); sit != sequence.end(); sit++) {
if (*sit == node) {
return true;
}
}
return false;
}
示例5: iter_binding_all
// Map I/O variables to provided offsets, and make bindings for
// unbound but live variables.
//
// Returns false if the input is too malformed to do this.
bool TIoMapper::addStage(EShLanguage stage, TIntermediate &intermediate, TInfoSink &infoSink, TIoMapResolver *resolver)
{
// Trivial return if there is nothing to do.
if (intermediate.getShiftSamplerBinding() == 0 &&
intermediate.getShiftTextureBinding() == 0 &&
intermediate.getShiftImageBinding() == 0 &&
intermediate.getShiftUboBinding() == 0 &&
intermediate.getAutoMapBindings() == false &&
resolver == nullptr)
return true;
if (intermediate.getNumEntryPoints() != 1 || intermediate.isRecursive())
return false;
TIntermNode* root = intermediate.getTreeRoot();
if (root == nullptr)
return false;
// if no resolver is provided, use the default resolver with the given shifts and auto map settings
TDefaultIoResolver defaultResolver;
if (resolver == nullptr) {
defaultResolver.baseSamplerBinding = intermediate.getShiftSamplerBinding();
defaultResolver.baseTextureBinding = intermediate.getShiftTextureBinding();
defaultResolver.baseImageBinding = intermediate.getShiftImageBinding();
defaultResolver.baseUboBinding = intermediate.getShiftUboBinding();
defaultResolver.doAutoMapping = intermediate.getAutoMapBindings();
resolver = &defaultResolver;
}
TVarLiveMap varMap;
TVarGatherTraverser iter_binding_all(intermediate, varMap, true);
TVarGatherTraverser iter_binding_live(intermediate, varMap, false);
root->traverse(&iter_binding_all);
iter_binding_live.pushFunction(intermediate.getEntryPointMangledName().c_str());
while (!iter_binding_live.functions.empty()) {
TIntermNode* function = iter_binding_live.functions.back();
iter_binding_live.functions.pop_back();
function->traverse(&iter_binding_live);
}
// sort entries by priority. see TVarEntryInfo::TOrderByPriority for info.
std::sort(varMap.begin(), varMap.end(), TVarEntryInfo::TOrderByPriority());
bool hadError = false;
TResolverAdaptor doResolve(stage, *resolver, infoSink, hadError);
std::for_each(varMap.begin(), varMap.end(), doResolve);
if (!hadError) {
// sort by id again, so we can use lower bound to find entries
std::sort(varMap.begin(), varMap.end(), TVarEntryInfo::TOrderById());
TVarSetTraverser iter_iomap(intermediate, varMap);
root->traverse(&iter_iomap);
}
return !hadError;
}
示例6: validateForLoopCond
bool ValidateLimitations::validateForLoopCond(TIntermLoop *node,
int indexSymbolId)
{
TIntermNode *cond = node->getCondition();
if (cond == NULL)
{
error(node->getLine(), "Missing condition", "for");
return false;
}
//
// condition has the form:
// loop_index relational_operator constant_expression
//
TIntermBinary *binOp = cond->getAsBinaryNode();
if (binOp == NULL)
{
error(node->getLine(), "Invalid condition", "for");
return false;
}
// Loop index should be to the left of relational operator.
TIntermSymbol *symbol = binOp->getLeft()->getAsSymbolNode();
if (symbol == NULL)
{
error(binOp->getLine(), "Invalid condition", "for");
return false;
}
if (symbol->getId() != indexSymbolId)
{
error(symbol->getLine(),
"Expected loop index", symbol->getSymbol().c_str());
return false;
}
// Relational operator is one of: > >= < <= == or !=.
switch (binOp->getOp())
{
case EOpEqual:
case EOpNotEqual:
case EOpLessThan:
case EOpGreaterThan:
case EOpLessThanEqual:
case EOpGreaterThanEqual:
break;
default:
error(binOp->getLine(),
"Invalid relational operator",
GetOperatorString(binOp->getOp()));
break;
}
// Loop index must be compared with a constant.
if (!isConstExpr(binOp->getRight()))
{
error(binOp->getLine(),
"Loop index cannot be compared with non-constant expression",
symbol->getSymbol().c_str());
return false;
}
return true;
}
示例7: validateForLoopInit
int ValidateLimitations::validateForLoopInit(TIntermLoop *node)
{
TIntermNode *init = node->getInit();
if (init == NULL)
{
error(node->getLine(), "Missing init declaration", "for");
return -1;
}
//
// init-declaration has the form:
// type-specifier identifier = constant-expression
//
TIntermAggregate *decl = init->getAsAggregate();
if ((decl == NULL) || (decl->getOp() != EOpDeclaration))
{
error(init->getLine(), "Invalid init declaration", "for");
return -1;
}
// To keep things simple do not allow declaration list.
TIntermSequence &declSeq = decl->getSequence();
if (declSeq.size() != 1)
{
error(decl->getLine(), "Invalid init declaration", "for");
return -1;
}
TIntermBinary *declInit = declSeq[0]->getAsBinaryNode();
if ((declInit == NULL) || (declInit->getOp() != EOpInitialize))
{
error(decl->getLine(), "Invalid init declaration", "for");
return -1;
}
TIntermSymbol *symbol = declInit->getLeft()->getAsSymbolNode();
if (symbol == NULL)
{
error(declInit->getLine(), "Invalid init declaration", "for");
return -1;
}
// The loop index has type int or float.
TBasicType type = symbol->getBasicType();
if ((type != EbtInt) && (type != EbtFloat))
{
error(symbol->getLine(),
"Invalid type for loop index", getBasicString(type));
return -1;
}
// The loop index is initialized with constant expression.
if (!isConstExpr(declInit->getRight()))
{
error(declInit->getLine(),
"Loop index cannot be initialized with non-constant expression",
symbol->getSymbol().c_str());
return -1;
}
return symbol->getId();
}
示例8: visitAggregateChildren
void TDependencyGraphBuilder::visitAggregateChildren(TIntermAggregate* intermAggregate)
{
TIntermSequence& sequence = intermAggregate->getSequence();
for(TIntermSequence::const_iterator iter = sequence.begin(); iter != sequence.end(); ++iter)
{
TIntermNode* intermChild = *iter;
intermChild->traverse(this);
}
}
示例9: TIntermLoop
//
// Create loop nodes.
//
TIntermNode *TIntermediate::addLoop(
TLoopType type, TIntermNode *init, TIntermTyped *cond, TIntermTyped *expr,
TIntermNode *body, const TSourceLoc &line)
{
TIntermNode *node = new TIntermLoop(type, init, cond, expr, ensureSequence(body));
node->setLine(line);
return node;
}
示例10: getLoopIncrement
int ForLoopUnroll::getLoopIncrement(TIntermLoop* node)
{
TIntermNode* expr = node->getExpression();
ASSERT(expr != NULL);
// for expression has one of the following forms:
// loop_index++
// loop_index--
// loop_index += constant_expression
// loop_index -= constant_expression
// ++loop_index
// --loop_index
// The last two forms are not specified in the spec, but I am assuming
// its an oversight.
TIntermUnary* unOp = expr->getAsUnaryNode();
TIntermBinary* binOp = unOp ? NULL : expr->getAsBinaryNode();
TOperator op = EOpNull;
TIntermConstantUnion* incrementNode = NULL;
if (unOp != NULL) {
op = unOp->getOp();
} else if (binOp != NULL) {
op = binOp->getOp();
ASSERT(binOp->getRight() != NULL);
incrementNode = binOp->getRight()->getAsConstantUnion();
ASSERT(incrementNode != NULL);
}
int increment = 0;
// The operator is one of: ++ -- += -=.
switch (op) {
case EOpPostIncrement:
case EOpPreIncrement:
ASSERT((unOp != NULL) && (binOp == NULL));
increment = 1;
break;
case EOpPostDecrement:
case EOpPreDecrement:
ASSERT((unOp != NULL) && (binOp == NULL));
increment = -1;
break;
case EOpAddAssign:
ASSERT((unOp == NULL) && (binOp != NULL));
increment = evaluateIntConstant(incrementNode);
break;
case EOpSubAssign:
ASSERT((unOp == NULL) && (binOp != NULL));
increment = - evaluateIntConstant(incrementNode);
break;
default:
ASSERT(false);
}
return increment;
}
示例11: FindMainIndex
size_t FindMainIndex(TIntermBlock *root)
{
const TIntermSequence &sequence = *root->getSequence();
for (size_t index = 0; index < sequence.size(); ++index)
{
TIntermNode *node = sequence[index];
TIntermFunctionDefinition *nodeFunction = node->getAsFunctionDefinition();
if (nodeFunction != nullptr && nodeFunction->getFunction()->isMain())
{
return index;
}
}
return std::numeric_limits<size_t>::max();
}
示例12: switch
bool ScalarizeVecAndMatConstructorArgs::visitAggregate(Visit visit, TIntermAggregate *node)
{
if (visit == PreVisit)
{
switch (node->getOp())
{
case EOpSequence:
mSequenceStack.push_back(TIntermSequence());
{
for (TIntermSequence::const_iterator iter = node->getSequence()->begin();
iter != node->getSequence()->end(); ++iter)
{
TIntermNode *child = *iter;
ASSERT(child != NULL);
child->traverse(this);
mSequenceStack.back().push_back(child);
}
}
if (mSequenceStack.back().size() > node->getSequence()->size())
{
node->getSequence()->clear();
*(node->getSequence()) = mSequenceStack.back();
}
mSequenceStack.pop_back();
return false;
case EOpConstructVec2:
case EOpConstructVec3:
case EOpConstructVec4:
case EOpConstructBVec2:
case EOpConstructBVec3:
case EOpConstructBVec4:
case EOpConstructIVec2:
case EOpConstructIVec3:
case EOpConstructIVec4:
if (ContainsMatrixNode(*(node->getSequence())))
scalarizeArgs(node, false, true);
break;
case EOpConstructMat2:
case EOpConstructMat3:
case EOpConstructMat4:
if (ContainsVectorNode(*(node->getSequence())))
scalarizeArgs(node, true, false);
break;
default:
break;
}
}
return true;
}
示例13: visitLoop
bool ValidateLimitations::visitLoop(Visit, TIntermLoop *node)
{
if (!validateLoopType(node))
return false;
if (!validateForLoopHeader(node))
return false;
TIntermNode *body = node->getBody();
if (body != NULL)
{
mLoopStack.push(node);
body->traverse(this);
mLoopStack.pop();
}
// The loop is fully processed - no need to visit children.
return false;
}
示例14: validate
// static
bool ValidateLimitations::IsLimitedForLoop(TIntermLoop *loop)
{
// The shader type doesn't matter in this case.
ValidateLimitations validate(GL_FRAGMENT_SHADER, nullptr);
validate.mValidateIndexing = false;
validate.mValidateInnerLoops = false;
if (!validate.validateLoopType(loop))
return false;
if (!validate.validateForLoopHeader(loop))
return false;
TIntermNode *body = loop->getBody();
if (body != nullptr)
{
validate.mLoopStack.push(loop);
body->traverse(&validate);
validate.mLoopStack.pop();
}
return (validate.mNumErrors == 0);
}
示例15: memset
bool ValidateLimitations::visitLoop(Visit, TIntermLoop* node)
{
if (!validateLoopType(node))
return false;
TLoopInfo info;
memset(&info, 0, sizeof(TLoopInfo));
info.loop = node;
if (!validateForLoopHeader(node, &info))
return false;
TIntermNode* body = node->getBody();
if (body != NULL) {
mLoopStack.push_back(info);
body->traverse(this);
mLoopStack.pop_back();
}
// The loop is fully processed - no need to visit children.
return false;
}