Finding class template instantiations via runtime reflection (for openmethods)

Steven Schveighoffer schveiguy at yahoo.com
Mon Sep 25 13:31:44 UTC 2017


On 9/24/17 12:30 AM, user1234 wrote:
> On Friday, 22 September 2017 at 12:16:52 UTC, Steven Schveighoffer wrote:
>> It used to be that classes were always in ModuleInfo (and that 
>> ModuleInfo was always generated). That's not so much the case any 
>> more, as there has been a push to reduce the runtime footprint and 
>> complexity (especially toward -betterC). This makes traditional 
>> runtime reflection more difficult and sporadic.
>>
>> However, I would expect that if ModuleInfo is generated for a file, 
>> and some classes are added, then ALL classes instantiated in the 
>> module should be added.
>>
>> I would say it's a bug.
>>
> 
> aliases are not symbol so it's expected that 'BarInt' doesn't appear in 
> the items.

Correct, even with a fixed compiler, BarInt would not appear.

> Would "Bar!int" be usable in Object.factory ?

I'm not sure what the name of the class might be, as this capability 
depends completely on the compiler.

As it stands, no entry for the class type is made in the ModuleInfo, so 
there's no way to know what the "right name" is -- someone needs to add 
the capability, and that may be when the decision is made.

Note to readers, Object.factory uses exactly the mechanism Jean-Louis 
has used, so if his code can't find it, neither can Object.factory.

-Steve


More information about the Digitalmars-d mailing list