Interceptor.FunctionArguments (interceptor v0.5.4) View Source
Link to this section Summary
Functions
Use this function to get a tuple containing a list with the names of the function arguments and the list of the arguments in AST form.
Returns the AST that gets us the value of each argument, so we can pass the intercepted function argument values to the callback.
Link to this section Functions
Use this function to get a tuple containing a list with the names of the function arguments and the list of the arguments in AST form.
For the function def abcd(a, b, c), do: 123
you would get:
{
[:a, :b, :c],
[{:a, [], Elixir}, {:b, [], Elixir}, {:c, [], Elixir}]
}
For a function with one or more "anonymous" arguments, this function will assign each argument like this to a random variable.
For the function def foo(x, y, {bar}), do: 42
it would return:
{
[:x, :y, :a1b2c3d],
[
{:x, [], Elixir},
{:y, [], Elixir},
{:=, [], [{:{}, [], [{:bar, [], Elixir}]}, {:a1b2c3d, [], Elixir}]}
]
}
Notice the last assignment to the a1b2c3d
random variable, returning
the argument list in AST form as if the
the function was defined like def foo(x, y, {bar} = a1b2c3d), do: 42
.
Returns the AST that gets us the value of each argument, so we can pass the intercepted function argument values to the callback.
If the arg_name
starts with _
, it means it isn't used in the intercepted
function body, hence we shouldn't access its value to pass it to the callback
function, passing instead the @ignored_value.
TODO: receive the current module and pass it as context