[−][src]Struct stack_vm::Builder
The builder struct.
Contains:
- an
InstructionTable
. - a list of instructions that have been pushed into this builder.
- a
Table
of labels used for jumping. - a list of
T
to be stored in the builder's data section.
Fields
instruction_table: &'a InstructionTable<T>
instructions: Vec<usize>
labels: WriteOnceTable<usize>
data: Vec<T>
Methods
impl<'a, T: Debug + PartialEq> Builder<'a, T>
[src]
pub fn new(instruction_table: &'a InstructionTable<T>) -> Builder<T>
[src]
Create a new Builder
from an InstructionTable
.
pub fn push(&mut self, name: &str, args: Vec<T>)
[src]
Push an instruction into the code.
name
should match that of an instruction in theInstructionTable
.args
a vector of operands to be pushed into the builder's data section.
pub fn label(&mut self, name: &str)
[src]
Insert a label at this point in the code.
Labels are used as targets for jumps. When you call this method a label is stored which points to the position of the next instruction.
pub fn len(&self) -> usize
[src]
Return the length of the instructions vector.
i.e. the number of instructions pushed so far.
pub fn is_empty(&self) -> bool
[src]
Return whether the Builder contains any instructions.
Trait Implementations
impl<'a, T: Debug + PartialEq> From<Builder<'a, T>> for Code<T>
[src]
fn from(builder: Builder<T>) -> Code<T>
[src]
Convert a Builder
into Code
.
This function consumes the builder and returns a Code
.
impl<'a, T: 'a + Debug + PartialEq> Debug for Builder<'a, T>
[src]
Auto Trait Implementations
impl<'a, T> Send for Builder<'a, T> where
T: Send,
T: Send,
impl<'a, T> Sync for Builder<'a, T> where
T: Sync,
T: Sync,
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,