本文整理汇总了C++中FunctionType::parameters方法的典型用法代码示例。如果您正苦于以下问题:C++ FunctionType::parameters方法的具体用法?C++ FunctionType::parameters怎么用?C++ FunctionType::parameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FunctionType
的用法示例。
在下文中一共展示了FunctionType::parameters方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
}
示例2: rvalue
void
SemanticAnalysis::visitCallExpr(CallExpr *node)
{
#if 0
HIR *callee = rvalue(node->callee());
if (!callee)
return;
if (!callee->type()->isFunction()) {
cc_.reportError(node->loc(), Message_CalleeNotFunction);
return;
}
FunctionType *fun = callee->type()->toFunction();
if (!checkArgumentCount(fun, node->arguments()->length())) {
cc_.reportError(node->loc(), Message_ArgumentCountMismatch);
return;
}
if (fun->isForward()) {
cc_.reportError(node->loc(), Message_ForwardNotImplemented, fun->name()->chars());
return;
}
HIRList *args = new (pool_) HIRList;
for (unsigned i = 0; i < node->arguments()->length(); i++) {
Expression *expression = node->arguments()->at(i);
Type *actual = nullptr;
bool needs_reference = false;
if (i >= fun->parameters()->length()) {
assert(fun->isNative() && fun->isNativeVariadic());
needs_reference = true;
} else {
actual = fun->parameterAt(i);
needs_reference = actual->isReference() || actual->isArray();
}
HIR *hir = nullptr;
if (!needs_reference) {
if ((hir = rvalue(expression)) == nullptr)
return;
if ((hir = coerce(hir, actual, Coerce_Arg)) == nullptr)
return;
} else {
SValue arg;
if (!svalue(expression, &arg))
return;
// :TODO:
assert(!arg.isRValue());
if (arg.isLValue()) {
const LValue &lval = arg.lvalue();
if (actual && actual->isReference() && lval.isBaseIndex()) {
// Disabled - this feature is dangerous.
cc_.reportError(expression->loc(), Message_CannotComputeIndexRef);
return;
}
// :TODO: need to type check.
hir = new (pool_) HAddressOf(expression, lval);
}
}
args->append(hir);
}
hir_ = new (pool_) HCall(node, fun->returnType(), callee, args);
#endif
}