interceptor v0.3.0 Interceptor.FunctionArguments 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

Link to this section Functions

Link to this function escape_module_function_but_not_args(arg) View Source
Link to this function get_args_names_and_new_args_list(function_hdr) View Source

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.

Link to this function get_function_header_with_new_args_names(function_hdr) View Source
Link to this function get_not_hygienic_args_values_ast(args_names) View Source