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


C++ FunctionType::isNativeVariadic方法代码示例

本文整理汇总了C++中FunctionType::isNativeVariadic方法的典型用法代码示例。如果您正苦于以下问题:C++ FunctionType::isNativeVariadic方法的具体用法?C++ FunctionType::isNativeVariadic怎么用?C++ FunctionType::isNativeVariadic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FunctionType的用法示例。


在下文中一共展示了FunctionType::isNativeVariadic方法的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());
  }
}
开发者ID:sharivan,项目名称:spcomp2,代码行数:58,代码来源:types.cpp

示例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
}
开发者ID:LittleKu,项目名称:sourcepawn,代码行数:71,代码来源:old-sema.cpp


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