Enum Instruction

Source
pub enum Instruction {
Show 75 variants LogicalAnd(LineCol), LogicalOr(LineCol), LogicalXor(LineCol), LogicalNot(LineCol), BitwiseAnd(LineCol), BitwiseOr(LineCol), BitwiseXor(LineCol), BitwiseNot(LineCol), ShiftLeft(LineCol), ShiftRight(LineCol), EqualBooleans(LineCol), NotEqualBooleans(LineCol), EqualDoubles(LineCol), NotEqualDoubles(LineCol), LessDoubles(LineCol), LessEqualDoubles(LineCol), GreaterDoubles(LineCol), GreaterEqualDoubles(LineCol), EqualIntegers(LineCol), NotEqualIntegers(LineCol), LessIntegers(LineCol), LessEqualIntegers(LineCol), GreaterIntegers(LineCol), GreaterEqualIntegers(LineCol), EqualStrings(LineCol), NotEqualStrings(LineCol), LessStrings(LineCol), LessEqualStrings(LineCol), GreaterStrings(LineCol), GreaterEqualStrings(LineCol), AddDoubles(LineCol), SubtractDoubles(LineCol), MultiplyDoubles(LineCol), DivideDoubles(LineCol), ModuloDoubles(LineCol), PowerDoubles(LineCol), NegateDouble(LineCol), AddIntegers(LineCol), SubtractIntegers(LineCol), MultiplyIntegers(LineCol), DivideIntegers(LineCol), ModuloIntegers(LineCol), PowerIntegers(LineCol), NegateInteger(LineCol), ConcatStrings(LineCol), ArrayAssignment(SymbolKey, LineCol, usize), ArrayLoad(SymbolKey, LineCol, usize), Assign(SymbolKey), BuiltinCall(SymbolKey, LineCol, usize), Call(JumpISpan), FunctionCall(SymbolKey, ExprType, LineCol, usize), Dim(DimISpan), DimArray(DimArrayISpan), End(bool), EnterScope, DoubleToInteger, IntegerToDouble, Jump(JumpISpan), JumpIfDefined(JumpIfDefinedISpan), JumpIfTrue(Address), JumpIfNotTrue(Address), LeaveScope, LoadBoolean(SymbolKey, LineCol), LoadDouble(SymbolKey, LineCol), LoadInteger(SymbolKey, LineCol), LoadString(SymbolKey, LineCol), LoadRef(SymbolKey, ExprType, LineCol), Nop, PushBoolean(bool, LineCol), PushDouble(f64, LineCol), PushInteger(i32, LineCol), PushString(String, LineCol), Return(LineCol), SetErrorHandler(ErrorHandlerISpan), Unset(UnsetISpan),
}
Expand description

Representation of all possible instructions in the bytecode.

Variants§

§

LogicalAnd(LineCol)

Represents a binary logical “and” operation.

§

LogicalOr(LineCol)

Represents a binary logical “or” operation.

§

LogicalXor(LineCol)

Represents a binary logical “xor” operation.

§

LogicalNot(LineCol)

Represents a unary logical “not” operation.

§

BitwiseAnd(LineCol)

Represents a binary bitwise “and” operation.

§

BitwiseOr(LineCol)

Represents a binary bitwise “or” operation.

§

BitwiseXor(LineCol)

Represents a binary bitwise “xor” operation.

§

BitwiseNot(LineCol)

Represents a unary bitwise “not” operation.

§

ShiftLeft(LineCol)

Represents a left bitshift.

§

ShiftRight(LineCol)

Represents a right bitshift.

§

EqualBooleans(LineCol)

Represents an equality comparison for booleans.

§

NotEqualBooleans(LineCol)

Represents an inequality comparison for booleans.

§

EqualDoubles(LineCol)

Represents an equality comparison for doubles.

§

NotEqualDoubles(LineCol)

Represents an inequality comparison for doubles.

§

LessDoubles(LineCol)

Represents a less-than comparison for doubles.

§

LessEqualDoubles(LineCol)

Represents a less-or-equal comparison for doubles.

§

GreaterDoubles(LineCol)

Represents a greater-than comparison for doubles.

§

GreaterEqualDoubles(LineCol)

Represents a greater-or-equal comparison for doubles.

§

EqualIntegers(LineCol)

Represents an equality comparison for integers.

§

NotEqualIntegers(LineCol)

Represents an inequality comparison for integers.

§

LessIntegers(LineCol)

Represents a less-than comparison for integers.

§

LessEqualIntegers(LineCol)

Represents a less-or-equal comparison for integers.

§

GreaterIntegers(LineCol)

Represents a greater-than comparison for integers.

§

GreaterEqualIntegers(LineCol)

Represents a greater-or-equal comparison for integers.

§

EqualStrings(LineCol)

Represents an equality comparison for strings.

§

NotEqualStrings(LineCol)

