本文整理汇总了C++中TIntermNode::getAsDeclarationNode方法的典型用法代码示例。如果您正苦于以下问题:C++ TIntermNode::getAsDeclarationNode方法的具体用法?C++ TIntermNode::getAsDeclarationNode怎么用?C++ TIntermNode::getAsDeclarationNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TIntermNode
的用法示例。
在下文中一共展示了TIntermNode::getAsDeclarationNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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
//
TIntermDeclaration *decl = init->getAsDeclarationNode();
if (decl == nullptr)
{
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 != EbtUInt) && (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();
}