Enum sage::vm::CoreOp

source ·
pub enum CoreOp {
Show 40 variants Comment(String), Set(Vec<i64>), Function, Call, Return, While, If, Else, End, Store(usize), Load(usize), Move(isize), Where, Deref, Refer, Index(usize), Offset(isize, usize), BitwiseNand(usize), BitwiseAnd(usize), BitwiseOr(usize), BitwiseXor(usize), BitwiseNot(usize), LeftShift(usize), LogicalRightShift(usize), ArithmeticRightShift(usize), And(usize), Or(usize), Not(usize), Add(usize), Sub(usize), Mul(usize), Div(usize), Rem(usize), Neg(usize), Inc(usize), Dec(usize), Swap(usize), IsNonNegative(usize), Get(Input), Put(Output),
}
Expand description

An individual core virtual machine instruction.

Variants§

§

Comment(String)

A comment in the machine code (not in the compiled output).

§

Set(Vec<i64>)

Set the register equal to a constant value.

§

Function

Create a new function.

§

Call

Calls the nth function defined in the program, where n is the value of the register.

§

Return

Return from the current function.

§

While

Begin a “while the register is not zero” loop.

§

If

Begin an “if the register is not zero” conditional.

If statements are structured like so:

if
    ...
end

if
    ...
else
    ...
end
§

Else

Begin an “else” conditional.

§

End

End a conditional.

§

Store(usize)

Store the register to the value pointed to on the tape.

§

Load(usize)

Store the value pointed to on the tape to the register.

§

Move(isize)

Move the pointer on the tape by a number of cells.

§

Where

Store the value of the pointer to the register.

§

Deref

The pointer is made equal to the value pointed to on the tape.

§

Refer

The last “deref” operation is undone; the pointer is made equal to the value it was before the last “deref” operation.

§

Index(usize)

Interpret the register’s value as a pointer to a cell. Index that pointer by the value on the tape. Store the address of the index into the register. The argument is the size of the vector to index.

§

Offset(isize, usize)

Interpret the register’s value as a pointer to a cell. Offset the pointer by a constant value. The first argument is the offset to add to the pointer. The second argument is the size of the vector to add to the pointer.

§

BitwiseNand(usize)

Perform bitwise nand on the cell and the value pointed to on the tape, and store the result in the register.

§

BitwiseAnd(usize)

Perform bitwise and on the cell and the value pointed to on the tape, and store the result in the register.

§

BitwiseOr(usize)

Perform bitwise or on the cell and the value pointed to on the tape, and store the result in the register.

§

BitwiseXor(usize)

Perform a bitwise xor on the cell and the value pointed to on the tape, and store the result in the register.

§

BitwiseNot(usize)

Bitwise not the register. Store the result in the register.

§

LeftShift(usize)

Left shift the cell by the value pointed to on the tape. Store the result in the register.

§

LogicalRightShift(usize)

Logical right shift the cell by the value pointed to on the tape. Store the result in the register.

§

ArithmeticRightShift(usize)

Interpret the register’s value as a signed integer. Arithmetic right shift the cell by the value pointed to on the tape. Store the result in the register.

§

And(usize)

Boolean-and the register and the value pointed to on the tape. Store the result in the register.

§

Or(usize)

Boolean-or the register and the value pointed to on the tape. Store the result in the register.

§

Not(usize)

Boolean-not the register (0 if the register is non-zero, 1 if the register is zero) Store the result in the register.

§

Add(usize)

Add the value pointed to on the tape to the register. The argument is the size of the vector to add to the register.

§

Sub(usize)

Subtract the value pointed to on the tape from the register. The argument is the size of the vector to subtract from the register.

§

Mul(usize)

Multiply the register by the value pointed to on the tape. The argument is the size of the vector to multiply the register by.

§

Div(usize)

Divide the register by the value pointed to on the tape. The argument is the size of the vector to divide the register by.

§

Rem(usize)

Store the remainder of the register and the value pointed to in the tape into the register. The argument is the size of the vector to take the remainder of the register by.

§

Neg(usize)

Negate the register. The argument is the size of the vector to negate the register by.

§

Inc(usize)

Increment the register. The argument is the size of the vector to increment.

§

Dec(usize)

Decrement the register.

§

Swap(usize)

Swap the value of the register with the value pointed to on the tape. The argument is the size of the vector to swap the register with.

§

IsNonNegative(usize)

Make the register equal to 1 if the register is non-negative, otherwise make it equal to 0. The argument is the size of the vector to check if the register is non-negative.

§

Get(Input)

Get a value from an input source and store it in the register.

§

Put(Output)

Write the value of the register to an output source.

Trait Implementations§

source§

impl Clone for CoreOp

source§

fn clone(&self) -> CoreOp

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 CoreOp

source§

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

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

impl Display for CoreOp

source§

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

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

impl Hash for CoreOp

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for CoreOp

source§

fn cmp(&self, other: &CoreOp) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for CoreOp

source§

fn eq(&self, other: &CoreOp) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for CoreOp

source§

fn partial_cmp(&self, other: &CoreOp) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Eq for CoreOp

source§

impl StructuralEq for CoreOp

source§

impl StructuralPartialEq for CoreOp

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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

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

§

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

§

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

§

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.