本文整理汇总了C++中TypeSpec::aggregate方法的典型用法代码示例。如果您正苦于以下问题:C++ TypeSpec::aggregate方法的具体用法?C++ TypeSpec::aggregate怎么用?C++ TypeSpec::aggregate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeSpec
的用法示例。
在下文中一共展示了TypeSpec::aggregate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TypeSpec
TypeSpec
ASTindex::typecheck (TypeSpec expected)
{
typecheck_children ();
const char *indextype = "";
TypeSpec t = lvalue()->typespec();
if (t.is_structure()) {
error ("Cannot use [] indexing on a struct");
return TypeSpec();
}
if (t.is_closure()) {
error ("Cannot use [] indexing on a closure");
return TypeSpec();
}
if (index3()) {
if (! t.is_array() && ! t.elementtype().is_matrix())
error ("[][][] only valid for a matrix array");
m_typespec = TypeDesc::FLOAT;
} else if (t.is_array()) {
indextype = "array";
m_typespec = t.elementtype();
if (index2()) {
if (t.aggregate() == TypeDesc::SCALAR)
error ("can't use [][] on a simple array");
m_typespec = TypeDesc::FLOAT;
}
} else if (t.aggregate() == TypeDesc::VEC3) {
indextype = "component";
TypeDesc tnew = t.simpletype();
tnew.aggregate = TypeDesc::SCALAR;
tnew.vecsemantics = TypeDesc::NOXFORM;
m_typespec = tnew;
if (index2())
error ("can't use [][] on a %s", type_c_str(t));
} else if (t.aggregate() == TypeDesc::MATRIX44) {
indextype = "component";
TypeDesc tnew = t.simpletype();
tnew.aggregate = TypeDesc::SCALAR;
tnew.vecsemantics = TypeDesc::NOXFORM;
m_typespec = tnew;
if (! index2())
error ("must use [][] on a matrix, not just []");
} else {
error ("can only use [] indexing for arrays or multi-component types");
return TypeSpec();
}
// Make sure the indices (children 1+) are integers
for (size_t c = 1; c < nchildren(); ++c)
if (! child(c)->typespec().is_int())
error ("%s index must be an integer, not a %s",
indextype, type_c_str(index()->typespec()));
// If the thing we're indexing is an lvalue, so is the indexed element
m_is_lvalue = lvalue()->is_lvalue();
return m_typespec;
}