[Issue 16683] Lower typeid expression to .typeidImpl!(T)

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Nov 28 00:24:02 PST 2016


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

Walter Bright <bugzilla at digitalmars.com> changed:

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

--- Comment #3 from Walter Bright <bugzilla at digitalmars.com> ---
In order to get this to work, it would have to have a druntime template that
generates the following info for the typeid:

               {
                    void **vptr;
                    monitor_t monitor;
                    byte[] m_init;              // static initialization data
                    string name;                // class name
                    void*[] vtbl;
                    Interface[] interfaces;
                    ClassInfo base;             // base class
                    void* destructor;
                    void function(Object) classInvariant;   // class invariant
                    ClassFlags m_flags;
                    void* deallocator;
                    OffsetTypeInfo[] offTi;
                    void function(Object) defaultConstructor;
                    //const(MemberInfo[]) function(string) xgetMembers;   //
module getMembers() function
                    immutable(void)* m_RTInfo;
                    //TypeInfo typeinfo;
               }

which is what the compiler does in the toobj.d module in the
visit(ClassDeclaration cd) function. Doing this is fairly complex, depending on
how far one wishes to go with it - for example, preparing the initializer for
the .vtbl field is quite daunting. Perhaps have the compiler provide that via a
__traits? That would relieve some of the complexity of doing this. Or maybe
have the compiler still generate this data, but only to make it accessible via
__traits() and then have the druntime template cherry pick it as necessary?

--


More information about the Digitalmars-d-bugs mailing list