本文整理汇总了C++中TIntermSymbol::getId方法的典型用法代码示例。如果您正苦于以下问题:C++ TIntermSymbol::getId方法的具体用法?C++ TIntermSymbol::getId怎么用?C++ TIntermSymbol::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TIntermSymbol
的用法示例。
在下文中一共展示了TIntermSymbol::getId方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseInitializer
bool TGlslOutputTraverser::parseInitializer( TIntermBinary *node )
{
TIntermTyped *left, *right;
left = node->getLeft();
right = node->getRight();
if (!left->getAsSymbolNode())
return false; //Something is likely seriously wrong
TIntermSymbol *symNode = left->getAsSymbolNode();
if (symNode->getBasicType() == EbtStruct)
return false;
GlslSymbol * sym = NULL;
if ( !current->hasSymbol( symNode->getId() ) )
{
int array = symNode->getTypePointer()->isArray() ? symNode->getTypePointer()->getArraySize() : 0;
const char* semantic = "";
if (symNode->getInfo())
semantic = symNode->getInfo()->getSemantic().c_str();
sym = new GlslSymbol( symNode->getSymbol().c_str(), semantic, symNode->getId(),
translateType(symNode->getTypePointer()), m_UsePrecision?node->getPrecision():EbpUndefined, translateQualifier(symNode->getQualifier()), array);
current->addSymbol(sym);
}
else
return false; //can't init already declared variable
if (right->getAsTyped())
{
std::stringstream ss;
std::stringstream* oldOut = ¤t->getActiveOutput();
current->pushDepth(0);
current->setActiveOutput(&ss);
right->getAsTyped()->traverse(this);
current->setActiveOutput(oldOut);
current->popDepth();
sym->setInitializer(ss.str());
}
return true;
}
示例2: fillInfo
void TLoopIndexInfo::fillInfo(TIntermLoop *node)
{
if (node == NULL)
return;
// Here we assume all the operations are valid, because the loop node is
// already validated in ValidateLimitations.
TIntermSequence *declSeq =
node->getInit()->getAsAggregate()->getSequence();
TIntermBinary *declInit = (*declSeq)[0]->getAsBinaryNode();
TIntermSymbol *symbol = declInit->getLeft()->getAsSymbolNode();
mId = symbol->getId();
mType = symbol->getBasicType();
if (mType == EbtInt)
{
TIntermConstantUnion* initNode = declInit->getRight()->getAsConstantUnion();
mInitValue = EvaluateIntConstant(initNode);
mCurrentValue = mInitValue;
mIncrementValue = GetLoopIntIncrement(node);
TIntermBinary* binOp = node->getCondition()->getAsBinaryNode();
mStopValue = EvaluateIntConstant(
binOp->getRight()->getAsConstantUnion());
mOp = binOp->getOp();
}
}
示例3: 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;
}
示例4: 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();
}
示例5: typeSampler
void TSamplerTraverser::typeSampler( TIntermTyped *node, TBasicType samp )
{
TIntermSymbol *symNode = node->getAsSymbolNode();
if ( !symNode)
{
//TODO: add logic to handle sampler arrays and samplers as struct members
//Don't try typing this one, it is a complex expression
TIntermBinary *biNode = node->getAsBinaryNode();
if ( biNode )
{
switch (biNode->getOp())
{
case EOpIndexDirect:
case EOpIndexIndirect:
infoSink.info << "Warning: " << node->getLine() << ": typing of sampler arrays presently unsupported\n";
break;
case EOpIndexDirectStruct:
infoSink.info << "Warning: " << node->getLine() << ": typing of samplers as struct members presently unsupported\n";
break;
}
}
else
{
infoSink.info << "Warning: " << node->getLine() << ": unexpected expression type for sampler, cannot type\n";
}
abort = false;
}
else
{
// We really have something to type, abort this traverse and activate typing
abort = true;
id = symNode->getId();
sampType = samp;
}
}
示例6: FillLoopIndexInfo
void ForLoopUnroll::FillLoopIndexInfo(TIntermLoop* node, TLoopIndexInfo& info)
{
ASSERT(node->getType() == ELoopFor);
ASSERT(node->getUnrollFlag());
TIntermNode* init = node->getInit();
ASSERT(init != NULL);
TIntermAggregate* decl = init->getAsAggregate();
ASSERT((decl != NULL) && (decl->getOp() == EOpDeclaration));
TIntermSequence& declSeq = decl->getSequence();
ASSERT(declSeq.size() == 1);
TIntermBinary* declInit = declSeq[0]->getAsBinaryNode();
ASSERT((declInit != NULL) && (declInit->getOp() == EOpInitialize));
TIntermSymbol* symbol = declInit->getLeft()->getAsSymbolNode();
ASSERT(symbol != NULL);
ASSERT(symbol->getBasicType() == EbtInt);
info.id = symbol->getId();
ASSERT(declInit->getRight() != NULL);
TIntermConstantUnion* initNode = declInit->getRight()->getAsConstantUnion();
ASSERT(initNode != NULL);
info.initValue = evaluateIntConstant(initNode);
info.currentValue = info.initValue;
TIntermNode* cond = node->getCondition();
ASSERT(cond != NULL);
TIntermBinary* binOp = cond->getAsBinaryNode();
ASSERT(binOp != NULL);
ASSERT(binOp->getRight() != NULL);
ASSERT(binOp->getRight()->getAsConstantUnion() != NULL);
info.incrementValue = getLoopIncrement(node);
info.stopValue = evaluateIntConstant(
binOp->getRight()->getAsConstantUnion());
info.op = binOp->getOp();
}
示例7: validateForLoopExpr
bool ValidateLimitations::validateForLoopExpr(TIntermLoop *node,
int indexSymbolId)
{
TIntermNode *expr = node->getExpression();
if (expr == NULL)
{
error(node->getLine(), "Missing expression", "for");
return false;
}
// 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;
TIntermSymbol *symbol = NULL;
if (unOp != NULL)
{
op = unOp->getOp();
symbol = unOp->getOperand()->getAsSymbolNode();
}
else if (binOp != NULL)
{
op = binOp->getOp();
symbol = binOp->getLeft()->getAsSymbolNode();
}
// The operand must be loop index.
if (symbol == NULL)
{
error(expr->getLine(), "Invalid expression", "for");
return false;
}
if (symbol->getId() != indexSymbolId)
{
error(symbol->getLine(),
"Expected loop index", symbol->getSymbol().c_str());
return false;
}
// The operator is one of: ++ -- += -=.
switch (op)
{
case EOpPostIncrement:
case EOpPostDecrement:
case EOpPreIncrement:
case EOpPreDecrement:
ASSERT((unOp != NULL) && (binOp == NULL));
break;
case EOpAddAssign:
case EOpSubAssign:
ASSERT((unOp == NULL) && (binOp != NULL));
break;
default:
error(expr->getLine(), "Invalid operator", GetOperatorString(op));
return false;
}
// Loop index must be incremented/decremented with a constant.
if (binOp != NULL)
{
if (!isConstExpr(binOp->getRight()))
{
error(binOp->getLine(),
"Loop index cannot be modified by non-constant expression",
symbol->getSymbol().c_str());
return false;
}
}
return true;
}