pub struct Builder<'a, T: 'a + Debug + PartialEq> {
pub instruction_table: &'a InstructionTable<T>,
pub instructions: Vec<usize>,
pub labels: WriteOnceTable<usize>,
pub data: Vec<T>,
}Expand description
The builder struct.
Contains:
- an
InstructionTable. - a list of instructions that have been pushed into this builder.
- a
Tableof labels used for jumping. - a list of
Tto be stored in the builder’s data section.
Fields§
§instruction_table: &'a InstructionTable<T>§instructions: Vec<usize>§labels: WriteOnceTable<usize>§data: Vec<T>Implementations§
Source§impl<'a, T: Debug + PartialEq> Builder<'a, T>
impl<'a, T: Debug + PartialEq> Builder<'a, T>
Sourcepub fn new(instruction_table: &'a InstructionTable<T>) -> Builder<'_, T>
pub fn new(instruction_table: &'a InstructionTable<T>) -> Builder<'_, T>
Create a new Builder from an InstructionTable.
Sourcepub fn push(&mut self, name: &str, args: Vec<T>)
pub fn push(&mut self, name: &str, args: Vec<T>)
Push an instruction into the code.
nameshould match that of an instruction in theInstructionTable.argsa vector of operands to be pushed into the builder’s data section.
Sourcepub fn label(&mut self, name: &str)
pub fn label(&mut self, name: &str)
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.
Trait Implementations§
Auto Trait Implementations§
impl<'a, T> Freeze for Builder<'a, T>
impl<'a, T> RefUnwindSafe for Builder<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Send for Builder<'a, T>where
T: Send,
impl<'a, T> Sync for Builder<'a, T>where
T: Sync,
impl<'a, T> Unpin for Builder<'a, T>where
T: Unpin,
impl<'a, T> UnwindSafe for Builder<'a, T>where
T: UnwindSafe,
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
Mutably borrows from an owned value. Read more