DSL.Stack (dsl v0.1.1)

Copy Markdown View Source

Process-local stack storage for nested DSL scopes.

Summary

Functions

Return true when a scope stack has an active scope.

Return active keys for an owning module from nearest to farthest.

Return the active scope state, or nil when inactive.

Return the active scope state or raise.

Return the active scope struct or raise.

Pop the active scope under a stack key and return its state.

Delete all scopes under a key. Intended for test cleanup and loader boundaries.

Push a named scope under a stack key.

Update the active scope state.

Types

key()

@type key() :: term()

Functions

active?(key)

@spec active?(key()) :: boolean()

Return true when a scope stack has an active scope.

active_keys(owner)

@spec active_keys(module()) :: [key()]

Return active keys for an owning module from nearest to farthest.

current(key)

@spec current(key()) :: term() | nil

Return the active scope state, or nil when inactive.

current!(key)

@spec current!(key()) :: term()

Return the active scope state or raise.

current_scope!(key)

@spec current_scope!(key()) :: DSL.Scope.t()

Return the active scope struct or raise.

finish(key, expected_name \\ nil)

@spec finish(key(), atom() | nil) :: term()

Pop the active scope under a stack key and return its state.

reset(key)

@spec reset(key()) :: :ok

Delete all scopes under a key. Intended for test cleanup and loader boundaries.

start(key, name, state, location \\ nil)

@spec start(key(), atom(), term(), Macro.Env.t() | DSL.Scope.location() | nil) :: :ok

Push a named scope under a stack key.

update(key, fun)

@spec update(key(), (term() -> term())) :: :ok

Update the active scope state.