本文整理汇总了C++中ArrayType::levels方法的典型用法代码示例。如果您正苦于以下问题:C++ ArrayType::levels方法的具体用法?C++ ArrayType::levels怎么用?C++ ArrayType::levels使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayType
的用法示例。
在下文中一共展示了ArrayType::levels方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Compare
bool
Type::Compare(Type *left, Type *right)
{
if (left == right)
return true;
if (left->kind() != right->kind())
return false;
switch (left->kind()) {
case Type::PRIMITIVE:
return left->primitive() == right->primitive();
case Type::ARRAY:
{
ArrayType *aleft = left->toArray();
ArrayType *aright = right->toArray();
if (aleft->levels() != aright->levels())
return false;
if (aleft->isFixedLength() != aright->isFixedLength())
return false;
if (aleft->isFixedLength() && aleft->fixedLength() != aright->fixedLength())
return false;
return Compare(aleft->contained(), aright->contained());
}
case Type::FUNCTION:
{
FunctionType *fleft = left->toFunction();
FunctionType *fright = right->toFunction();
if (!Compare(fleft->returnType(), fright->returnType()))
return false;
if (fleft->parameters()->length() != fright->parameters()->length())
return false;
if (fleft->isNative() != fright->isNative())
return false;
if (fleft->isNative() && (fleft->isNativeVariadic() != fright->isNativeVariadic()))
return false;
for (unsigned i = 0; i < fleft->parameters()->length(); i++) {
Type *leftparam = fleft->parameterAt(i);
Type *rightparam = fright->parameterAt(i);
if (!Compare(leftparam, rightparam))
return false;
}
return true;
}
case Type::ENUM:
return false;
case Type::VOID:
return true;
default:
assert(left->kind() == Type::REFERENCE);
return Compare(left->toReference()->contained(), right->toReference()->contained());
}
}