[−][src]Enum ketos::bytecode::Instruction
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 a value onto the stack; value is invalidated.
Load ()
into value
Load true
into value
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
Load ()
, then push
Load true
, then push
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
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
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
Jump if value is equal to const; parameters are (label, n)
Jump if value is not equal to const; parameters are (label, n)
Test whether value is ()
Test whether value is not ()
Pops from the top of the stack and tests for equality with value.
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
Negate boolean value
Increment integer value
Decrement integer value
Append value to list on top of stack; result will be in value
Take first element of list or string and assign to value
Take tail of list or string and assign to value
Take head of list or string and assign to value
Take last element of list or string and assign to value
Push first value from list or string
Push tail from list or string
Push head from list or string
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.
Call system function with n arguments on the stack;
parameters are (sys_fn, n_args)
.
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
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 value from function
Methods
impl Instruction
[src]
pub fn decode(r: &mut CodeReader) -> Result<Instruction, ExecError>
[src]
Decodes a single Instruction
from a CodeReader
.
pub fn encode(&self, w: &mut CodeBlock, short: bool) -> Result<(), CompileError>
[src]
Encodes a single Instruction
into a CodeBlock
.
pub fn is_trivial(&self) -> bool
[src]
Returns whether the Instruction
is trivial;
that is, in valid top-level code, it does not produce any side effects.
pub fn jump_label(&self) -> Option<u32>
[src]
If the instruction is a jump instruction, returns the jump offset.
Otherwise, returns None
.
pub fn max_len() -> usize
[src]
Returns the maximum length, in bytes, of an encoded instruction.
Trait Implementations
impl Clone for Instruction
[src]
fn clone(&self) -> Instruction
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for Instruction
[src]
impl Debug for Instruction
[src]
impl Eq for Instruction
[src]
impl PartialEq<Instruction> for Instruction
[src]
fn eq(&self, other: &Instruction) -> bool
[src]
fn ne(&self, other: &Instruction) -> bool
[src]
impl StructuralEq for Instruction
[src]
impl StructuralPartialEq for Instruction
[src]
Auto Trait Implementations
impl RefUnwindSafe for Instruction
impl Send for Instruction
impl Sync for Instruction
impl Unpin for Instruction
impl UnwindSafe for Instruction
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,