pub enum Instruction {
}Expand description
Stack-based VM instruction.
Instructions operate on a Vec<VmValue> stack and an instruction pointer.
All binary operations pop two values and push one; all unary operations pop
one and push one.
Variants§
PushNum(f64)
Push a numeric constant onto the stack.
PushBool(bool)
Push a boolean constant onto the stack.
PushSym(String)
Push a symbol literal onto the stack.
Pop
Discard the top-of-stack value.
Dup
Duplicate the top-of-stack value.
Add
Pop b, pop a; push a + b.
Sub
Pop b, pop a; push a - b.
Mul
Pop b, pop a; push a * b.
Div
Pop b, pop a; push a / b (error on zero divisor).
Pow
Pop b, pop a; push a ^ b.
Mod
Pop b, pop a; push a % b.
Neg
Pop a; push -a.
Abs
Pop a; push |a|.
Sqrt
Pop a; push √a.
Exp
Pop a; push e^a.
Log
Pop a; push ln(a).
Min
Pop b, pop a; push min(a, b).
Max
Pop b, pop a; push max(a, b).
Eq
Pop b, pop a; push a == b.
Ne
Pop b, pop a; push a != b.
Lt
Pop b, pop a; push a < b.
Le
Pop b, pop a; push a <= b.
Gt
Pop b, pop a; push a > b.
Ge
Pop b, pop a; push a >= b.
And
Pop b, pop a; push a && b (both must be truthy-compatible).
Or
Pop b, pop a; push a || b.
Not
Pop a; push !a.
JumpIfFalse(usize)
If TOS is falsy, jump to absolute instruction index; otherwise fall through. TOS is consumed.
JumpIfTrue(usize)
If TOS is truthy, jump to absolute instruction index; otherwise fall through. TOS is consumed.
Jump(usize)
Unconditional jump to absolute instruction index.
LoadVar(String)
Push the value of the named variable from the execution environment.
StoreVar(String)
Pop TOS and bind it to the named variable in the execution environment.
TNorm
Product t-norm: pop b, pop a; push a * b.
TCoNorm
Probabilistic sum t-conorm: pop b, pop a; push a + b - a*b.
FuzzyNot
Standard fuzzy NOT: pop a; push 1.0 - a.
Halt
Stop execution; TOS is the result.
Trait Implementations§
Source§impl Clone for Instruction
impl Clone for Instruction
Source§fn clone(&self) -> Instruction
fn clone(&self) -> Instruction
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more