Re: How can we view source code that has been generated (say via "static foreach") ?
On Wednesday, 15 September 2021 at 19:59:43 UTC, james.p.leblanc wrote: However, with various combinations of templates, UDAs, and mixins it has not been easy. Apart from -mixin, there's also the undocumented -vcg-ast switch that prints the AST before code generation, showing instantiated templates and unrolled static foreach loops.
Re: How can we view source code that has been generated (say via "static foreach") ?
On Thursday, 16 September 2021 at 04:54:21 UTC, james.p.leblanc wrote: Thank you for your kind response. Wow, at first the large output file from a small test program was a bit surprising .., but actually it is manageable to dig through to find the interesting bits. So, this is quite useful! Thanks again, now I am off to do some digging... Best Regards, James Note that that will only give the expansions from string mixins, not from template mixins, templates and other things.
Re: How can we view source code that has been generated (say via "static foreach") ?
On Thursday, 16 September 2021 at 03:26:46 UTC, Tejas wrote: On Wednesday, 15 September 2021 at 19:59:43 UTC, james.p.leblanc wrote: s Use the `mixin` compiler flag `dmd -mixin= file.d` Beware, this will also include **all** the mixin code from standard library and runtime. But it's manageable, reflecting on my experience. Tejas, Thank you for your kind response. Wow, at first the large output file from a small test program was a bit surprising .., but actually it is manageable to dig through to find the interesting bits. So, this is quite useful! Thanks again, now I am off to do some digging... Best Regards, James
Re: How can we view source code that has been generated (say via "static foreach") ?
On Wednesday, 15 September 2021 at 19:59:43 UTC, james.p.leblanc wrote: Dear All, In attempting to learn and use code generation, it would be useful to be able to view the source code that gets generated. However, with various combinations of templates, UDAs, and mixins it has not been easy. Is there some standard way this is done? Optimal would be to print out the entire generated source code to allow inspection. Best Regards, James Use the `mixin` compiler flag `dmd -mixin= file.d` Beware, this will also include **all** the mixin code from standard library and runtime. But it's manageable, reflecting on my experience.
How can we view source code that has been generated (say via "static foreach") ?
Dear All, In attempting to learn and use code generation, it would be useful to be able to view the source code that gets generated. However, with various combinations of templates, UDAs, and mixins it has not been easy. Is there some standard way this is done? Optimal would be to print out the entire generated source code to allow inspection. Best Regards, James