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


C++ Argument::hasInitializer方法代码示例

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


在下文中一共展示了Argument::hasInitializer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: maybeValidPrototype

bool Function::maybeValidPrototype(unsigned actualArgumentCount) const
{
    const unsigned argc = argumentCount();
    unsigned minNumberArguments = 0;

    for (; minNumberArguments < argc; ++minNumberArguments) {
        Argument *arg = argumentAt(minNumberArguments)->asArgument();

        if (! arg)
            return false;

        if (arg->hasInitializer())
            break;
    }

    if (actualArgumentCount < minNumberArguments) {
        // not enough arguments.
        return false;

    } else if (!isVariadic() && actualArgumentCount > argc) {
        // too many arguments.
        return false;
    }

    return true;
}
开发者ID:Andersbakken,项目名称:CPlusPlus,代码行数:26,代码来源:Symbols.cpp

示例2: visit

bool CheckDeclarator::visit(FunctionDeclaratorAST *ast)
{
    Function *fun = control()->newFunction(ast->firstToken());
    fun->setAmbiguous(ast->as_cpp_initializer != 0);
    ast->symbol = fun;
    fun->setReturnType(_fullySpecifiedType);

    if (_fullySpecifiedType.isVirtual())
        fun->setVirtual(true);

    if (ast->parameters) {
        DeclarationListAST *parameter_declarations = ast->parameters->parameter_declarations;
        for (DeclarationListAST *decl = parameter_declarations; decl; decl = decl->next) {
            semantic()->check(decl->declaration, fun->arguments());
        }

        if (ast->parameters->dot_dot_dot_token)
            fun->setVariadic(true);
    }

    // check the arguments
    bool hasDefaultArguments = false;
    for (unsigned i = 0; i < fun->argumentCount(); ++i) {
        Argument *arg = fun->argumentAt(i)->asArgument();
        if (hasDefaultArguments && ! arg->hasInitializer()) {
            translationUnit()->error(ast->firstToken(),
                "default argument missing for parameter at position %d", i + 1);
        } else if (! hasDefaultArguments) {
            hasDefaultArguments = arg->hasInitializer();
        }
    }

    FullySpecifiedType funTy(fun);
    _fullySpecifiedType = funTy;

    for (SpecifierAST *it = ast->cv_qualifier_seq; it; it = it->next) {
        SimpleSpecifierAST *cv = static_cast<SimpleSpecifierAST *>(it);
        int k = tokenKind(cv->specifier_token);
        if (k == T_CONST)
            fun->setConst(true);
        else if (k == T_VOLATILE)
            fun->setVolatile(true);
    }

    accept(ast->next);
    return false;
}
开发者ID:halsten,项目名称:beaverdbg,代码行数:47,代码来源:CheckDeclarator.cpp


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