Skip to main content

if_else

Function if_else 

Source
pub fn if_else(cond: &[Opcode], thn: &[Opcode], els: &[Opcode]) -> Vec<Opcode>
Expand description

Like branch, but also holds the conditional.

Example: if_else(EMPTY_STACK_CHECK, [], [op::RETURN])

type: ((ti ∪ ei) - co) + ci -> (co - (ti ∪ ei)) + (to ∪ eo) where cond: ci -> co + [Bool] thn: ti -> to els: ei -> eo

The suffix removasl (-) in the type here is because cond can put elements on the stack, and the branches must consume that output first (if they consume any input at all). And then on the output side, if the output of cond was more than the branches consume, that residue is left on the stack prior to the outputs of the branches.