You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The application I'm building requires walking all expressions, including arguments of macro calls. How hard would it be to have a kwarg that does that?
The text was updated successfully, but these errors were encountered:
Hey @0x0f0f0f ! Nice to hear that you're using ExpressionExplorer!
Our idea here was that we don't need so much API in ExpressionExplorer, because you can transform expressions before passing them to ExpressionExplorer.
In the README, there is an example of expanding macros before using ExpressionExplorer. I'm assuming that this doesn't work for you because you are doing static analysis (so you can't run the macros)?
In that case, you could just change the Expression into something that ExpressionExplorer will understand. I think you could search for all macrocalls, find all the argument expressions, and add them to the tree outside of a macro call. For example:
this_is_an_example(expression)
@somemacro with [multiple, :arguments]
You could turn this into:
this_is_an_example(expression)
begin@somemacro with [multiple, :arguments]
with
[multiple, :arguments]
end
Now, the arguments are visible to ExpressionExplorer because they do not appear inside a macrocall.
Code example
The code might look something like this:
functionwith_macrocall_args_exposed(e::Expr)
if e.head ===:macrocallExpr(
:block,
# the original call
e,
# the arguments, added as regular expressions
(with_macrocall_args_exposed(a) for a in e.args)...,
)
else
e
endendwith_macrocall_args_exposed(x) = x
ExpressionExplorer.compute_reactive_node(with_macrocall_args_exposed(my_expr))
The application I'm building requires walking all expressions, including arguments of macro calls. How hard would it be to have a kwarg that does that?
The text was updated successfully, but these errors were encountered: