Collect the arguments of all the function calls at a compile time in the whole program.

Paul Backus snarwin at gmail.com
Fri Apr 15 22:52:25 UTC 2022


On Friday, 15 April 2022 at 18:11:11 UTC, BoQsc wrote:
> Let's say I have this example program.
> I want to get the arguments of all the `some_function();` in 
> the whole program.
> **Even if the scope of the function call is never executed.** 
> (Ex. due to IF statement being negative.)

You can't do this with any of D's built-in introspection features 
(like `__traits`), because those features have no way of looking 
inside functions.

However, you can probably write a program to do this using the 
DMD frontend as a library.

Dub package (use the `dmd:frontend` subpackage): 
https://code.dlang.org/packages/dmd
Documentation: https://dlang.org/library/dmd/frontend.html

Unfortunately the documentation is somewhat incomplete, so you 
may need to spend some time reading the source code to figure out 
how it all works. Don't hesitate to ask if you have any questions.


More information about the Digitalmars-d-learn mailing list