Navigate from ClassInfo to TypeInfo

Christopher Wright dhasenan at gmail.com
Tue Apr 14 16:35:43 PDT 2009


Frank Benoit wrote:
> I need to retrieve an instance of TypeInfo from an object instance at
> runtime.
> 
> TypeInfo info = typeid(obj) // does not work, only compile time
> 
> TypeInfo info = obj.classinfo.????; // how to navigate to TypeInfo?
> 
> Is that possible?
> If not, why? And can it be added (D1)?

There is no way that I know of to do so, and I've looked into the issue 
previously. -- I don't know how TypeInfo is instantiated; I imagine it's 
in the data segment of the executable; so it should be possible to 
examine all symbols in an executable to find TypeInfo instances and 
determine what they refer to. However, the language and runtime lack 
support for this.



More information about the Digitalmars-d mailing list