Navigate from ClassInfo to TypeInfo

Tomas Lindquist Olsen tomas.l.olsen at gmail.com
Tue Apr 14 16:46:57 PDT 2009


On Wed, Apr 15, 2009 at 1:35 AM, Christopher Wright <dhasenan at gmail.com> wrote:
> 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.
>

Seems reasonable to me to add a TypeInfo field to ClassInfo.



More information about the Digitalmars-d mailing list