本文整理汇总了C++中TIntermTyped::isArray方法的典型用法代码示例。如果您正苦于以下问题:C++ TIntermTyped::isArray方法的具体用法?C++ TIntermTyped::isArray怎么用?C++ TIntermTyped::isArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TIntermTyped
的用法示例。
在下文中一共展示了TIntermTyped::isArray方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// Special case for matrix[idx1][idx2]: output as matrix[idx2][idx1]
static bool Check2DMatrixIndex (TGlslOutputTraverser* goit, std::stringstream& out, TIntermTyped* left, TIntermTyped* right)
{
if (left->isVector() && !left->isArray())
{
TIntermBinary* leftBin = left->getAsBinaryNode();
if (leftBin && (leftBin->getOp() == EOpIndexDirect || leftBin->getOp() == EOpIndexIndirect))
{
TIntermTyped* superLeft = leftBin->getLeft();
TIntermTyped* superRight = leftBin->getRight();
if (superLeft->isMatrix() && !superLeft->isArray())
{
superLeft->traverse (goit);
out << "[";
right->traverse(goit);
out << "][";
superRight->traverse(goit);
out << "]";
return true;
}
}
}
return false;
}
示例2: traverseBinary
bool TGlslOutputTraverser::traverseBinary( bool preVisit, TIntermBinary *node, TIntermTraverser *it )
{
TString op = "??";
TGlslOutputTraverser* goit = static_cast<TGlslOutputTraverser*>(it);
GlslFunction *current = goit->current;
std::stringstream& out = current->getActiveOutput();
bool infix = true;
bool assign = false;
bool needsParens = true;
switch (node->getOp())
{
case EOpAssign: op = "="; infix = true; needsParens = false; break;
case EOpAddAssign: op = "+="; infix = true; needsParens = false; break;
case EOpSubAssign: op = "-="; infix = true; needsParens = false; break;
case EOpMulAssign: op = "*="; infix = true; needsParens = false; break;
case EOpVectorTimesMatrixAssign: op = "*="; infix = true; needsParens = false; break;
case EOpVectorTimesScalarAssign: op = "*="; infix = true; needsParens = false; break;
case EOpMatrixTimesScalarAssign: op = "*="; infix = true; needsParens = false; break;
case EOpMatrixTimesMatrixAssign: op = "*="; infix = true; needsParens = false; break;
case EOpDivAssign: op = "/="; infix = true; needsParens = false; break;
case EOpModAssign: op = "%="; infix = true; needsParens = false; break;
case EOpAndAssign: op = "&="; infix = true; needsParens = false; break;
case EOpInclusiveOrAssign: op = "|="; infix = true; needsParens = false; break;
case EOpExclusiveOrAssign: op = "^="; infix = true; needsParens = false; break;
case EOpLeftShiftAssign: op = "<<="; infix = true; needsParens = false; break;
case EOpRightShiftAssign: op = "??="; infix = true; needsParens = false; break;
case EOpIndexDirect:
{
TIntermTyped *left = node->getLeft();
TIntermTyped *right = node->getRight();
assert( left && right);
current->beginStatement();
if (Check2DMatrixIndex (goit, out, left, right))
return false;
if (left->isMatrix() && !left->isArray())
{
if (right->getAsConstant())
{
current->addLibFunction (EOpMatrixIndex);
out << "xll_matrixindex (";
left->traverse(goit);
out << ", ";
right->traverse(goit);
out << ")";
return false;
}
else
{
current->addLibFunction (EOpTranspose);
current->addLibFunction (EOpMatrixIndex);
current->addLibFunction (EOpMatrixIndexDynamic);
out << "xll_matrixindexdynamic (";
left->traverse(goit);
out << ", ";
right->traverse(goit);
out << ")";
return false;
}
}
left->traverse(goit);
// Special code for handling a vector component select (this improves readability)
if (left->isVector() && !left->isArray() && right->getAsConstant())
{
char swiz[] = "xyzw";
goit->visitConstantUnion = TGlslOutputTraverser::traverseImmediateConstant;
goit->generatingCode = false;
right->traverse(goit);
assert( goit->indexList.size() == 1);
assert( goit->indexList[0] < 4);
out << "." << swiz[goit->indexList[0]];
goit->indexList.clear();
goit->visitConstantUnion = TGlslOutputTraverser::traverseConstantUnion;
goit->generatingCode = true;
}
else
{
out << "[";
right->traverse(goit);
out << "]";
}
return false;
}
case EOpIndexIndirect:
{
TIntermTyped *left = node->getLeft();
TIntermTyped *right = node->getRight();
current->beginStatement();
if (Check2DMatrixIndex (goit, out, left, right))
return false;
if (left && right && left->isMatrix() && !left->isArray())
{
//.........这里部分代码省略.........
示例3: ir_add_unary_math
// Add one node as the parent of another that it operates on.
TIntermTyped* ir_add_unary_math(TOperator op, TIntermNode* childNode, TSourceLoc line, TParseContext& ctx)
{
TIntermUnary* node;
TIntermTyped* child = childNode->getAsTyped();
if (child == 0)
{
ctx.infoSink.info.message(EPrefixInternalError, "Bad type in AddUnaryMath", line);
return 0;
}
switch (op)
{
case EOpLogicalNot:
if (!child->isScalar())
return 0;
break;
case EOpPostIncrement:
case EOpPreIncrement:
case EOpPostDecrement:
case EOpPreDecrement:
case EOpNegative:
if (child->getType().getBasicType() == EbtStruct || child->getType().isArray())
return 0;
default: break;
}
//
// Do we need to promote the operand?
//
// Note: Implicit promotions were removed from the language.
//
TBasicType newType = EbtVoid;
switch (op)
{
case EOpConstructInt: newType = EbtInt; break;
case EOpConstructBool: newType = EbtBool; break;
case EOpConstructFloat: newType = EbtFloat; break;
case EOpLogicalNot: newType = EbtBool; break;
default: break;
}
if (newType != EbtVoid)
{
child = ir_add_conversion(op, TType(newType, child->getPrecision(), EvqTemporary, child->getColsCount(), child->getRowsCount(),
child->isMatrix(),
child->isArray()),
child, ctx.infoSink);
if (child == 0)
return 0;
}
//
// For constructors, we are now done, it's all in the conversion.
//
switch (op)
{
case EOpConstructInt:
case EOpConstructBool:
case EOpConstructFloat:
return child;
default: break;
}
TIntermConstant* childConst = child->getAsConstant();
//
// Make a new node for the operator.
//
node = new TIntermUnary(op);
if (line.line == 0)
line = child->getLine();
node->setLine(line);
node->setOperand(child);
if (! node->promote(ctx))
return 0;
//
// See if we can fold constants
if (childConst)
{
TIntermConstant* FoldUnaryConstantExpression(TOperator op, TIntermConstant* node);
TIntermConstant* res = FoldUnaryConstantExpression(node->getOp(), childConst);
if (res)
{
delete node;
return res;
}
}
return node;
}
示例4: addUnaryMath
//
// Add one node as the parent of another that it operates on.
//
// Returns the added node.
//
TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermNode* childNode, TSourceLoc line, TSymbolTable& symbolTable)
{
TIntermUnary* node;
TIntermTyped* child = childNode->getAsTyped();
if (child == 0) {
infoSink.info.message(EPrefixInternalError, "Bad type in AddUnaryMath", line);
return 0;
}
switch (op) {
case EOpLogicalNot:
if (child->getType().getBasicType() != EbtBool || child->getType().isMatrix() || child->getType().isArray() || child->getType().isVector()) {
return 0;
}
break;
case EOpPostIncrement:
case EOpPreIncrement:
case EOpPostDecrement:
case EOpPreDecrement:
case EOpNegative:
if (child->getType().getBasicType() == EbtStruct || child->getType().isArray())
return 0;
default: break;
}
//
// Do we need to promote the operand?
//
// Note: Implicit promotions were removed from the language.
//
TBasicType newType = EbtVoid;
switch (op) {
case EOpConstructInt: newType = EbtInt; break;
case EOpConstructBool: newType = EbtBool; break;
case EOpConstructFloat: newType = EbtFloat; break;
default: break;
}
if (newType != EbtVoid) {
child = addConversion(op, TType(newType, child->getPrecision(), EvqTemporary,
child->getNominalSize(),
child->isMatrix(),
child->isArray()),
child);
if (child == 0)
return 0;
}
//
// For constructors, we are now done, it's all in the conversion.
//
switch (op) {
case EOpConstructInt:
case EOpConstructBool:
case EOpConstructFloat:
return child;
default: break;
}
TIntermConstantUnion *childTempConstant = 0;
if (child->getAsConstantUnion())
childTempConstant = child->getAsConstantUnion();
//
// Make a new node for the operator.
//
node = new TIntermUnary(op);
if (line == 0)
line = child->getLine();
node->setLine(line);
node->setOperand(child);
if (! node->promote(infoSink))
return 0;
if (childTempConstant) {
TIntermTyped* newChild = childTempConstant->fold(op, 0, infoSink);
if (newChild)
return newChild;
}
return node;
}
示例5: visitBinary
bool TOutputGLSLBase::visitBinary(Visit visit, TIntermBinary* node)
{
bool visitChildren = true;
TInfoSinkBase& out = objSink();
switch (node->getOp())
{
case EOpInitialize:
if (visit == InVisit)
{
out << " = ";
// RHS of initialize is not being declared.
mDeclaringVariables = false;
}
break;
case EOpAssign: writeTriplet(visit, "(", " = ", ")"); break;
case EOpAddAssign: writeTriplet(visit, "(", " += ", ")"); break;
case EOpSubAssign: writeTriplet(visit, "(", " -= ", ")"); break;
case EOpDivAssign: writeTriplet(visit, "(", " /= ", ")"); break;
// Notice the fall-through.
case EOpMulAssign:
case EOpVectorTimesMatrixAssign:
case EOpVectorTimesScalarAssign:
case EOpMatrixTimesScalarAssign:
case EOpMatrixTimesMatrixAssign:
writeTriplet(visit, "(", " *= ", ")");
break;
case EOpIndexDirect:
writeTriplet(visit, NULL, "[", "]");
break;
case EOpIndexIndirect:
if (node->getAddIndexClamp())
{
if (visit == InVisit)
{
if (mClampingStrategy == SH_CLAMP_WITH_CLAMP_INTRINSIC) {
out << "[int(clamp(float(";
} else {
out << "[webgl_int_clamp(";
}
}
else if (visit == PostVisit)
{
int maxSize;
TIntermTyped *left = node->getLeft();
TType leftType = left->getType();
if (left->isArray())
{
// The shader will fail validation if the array length is not > 0.
maxSize = leftType.getArraySize() - 1;
}
else
{
maxSize = leftType.getNominalSize() - 1;
}
if (mClampingStrategy == SH_CLAMP_WITH_CLAMP_INTRINSIC) {
out << "), 0.0, float(" << maxSize << ")))]";
} else {
out << ", 0, " << maxSize << ")]";
}
}
}
else
{
writeTriplet(visit, NULL, "[", "]");
}
break;
case EOpIndexDirectStruct:
if (visit == InVisit)
{
out << ".";
// TODO(alokp): ASSERT
TString fieldName = node->getType().getFieldName();
const TType& structType = node->getLeft()->getType();
if (!mSymbolTable.findBuiltIn(structType.getTypeName()))
fieldName = hashName(fieldName);
out << fieldName;
visitChildren = false;
}
break;
case EOpVectorSwizzle:
if (visit == InVisit)
{
out << ".";
TIntermAggregate* rightChild = node->getRight()->getAsAggregate();
TIntermSequence& sequence = rightChild->getSequence();
for (TIntermSequence::iterator sit = sequence.begin(); sit != sequence.end(); ++sit)
{
TIntermConstantUnion* element = (*sit)->getAsConstantUnion();
ASSERT(element->getBasicType() == EbtInt);
ASSERT(element->getNominalSize() == 1);
const ConstantUnion& data = element->getUnionArrayPointer()[0];
ASSERT(data.getType() == EbtInt);
switch (data.getIConst())
{
case 0: out << "x"; break;
//.........这里部分代码省略.........
示例6: visitBinary
bool TOutputGLSLBase::visitBinary(Visit visit, TIntermBinary *node)
{
bool visitChildren = true;
TInfoSinkBase &out = objSink();
switch (node->getOp())
{
case EOpInitialize:
if (visit == InVisit)
{
out << " = ";
// RHS of initialize is not being declared.
mDeclaringVariables = false;
}
break;
case EOpAssign:
writeTriplet(visit, "(", " = ", ")");
break;
case EOpAddAssign:
writeTriplet(visit, "(", " += ", ")");
break;
case EOpSubAssign:
writeTriplet(visit, "(", " -= ", ")");
break;
case EOpDivAssign:
writeTriplet(visit, "(", " /= ", ")");
break;
case EOpIModAssign:
writeTriplet(visit, "(", " %= ", ")");
break;
// Notice the fall-through.
case EOpMulAssign:
case EOpVectorTimesMatrixAssign:
case EOpVectorTimesScalarAssign:
case EOpMatrixTimesScalarAssign:
case EOpMatrixTimesMatrixAssign:
writeTriplet(visit, "(", " *= ", ")");
break;
case EOpBitShiftLeftAssign:
writeTriplet(visit, "(", " <<= ", ")");
break;
case EOpBitShiftRightAssign:
writeTriplet(visit, "(", " >>= ", ")");
break;
case EOpBitwiseAndAssign:
writeTriplet(visit, "(", " &= ", ")");
break;
case EOpBitwiseXorAssign:
writeTriplet(visit, "(", " ^= ", ")");
break;
case EOpBitwiseOrAssign:
writeTriplet(visit, "(", " |= ", ")");
break;
case EOpIndexDirect:
writeTriplet(visit, NULL, "[", "]");
break;
case EOpIndexIndirect:
if (node->getAddIndexClamp())
{
if (visit == InVisit)
{
if (mClampingStrategy == SH_CLAMP_WITH_CLAMP_INTRINSIC)
out << "[int(clamp(float(";
else
out << "[webgl_int_clamp(";
}
else if (visit == PostVisit)
{
int maxSize;
TIntermTyped *left = node->getLeft();
TType leftType = left->getType();
if (left->isArray())
{
// The shader will fail validation if the array length is not > 0.
maxSize = leftType.getArraySize() - 1;
}
else
{
maxSize = leftType.getNominalSize() - 1;
}
if (mClampingStrategy == SH_CLAMP_WITH_CLAMP_INTRINSIC)
out << "), 0.0, float(" << maxSize << ")))]";
else
out << ", 0, " << maxSize << ")]";
}
}
else
{
writeTriplet(visit, NULL, "[", "]");
}
break;
case EOpIndexDirectStruct:
if (visit == InVisit)
{
// Here we are writing out "foo.bar", where "foo" is struct
// and "bar" is field. In AST, it is represented as a binary
// node, where left child represents "foo" and right child "bar".
// The node itself represents ".". The struct field "bar" is
//.........这里部分代码省略.........