#[repr(u8)]pub enum Op {
Show 69 variants
Constant = 0,
Nil = 1,
True = 2,
False = 3,
GetVar = 4,
DefLet = 5,
DefVar = 6,
SetVar = 7,
PushScope = 8,
PopScope = 9,
Add = 10,
Sub = 11,
Mul = 12,
Div = 13,
Mod = 14,
Pow = 15,
Negate = 16,
Equal = 17,
NotEqual = 18,
Less = 19,
Greater = 20,
LessEqual = 21,
GreaterEqual = 22,
Not = 23,
Jump = 24,
JumpIfFalse = 25,
JumpIfTrue = 26,
Pop = 27,
Call = 28,
TailCall = 29,
Return = 30,
Closure = 31,
BuildList = 32,
BuildDict = 33,
Subscript = 34,
Slice = 35,
GetProperty = 36,
GetPropertyOpt = 37,
SetProperty = 38,
SetSubscript = 39,
MethodCall = 40,
MethodCallOpt = 41,
Concat = 42,
IterInit = 43,
IterNext = 44,
Pipe = 45,
Throw = 46,
TryCatchSetup = 47,
PopHandler = 48,
Parallel = 49,
ParallelMap = 50,
ParallelSettle = 51,
Spawn = 52,
Import = 53,
SelectiveImport = 54,
DeadlineSetup = 55,
DeadlineEnd = 56,
BuildEnum = 57,
MatchEnum = 58,
PopIterator = 59,
GetArgc = 60,
CheckType = 61,
TryUnwrap = 62,
CallSpread = 63,
MethodCallSpread = 64,
Dup = 65,
Swap = 66,
Contains = 67,
Yield = 68,
}Expand description
Bytecode opcodes for the Harn VM.
Variants§
Constant = 0
Push a constant from the constant pool onto the stack.
Nil = 1
Push nil onto the stack.
True = 2
Push true onto the stack.
False = 3
Push false onto the stack.
GetVar = 4
Get a variable by name (from constant pool).
DefLet = 5
Define a new immutable variable. Pops value from stack.
DefVar = 6
Define a new mutable variable. Pops value from stack.
SetVar = 7
Assign to an existing mutable variable. Pops value from stack.
PushScope = 8
Push a new lexical scope onto the environment stack.
PopScope = 9
Pop the current lexical scope from the environment stack.
Add = 10
Sub = 11
Mul = 12
Div = 13
Mod = 14
Pow = 15
Negate = 16
Equal = 17
NotEqual = 18
Less = 19
Greater = 20
LessEqual = 21
GreaterEqual = 22
Not = 23
Jump = 24
Jump unconditionally. arg: u16 offset.
JumpIfFalse = 25
Jump if top of stack is falsy. Does not pop. arg: u16 offset.
JumpIfTrue = 26
Jump if top of stack is truthy. Does not pop. arg: u16 offset.
Pop = 27
Pop top of stack (discard).
Call = 28
Call a function/builtin. arg: u8 = arg count. Name is on stack below args.
TailCall = 29
Tail call: like Call, but replaces the current frame instead of pushing
a new one. Used for return f(x) to enable tail call optimization.
For builtins, behaves like a regular Call (no frame to replace).
Return = 30
Return from current function. Pops return value.
Closure = 31
Create a closure. arg: u16 = chunk index in function table.
BuildList = 32
Build a list. arg: u16 = element count. Elements are on stack.
BuildDict = 33
Build a dict. arg: u16 = entry count. Key-value pairs on stack.
Subscript = 34
Subscript access: stack has [object, index]. Pushes result.
Slice = 35
Slice access: stack has [object, start_or_nil, end_or_nil]. Pushes sublist/substring.
GetProperty = 36
Property access. arg: u16 = constant index (property name).
GetPropertyOpt = 37
Optional property access (?.). Like GetProperty but returns nil instead of erroring when the object is nil. arg: u16 = constant index.
SetProperty = 38
Property assignment. arg: u16 = constant index (property name). Stack: [value] → assigns to the named variable’s property.
SetSubscript = 39
Subscript assignment. arg: u16 = constant index (variable name). Stack: [index, value] → assigns to variable[index] = value.
MethodCall = 40
Method call. arg1: u16 = constant index (method name), arg2: u8 = arg count.
MethodCallOpt = 41
Optional method call (?.). Like MethodCall but returns nil if the receiver is nil instead of dispatching. arg1: u16, arg2: u8.
Concat = 42
String concatenation of N parts. arg: u16 = part count.
IterInit = 43
Set up a for-in loop. Expects iterable on stack. Pushes iterator state.
IterNext = 44
Advance iterator. If exhausted, jumps. arg: u16 = jump offset. Pushes next value and the variable name is set via DefVar before the loop.
Pipe = 45
Pipe: pops [value, callable], invokes callable(value).
Throw = 46
Pop value, raise as error.
TryCatchSetup = 47
Push exception handler. arg: u16 = offset to catch handler.
PopHandler = 48
Remove top exception handler (end of try body).
Parallel = 49
Execute closure N times sequentially, push results as list. Stack: count, closure → result_list
ParallelMap = 50
Execute closure for each item in list, push results as list. Stack: list, closure → result_list
ParallelSettle = 51
Like ParallelMap but wraps each result in Result.Ok/Err, never fails. Stack: list, closure → {results: Result, succeeded: int, failed: int}
Spawn = 52
Store closure for deferred execution, push TaskHandle. Stack: closure → TaskHandle
Import = 53
Import a file. arg: u16 = constant index (path string).
SelectiveImport = 54
Selective import. arg1: u16 = path string, arg2: u16 = names list constant.
DeadlineSetup = 55
Pop duration value, push deadline onto internal deadline stack.
DeadlineEnd = 56
Pop deadline from internal deadline stack.
BuildEnum = 57
Build an enum variant value. arg1: u16 = constant index (enum name), arg2: u16 = constant index (variant name), arg3: u16 = field count. Fields are on stack.
MatchEnum = 58
Match an enum pattern. Checks enum_name + variant on the top of stack (dup’d match value). arg1: u16 = constant index (enum name), arg2: u16 = constant index (variant name). If match succeeds, pushes true; else pushes false.
PopIterator = 59
Pop the top iterator from the iterator stack (cleanup on break from for-in).
GetArgc = 60
Push the number of arguments passed to the current function call.
CheckType = 61
Runtime type check on a variable. arg1: u16 = constant index (variable name), arg2: u16 = constant index (expected type name). Throws a TypeError if the variable’s type doesn’t match.
TryUnwrap = 62
Try-unwrap: if top is Result.Ok(v), replace with v. If Result.Err(e), return it.
CallSpread = 63
Call with spread arguments. Stack: [callee, args_list] -> result.
MethodCallSpread = 64
Method call with spread arguments. Stack: [object, args_list] -> result. Followed by 2 bytes for method name constant index.
Dup = 65
Duplicate top of stack.
Swap = 66
Swap top two stack values.
Contains = 67
Membership test: stack has [item, collection]. Pushes bool. Works for lists (item in list), dicts (key in dict), strings (substr in string), and sets.
Yield = 68
Yield a value from a generator. Pops value, sends through channel, suspends.
Trait Implementations§
impl Copy for Op
impl Eq for Op
impl StructuralPartialEq for Op
Auto Trait Implementations§
impl Freeze for Op
impl RefUnwindSafe for Op
impl Send for Op
impl Sync for Op
impl Unpin for Op
impl UnsafeUnpin for Op
impl UnwindSafe for Op
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,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§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();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§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();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§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();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§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();Source§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.
Source§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);