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


C++ Dsymbol::isAttribDeclaration方法代码示例

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


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

示例1: foreach

int ScopeDsymbol::foreach(Dsymbols *members, ScopeDsymbol::ForeachDg dg, void *ctx, size_t *pn)
{
    assert(dg);
    if (!members)
        return 0;

    size_t n = pn ? *pn : 0; // take over index
    int result = 0;
    for (size_t i = 0; i < members->dim; i++)
    {   Dsymbol *s = (*members)[i];

        if (AttribDeclaration *a = s->isAttribDeclaration())
            result = foreach(a->decl, dg, ctx, &n);
        else if (TemplateMixin *tm = s->isTemplateMixin())
            result = foreach(tm->members, dg, ctx, &n);
        else if (s->isTemplateInstance())
            ;
        else
            result = dg(ctx, n++, s);

        if (result)
            break;
    }

    if (pn)
        *pn = n; // update index
    return result;
}
开发者ID:olgk,项目名称:ldc,代码行数:28,代码来源:dsymbol.c

示例2: if

Dsymbol *ScopeDsymbol::getNth(Array *members, size_t nth, size_t *pn)
{
    if (!members)
        return NULL;

    size_t n = 0;
    for (size_t i = 0; i < members->dim; i++)
    {   Dsymbol *s = (Dsymbol *)members->data[i];
        AttribDeclaration *a = s->isAttribDeclaration();

        if (a)
        {
            s = getNth(a->decl, nth - n, &n);
            if (s)
                return s;
        }
        else if (n == nth)
            return s;
        else
            n++;
    }

    if (pn)
        *pn += n;
    return NULL;
}
开发者ID:apriori,项目名称:dsss,代码行数:26,代码来源:dsymbol.c

示例3: collectUnitTests

/**
 * Collects all unit test functions from the given array of symbols.
 *
 * This is a helper function used by the implementation of __traits(getUnitTests).
 *
 * Input:
 *      symbols             array of symbols to collect the functions from
 *      uniqueUnitTests     an associative array (should actually be a set) to
 *                          keep track of already collected functions. We're
 *                          using an AA here to avoid doing a linear search of unitTests
 *
 * Output:
 *      unitTests           array of DsymbolExp's of the collected unit test functions
 *      uniqueUnitTests     updated with symbols from unitTests[ ]
 */
static void collectUnitTests(Dsymbols *symbols, AA *uniqueUnitTests, Expressions *unitTests)
{
    if (!symbols)
        return;
    for (size_t i = 0; i < symbols->dim; i++)
    {
        Dsymbol *symbol = (*symbols)[i];
        UnitTestDeclaration *unitTest = symbol->isUnitTestDeclaration();
        if (unitTest)
        {
            if (!_aaGetRvalue(uniqueUnitTests, unitTest))
            {
                FuncAliasDeclaration* alias = new FuncAliasDeclaration(unitTest, 0);
                alias->protection = unitTest->protection;
                Expression* e = new DsymbolExp(Loc(), alias);
                unitTests->push(e);
                bool* value = (bool*) _aaGet(&uniqueUnitTests, unitTest);
                *value = true;
            }
        }
        else
        {
            AttribDeclaration *attrDecl = symbol->isAttribDeclaration();

            if (attrDecl)
            {
                Dsymbols *decl = attrDecl->include(NULL, NULL);
                collectUnitTests(decl, uniqueUnitTests, unitTests);
            }
        }
    }
}
开发者ID:damianday,项目名称:dmd,代码行数:47,代码来源:traits.c

示例4: dim

size_t ScopeDsymbol::dim(Array *members)
{
    size_t n = 0;
    if (members)
    {
        for (size_t i = 0; i < members->dim; i++)
        {   Dsymbol *s = (Dsymbol *)members->data[i];
            AttribDeclaration *a = s->isAttribDeclaration();

            if (a)
            {
                n += dim(a->decl);
            }
            else
                n++;
        }
    }
    return n;
}
开发者ID:apriori,项目名称:dsss,代码行数:19,代码来源:dsymbol.c

