pub enum EdgeInstr {
Show 34 variants
Cast {
res_type: DataType,
},
Pop {},
PopMarker {},
DynamicPop {},
Branch {
next: i64,
},
BranchNot {
next: i64,
},
Not {},
Neg {},
And {},
Or {},
Add {},
Sub {},
Mul {},
Div {},
Mod {},
Eq {},
Ne {},
Lt {},
Le {},
Gt {},
Ge {},
Array {
length: usize,
res_type: DataType,
},
ArrayIndex {
res_type: DataType,
},
Instance {
def: usize,
},
Proj {
field: String,
},
VarDec {
def: usize,
},
VarUndec {
def: usize,
},
VarGet {
def: usize,
},
VarSet {
def: usize,
},
Boolean {
value: bool,
},
Integer {
value: i64,
},
Real {
value: f64,
},
String {
value: String,
},
Function {
def: usize,
},
}
Expand description
Defines an instruction for use within edges, which performs some computation in BraneScriptland (i.e., the edges).
Variants§
Cast
Casts the top value on the stack to another data type.
§Stack layout
- A value with a datatype casteable to the target on top of the stack.
Pop
Pops the top value of the stack without doing anything with it.
§Stack layout
- At least one value of any type on top of the stack.
PopMarker
Pushes a special, so-called PopMarker onto the stack. This is used to pop dynamically in the case expression return types are unresolved.
DynamicPop
A special pop that attempts to pop intelligently based on the stack. This is required for unresolved function return values, where we don’t know how if the function produced a value to remove.
Use EdgeInstr::PopMarker
to push the marker onto the stack. It will be invisible for other operations.
§Stack layout
- At least one
PopMarker
value somewhere on the stack. Anything up to there is popped.
Branch
A branch instruction takes a branch if the top value on the stack is true.
§Stack layout
- A boolean value on top of the stack.
Fields
BranchNot
The same as a branch, but now if the top value of the stack is false.
§Stack layout
- A boolean value on top of the stack.
Fields
Not
Neg
The -
operator (negation)
§Stack layout
- A numeric (i.e., integral or real) value on top of the stack.
And
The &&
operator (logical and)
Or
The ||
operator (logical or)
Add
The +
operator (addition)
§Stack layout
- A numeric (i.e., integral or real) value on top of the stack as the righthand-side.
- Another numeric value on second-to-top of the stack as the lefthand-side.
Sub
The -
operator (subtraction)
§Stack layout
- A numeric (i.e., integral or real) value on top of the stack as the righthand-side.
- Another numeric value on second-to-top of the stack as the lefthand-side.
Mul
The *
operator (multiplication)
§Stack layout
- A numeric (i.e., integral or real) value on top of the stack as the righthand-side.
- Another numeric value on second-to-top of the stack as the lefthand-side.
Div
The /
operator (division)
§Stack layout
- A numeric (i.e., integral or real) value on top of the stack as the righthand-side.
- Another numeric value on second-to-top of the stack as the lefthand-side.
Mod
The ‘%’ operator (modulo)
§Stack layout
- An integral value on top of the stack as the righthand-side.
- Another integral value on second-to-top of the stack as the lefthand-side.
Eq
The ==
operator (equality)
§Stack layout
- An arbitrary value on top of the stack as the righthand-side.
- Another arbitrary value on second-to-top of the stack as the lefthand-side.
Ne
The !=
operator (not equal to)
§Stack layout
- An arbitrary value on top of the stack as the righthand-side.
- Another arbitrary value on second-to-top of the stack as the lefthand-side.
Lt
The <
operator (less than)
§Stack layout
- A numeric (i.e., integral or real) value on top of the stack as the righthand-side.
- Another numeric value on second-to-top of the stack as the lefthand-side.
Le
The <=
operator (less than or equal to)
§Stack layout
- A numeric (i.e., integral or real) value on top of the stack as the righthand-side.
- Another numeric value on second-to-top of the stack as the lefthand-side.
Gt
The >
operator (greater than)
§Stack layout
- A numeric (i.e., integral or real) value on top of the stack as the righthand-side.
- Another numeric value on second-to-top of the stack as the lefthand-side.
Ge
The >=
operator (greater than or equal to)
§Stack layout
- A numeric (i.e., integral or real) value on top of the stack as the righthand-side.
- Another numeric value on second-to-top of the stack as the lefthand-side.
Array
Groups the previous N values on the stack into an Array.
§Stack layout
- N elements on top of the stack of the same data type (stored in the Array instruction itself).
Fields
ArrayIndex
Gets the i’th element of the top element on the stack (as an Array). Note that the array itself should be on the second-to-top value on the stack, and the index the top one.
§Stack layout
- An integral value on top of the stack that is the index.
- An array value on second-to-top of the stack that is indexed.
Instance
Pushes a new instance onto the stack. It uses the previous elements on there in reverse order.
§Stack layout
- N values of heterogeneous types on top of the stack that form the properties. They should be sorted alphabetically, with the most a-ish property on the bottom and the most z-ish property on the top.
Proj
Projects/‘indexes’ the given instance with a certain field.
§Stack layout
- An instance-value to project on top of the stack.
VarDec
Declares the given variable in the framestack.
It is a bit of an artificial instruction, mainly used to keep track of initialization status at runtime.
VarUndec
Undeclares the given variable in the framestack.
It’s a bit of an artificial instruction, mainly used to keep track of initialization status at runtime.
VarGet
Puts the value of the given variable on top of the stack.
§Stack layout
- A value on top of the stack of the same type as the variable referenced.
VarSet
Pops the value on top of the stack to the given variable.
Boolean
Pushes a boolean value onto the stack.
Integer
Pushes an integral value onto the stack.
Real
Pushes a boolean value onto the stack.
String
Pushes a boolean value onto the stack.
Function
Pushes a function reference onto the stack.
Trait Implementations§
source§impl<'de> Deserialize<'de> for EdgeInstr
impl<'de> Deserialize<'de> for EdgeInstr
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 EnumDebug for EdgeInstr
impl EnumDebug for EdgeInstr
source§fn type_name() -> &'static str
fn type_name() -> &'static str
source§fn variant_names() -> &'static [&'static str]
fn variant_names() -> &'static [&'static str]
source§fn variant_name(&self) -> &'static str
fn variant_name(&self) -> &'static str
source§fn variant(&self) -> EnumDebugFormatter<'_, Self>
fn variant(&self) -> EnumDebugFormatter<'_, Self>
Auto Trait Implementations§
impl Freeze for EdgeInstr
impl RefUnwindSafe for EdgeInstr
impl Send for EdgeInstr
impl Sync for EdgeInstr
impl Unpin for EdgeInstr
impl UnwindSafe for EdgeInstr
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
)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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request