pub enum Inst {
Show 69 variants
Allocate {
size: usize,
},
Not {
addr: InstAddress,
out: Output,
},
Neg {
addr: InstAddress,
out: Output,
},
Closure {
hash: Hash,
addr: InstAddress,
count: usize,
out: Output,
},
CallOffset {
offset: usize,
call: Call,
addr: InstAddress,
args: usize,
out: Output,
},
Call {
hash: Hash,
addr: InstAddress,
args: usize,
out: Output,
},
CallAssociated {
hash: Hash,
addr: InstAddress,
args: usize,
out: Output,
},
LoadInstanceFn {
addr: InstAddress,
hash: Hash,
out: Output,
},
CallFn {
function: InstAddress,
addr: InstAddress,
args: usize,
out: Output,
},
IndexGet {
target: InstAddress,
index: InstAddress,
out: Output,
},
TupleIndexSet {
target: InstAddress,
index: usize,
value: InstAddress,
},
TupleIndexGetAt {
addr: InstAddress,
index: usize,
out: Output,
},
ObjectIndexSet {
target: InstAddress,
slot: usize,
value: InstAddress,
},
ObjectIndexGetAt {
addr: InstAddress,
slot: usize,
out: Output,
},
IndexSet {
target: InstAddress,
index: InstAddress,
value: InstAddress,
},
Await {
addr: InstAddress,
out: Output,
},
Select {
addr: InstAddress,
len: usize,
value: Output,
},
LoadFn {
hash: Hash,
out: Output,
},
Store {
value: InstValue,
out: Output,
},
Copy {
addr: InstAddress,
out: Output,
},
Move {
addr: InstAddress,
out: Output,
},
Drop {
set: usize,
},
Swap {
a: InstAddress,
b: InstAddress,
},
Return {
addr: InstAddress,
},
ReturnUnit,
Jump {
jump: usize,
},
JumpIf {
cond: InstAddress,
jump: usize,
},
JumpIfNot {
cond: InstAddress,
jump: usize,
},
Vec {
addr: InstAddress,
count: usize,
out: Output,
},
Tuple1 {
addr: [InstAddress; 1],
out: Output,
},
Tuple2 {
addr: [InstAddress; 2],
out: Output,
},
Tuple3 {
addr: [InstAddress; 3],
out: Output,
},
Tuple4 {
addr: [InstAddress; 4],
out: Output,
},
Tuple {
addr: InstAddress,
count: usize,
out: Output,
},
Environment {
addr: InstAddress,
count: usize,
out: Output,
},
Object {
addr: InstAddress,
slot: usize,
out: Output,
},
Range {
range: InstRange,
out: Output,
},
EmptyStruct {
hash: Hash,
out: Output,
},
Struct {
addr: InstAddress,
hash: Hash,
out: Output,
},
ConstConstruct {
addr: InstAddress,
hash: Hash,
count: usize,
out: Output,
},
String {
slot: usize,
out: Output,
},
Bytes {
slot: usize,
out: Output,
},
StringConcat {
addr: InstAddress,
len: usize,
size_hint: usize,
out: Output,
},
Format {
addr: InstAddress,
spec: FormatSpec,
out: Output,
},
IsUnit {
addr: InstAddress,
out: Output,
},
Try {
addr: InstAddress,
out: Output,
},
EqChar {
addr: InstAddress,
value: char,
out: Output,
},
EqSigned {
addr: InstAddress,
value: i64,
out: Output,
},
EqUnsigned {
addr: InstAddress,
value: u64,
out: Output,
},
EqBool {
addr: InstAddress,
value: bool,
out: Output,
},
EqString {
addr: InstAddress,
slot: usize,
out: Output,
},
EqBytes {
addr: InstAddress,
slot: usize,
out: Output,
},
MatchType {
hash: Hash,
addr: InstAddress,
out: Output,
},
MatchVariant {
variant_hash: Hash,
enum_hash: Hash,
index: usize,
addr: InstAddress,
out: Output,
},
MatchBuiltIn {
type_check: TypeCheck,
addr: InstAddress,
out: Output,
},
MatchSequence {
type_check: TypeCheck,
len: usize,
exact: bool,
addr: InstAddress,
out: Output,
},
MatchObject {
slot: usize,
exact: bool,
addr: InstAddress,
out: Output,
},
Yield {
addr: InstAddress,
out: Output,
},
YieldUnit {
out: Output,
},
Variant {
addr: InstAddress,
variant: InstVariant,
out: Output,
},
Op {
op: InstOp,
a: InstAddress,
b: InstAddress,
out: Output,
},
Arithmetic {
op: InstArithmeticOp,
a: InstAddress,
b: InstAddress,
out: Output,
},
Bitwise {
op: InstBitwiseOp,
a: InstAddress,
b: InstAddress,
out: Output,
},
Shift {
op: InstShiftOp,
a: InstAddress,
b: InstAddress,
out: Output,
},
AssignArithmetic {
op: InstArithmeticOp,
target: InstTarget,
rhs: InstAddress,
},
AssignBitwise {
op: InstBitwiseOp,
target: InstTarget,
rhs: InstAddress,
},
AssignShift {
op: InstShiftOp,
target: InstTarget,
rhs: InstAddress,
},
IterNext {
addr: InstAddress,
jump: usize,
out: Output,
},
Panic {
reason: PanicReason,
},
}
Expand description
An operation in the stack-based virtual machine.
Variants§
Allocate
Make sure that the memory region has size
slots of memory available.
Not
Not operator. Takes a boolean from the top of the stack and inverts its logical value.
§Operation
<bool>
=> <bool>
Fields
addr: InstAddress
The operand to negate.
Neg
Fields
addr: InstAddress
The operand to negate.
Closure
Construct a closure that takes the given number of arguments and
captures count
elements from the top of the stack.
§Operation
<value..>
=> <fn>
Fields
addr: InstAddress
Where to load captured values from.
CallOffset
Perform a function call within the same unit.
It will construct a new stack frame which includes the last args
number of entries.
Fields
addr: InstAddress
The address where the arguments are stored.
Call
Call a function by hash.
The function will be looked up in the unit and context. The arguments
passed to the function call are stored at addr
, where size
determines the number of arguments. The arguments will be dropped.
The return value of the function call will be written to out
.
Fields
addr: InstAddress
The address of the arguments being passed.
CallAssociated
Call an associated function.
The instance being called should be the the object at address addr
.
The number of arguments specified should include this object.
The return value of the function call will be written to out
.
Fields
addr: InstAddress
The address of arguments being passed.
LoadInstanceFn
Look up an instance function.
The instance being used is stored at addr
, and the function hash to look up is hash
.
Fields
addr: InstAddress
The address of the instance for which the function is being loaded.
CallFn
Perform a function call on a function pointer stored on the stack.
§Operation
<fn>
<args...>
=> <ret>
Fields
function: InstAddress
The address of the function being called.
addr: InstAddress
The address of the arguments being passed.
IndexGet
Perform an index get operation. Pushing the result on the stack.
§Operation
<target>
<index>
=> <value>
Fields
target: InstAddress
How the target is addressed.
index: InstAddress
How the index is addressed.
TupleIndexSet
Set the given index of the tuple on the stack, with the given value.
§Operation
<value>
<tuple>
=> *nothing*
Fields
target: InstAddress
The object being assigned to.
value: InstAddress
The value being assigned.
TupleIndexGetAt
Get the given index out of a tuple from the given variable slot. Errors if the item doesn’t exist or the item is not a tuple.
§Operation
=> <value>
Fields
addr: InstAddress
The address where the tuple we are getting from is stored.
ObjectIndexSet
Set the given index out of an object on the top of the stack. Errors if the item doesn’t exist or the item is not an object.
The index is identifier by a static string slot, which is provided as an argument.
§Operation
<object>
<value>
=>
Fields
target: InstAddress
The object being assigned to.
value: InstAddress
The value being assigned.
ObjectIndexGetAt
Get the given index out of an object from the given variable slot. Errors if the item doesn’t exist or the item is not an object.
The index is identifier by a static string slot, which is provided as an argument.
§Operation
=> <value>
Fields
addr: InstAddress
The address where the object is stored.
IndexSet
Fields
target: InstAddress
The object being assigned to.
index: InstAddress
The index to set.
value: InstAddress
The value being assigned.
Await
Await the future that is on the stack and push the value that it produces.
§Operation
<future>
=> <value>
Fields
addr: InstAddress
Address of the future being awaited.
Select
Select over len
futures stored at address addr
.
Once a branch has been matched, will store the branch that matched in the branch register and perform a jump by the index of the branch that matched.
Will also store the output if the future into value
. If no branch
matched, the empty value will be stored.
Fields
addr: InstAddress
The base address of futures being waited on.
LoadFn
Store
Copy
Copy a variable from a location offset
relative to the current call
frame.
A copy is very cheap. It simply means pushing a reference to the stack.
Fields
addr: InstAddress
Address of the value being copied.
Move
Move a variable from a location offset
relative to the current call
frame.
Fields
addr: InstAddress
Address of the value being moved.
Drop
Drop the given value set.
Swap
Swap two values on the stack using their offsets relative to the current stack frame.
Return
Pop the current stack frame and restore the instruction pointer from it.
The stack frame will be cleared, and the value on the top of the stack will be left on top of it.
Fields
addr: InstAddress
The address of the value to return.
ReturnUnit
Pop the current stack frame and restore the instruction pointer from it.
The stack frame will be cleared, and a unit value will be pushed to the top of the stack.
Jump
Unconditionally jump to offset
relative to the current instruction
pointer.
§Operation
*nothing*
=> *nothing*
JumpIf
Jump to offset
relative to the current instruction pointer if the
condition is true
.
§Operation
<boolean>
=> *nothing*
JumpIfNot
Fields
cond: InstAddress
The address of the condition for the jump.
Vec
Construct a vector at out
, populating it with count
elements from
addr
.
The values at addr
are dropped.
Fields
addr: InstAddress
Where the arguments to the vector are stored.
Tuple1
Construct a one element tuple at out
, populating it with count
elements from addr
.
The values at addr
are not dropped.
Tuple2
Construct a two element tuple at out
, populating it with count
elements from addr
.
The values at addr
are not dropped.
Tuple3
Construct a three element tuple at out
, populating it with count
elements from addr
.
The values at addr
are not dropped.
Tuple4
Construct a four element tuple at out
, populating it with count
elements from addr
.
The values at addr
are not dropped.
Tuple
Construct a tuple at out
, populating it with count
elements from
addr
.
Unlike TupleN
variants, values at addr
are dropped.
Fields
addr: InstAddress
Where the arguments to the tuple are stored.
Environment
Take the tuple that is on top of the stack and push its content onto the stack.
This is used to unpack an environment for closures - if the closure has an environment.
§Operation
<tuple>
=> <value...>
Fields
addr: InstAddress
The tuple to push.
Object
Construct a push an object onto the stack. The number of elements
in the object are determined the slot of the object keys slot
and are
popped from the stack.
For each element, a value is popped corresponding to the object key.
§Operation
<value..>
=> <object>
Fields
addr: InstAddress
Where the arguments to the tuple are stored.
Range
Construct a range.
The arguments loaded are determined by the range being constructed.
Fields
EmptyStruct
Construct a push an object of the given type onto the stack. The type is an empty struct.
§Operation
=> <object>
Struct
Construct a struct of type hash
at out
, populating it with fields
from addr
. The number of fields and their names is determined by the
slot
being referenced.
The values at addr
are dropped.
Fields
addr: InstAddress
The address to load fields from.
ConstConstruct
Construct a struct from a constant.
The values at addr
are dropped.
Fields
addr: InstAddress
Where constructor arguments are stored.
String
Fields
Bytes
Fields
StringConcat
Pop the given number of values from the stack, and concatenate a string from them.
This is a dedicated template-string optimization.
§Operation
<value...>
=> <string>
Fields
addr: InstAddress
Where the strings to concatenate are stored.
Format
Push a combined format specification and value onto the stack. The value used is the last value on the stack.
Fields
addr: InstAddress
Address of the value being formatted.
spec: FormatSpec
The format specification to use.
IsUnit
Try
Perform the try operation which takes the value at the given address
and tries to unwrap it or return from the current call frame.
§Operation
<value>
=> <boolean>
Fields
addr: InstAddress
Address of value to try.
EqChar
Fields
addr: InstAddress
Address of the value to compare.
EqSigned
Test if the specified value is a specific signed integer.
Fields
addr: InstAddress
Address of the value to compare.
EqUnsigned
Test if the specified value is a specific unsigned integer.
Fields
addr: InstAddress
Address of the value to compare.
EqBool
Fields
addr: InstAddress
Address of the value to compare.
EqString
Fields
addr: InstAddress
Address of the value to compare.
EqBytes
Fields
addr: InstAddress
Address of the value to compare.
MatchType
Fields
addr: InstAddress
The address of the value to test.
MatchVariant
Test if the specified variant matches. This is distinct from Inst::MatchType because it will match immediately on the variant type if appropriate which is possible for internal types, but external types will require an additional runtime check for matching.
§Operation
<value>
=> <boolean>
Fields
addr: InstAddress
The address of the value to test.
MatchBuiltIn
Fields
addr: InstAddress
The address of the value to test.
MatchSequence
Test that the top of the stack is a tuple with the given length requirements.
§Operation
<value>
=> <boolean>
Fields
addr: InstAddress
The address of the value to test.
MatchObject
Test that the top of the stack is an object matching the given slot of object keys.
§Operation
<object>
=> <boolean>
Fields
addr: InstAddress
The address of the value to test.
Yield
Perform a generator yield where the value yielded is expected to be found at the top of the stack.
This causes the virtual machine to suspend itself.
§Operation
<value>
=> <value>
Fields
addr: InstAddress
Address of the value being yielded.
YieldUnit
Perform a generator yield with a unit.
This causes the virtual machine to suspend itself.
§Operation
=> <unit>
Variant
Construct a built-in variant onto the stack.
The variant will pop as many values of the stack as necessary to construct it.
§Operation
<value..>
=> <variant>
Fields
addr: InstAddress
Where the arguments to construct the variant are stored.
variant: InstVariant
The kind of built-in variant to construct.
Op
An operation.
Fields
a: InstAddress
The address of the first argument.
b: InstAddress
The address of the second argument.
Arithmetic
An arithmetic operation.
Fields
op: InstArithmeticOp
The kind of operation.
a: InstAddress
The address of the first argument.
b: InstAddress
The address of the second argument.
Bitwise
A bitwise operation.
Fields
op: InstBitwiseOp
The kind of operation.
a: InstAddress
The address of the first argument.
b: InstAddress
The address of the second argument.
Shift
A shift operation.
Fields
op: InstShiftOp
The kind of operation.
a: InstAddress
The address of the first argument.
b: InstAddress
The address of the second argument.
AssignArithmetic
Instruction for assigned arithmetic operations.
Fields
op: InstArithmeticOp
The kind of operation.
target: InstTarget
The target of the operation.
rhs: InstAddress
The value being assigned.
AssignBitwise
Instruction for assigned bitwise operations.
Fields
op: InstBitwiseOp
The kind of operation.
target: InstTarget
The target of the operation.
rhs: InstAddress
The value being assigned.
AssignShift
Instruction for assigned shift operations.
Fields
op: InstShiftOp
The kind of operation.
target: InstTarget
The target of the operation.
rhs: InstAddress
The value being assigned.
IterNext
Advance an iterator at the given position.
Fields
addr: InstAddress
The address of the iterator to advance.
Panic
Cause the VM to panic and error out without a reason.
This should only be used during testing or extreme scenarios that are completely unrecoverable.
Fields
reason: PanicReason
The reason for the panic.
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Inst
impl<'de> Deserialize<'de> for Inst
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 Copy for Inst
Auto Trait Implementations§
impl Freeze for Inst
impl RefUnwindSafe for Inst
impl Send for Inst
impl Sync for Inst
impl Unpin for Inst
impl UnwindSafe for Inst
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)