Enum brane_ast::ast::EdgeInstr

source ·
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.

Fields

§res_type: DataType

The target type to cast to.

§

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

§next: i64

The index of the flowstep where we jump to. Note that this address is actually relative to the current (i.e., the branch’s) program counter.

§

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

§next: i64

The index of the flowstep where we jump to. Note that this address is actually relative to the current (i.e., the branch’s) program counter.

§

Not

The ! operator (logical inversion)

§Stack layout

  • A boolean value on top of the stack.
§

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

§length: usize

The number of elements.

§res_type: DataType

The data type of this Array (‘Array’ included)

§

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.

Fields

§res_type: DataType

The data type of this index expression

§

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.

Fields

§def: usize

The signature of the instance we create.

§

Proj

Projects/‘indexes’ the given instance with a certain field.

§Stack layout

  • An instance-value to project on top of the stack.

Fields

§field: String

The name of the field to project.

§

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.

Fields

§def: usize

The identifier of the variable to declare.

§

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.

Fields

§def: usize

The identifier of the variable to undeclare.

§

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.

Fields

§def: usize

The identifier of the variable.

§

VarSet

Pops the value on top of the stack to the given variable.

Fields

§def: usize

The identifier of the variable.

§

Boolean

Pushes a boolean value onto the stack.

Fields

§value: bool

The value of the Bbolean.

§

Integer

Pushes an integral value onto the stack.

Fields

§value: i64

The value of the integer.

§

Real

Pushes a boolean value onto the stack.

Fields

§value: f64

The value of the real.

§

String

Pushes a boolean value onto the stack.

Fields

§value: String

The value of the string.

§

Function

Pushes a function reference onto the stack.

Fields

§def: usize

The reference to the function that is pushed on top of it.

Trait Implementations§

source§

impl Clone for EdgeInstr

source§

fn clone(&self) -> EdgeInstr

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for EdgeInstr

source§

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

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

impl<'de> Deserialize<'de> for EdgeInstr

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for EdgeInstr

source§

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

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

impl EnumDebug for EdgeInstr

source§

fn type_name() -> &'static str

Returns the static name of the type used for EnumDebug-printing. Read more
source§

fn variant_names() -> &'static [&'static str]

Returns all variants in the trait as a list of names. Read more
source§

fn variant_name(&self) -> &'static str

Returns the static name of the variant. Read more
source§

fn variant(&self) -> EnumDebugFormatter<'_, Self>

Returns a formatter for this enum that writes its variant name. Read more
source§

fn variants() -> Copied<Iter<'static, &'static str>>

Returns an iterator over all variants in this enum. Read more
source§

impl Serialize for EdgeInstr

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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
source§

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

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

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

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T