pub enum Stack {
Show 14 variants
Push(i64),
Pop,
Dup,
DupFrom,
Swap,
SwapIndex,
Select,
SelectRange,
Repeat,
RepeatEnd,
Reserve,
Load,
Store,
Drop,
}
Expand description
Operations related to stack manipulation.
Variants§
Push(i64)
0x01
Push one word onto the stack.
§Bytecode Argument
This operation expects a 8-byte (1-word) argument following its opcode within bytecode.
§Stack Output
[value]
Pop
Dup
DupFrom
0x04
: DUPF
Duplicate the word at the given stack depth index.
0
is the index of the element at the top of the stack.
§Stack Input
[index]
§Stack Output
[value_i]
Swap
SwapIndex
0x06
: SWAPI
Swap the top word on the stack with the word at the given stack depth index.
0
is the index of the element at the top of the stack.
§Stack Input
[a, b, c, d, index]
§Stack Output
[a, d, c, b]
§Panics
- Index is out of range.
Select
0x07
: SEL
Conditionally keep one of the top two elements on the stack.
If condition is true
, the top element is kept.
§Stack Input
[a, b, cond]
§Stack Output
[b]
SelectRange
0x08
: SLTR
Conditionally keep one of the top two ranges on the stack.
If condition is true
, the top range is kept.
The ranges must be of equal length.
The ranges must be stacked sequentially.
Here N
is len -1
.
§Stack Input
[arr_a_0, ..arr_a_N, arr_b_0, ..arr_b_N, len, cond]
§Stack Output
[arr_b_0, ..arr_b_N]
Repeat
0x09
: REP
Repeat a section of code the number of times. Takes a boolean to either count from 0 up or from the number of repeats down to 0.
§Stack Input
[num_repeats, count_up_bool]
RepeatEnd
0x0A
: REPE
Increment or decrements the top counter on the repeat stack.
If the counter is counting up and counter == limit - 1
then this pops the counter and continues with the program.
If the counter is counting down and the counter is 0
then this pops the counter and continues with the program.
If it is < limit - 1
or > 0
respectively then the program jumps to
the last Repeat
§Panics
- If there is no counter on the repeat stack.
- If there is no repeat registered to return to.
Reserve
0x0B
: RES
Reserve space on the stack for len
words.
The reserved space is set to 0.
Returns the index to the start of the reserved space.
§Stack Input
[len]
§Stack Output
[index]
Load
0x0C
: LODS
Load the value at the given stack depth index relative to the bottom.
0
is the index of the element at the bottom of the stack.
§Stack Input
[index]
§Stack Output
[value]
§Panics
- Index is out of range.
Store
0x0D
: STOS
Store the value at the given stack depth index relative to the bottom.
0
is the index of the element at the bottom of the stack.
§Stack Input
[value, index]
§Panics
- Index is out of range.
Drop
Trait Implementations§
Source§impl Ord for Stack
impl Ord for Stack
Source§impl PartialOrd for Stack
impl PartialOrd for Stack
Source§impl TryFromBytes for Stack
impl TryFromBytes for Stack
impl Copy for Stack
impl Eq for Stack
impl StructuralPartialEq for Stack
Auto Trait Implementations§
impl Freeze for Stack
impl RefUnwindSafe for Stack
impl Send for Stack
impl Sync for Stack
impl Unpin for Stack
impl UnwindSafe for Stack
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§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more