[Dlang-internal] Finding the module that caused a template instanciation
Walter Bright
newshound2 at digitalmars.com
Tue Dec 26 23:05:57 UTC 2017
On 12/18/2017 4:33 AM, Benjamin Thaut wrote:
> For my dll work I need some pointers from someone who has a deeper understanding
> of how the template implementation inside dmd works. Here is the problem
>
> Given a template instance I need to know which module caused this template to be
> instanciated. I don't need the module the template was declared in but instead
> the module that triggered the instanciation. This also has to work in cases
> where the compiler re-uses existing template instances. In a re-use case I need
> the module that caused instaciation of the re-used instance.
The model used internally by the compiler is "as if" it was instantiated every
time it was used, and then duplicates are discarded by the linker. The compiler
does an optimization internally by looking to see if it was already
instantiated, and just pointing to that instead of instantiating it again.
I suspect the problem you're having is a dependency on who instantiated it that
shouldn't be a dependency.
More information about the Dlang-internal
mailing list