本文整理汇总了C++中TIntermSymbol类的典型用法代码示例。如果您正苦于以下问题:C++ TIntermSymbol类的具体用法?C++ TIntermSymbol怎么用?C++ TIntermSymbol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TIntermSymbol类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
// Test for and give an error if the node can't be read from.
void TParseContextBase::rValueErrorCheck(const TSourceLoc& loc, const char* op, TIntermTyped* node)
{
if (! node)
return;
TIntermBinary* binaryNode = node->getAsBinaryNode();
if (binaryNode) {
switch(binaryNode->getOp()) {
case EOpIndexDirect:
case EOpIndexIndirect:
case EOpIndexDirectStruct:
case EOpVectorSwizzle:
case EOpMatrixSwizzle:
rValueErrorCheck(loc, op, binaryNode->getLeft());
default:
break;
}
return;
}
TIntermSymbol* symNode = node->getAsSymbolNode();
if (symNode && symNode->getQualifier().writeonly)
error(loc, "can't read from writeonly object: ", op, symNode->getName().c_str());
}
示例2: GetNodeVarName
// Returns name to be used in generated assembly for a given node
string ARBVar::GetNodeVarName(TIntermTyped* node) {
TIntermSymbol* symbol = node->getAsSymbolNode();
if (symbol) {
return string("symbol_") + symbol->getSymbol().c_str();
}
TIntermConstantUnion* cu = node->getAsConstantUnion();
if (cu) {
string ret = "";
if (cu->getBasicType() == EbtFloat) {
if (cu->getNominalSize() == 1) {
ret = "const_" + floattostr(cu->getUnionArrayPointer()[0].getFConst());
} else if (cu->isVector() && cu->getNominalSize() > 1 && cu->getNominalSize() <= 4) {
ret = "const_vec" + inttostr(cu->getNominalSize());
for (int i = 0; i < cu->getNominalSize(); ++i) {
ret += "_" + floattostr(cu->getUnionArrayPointer()[i].getFConst());
}
}
}
if (ret != "") {
for (unsigned int i = 0; i < ret.size(); ++i) {
if (ret[i] == '.') {
ret[i] = 'x';
}
}
return ret;
}
}
failmsg() << "Unknown node in GetNodeVarName [" << node->getCompleteString() << "]\n";
return "{unknown node}";
}
示例3: 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();
}
}
示例4: TIntermSymbol
//
// Add a terminal node for an identifier in an expression.
//
// Returns the added node.
//
TIntermSymbol* TIntermediate::addSymbol(int id, const TString& name, const TType& type, TSourceLoc line)
{
TIntermSymbol* node = new TIntermSymbol(id, name, type);
node->setLine(line);
return node;
}
示例5: error
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;
}
示例6: ir_grow_declaration
TIntermDeclaration* ir_grow_declaration(TIntermDeclaration* declaration, TSymbol* symbol, TIntermTyped* initializer, TInfoSink& infoSink)
{
TVariable* var = static_cast<TVariable*>(symbol);
TIntermSymbol* sym = ir_add_symbol(var->getUniqueId(), var->getName(), var->getType(), var->getType().getLine());
sym->setGlobal(symbol->isGlobal());
return ir_grow_declaration(declaration, sym, initializer, infoSink);
}
示例7: error
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: ASSERT
TIntermBinary *TIntermTraverser::createTempAssignment(TIntermTyped *rightNode)
{
ASSERT(rightNode != nullptr);
TIntermSymbol *tempSymbol = createTempSymbol(rightNode->getType());
TIntermBinary *assignment = new TIntermBinary(EOpAssign);
assignment->setLeft(tempSymbol);
assignment->setRight(rightNode);
assignment->setType(tempSymbol->getType());
return assignment;
}
示例9: 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;
}
示例10: validateOperation
bool ValidateLimitations::validateOperation(TIntermOperator *node,
TIntermNode* operand)
{
// Check if loop index is modified in the loop body.
if (!withinLoopBody() || !node->isAssignment())
return true;
TIntermSymbol *symbol = operand->getAsSymbolNode();
if (symbol && isLoopIndex(symbol))
{
error(node->getLine(),
"Loop index cannot be statically assigned to within the body of the loop",
symbol->getSymbol().c_str());
}
return true;
}
示例11: ASSERT
TIntermSymbol *TIntermTraverser::createTempSymbol(const TType &type, TQualifier qualifier)
{
// Each traversal uses at most one temporary variable, so the index stays the same within a single traversal.
TInfoSinkBase symbolNameOut;
ASSERT(mTemporaryIndex != nullptr);
symbolNameOut << "s" << (*mTemporaryIndex);
TString symbolName = symbolNameOut.c_str();
TIntermSymbol *node = new TIntermSymbol(0, symbolName, type);
node->setInternal(true);
ASSERT(qualifier == EvqTemporary || qualifier == EvqConst || qualifier == EvqGlobal);
node->getTypePointer()->setQualifier(qualifier);
// TODO(oetuaho): Might be useful to sanitize layout qualifier etc. on the type of the created
// symbol. This might need to be done in other places as well.
return node;
}
示例12: buildShader
ParsedCode Parser::buildShader(TIntermAggregate* f) {
cur.pos = f->getLine().first_line;
cur.args.clear();
cur.exprs.clear();
Position pos = f->getLine().first_line;
TIntermSequence& sequence = f->getSequence();
TIntermSequence& arguments = sequence[0]->getAsAggregate()->getSequence();
for (auto it = arguments.begin(); it != arguments.end(); ++it) {
TIntermSymbol* symbol = (*it)->getAsSymbolNode();
//if (symbol->getType().getStruct()) {
// addConstructor(symbol->getType(), scopedStruct(symbol->getType().getTypeName()), NULL);
//}
cur.args.push_back(allocVar(symbol->getQualifierString(), symbol->getTypePointer(), VUnknown, pos));
}
parseExpr(sequence[1]->getAsAggregate()->getSequence());
return cur;
}
示例13: 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;
}
}
示例14: ASSERT
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();
}
示例15: validateOperation
bool ValidateLimitations::visitBinary(Visit, TIntermBinary* node)
{
// Check if loop index is modified in the loop body.
validateOperation(node, node->getLeft());
// Check indexing.
switch (node->getOp()) {
case EOpIndexDirect:
validateIndexing(node);
break;
case EOpIndexIndirect:
#if defined(__APPLE__)
// Loop unrolling is a work-around for a Mac Cg compiler bug where it
// crashes when a sampler array's index is also the loop index.
// Once Apple fixes this bug, we should remove the code in this CL.
// See http://codereview.appspot.com/4331048/.
if ((node->getLeft() != NULL) && (node->getRight() != NULL) &&
(node->getLeft()->getAsSymbolNode())) {
TIntermSymbol* symbol = node->getLeft()->getAsSymbolNode();
if (IsSampler(symbol->getBasicType()) && symbol->isArray()) {
ValidateLoopIndexExpr validate(mLoopStack);
node->getRight()->traverse(&validate);
if (validate.usesFloatLoopIndex()) {
error(node->getLine(),
"sampler array index is float loop index",
"for");
}
}
}
#endif
validateIndexing(node);
break;
default: break;
}
return true;
}