@mymacro function (arg1, arg2)
bound1 = arg1 + arg2
bound2 = bound1 + closure1
....
end
Is there any builtin tool to supply this sort of analysis?
@mymacro function (arg1, arg2)
bound1 = arg1 + arg2
bound2 = bound1 + closure1
....
end
Is there any builtin tool to supply this sort of analysis?
Check out MacroTools.jl
Which sort of analysis?
No, there is not. Julia figures this type of information (free and bound names) out after the macro expansion pass. All you have is what dump
shows is in the AST. However, once you parsed the function header (preferably using MacroTools) you can do it yourself.
Good reads: https://docs.julialang.org/en/stable/devdocs/ast/, https://docs.julialang.org/en/stable/devdocs/eval/.
At least I want to get the variable names inside an AST and group them into bound names
and free vars
. It could be better if any type inference there.
Yes, postwalk
in MacroTools.jl
could work but it’s still a heavy task to reach my goal from using MacroTools…
Did you see GitHub - FluxML/MacroTools.jl: MacroTools provides a library of tools for working with Julia code and expressions.?
Thanks, I do have checked it out, but only the function signature is not enough, bound names except arguments and free vars are from function body.
splitdef
could extract the body for me and then I have to traverse it to get all of the variable names and group them into bound names and free vars.