propeller.push.instructions
def-instruction
(def-instruction instruction function)
Defines a Push instruction as a keyword-function pair, and adds it to the
instruction table
generate-instructions
(generate-instructions stacks functions)
Given a sequence of stacks, e.g. [:float :integer], and a sequence of suffix
function strings, e.g. [_add, _mult, _eq], automates the generation of all
possible combination instructions, which here would be :float_add, :float_mult,
:float_eq, :integer_add, :integer_mult, and :integer_eq, also transferring
and updating the generic function's stack-type metadata. For some vector
instructions, the placeholder :elem will be replaced with the stack of the
corresponding element type (e.g. for :vector_integer, with :integer)
get-literal-type
(get-literal-type data)
If a piece of data is a literal, return its corresponding stack name
e.g. `:integer`. Otherwise, return `nil`.
get-stack-instructions
(get-stack-instructions stacks)
Given a set of stacks, returns all instructions that operate on those stacks
only. Won't include random instructions unless :random is in the set as well
get-vector-literal-type
(get-vector-literal-type vector-stack)
Returns the literal stack corresponding to some vector stack.
make-instruction
(make-instruction state function arg-stacks return-stack)
A utility function for making Push instructions. Takes a state, a function
to apply to the args, the stacks to take the args from, and the stack to
return the result to. Applies the function to the args (popped from the
given stacks), and pushes the result onto the return-stack.
If the function returns :ignore-instruction, then we will return the
initial state unchanged. This allows instructions to fail gracefully
without consuming stack values.