当前位置: 首页>>代码示例>>C++>>正文


C++ QualifiedType::irParameterType方法代码示例

本文整理汇总了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;
}
开发者ID:afrog33k,项目名称:tart,代码行数:96,代码来源:CodeGenCall.cpp


注:本文中的QualifiedType::irParameterType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。