Struct stack_vm::Builder
[−]
[src]
pub struct Builder<'a, T: 'a + Debug> { pub instruction_table: &'a InstructionTable<T>, pub instructions: Vec<usize>, pub labels: WriteOnceTable<usize>, pub data: Vec<T>, }
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> Builder<'a, T>
[src]
fn new(instruction_table: &'a InstructionTable<T>) -> Builder<T>
[src]
Create a new Builder
from an InstructionTable
.
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.
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.
fn len(&self) -> usize
[src]
Return the length of the instructions vector.
i.e. the number of instructions pushed so far.