本文整理汇总了C++中QualifiedType::irParameterType方法的典型用法代码示例。如果您正苦于以下问题:C++ QualifiedType::irParameterType方法的具体用法?C++ QualifiedType::irParameterType怎么用?C++ QualifiedType::irParameterType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QualifiedType
的用法示例。
在下文中一共展示了QualifiedType::irParameterType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rootStackSize
Value * CodeGenerator::genCall(const tart::FnCallExpr* in) {
const FunctionDefn * fn = in->function();
const FunctionType * fnType = fn->functionType();
bool saveIntermediateStackRoots = true;
if (fn->isIntrinsic()) {
return fn->intrinsic()->generate(*this, in);
}
size_t savedRootCount = rootStackSize();
ValueList args;
fnType->irType(); // Need to know the irType for isStructReturn.
Value * retVal = NULL;
if (fnType->isStructReturn()) {
DASSERT(in->exprType() != Expr::CtorCall); // Constructors have no return.
retVal = builder_.CreateAlloca(fnType->returnType()->irType(), NULL, "sret");
args.push_back(retVal);
}
Value * selfArg = NULL;
if (in->selfArg() != NULL) {
Type::TypeClass selfTypeClass = in->selfArg()->type()->typeClass();
if (selfTypeClass == Type::Struct) {
if (in->exprType() == Expr::CtorCall) {
selfArg = genExpr(in->selfArg());
} else {
selfArg = genLValueAddress(in->selfArg());
}
} else {
selfArg = genArgExpr(in->selfArg(), saveIntermediateStackRoots);
}
DASSERT_OBJ(selfArg != NULL, in->selfArg());
// Upcast the self argument type.
if (fnType->selfParam() != NULL) {
const Type * selfType = fnType->selfParam()->type().dealias().unqualified();
selfArg = genUpCastInstr(selfArg, in->selfArg()->type().unqualified(), selfType);
}
if (fn->storageClass() == Storage_Instance) {
args.push_back(selfArg);
}
}
const ExprList & inArgs = in->args();
for (ExprList::const_iterator it = inArgs.begin(); it != inArgs.end(); ++it) {
const Expr * arg = *it;
QualifiedType argType = arg->canonicalType();
Value * argVal = genArgExpr(arg, saveIntermediateStackRoots);
if (argVal == NULL) {
return NULL;
}
DASSERT_TYPE_EQ(in, argType->irParameterType(), argVal->getType());
args.push_back(argVal);
}
// Generate the function to call.
Value * fnVal;
if (in->exprType() == Expr::VTableCall) {
DASSERT_OBJ(selfArg != NULL, in);
const Type * classType = fnType->selfParam()->type().dealias().unqualified();
if (classType->typeClass() == Type::Class) {
fnVal = genVTableLookup(fn, static_cast<const CompositeType *>(classType), selfArg);
} else if (classType->typeClass() == Type::Interface) {
fnVal = genITableLookup(fn, static_cast<const CompositeType *>(classType), selfArg);
} else {
DASSERT(classType->typeClass() == Type::Struct);
// Struct or protocol.
fnVal = genFunctionValue(fn);
}
} else {
fnVal = genCallableDefn(fn);
}
Value * result = genCallInstr(fnVal, args, fn->name());
if (in->exprType() == Expr::CtorCall) {
// Constructor call returns the 'self' argument.
TypeShape selfTypeShape = in->selfArg()->type()->typeShape();
// A large value type will, at this point, be a pointer.
if (selfTypeShape == Shape_Small_LValue) {
selfArg = builder_.CreateLoad(selfArg, "self");
}
result = selfArg;
} else if (fnType->isStructReturn()) {
result = retVal;
}
// Clear out all the temporary roots
popRootStack(savedRootCount);
return result;
}