Exemplo n.º 1
0
// Lambda function
int cv_mem_count(Dsymbol *s, void *param)
{   CvMemberCount *pmc = (CvMemberCount *)param;

    int nwritten = cvMember(s, NULL);
    if (nwritten)
    {
        pmc->fnamelen += nwritten;
        pmc->nfields++;
    }
    return 0;
}
Exemplo n.º 2
0
int cvMember(unsigned char *p, char *id, idx_t typidx)
{
    int nwritten = 0;
    if (!p)
        nwritten = cv_stringbytes(id);

    switch (config.fulltypes)
    {
        case CV8:
            if (!p)
            {
                nwritten += 8;
                nwritten = cv_align(NULL, nwritten);
            }
            else
            {
                TOWORD(p,LF_NESTTYPE_V3);
                TOWORD(p + 2,0);
                TOLONG(p + 4,typidx);
                nwritten = 8 + cv_namestring(p + 8, id);
                nwritten = cv_align(p + nwritten, nwritten);
            }
            break;

        case CV4:
            if (!p)
            {
                nwritten += 4;
            }
            else
            {
                TOWORD(p,LF_NESTTYPE);
                TOWORD(p + 2,typidx);
                nwritten = 4 + cv_namestring(p + 4, id);
            }
            break;

        default:
            assert(0);
    }
#ifdef DEBUG
    if (p)
        assert(nwritten == cvMember(NULL, id, typidx));
#endif
    return nwritten;
}
Exemplo n.º 3
0
int VarDeclaration::cvMember(unsigned char *p)
{
    int nwritten = 0;

    //printf("VarDeclaration::cvMember(p = %p) '%s'\n", p, toChars());

    if (type->toBasetype()->ty == Ttuple)
        return 0;

    char *id = toChars();

    if (!p)
    {
        if (isField())
        {
            if (config.fulltypes == CV8)
                nwritten += 2;
            nwritten += 6 + cv_stringbytes(id);
            nwritten += cv4_numericbytes(offset);
        }
        else if (isStatic())
        {
            if (config.fulltypes == CV8)
                nwritten += 2;
            nwritten += 6 + cv_stringbytes(id);
        }
        nwritten = cv_align(NULL, nwritten);
    }
    else
    {
        idx_t typidx = cv_typidx(type->toCtype());
        unsigned attribute = PROTtoATTR(prot());
        assert((attribute & ~3) == 0);
        switch (config.fulltypes)
        {
            case CV8:
                if (isField())
                {
                    TOWORD(p,LF_MEMBER_V3);
                    TOWORD(p + 2,attribute);
                    TOLONG(p + 4,typidx);
                    cv4_storenumeric(p + 8, offset);
                    nwritten = 8 + cv4_numericbytes( offset);
                    nwritten += cv_namestring(p + nwritten, id);
                }
                else if (isStatic())
                {
                    TOWORD(p,LF_STMEMBER_V3);
                    TOWORD(p + 2,attribute);
                    TOLONG(p + 4,typidx);
                    nwritten = 8;
                    nwritten += cv_namestring(p + nwritten, id);
                }
                break;

            case CV4:
                if (isField())
                {
                    TOWORD(p,LF_MEMBER);
                    TOWORD(p + 2,typidx);
                    TOWORD(p + 4,attribute);
                    cv4_storenumeric(p + 6, offset);
                    nwritten = 6 + cv4_numericbytes( offset);
                    nwritten += cv_namestring(p + nwritten, id);
                }
                else if (isStatic())
                {
                    TOWORD(p,LF_STMEMBER);
                    TOWORD(p + 2,typidx);
                    TOWORD(p + 4,attribute);
                    nwritten = 6;
                    nwritten += cv_namestring(p + nwritten, id);
                }
                break;

             default:
                assert(0);
        }

        nwritten = cv_align(p + nwritten, nwritten);
#ifdef DEBUG
        assert(nwritten == cvMember(NULL));
#endif
    }
    return nwritten;
}
Exemplo n.º 4
0
int FuncDeclaration::cvMember(unsigned char *p)
{
    int nwritten = 0;

    //printf("FuncDeclaration::cvMember() '%s'\n", toChars());

    if (!type)                  // if not compiled in,
        return 0;               // skip it

    char *id = toChars();

    if (!p)
    {
        nwritten = 2 + 2 + cgcv.sz_idx + cv_stringbytes(id);
        nwritten = cv_align(NULL, nwritten);
        return nwritten;
    }
    else
    {
        int count = 0;
        int mlen = 2;
        {
            if (introducing)
                mlen += 4;
            mlen += cgcv.sz_idx * 2;
            count++;
        }

        // Allocate and fill it in
        debtyp_t *d = debtyp_alloc(mlen);
        unsigned char *q = d->data;
        TOWORD(q,config.fulltypes == CV8 ? LF_METHODLIST_V2 : LF_METHODLIST);
        q += 2;
//      for (s = sf; s; s = s->Sfunc->Foversym)
        {
            unsigned attribute = PROTtoATTR(prot());

            /* 0*4 vanilla method
             * 1*4 virtual method
             * 2*4 static method
             * 3*4 friend method
             * 4*4 introducing virtual method
             * 5*4 pure virtual method
             * 6*4 pure introducing virtual method
             * 7*4 reserved
             */

            if (isStatic())
                attribute |= 2*4;
            else if (isVirtual())
            {
                if (introducing)
                {
                    if (isAbstract())
                        attribute |= 6*4;
                    else
                        attribute |= 4*4;
                }
                else
                {
                    if (isAbstract())
                        attribute |= 5*4;
                    else
                        attribute |= 1*4;
                }
            }
            else
                attribute |= 0*4;

            TOIDX(q,attribute);
            q += cgcv.sz_idx;
            TOIDX(q, cv4_memfunctypidx(this));
            q += cgcv.sz_idx;
            if (introducing)
            {   TOLONG(q, vtblIndex * Target::ptrsize);
                q += 4;
            }
        }
        assert(q - d->data == mlen);

        idx_t typidx = cv_debtyp(d);
        if (typidx)
        {
            switch (config.fulltypes)
            {
                case CV8:
                    TOWORD(p,LF_METHOD_V3);
                    goto Lmethod;
                case CV4:
                    TOWORD(p,LF_METHOD);
                Lmethod:
                    TOWORD(p + 2,count);
                    nwritten = 4;
                    TOIDX(p + nwritten, typidx);
                    nwritten += cgcv.sz_idx;
                    nwritten += cv_namestring(p + nwritten, id);
                    break;

                default:
                    assert(0);
            }
        }
        nwritten = cv_align(p + nwritten, nwritten);
#ifdef DEBUG
        assert(nwritten == cvMember(NULL));
#endif
    }
    return nwritten;
}
Exemplo n.º 5
0
// Lambda function
int cv_mem_p(Dsymbol *s, void *param)
{
    unsigned char **pp = (unsigned char **)param;
    *pp += cvMember(s, *pp);
    return 0;
}