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


C++ BaseClass::setVirtual方法代码示例

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


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

示例1: visit

bool CheckSpecifier::visit(ClassSpecifierAST *ast)
{
    unsigned sourceLocation = ast->firstToken();

    if (ast->name)
        sourceLocation = ast->name->firstToken();

    const Name *className = semantic()->check(ast->name, _scope);
    Class *klass = control()->newClass(sourceLocation, className);
    klass->setStartOffset(tokenAt(ast->firstToken()).offset);
    klass->setEndOffset(tokenAt(ast->lastToken()).offset);
    ast->symbol = klass;
    unsigned classKey = tokenKind(ast->classkey_token);
    if (classKey == T_CLASS)
        klass->setClassKey(Class::ClassKey);
    else if (classKey == T_STRUCT)
        klass->setClassKey(Class::StructKey);
    else if (classKey == T_UNION)
        klass->setClassKey(Class::UnionKey);
    klass->setVisibility(semantic()->currentVisibility());
    _scope->enterSymbol(klass);
    _fullySpecifiedType.setType(klass);

    for (BaseSpecifierListAST *it = ast->base_clause_list; it; it = it->next) {
        BaseSpecifierAST *base = it->value;
        const Name *baseClassName = semantic()->check(base->name, _scope);
        BaseClass *baseClass = control()->newBaseClass(ast->firstToken(), baseClassName);
        base->symbol = baseClass;
        if (base->virtual_token)
            baseClass->setVirtual(true);
        if (base->access_specifier_token) {
            int accessSpecifier = tokenKind(base->access_specifier_token);
            int visibility = semantic()->visibilityForAccessSpecifier(accessSpecifier);
            baseClass->setVisibility(visibility);
        }
        klass->addBaseClass(baseClass);
    }

    int visibility = semantic()->visibilityForClassKey(classKey);
    int previousVisibility = semantic()->switchVisibility(visibility);
    int previousMethodKey = semantic()->switchMethodKey(Function::NormalMethod);

    DeclarationAST *previousDeclaration = 0;
    for (DeclarationListAST *it = ast->member_specifier_list; it; it = it->next) {
        DeclarationAST *declaration = it->value;
        semantic()->check(declaration, klass->members());

        if (previousDeclaration && declaration &&
                declaration->asEmptyDeclaration() != 0 &&
                previousDeclaration->asFunctionDefinition() != 0)
            translationUnit()->warning(declaration->firstToken(), "unnecessary semicolon after function body");

        previousDeclaration = declaration;
    }

    (void) semantic()->switchMethodKey(previousMethodKey);
    (void) semantic()->switchVisibility(previousVisibility);

    return false;
}
开发者ID:,项目名称:,代码行数:60,代码来源:


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