Getting function's AST at compile-time

Kapps opantm2+spam at gmail.com
Mon Sep 16 00:06:57 PDT 2013


On Sunday, 15 September 2013 at 22:59:37 UTC, Piotr Szturmaj 
wrote:
> I'm looking for something like __traits(getAST, fn). The AST 
> should represent only run-time (instantiated) code without any 
> compile-time features.
>
> How hard it would be to implement this in the frontend?
>
> It would enable analysis of code at compile-time (without the 
> need to modify the compiler).

There was a pull request previously for a trait that would get 
the code of a function, but apparently there were issues with 
when the semantic stage was run and having things be transformed 
at that point. I don't remember the exact details, but the pull 
request goes into a bit more detail: 
https://github.com/D-Programming-Language/dmd/pull/953


More information about the Digitalmars-d mailing list