digitalmars.D - Post-mixin-expansion source output
- Mithun Hunsur (18/18) May 08 2016 Hi all,
- Iakh (6/11) May 08 2016 I think it would be better to have mixin-dump file with all mixins
- Stefan Koch (4/10) May 08 2016 Yes exactly, splicing it into the original source is precisely
Hi all, I was discussing this with Stefan Koch and a few other people at DConf - would it be possible to have a compiler switch for outputting the complete source file after the mixins have been expanded, similar to gcc -E? I assume that mixin expansion occurs in the semantic pass, which might make this difficult; however, it'd be pretty useful, especially when working on heavily CTFE-dependent code where almost everything is generated at compile-time; while you can splatter pragma(msg) around, it can get rather tedious, especially when debugging. A quick look at CompileStatement.semantic indicates that the string is parsed, with the resulting statements made the subject of a CompoundStatement - at this point, I'm assuming the AST has already been processed (lowering, etc), making it difficult to recover the original source code from the AST. Perhaps it would be possible to splice in the mixin string into the original source?
May 08 2016
On Sunday, 8 May 2016 at 10:24:12 UTC, Mithun Hunsur wrote:Hi all, I was discussing this with Stefan Koch and a few other people at DConf - would it be possible to have a compiler switch for outputting the complete source file after the mixins have been expanded, similar to gcc -E?I think it would be better to have mixin-dump file with all mixins printed into it and references set to this file. So debug info could point to some "real" source. But I didn't do any investigation how to implement it.
May 08 2016
On Sunday, 8 May 2016 at 10:24:12 UTC, Mithun Hunsur wrote:Hi all, I was discussing this with Stefan Koch and a few other people at DConf - would it be possible to have a compiler switch for outputting the complete source file after the mixins have been expanded, similar to gcc -E? [...]Yes exactly, splicing it into the original source is precisely what I want to do. You are correct the constructs are already lowered.
May 08 2016