Represents an inequality comparison for strings.

§

LessStrings(LineCol)

Represents a less-than comparison for strings.

§

LessEqualStrings(LineCol)

Represents a less-or-equal comparison for strings.

§

GreaterStrings(LineCol)

Represents a greater-than comparison for strings.

§

GreaterEqualStrings(LineCol)

Represents a greater-or-equal comparison for strings.

§

AddDoubles(LineCol)

Represents an arithmetic addition operation for doubles.

§

SubtractDoubles(LineCol)

Represents an arithmetic subtraction operation for doubles.

§

MultiplyDoubles(LineCol)

Represents an arithmetic multiplication operation for doubles.

§

DivideDoubles(LineCol)

Represents an arithmetic division operation for doubles.

§

ModuloDoubles(LineCol)

Represents an arithmetic modulo operation for doubles.

§

PowerDoubles(LineCol)

Represents an arithmetic power operation for doubles.

§

NegateDouble(LineCol)

Represents an arithmetic sign flip operation for a double.

§

AddIntegers(LineCol)

Represents an arithmetic addition operation for integers.

§

SubtractIntegers(LineCol)

Represents an arithmetic subtraction operation for integers.

§

MultiplyIntegers(LineCol)

Represents an arithmetic multiplication operation for integers.

§

DivideIntegers(LineCol)

Represents an arithmetic division operation for integers.

§

ModuloIntegers(LineCol)

Represents an arithmetic modulo operation for integers.

§

PowerIntegers(LineCol)

Represents an arithmetic power operation for integers.

§

NegateInteger(LineCol)

Represents an arithmetic sign flip operation for an integer.

§

ConcatStrings(LineCol)

Represents the concatenation of strings.

§

ArrayAssignment(SymbolKey, LineCol, usize)

Represents an assignment to an element of an array with the given number of subscripts.

§

ArrayLoad(SymbolKey, LineCol, usize)

Represents a load of an array’s element into the stack.

§

Assign(SymbolKey)

Represents an assignment of a value to a variable.

§

BuiltinCall(SymbolKey, LineCol, usize)

Represents a call to a builtin command such as PRINT with the given number of arguments.

The arguments in the stack are interspersed with the separators used to separate them from. each other, because those separators have meaning.

§

Call(JumpISpan)

Represents an unconditional call to a location that will return.

§

FunctionCall(SymbolKey, ExprType, LineCol, usize)

Represents a call to the given function with the given number of arguments.

§

Dim(DimISpan)

Represents a variable definition.

§

DimArray(DimArrayISpan)

Represents an array definition.

§

End(bool)

Represents a request to terminate the program. If the boolean is true, the exit ode is at the top of the stack.

§

EnterScope

Represents a request to create a new scope for symbols.

§

DoubleToInteger

Represents a conversion of a float to an integer with rounding.

§

IntegerToDouble

Represents a conversion of an integer to a float.

§

Jump(JumpISpan)

Represents an unconditional jump.

§

JumpIfDefined(JumpIfDefinedISpan)

Represents an conditional jump that jumps if the variable is defined.

§

JumpIfTrue(Address)

Represents an conditional jump that jumps if the condition is met.

§

JumpIfNotTrue(Address)

Represents an conditional jump that jumps if the condition is not met.

§

LeaveScope

Represents a request to leave the current scope for symbols.

§

LoadBoolean(SymbolKey, LineCol)

Represents a load of a boolean variable’s value from main memory into the stack.

§

LoadDouble(SymbolKey, LineCol)

Represents a load of a double variable’s value from main memory into the stack.

§

LoadInteger(SymbolKey, LineCol)

Represents a load of an integer variable’s value from main memory into the stack.

§

LoadString(SymbolKey, LineCol)

Represents a load of a string variable’s value from main memory into the stack.

§

LoadRef(SymbolKey, ExprType, LineCol)

Represents a load of a variable’s reference into the stack.

§

Nop

Represents an instruction that does nothing.

§

PushBoolean(bool, LineCol)

Represents a load of a literal boolean value into the top of the stack.

§

PushDouble(f64, LineCol)

Represents a load of a literal double value into the top of the stack.

§

PushInteger(i32, LineCol)

Represents a load of a literal integer value into the top of the stack.

§

PushString(String, LineCol)

Represents a load of a literal string value into the top of the stack.

§

Return(LineCol)

Represents a return after a call.

§

SetErrorHandler(ErrorHandlerISpan)

Represents a change in the error handler state.

§

Unset(UnsetISpan)

Represents a request to unset a variable.

Implementations§

Source§

impl Instruction

Source

pub fn repr(&self) -> (&'static str, Option<String>)

Returns the textual representation of the instruction.

Source

pub fn pos(&self) -> Option<LineCol>

Returns the position in the source code where this instruction originated.

For some instructions, we cannot tell their location right now, so we return None for those.

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

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.