Пример #1
0
Class* ModuleEmitter::createClass(ClassDeclaration& decl)
{
    Class* c = NULL;
    if (Dsymbol* parent = decl.toParent())
    {
        //start by assuming class is declared at module scope
        block* blk = &DEREF(irState_).getBlock();
        if (AggregateDeclaration* aggrDecl = parent->isAggregateDeclaration())
        {
            decl.isnested = true;
            blk = &getAggregate(*aggrDecl).getBlock();
        }

        //if the class lives in another assembly, generate it in a hidden block
#if 0
        for (Dsymbol* p = parent; p; p = p->toParent())
        {
            if (PragmaScope* pscope = p->isPragmaScope())
            {
                if (pscope->kind() == PragmaScope::pragma_assembly)
                {
                    blk = &BackEnd::instance().getAssembly();
                    break;
                }
            }
        }
#else
        if (inPragmaAssembly(parent))
        {
            blk = &BackEnd::instance().getAssembly();
        }
#endif
        c = new Class(decl, blk->depth());
        blk->add(*c);
        assert(decl.csym == c);
    }
    return c;
}