digitalmars.D.learn - How can we view source code that has been generated (say via "static
- james.p.leblanc (11/11) Sep 15 2021 Dear All,
- Tejas (7/18) Sep 15 2021 Use the `mixin` compiler flag
- james.p.leblanc (12/19) Sep 15 2021 Tejas,
- Nicholas Wilson (4/13) Sep 17 2021 Note that that will only give the expansions from string mixins,
- Dennis (5/7) Sep 17 2021 Apart from -mixin, there's also the undocumented -vcg-ast switch
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
Sep 15 2021
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, JamesUse the `mixin` compiler flag `dmd -mixin=<whatever-name> file.d` Beware, this will also include **all** the mixin code from standard library and runtime. But it's manageable, reflecting on my experience.
Sep 15 2021
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:sUse the `mixin` compiler flag `dmd -mixin=<whatever-name> 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
Sep 15 2021
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, JamesNote that that will only give the expansions from string mixins, not from template mixins, templates and other things.
Sep 17 2021
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.
Sep 17 2021