[Issue 21144] A __trait should give access to interface implementation vtbl and their offsets

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Aug 10 23:38:06 UTC 2020


https://issues.dlang.org/show_bug.cgi?id=21144

Walter Bright <bugzilla at digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla at digitalmars.com

--- Comment #1 from Walter Bright <bugzilla at digitalmars.com> ---
It is an array of:

    for (size_t i = 0; i < cd.vtblInterfaces.dim; i++)
    {
        BaseClass *b = (*cd.vtblInterfaces)[i];
        ClassDeclaration id = b.sym;

        /* The layout is:
         *  struct Interface
         *  {
         *      ClassInfo classinfo;
         *      void*[] vtbl;
         *      size_t offset;
         *  }
         */

        // Fill in vtbl[]
        b.fillVtbl(cd, &b.vtbl, 1);

        // classinfo
        dtb.xoff(toSymbol(id), 0, TYnptr);

        // vtbl[]
        dtb.size(id.vtbl.dim);
        dtb.xoff(cd.csym, offset, TYnptr);

        // offset
        dtb.size(b.offset);
    }

The compiler doesn't emit this as a separate symbol. A toInterfacesSymbol()
function would have to be written to emit it.

--


More information about the Digitalmars-d-bugs mailing list