elixush v0.0.3 Elixush.PushState

Summary

Functions

Ends the current environment by popping the :environment stack and replacing all stacks with those on the environment stack. Then, everything on the old :return stack is pushed onto the :exec stack

Returns an empty push state

Returns a copy of the state with the specified stack popped. This is a utility, not for use as an instruction in Push programs

Returns a copy of the state with the value pushed on the named stack. This is a utility, not for use in Push programs

Takes a map of stack names and entire stack states, and returns a new push-state with those stacks set

Add the provided name to the global list of registered instructions

Takes a list of stacks and returns all instructions that have all of their stack requirements fulfilled. This won't include random instructions unless :random is in the types list. This won't include parenthesis-altering instructions unless :parentheses is in the types list

Returns a list of all registered instructions with the given type name as a prefix

Returns a list of all registered instructions aside from random instructions

Puts value at position on type stack in state. This is a utility, not for use as an instruction in Push programs. NOT SAFE for invalid positions

Returns the indicated item of the type stack in state. Returns :no-stack-item if called on an empty stack. This is a utility, not for use as an instruction in Push programs. NOT SAFE for invalid positions

Returns the top item of the type stack in state. Returns :no-stack-item if called on an empty stack. This is a utility, not for use as an instruction in Push programs

Functions

define_registered(instruction, definition)
end_environment(state)

Specs

end_environment(map) :: map

Ends the current environment by popping the :environment stack and replacing all stacks with those on the environment stack. Then, everything on the old :return stack is pushed onto the :exec stack.

make_push_state()

Returns an empty push state.

pop_item(type, state)

Specs

pop_item(atom, map) :: map

Returns a copy of the state with the specified stack popped. This is a utility, not for use as an instruction in Push programs.

push_item(value, type, state)

Returns a copy of the state with the value pushed on the named stack. This is a utility, not for use in Push programs.

push_state_from_stacks(stack_assignments)

Specs

push_state_from_stacks(map) :: map

Takes a map of stack names and entire stack states, and returns a new push-state with those stacks set.

register_instruction(name)

Add the provided name to the global list of registered instructions.

registered_for_stacks(types_list)

Specs

registered_for_stacks(Enum.t) :: Enum.t

Takes a list of stacks and returns all instructions that have all of their stack requirements fulfilled. This won't include random instructions unless :random is in the types list. This won't include parenthesis-altering instructions unless :parentheses is in the types list.

registered_for_type(type, argmap \\ %{})

Specs

registered_for_type(atom, map) :: Enum.t

Returns a list of all registered instructions with the given type name as a prefix.

registered_nonrandom()

Specs

registered_nonrandom :: Enum.t

Returns a list of all registered instructions aside from random instructions.

stack_assoc(value, type, position, state)

Puts value at position on type stack in state. This is a utility, not for use as an instruction in Push programs. NOT SAFE for invalid positions.

stack_ref(type, position, state)

Specs

stack_ref(atom, integer, map) :: any

Returns the indicated item of the type stack in state. Returns :no-stack-item if called on an empty stack. This is a utility, not for use as an instruction in Push programs. NOT SAFE for invalid positions.

state_pretty_print(state)
top_item(type, state)

Returns the top item of the type stack in state. Returns :no-stack-item if called on an empty stack. This is a utility, not for use as an instruction in Push programs.