Post-mixin-expansion source output

Mithun Hunsur via Digitalmars-d digitalmars-d at puremagic.com
Sun May 8 03:24:12 PDT 2016


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?


More information about the Digitalmars-d mailing list