#[repr(u8)]pub enum Instr {
Show 117 variants
Print(u16),
Jmp(u16),
JmpBack(u16),
IsFalseJmp(u16, u16),
IsTrueJmp(u16, u16),
SupEqFloatJmp(u16, u16, u16),
SupEqIntJmp(u16, u16, u16),
SupFloatJmp(u16, u16, u16),
SupIntJmp(u16, u16, u16),
InfEqFloatJmp(u16, u16, u16),
InfEqIntJmp(u16, u16, u16),
InfFloatJmp(u16, u16, u16),
InfIntJmp(u16, u16, u16),
InfIntJmpBack(u16, u16, u16),
StepIntJmpBack(u16, u16, u16),
NotEqJmp(u16, u16, u16),
EqJmp(u16, u16, u16),
ObjNotEqJmp(u16, u16, u16),
ObjEqJmp(u16, u16, u16),
StrNotEqJmp(u16, u16, u16),
StrEqJmp(u16, u16, u16),
Mov(u16, u16),
MovChain(u16, u16, u16),
SetInt(u16, i32),
SetBool(bool, u16),
AddFloat(u16, u16, u16),
AddInt(u16, u16, u16),
AddIntImm(u16, i16, u16),
AddArray(u16, u16, u16),
AddStr(u16, u16, u16),
MulFloat(u16, u16, u16),
MulInt(u16, u16, u16),
SubFloat(u16, u16, u16),
SubInt(u16, u16, u16),
DivFloat(u16, u16, u16),
DivInt(u16, u16, u16),
ModFloat(u16, u16, u16),
ModInt(u16, u16, u16),
PowFloat(u16, u16, u16),
PowInt(u16, u16, u16),
BitAndInt(u16, u16, u16),
BitOrInt(u16, u16, u16),
BitXorInt(u16, u16, u16),
BitNotInt(u16, u16),
ShlInt(u16, u16, u16),
ShrInt(u16, u16, u16),
IncInt(u16),
DecInt(u16),
IncIntTo(u16, u16),
DecIntTo(u16, u16),
Eq(u16, u16, u16),
NotEq(u16, u16, u16),
ObjEq(u16, u16, u16),
ObjNotEq(u16, u16, u16),
StrEq(u16, u16, u16),
StrNotEq(u16, u16, u16),
SupFloat(u16, u16, u16),
SupInt(u16, u16, u16),
SupEqFloat(u16, u16, u16),
SupEqInt(u16, u16, u16),
InfFloat(u16, u16, u16),
InfInt(u16, u16, u16),
InfEqFloat(u16, u16, u16),
InfEqInt(u16, u16, u16),
SupStr(u16, u16, u16),
SupEqStr(u16, u16, u16),
InfStr(u16, u16, u16),
InfEqStr(u16, u16, u16),
BoolAnd(u16, u16, u16),
BoolOr(u16, u16, u16),
NegBool(u16, u16),
NegFloat(u16, u16),
NegInt(u16, u16),
CallFunc(u16, u16),
CallFuncRecursive(u16, u16),
VoidReturn,
Return(u16),
RecursiveReturn(u16),
SaveFrame(u16, u16, u16),
CallIndirect(u16),
CallDynamicLibFunc(u16, u16),
CallHostFunc(u16, u16),
StoreFuncArg(u16),
CallLibFunc(LibFunc, u16, u16),
CallLibFuncVoid(LibFuncVoid, u16, u16),
StartErrorCatch(u16, u16),
StopErrorCatch,
ThrowError(u16),
ObjElemMov(u16, u16, u16),
EmptyArray(u16),
EmptyFnValue(u16),
CloneArray(u16, u16, u16),
CloneStruct(u16, u16),
CloneEnum(u16, u16),
SetElementObj(u16, u16, u16),
SetElementString(u16, u16, u16),
SetFieldStruct(u16, u16, u16),
AddFieldFloat(u16, u16, u16),
GetIndexArray(u16, u16, u16),
GetIndexString(u16, u16, u16),
GetFieldStruct(u16, u16, u16),
GetSliceArray(u16, u16, u16),
GetSliceString(u16, u16, u16),
Push(u16, u16),
Remove(u16, u16),
MapGet(u16, u16, u16),
MapInsert(u16, u16, u16),
MapInsertReg(u16, u16, u16),
MapRemove(u16, u16),
CloneMap(u16, u16),
NewCell(u16, u16),
LoadCell(u16, u16),
StoreCell(u16, u16),
Halt(u16),
CallNative(u16, u16),
CallNativeRec(u16, u16),
NativeExit,
}Variants§
Print(u16)
Jmp(u16)
Jumps x instructions forwards
JmpBack(u16)
Jumps x instructions backwards
IsFalseJmp(u16, u16)
IsTrueJmp(u16, u16)
SupEqFloatJmp(u16, u16, u16)
SupEqIntJmp(u16, u16, u16)
SupFloatJmp(u16, u16, u16)
SupIntJmp(u16, u16, u16)
InfEqFloatJmp(u16, u16, u16)
InfEqIntJmp(u16, u16, u16)
InfFloatJmp(u16, u16, u16)
InfIntJmp(u16, u16, u16)
InfIntJmpBack(u16, u16, u16)
StepIntJmpBack(u16, u16, u16)
StepIntJmpBack(counter_reg, end_reg, size)
Adds 1 to the int in counter_reg, then jumps size instructions
backwards while it is below the int in end_reg. The step at the
bottom of every counted loop and every loop over a collection, which
would otherwise be an IncInt and an InfIntJmpBack.
NotEqJmp(u16, u16, u16)
EqJmp(u16, u16, u16)
ObjNotEqJmp(u16, u16, u16)
ObjEqJmp(u16, u16, u16)
StrNotEqJmp(u16, u16, u16)
StrEqJmp(u16, u16, u16)
Mov(u16, u16)
MovChain(u16, u16, u16)
MovChain(dest, mid, src)
dest = mid, then mid = src: two moves where the second refills the
register the first read, the way a = b; b = c; rotates values.
SetInt(u16, i32)
SetInt(dest_reg_id, val)
Writes val directly into dest_reg_id. The operand is narrower than an
int, so a wider constant is moved out of its register instead, which
keeps every instruction one word.
SetBool(bool, u16)
SetBool(dest_reg_id, val)
Writes val directly into dest_reg_id
AddFloat(u16, u16, u16)
AddInt(u16, u16, u16)
AddIntImm(u16, i16, u16)
AddIntImm(src_reg, imm, dest_reg)
dest = src + imm, for an int src. What adding or subtracting a
constant that fits the operand compiles to.
AddArray(u16, u16, u16)
AddStr(u16, u16, u16)
MulFloat(u16, u16, u16)
MulInt(u16, u16, u16)
SubFloat(u16, u16, u16)
SubInt(u16, u16, u16)
DivFloat(u16, u16, u16)
DivInt(u16, u16, u16)
ModFloat(u16, u16, u16)
ModInt(u16, u16, u16)
PowFloat(u16, u16, u16)
PowInt(u16, u16, u16)
BitAndInt(u16, u16, u16)
BitOrInt(u16, u16, u16)
BitXorInt(u16, u16, u16)
BitNotInt(u16, u16)
BitNotInt(operand, dest)
dest = every bit of operand flipped
ShlInt(u16, u16, u16)
ShlInt(value, count, dest)
Raises shift_count_out_of_range for a count outside 0..64.
ShrInt(u16, u16, u16)
ShrInt(value, count, dest)
Arithmetic: int is signed, so the sign bit is what the vacated places
are filled with. Raises shift_count_out_of_range for a count outside
0..64.
IncInt(u16)
Increments the integer in-place by 1
DecInt(u16)
Decrements the integer in-place by 1
IncIntTo(u16, u16)
IncIntTo(src, dst)
dst = src + 1
DecIntTo(u16, u16)
DecIntTo(src, dst)
dst = src - 1
Eq(u16, u16, u16)
NotEq(u16, u16, u16)
ObjEq(u16, u16, u16)
ObjNotEq(u16, u16, u16)
StrEq(u16, u16, u16)
StrNotEq(u16, u16, u16)
SupFloat(u16, u16, u16)
SupInt(u16, u16, u16)
SupEqFloat(u16, u16, u16)
SupEqInt(u16, u16, u16)
InfFloat(u16, u16, u16)
InfInt(u16, u16, u16)
InfEqFloat(u16, u16, u16)
InfEqInt(u16, u16, u16)
SupStr(u16, u16, u16)
SupStr(l_reg_id, r_reg_id, dest_reg_id)
Orders two strings by their bytes, the order sort puts a list of
strings in. The four string comparisons are their own instructions
rather than one carrying an ordering operand, because a fourth operand
would take an instruction past a single word.
SupEqStr(u16, u16, u16)
SupEqStr(l_reg_id, r_reg_id, dest_reg_id)
InfStr(u16, u16, u16)
InfStr(l_reg_id, r_reg_id, dest_reg_id)
InfEqStr(u16, u16, u16)
InfEqStr(l_reg_id, r_reg_id, dest_reg_id)
BoolAnd(u16, u16, u16)
BoolOr(u16, u16, u16)
NegBool(u16, u16)
NegFloat(u16, u16)
NegInt(u16, u16)
CallFunc(u16, u16)
CallFunc(n,y)
Jumps to the nth instruction, and adds y as a slot to be set by the Return instruction
VoidReturn/Return will jump back to this location
CallFuncRecursive(u16, u16)
CallFuncRecursive(n, register_id)
Jumps to the nth instruction, register_id is only used during parsing.
VoidReturn
Jumps to the instruction right after the last CallFunc encountered by the interpreter
Return(u16)
Return(n)
Returns the data located in register n
RecursiveReturn(u16)
RecursiveReturn(n,function_id)
Returns the data located in register n, and restores the function’s register state
SaveFrame(u16, u16, u16)
SaveFrame(function_location, return_register, function_id)
CallIndirect(u16)
CallIndirect(callee_register_id)
Jumps to the instruction the function value in callee_register_id names
in its first slot. The frame is pushed by the SaveFrame that precedes
this instruction, which also carries the register the return lands in,
so a call whose callee is only known at run time keeps the caller’s
registers across it.
CallDynamicLibFunc(u16, u16)
CallDynamicLibFunc(fn_id, dest_register_id)
CallHostFunc(u16, u16)
CallHostFunc(host_fn_id, dest_register_id)
Dispatches to a Rust closure registered on the embedding Engine,
marshalling StoreFuncArg operands into the closure and its result back
into dest_register_id.
StoreFuncArg(u16)
CallLibFunc(LibFunc, u16, u16)
CallLibFunc(function, src_register_id, dest_register_id)
CallLibFuncVoid(LibFuncVoid, u16, u16)
CallLibFuncVoid(function, src_register_1, src_register_2) For single-source ops, src register 2 is unused
StartErrorCatch(u16, u16)
StartErrorCatch(jump_size, error_register_id)
StopErrorCatch
ThrowError(u16)
ThrowError(error_register_id) Throws the error (a string) located in error_register_id
ObjElemMov(u16, u16, u16)
ArrayMov(new_elem_reg_id, array_id, idx)
Replaces the idx-th element in the array (with the id array_id) with the element located in new_elem_reg_id
EmptyArray(u16)
EmptyArray(array_reg_id) Allocates a fresh empty array and stores its address in array_reg_id
EmptyFnValue(u16)
EmptyFnValue(value_reg_id)
Allocates a fresh entry like EmptyArray and stores a function value
naming it in value_reg_id. The pushes that follow fill it with where
the body starts and the cells the function captured; the value is a
function rather than the list it is built as, which is what makes it
read as one wherever it becomes text.
CloneArray(u16, u16, u16)
CloneArray(src_reg, dest_reg, len) Allocates a fresh array with exact capacity len and clones the array in src_reg to dest_reg
CloneStruct(u16, u16)
CloneEnum(u16, u16)
CloneEnum(template_reg, dest_reg)
Clones the enum value in template_reg into a fresh object-pool entry,
preserving the enum type tag. Mirrors CloneStruct for enum values.
SetElementObj(u16, u16, u16)
SetElementArray(array_reg_id, new_elem_reg_id, idx)
Replaces the idx-th element in the array located in array_reg_id with the element located in new_elem_reg_id
SetElementString(u16, u16, u16)
SetElementString(string_reg_id, new_str_reg_id, idx)
Replaces the idx-th char in the string located in string_reg_id with the string located in new_str_reg_id
SetFieldStruct(u16, u16, u16)
SetFieldStruct(struct_reg_id, new_elem_reg_id, idx)
AddFieldFloat(u16, u16, u16)
AddFieldFloat(struct_reg_id, value_reg_id, field_idx)
Adds the float in value_reg_id to the float field field_idx of the
struct, the whole of s.f += x.
GetIndexArray(u16, u16, u16)
GetIndexArray(array_reg_id, index_reg_id, output_reg_id)
GetIndexString(u16, u16, u16)
GetIndexString(str_reg_id, index_reg_id, output_reg_id)
GetFieldStruct(u16, u16, u16)
GetFieldStruct(struct_reg_id, index, output_reg_id)
GetSliceArray(u16, u16, u16)
GetSliceArray(array_reg_id, idx_start_reg_id, output_reg_id)
idx_end_reg_id is pulled from a StoreFuncArg
GetSliceString(u16, u16, u16)
GetSliceString(str_reg_id, idx_start_reg_id, output_reg_id)
idx_end_reg_id is pulled from a StoreFuncArg
Push(u16, u16)
Push(array_reg_id, elem_reg_id)
Remove(u16, u16)
Remove(array_reg_id, elem_index_reg_id)
MapGet(u16, u16, u16)
MapGet(map_pool_id, key_reg_id, dest_reg_id)
MapInsert(u16, u16, u16)
MapSet(map_pool_id, key_reg_id, val_reg_id)
MapInsertReg(u16, u16, u16)
MapSet(map_reg_id, key_reg_id, val_reg_id)
MapRemove(u16, u16)
MapRemove(map_reg_id, key_reg_id)
CloneMap(u16, u16)
NewCell(u16, u16)
NewCell(src_reg_id, dest_reg_id)
Allocates a one-slot cell holding what src_reg_id holds and puts the
cell in dest_reg_id. A variable a closure captures lives in a cell, so
the function that declared it and every closure that took it read and
write one slot.
LoadCell(u16, u16)
LoadCell(cell_reg_id, dest_reg_id)
Reads the value out of the cell in cell_reg_id.
StoreCell(u16, u16)
StoreCell(cell_reg_id, src_reg_id)
Writes what src_reg_id holds into the cell in cell_reg_id.
Halt(u16)
Exits the program with the i32 code if it’s != 0
CallNative(u16, u16)
CallNative(function, dest_register_id)
A CallFunc whose callee runs as machine code: calls native function
function of the loaded program and writes what it returns into
dest_register_id.
CallNativeRec(u16, u16)
CallNativeRec(function, dest_register_id)
A CallFuncRecursive whose callee runs as machine code. The
SaveFrame before it has pushed the frame the call returns through.
NativeExit
Where a call machine code makes into the interpreter returns to: the run that call started ends here.
Implementations§
Source§impl Instr
impl Instr
Sourcepub fn get_tgt_id(self) -> Option<u16>
pub fn get_tgt_id(self) -> Option<u16>
Returns the ID of the register that will be modified by the given instruction
Sourcepub fn tgt_id_mut(&mut self) -> Option<&mut u16>
pub fn tgt_id_mut(&mut self) -> Option<&mut u16>
The operand naming the register this instruction writes, to look at or
to rewrite. See Self::get_tgt_id.
MovChain writes a second register, the one it refills, which this
does not name; Self::for_each_write_reg names both. The compiler
joins moves into it after every pass that rewrites registers.
Sourcepub fn for_each_write_reg(self, f: impl FnMut(u16))
pub fn for_each_write_reg(self, f: impl FnMut(u16))
Calls f with each register this instruction writes: the one
Self::get_tgt_id names, and for MovChain the register it refills
as well.
Sourcepub fn for_each_read_reg(self, f: impl FnMut(u16))
pub fn for_each_read_reg(self, f: impl FnMut(u16))
Calls f with each register this instruction reads.
Sourcepub fn read_regs_mut(&mut self, f: impl FnMut(&mut u16))
pub fn read_regs_mut(&mut self, f: impl FnMut(&mut u16))
Hands f each operand of this instruction that names a register it
reads, to look at or to rewrite.
Trait Implementations§
impl Copy for Instr
Source§impl<'de> Deserialize<'de> for Instr
impl<'de> Deserialize<'de> for Instr
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Instr
impl StructuralPartialEq for Instr
Auto Trait Implementations§
impl Freeze for Instr
impl RefUnwindSafe for Instr
impl Send for Instr
impl Sync for Instr
impl Unpin for Instr
impl UnsafeUnpin for Instr
impl UnwindSafe for Instr
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);