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 Ord for CoreOp
impl Ord for CoreOp
source§impl PartialEq for CoreOp
impl PartialEq for CoreOp
source§impl PartialOrd for CoreOp
impl PartialOrd for CoreOp
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more