Juggernaut.Mutator.Walk (Juggernaut v0.4.0)

Copy Markdown View Source

Walks one function clause (or one compile-time module-body expression) and lists its sites: every node an operator may be offered, with its AST path and its Juggernaut.Mutator.Context.

Paths are child indices from the clause node, numbered as Sourceror.Zipper numbers children (design notes §6): a call with an atom head numbers its arguments, a remote call its head first, a two-element tuple both elements, a list its elements. A literal is wrapped in a :__block__, so a path into one has one more step. Paths are built reversed; Juggernaut.Mutator reverses the ones it keeps.

What is never walked: quote blocks, module attribute reads, function captures by name (&Mod.fun/2), the positional argument of &1, keyword keys, struct names, remote call heads, sigil contents, bitstring segment types and pinned variables. A call routed :skip is not walked at all; a call routed raw keeps its node but not the listed arguments (Juggernaut.Routing).

Summary

Functions

The sites of one clause, in walk order, and the routing entries that decided a call in it. The clause node itself is the first site (path []).

The sites of one module-body expression (they run at compile time).

Variable names bound more than once across patterns (pins and _ names excluded).

Types

env()

@type env() :: %{
  route: (Juggernaut.Mutator.Calls.call(), Juggernaut.Mutator.Context.t() ->
            route())
}

result()

@type result() :: {[site()], [term()]}

route()

@type route() :: {:walk | :skip | {:raw, :all | [non_neg_integer()]}, term()}

site()

Functions

clause(map, ctx, env)

The sites of one clause, in walk order, and the routing entries that decided a call in it. The clause node itself is the first site (path []).

compile_time(node, ctx, env)

@spec compile_time(Macro.t(), Juggernaut.Mutator.Context.t(), env()) :: result()

The sites of one module-body expression (they run at compile time).

repeated(patterns)

@spec repeated([Macro.t()]) :: MapSet.t(atom())

Variable names bound more than once across patterns (pins and _ names excluded).