示例5: parsepragmas

void ConditionalDeclaration::parsepragmas(Module *m)
{
    // we only know how to disclude the right version
    bool doinclude = true;
    
    if (dynamic_cast<VersionCondition*>(condition)) {
        VersionCondition *vc = (VersionCondition *) condition;
        
        if (!(vc->include(NULL, NULL))) {
            doinclude = false;
        }
    } else if (dynamic_cast<DebugCondition*>(condition)) {
        DebugCondition *dc = (DebugCondition *) condition;
        
        if (!(dc->include(NULL, NULL))) {
            doinclude = false;
        }
    }
    
    if (doinclude) {
        AttribDeclaration::parsepragmas(m);
        
    } else if (elsedecl) {
        for (int i = 0; i < elsedecl->dim; i++) {
            Dsymbol *ds = (Dsymbol *) elsedecl->data[i];
            
            if (ds->isAttribDeclaration()) {
                AttribDeclaration *ad = (AttribDeclaration *) ds;
                ad->parsepragmas(m);
                
            } else if (ds->isImport()) {
                Import *im = (Import *) ds;
                im->load(m, NULL);
                im->mod->parsepragmas();
                
            } else if (dynamic_cast<VersionSymbol*>(ds)) {
                VersionSymbol *vs = (VersionSymbol *) ds;
                vs->addMember(NULL, m, 0);
                
            }
        }
    }
}
开发者ID:apriori,项目名称:dsss,代码行数:43,代码来源:attrib.c

示例6: semantic


//.........这里部分代码省略.........
             */
            sc->linkage = LINKc;
    }
    sc->protection = PROTpublic;
    sc->explicitProtection = 0;
    sc->structalign = STRUCTALIGN_DEFAULT;
    if (baseClass)
    {   sc->offset = baseClass->structsize;
        alignsize = baseClass->alignsize;
//      if (enclosing)
//          sc->offset += Target::ptrsize;      // room for uplevel context pointer
    }
    else
    {   sc->offset = Target::ptrsize * 2;       // allow room for __vptr and __monitor
        alignsize = Target::ptrsize;
    }
    sc->userAttributes = NULL;
    structsize = sc->offset;
    Scope scsave = *sc;
    size_t members_dim = members->dim;
    sizeok = SIZEOKnone;

    /* Set scope so if there are forward references, we still might be able to
     * resolve individual members like enums.
     */
    for (size_t i = 0; i < members_dim; i++)
    {   Dsymbol *s = (*members)[i];
        /* There are problems doing this in the general case because
         * Scope keeps track of things like 'offset'
         */
        if (s->isEnumDeclaration() ||
            (s->isAggregateDeclaration() && s->ident) ||
            s->isTemplateMixin() ||
            s->isAttribDeclaration() ||
            s->isAliasDeclaration())
        {
            //printf("[%d] setScope %s %s, sc = %p\n", i, s->kind(), s->toChars(), sc);
            s->setScope(sc);
        }
    }

    for (size_t i = 0; i < members_dim; i++)
    {   Dsymbol *s = (*members)[i];
        s->semantic(sc);
    }

    // Set the offsets of the fields and determine the size of the class

    unsigned offset = structsize;
    bool isunion = isUnionDeclaration() != NULL;
    for (size_t i = 0; i < members->dim; i++)
    {   Dsymbol *s = (*members)[i];
        s->setFieldOffset(this, &offset, false);
    }
    sc->offset = structsize;

    if (global.errors != errors)
    {   // The type is no good.
        type = Type::terror;
    }

    if (sizeok == SIZEOKfwd)            // failed due to forward references
    {   // semantic() failed due to forward references
        // Unwind what we did, and defer it for later

        for (size_t i = 0; i < fields.dim; i++)
开发者ID:AlexeyProkhin,项目名称:ldc,代码行数:67,代码来源:class.c


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