Skip to main content

Op

Enum Op 

Source
#[repr(u8)]
pub enum Op {
Show 55 variants PushNull = 0, PushBool = 1, PushInt = 2, PushUInt = 3, PushFloat = 4, PushString = 5, PushIri = 6, LoadVar = 7, StoreVar = 8, Pop = 9, Dup = 10, PushQuantity = 11, Add = 16, Sub = 17, Mul = 18, Div = 19, Rem = 20, Neg = 21, Not = 22, Eq = 23, Ne = 24, Lt = 25, Le = 26, Gt = 27, Ge = 28, And = 29, Or = 30, Jump = 32, JumpIfFalse = 33, JumpIfTrue = 34, CallHost = 48, CallUser = 49, Return = 50, ReturnNull = 51, CallHostNamed = 52, MakeList = 64, MakeRecord = 65, GetMember = 66, GetIndex = 67, TryUnwrap = 68, Effect = 69, IsOk = 70, UnwrapOk = 71, IsErr = 72, UnwrapErr = 73, IsVariant = 74, GetVariantField = 75, IsRecord = 76, HasMember = 77, IsListLen = 78, TrapMatch = 79, MakeVariant = 80, MakeOk = 81, MakeErr = 82, Halt = 255,
}
Expand description

A single bytecode opcode.

Variants§

§

PushNull = 0

Push null onto the stack.

§

PushBool = 1

Push a boolean. Operand: 1 byte (0 = false, 1 = true).

§

PushInt = 2

Push an i64. Operand: 8 bytes little-endian.

§

PushUInt = 3

Push a u64. Operand: 8 bytes little-endian.

§

PushFloat = 4

Push an f64. Operand: 8 bytes (f64 bits, little-endian).

§

PushString = 5

Push a string from the constant pool. Operand: u16 const index.

§

PushIri = 6

Push an IRI from the constant pool. Operand: u16 const index.

§

LoadVar = 7

Load a local variable. Operand: u16 slot index.

§

StoreVar = 8

Store top of stack to a local variable. Operand: u16 slot index.

§

Pop = 9

Pop and discard the top of stack.

§

Dup = 10

Duplicate the top of stack.

§

PushQuantity = 11

Push a quantity: f64 bits (8) then u16 constant-pool unit string.

§

Add = 16

§

Sub = 17

§

Mul = 18

§

Div = 19

§

Rem = 20

§

Neg = 21

§

Not = 22

§

Eq = 23

§

Ne = 24

§

Lt = 25

§

Le = 26

§

Gt = 27

§

Ge = 28

§

And = 29

§

Or = 30

§

Jump = 32

Unconditional jump. Operand: u16 code offset.

§

JumpIfFalse = 33

Jump if top of stack is falsy. Operand: u16 code offset. Pops the condition.

§

JumpIfTrue = 34

Jump if top of stack is truthy. Operand: u16 code offset. Pops the condition.

§

CallHost = 48

Call a host capability. Operands: u16 path const index, u8 arg count.

§

CallUser = 49

Call a user-defined function. Operands: u16 function index, u8 arg count.

§

Return = 50

Return from the current function. Pops the return value.

§

ReturnNull = 51

Return null (void) from the current function.

§

CallHostNamed = 52

Call a host capability with explicit positional and named args. Operands: u16 path const index, u8 positional count, u8 named pair count.

§

MakeList = 64

Create a list from N stack elements. Operand: u16 count.

§

MakeRecord = 65

Create a record from N key-value pairs. Operand: u16 pair count. Keys are string constants (u16 const index pushed before each value).

§

GetMember = 66

Get a named member from a record. Operand: u16 name const index.

§

GetIndex = 67

Get an indexed element from a list. Pops index then list.

§

TryUnwrap = 68

Unwrap a Try (Ok → value, Err → catch or diagnostic). Operand: u16 catch offset.

§

Effect = 69

Execute an effect expression (pop and discard, for side effects).

§

IsOk = 70

Pop top of stack, push Bool indicating whether it is Value::Ok(_).

§

UnwrapOk = 71

Pop Value::Ok(inner) and push *inner.

§

IsErr = 72

Pop top of stack, push Bool indicating whether it is Value::Err(_).

§

UnwrapErr = 73

Pop Value::Err(inner) and push *inner.

§

IsVariant = 74

Pop top of stack, push Bool matching enum/variant/arity. Operands: u16 enum name const, u16 variant name const, u8 field count.

§

GetVariantField = 75

Pop Value::Enum(e) and push e.payload[idx]. Operand: u8 field index.

§

IsRecord = 76

Pop top of stack, push Bool indicating Value::Record(_).

§

HasMember = 77

Pop Value::Record(r) and push Bool indicating r.contains_key(name). Operand: u16 key const.

§

IsListLen = 78

Pop top of stack, push Bool indicating Value::List(xs) of length len. Operand: u16 len.

§

TrapMatch = 79

Fail execution with a destructuring pattern mismatch diagnostic.

§

MakeVariant = 80

Construct a Value::Enum from N stack payload args. Operands: u16 enum name const, u16 variant name const, u8 arg count.

§

MakeOk = 81

Pop value, push Value::Ok(Box::new(v)).

§

MakeErr = 82

Pop value, push Value::Err(Box::new(v)).

§

Halt = 255

Halt execution (end of code segment).

Implementations§

Source§

impl Op

Source

pub fn from_byte(b: u8) -> Option<Self>

Decode an opcode from a byte.

Source

pub fn operand_size(self) -> usize

Number of operand bytes following this opcode (not counting the opcode itself).

Trait Implementations§

Source§

impl Clone for Op

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Op

Source§

impl Debug for Op

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Op

Source§

impl Hash for Op

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Op

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,