Enum ketos::bytecode::Instruction
[−]
[src]
pub enum Instruction { Load(u32), LoadC(u32), UnboundToUnit(u32), GetDef(u32), Push, Unit, True, False, Const(u32), Store(u32), LoadPush(u32), LoadCPush(u32), GetDefPush(u32), UnitPush, TruePush, FalsePush, ConstPush(u32), SetDef(u32), List(u32), Quote(u32), Quasiquote(u32), Comma(u32), CommaAt(u32), BuildClosure(u32, u32), Jump(u32), JumpIf(u32), JumpIfBound(u32, u32), JumpIfNot(u32), JumpIfNull(u32), JumpIfNotNull(u32), JumpIfEq(u32), JumpIfNotEq(u32), JumpIfEqConst(u32, u32), JumpIfNotEqConst(u32, u32), Null, NotNull, Eq, NotEq, EqConst(u32), NotEqConst(u32), Not, Inc, Dec, Append, First, Tail, Init, Last, FirstPush, TailPush, InitPush, LastPush, CallSys(u32), CallSysArgs(u32, u32), CallConst(u32, u32), Call(u32), Apply(u32), ApplyConst(u32, u32), ApplySelf(u32), TailApplySelf(u32), CallSelf(u32), TailCallSelf(u32), Skip(u32), Return, }
Represents an instruction and any immediate parameters.
Any addition, deletion, or modification to this enum constitutes a breaking change to the bytecode format.
Variants
Load(u32)
Load a value from the stack
LoadC(u32)
Load a value from enclosed values
UnboundToUnit(u32)
If value n on the stack is Unbound
, replace it with ()
.
GetDef(u32)
Load a named value from global scope
Push
Push a value onto the stack; value is invalidated.
Unit
Load ()
into value
True
Load true
into value
False
Load false
into value
Const(u32)
Load a const into value
Store(u32)
Store a value in the stack; value is invalidated.
LoadPush(u32)
Load, then push
LoadCPush(u32)
Load enclosed value, then push
GetDefPush(u32)
Load a name from global scope, then push
UnitPush
Load ()
, then push
TruePush
Load true
, then push
FalsePush
Load false
, then push
ConstPush(u32)
Load a const, then push
SetDef(u32)
Assign a value to a name into global scope
List(u32)
Build a list of n values from the stack
Quote(u32)
Transform value into an n-quoted value
Quasiquote(u32)
Transform value into an n-quasiquoted value
Comma(u32)
Transform value into an n-comma'd value
CommaAt(u32)
Transform value into an n-comma-at'd value
BuildClosure(u32, u32)
Create a closure from code object in n_const and a list of
n_values values on the stack; parameters are (n_const, n_values)
.
Jump(u32)
Jump to a label
JumpIf(u32)
Jump if value is true
JumpIfBound(u32, u32)
Jump if value n from the stack is bound; parameters are (label, n)
JumpIfNot(u32)
Jump if value is false
JumpIfNull(u32)
Jump if value is ()
JumpIfNotNull(u32)
Jump if value is not ()
JumpIfEq(u32)
Jump if value is equal to top of stack
JumpIfNotEq(u32)
Jump if value is not equal to top of stack
JumpIfEqConst(u32, u32)
Jump if value is equal to const; parameters are (label, n)
JumpIfNotEqConst(u32, u32)
Jump if value is not equal to const; parameters are (label, n)
Null
Test whether value is ()
NotNull
Test whether value is not ()
Eq
Pops from the top of the stack and tests for equality with value.
NotEq
Pops from the top of the stack and tesst for inequality with value.
EqConst(u32)
Tests value for equality with const n
NotEqConst(u32)
Tests value for inequality with const n
Not
Negate boolean value
Inc
Increment integer value
Dec
Decrement integer value
Append
Append value to list on top of stack; result will be in value
First
Take first element of list or string and assign to value
Tail
Take tail of list or string and assign to value
Init
Take head of list or string and assign to value
Last
Take last element of list or string and assign to value
FirstPush
Push first value from list or string
TailPush
Push tail from list or string
InitPush
Push head from list or string
LastPush
Push last value from list or string
CallSys(u32)
Call system function n with known number of arguments on stack.
Only functions with Exact
arity may be called in this manner.
CallSysArgs(u32, u32)
Call system function with n arguments on the stack;
parameters are (sys_fn, n_args)
.
CallConst(u32, u32)
Call const function with arguments on the stack;
parameters are (const, n_args)
.
Call(u32)
Call function on the stack with n arguments from the top of the stack
Apply(u32)
Call function on the stack with n stack arguments, plus additional arguments from list value
ApplyConst(u32, u32)
Call const function with n stack arguments,
plus additional arguments from list value;
parameters are (const, n_args)
.
ApplySelf(u32)
Call current code object with n stack arguments, plus additional arguments from list value; does not perform a tail call
TailApplySelf(u32)
Call current code object with n stack arguments, plus additional arguments from list value
CallSelf(u32)
Call current code object with n arguments from the top of the stack; this does not perform a tail call
TailCallSelf(u32)
Perform tail-recursive call with n arguments from the top of the stack
Skip(u32)
Remove n values from the top of the stack
Return
Return value from function
Methods
impl Instruction
[src]
fn decode(r: &mut CodeReader) -> Result<Instruction, ExecError>
Decodes a single Instruction
from a CodeReader
.
fn encode(&self, w: &mut CodeBlock, short: bool) -> Result<(), CompileError>
Encodes a single Instruction
into a CodeBlock
.
fn is_trivial(&self) -> bool
Returns whether the Instruction
is trivial;
that is, in valid top-level code, it does not produce any side effects.
fn jump_label(&self) -> Option<u32>
If the instruction is a jump instruction, returns the jump offset.
Otherwise, returns None
.
fn max_len() -> usize
Returns the maximum length, in bytes, of an encoded instruction.
Trait Implementations
impl Copy for Instruction
[src]
impl Clone for Instruction
[src]
fn clone(&self) -> Instruction
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Debug for Instruction
[src]
impl Eq for Instruction
[src]
impl PartialEq for Instruction
[src]
fn eq(&self, __arg_0: &Instruction) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Instruction) -> bool
This method tests for !=
.