Enum gluon_vm::types::Instruction
source · pub enum Instruction {
Show 46 variants
PushInt(VmInt),
PushByte(u8),
PushFloat(EqFloat),
PushString(VmIndex),
PushUpVar(VmIndex),
Push(VmIndex),
Call(VmIndex),
TailCall(VmIndex),
ConstructVariant {
tag: VmIndex,
args: VmIndex,
},
ConstructPolyVariant {
tag: VmIndex,
args: VmIndex,
},
NewVariant {
tag: VmIndex,
args: VmIndex,
},
NewRecord {
record: VmIndex,
args: VmIndex,
},
CloseData {
index: VmIndex,
},
ConstructRecord {
record: VmIndex,
args: VmIndex,
},
ConstructArray(VmIndex),
GetOffset(VmIndex),
GetField(VmIndex),
Split,
TestTag(VmTag),
TestPolyTag(VmIndex),
Jump(VmIndex),
CJump(VmIndex),
Pop(VmIndex),
Slide(VmIndex),
MakeClosure {
function_index: VmIndex,
upvars: VmIndex,
},
NewClosure {
function_index: VmIndex,
upvars: VmIndex,
},
CloseClosure(VmIndex),
AddInt,
SubtractInt,
MultiplyInt,
DivideInt,
IntLT,
IntEQ,
AddByte,
SubtractByte,
MultiplyByte,
DivideByte,
ByteLT,
ByteEQ,
AddFloat,
SubtractFloat,
MultiplyFloat,
DivideFloat,
FloatLT,
FloatEQ,
Return,
}
Expand description
Enum which represent the instructions executed by the virtual machine.
The binary arithmetic instructions pop two values of the stack and then push the result.
Variants§
PushInt(VmInt)
Push an integer to the stack
PushByte(u8)
Push a byte to the stack
PushFloat(EqFloat)
Push a float to the stack
PushString(VmIndex)
Push a string to the stack by loading the string at index
in the currently executing
function
PushUpVar(VmIndex)
Push a variable to the stack by loading the upvariable at index
from the currently
executing function
Push(VmIndex)
Push the value at index
Call(VmIndex)
Call a function by passing it args
number of arguments. The function is at the index in
the stack just before the arguments. After the call is all arguments are removed and the
function is replaced by the result of the call.
TailCall(VmIndex)
Tailcalls a function, removing the current stack frame before calling it.
See Call
.
ConstructVariant
Fields
Constructs a data value tagged by tag
by taking the top args
values of the stack.
ConstructPolyVariant
Fields
NewVariant
Fields
NewRecord
Fields
CloseData
ConstructRecord
Fields
ConstructArray(VmIndex)
Constructs an array containing args
values.
GetOffset(VmIndex)
Retrieves the field at offset
of an object at the top of the stack. The result of the
field access replaces the object on the stack.
GetField(VmIndex)
Retrieves the field of a polymorphic record by retrieving the string constant at index
and using that to retrieve lookup the field. The result of the
field access replaces the object on the stack.
Split
Splits a object, pushing all contained values to the stack.
TestTag(VmTag)
Tests if the value at the top of the stack is tagged with tag
. Pushes True
if the tag
matches, otherwise False
TestPolyTag(VmIndex)
Jump(VmIndex)
Jumps to the instruction at index
in the currently executing function.
CJump(VmIndex)
Jumps to the instruction at index
in the currently executing function if True
is at the
top of the stack and pops that value.
Pop(VmIndex)
Pops the top n
values from the stack.
Slide(VmIndex)
Pops the top value from the stack, then pops n
more values, finally the first value is
pushed back to the stack.
MakeClosure
Fields
Creates a closure with the function at function_index
of the currently executing function
and upvars
upvariables popped from the top of the stack.
NewClosure
Fields
Creates a closure with the function at function_index
of the currently executing
function. The closure has room for upvars
upvariables but these are not filled until the
matching call to ClosureClosure
is executed.
CloseClosure(VmIndex)
Fills the previously allocated closure with n
upvariables.
AddInt
SubtractInt
MultiplyInt
DivideInt
IntLT
IntEQ
AddByte
SubtractByte
MultiplyByte
DivideByte
ByteLT
ByteEQ
AddFloat
SubtractFloat
MultiplyFloat
DivideFloat
FloatLT
FloatEQ
Return
Implementations§
Trait Implementations§
source§impl Clone for Instruction
impl Clone for Instruction
source§fn clone(&self) -> Instruction
fn clone(&self) -> Instruction
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for Instruction
impl Debug for Instruction
source§impl<'de> Deserialize<'de> for Instruction
impl<'de> Deserialize<'de> for Instruction
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>,
source§impl Hash for Instruction
impl Hash for Instruction
source§impl PartialEq for Instruction
impl PartialEq for Instruction
source§fn eq(&self, other: &Instruction) -> bool
fn eq(&self, other: &Instruction) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl Serialize for Instruction
impl Serialize for Instruction
impl Copy for Instruction
impl Eq for Instruction
impl StructuralEq for Instruction
impl StructuralPartialEq for Instruction
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§
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
§impl<T> CallHasher for T
impl<T> CallHasher for T
§impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.source§impl<T> DowncastArc for T
impl<T> DowncastArc for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§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.