Bug 21144 – A __trait should give access to interface implementation vtbl and their offsets

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-08-10T01:41:20Z
Last change time
2024-12-13T19:10:50Z
Assigned to
No Owner
Creator
Andrei Alexandrescu
Moved to GitHub: dmd#19766 →

Comments

Comment #0 by andrei — 2020-08-10T01:41:20Z
Currently TypeInfo_Class implements a primitive interfaces() that returns an array of struct Interface. The vtbl and offset of the interface are magic. Should be available as __traits. This blocks https://github.com/dlang/druntime/pull/3174.
Comment #1 by bugzilla — 2020-08-10T23:38:06Z
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.
Comment #2 by robert.schadek — 2024-12-13T19:10:50Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19766 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB