pub struct Program<'sym> {
pub version: String,
pub code: Vec<Instr<'sym>>,
}Expand description
Executable program containing bytecode instructions.
Programs reference symbols from a SymTable and can be serialized
to binary format for storage or transmission.
Fields§
§version: String§code: Vec<Instr<'sym>>Implementations§
Source§impl<'sym> Program<'sym>
impl<'sym> Program<'sym>
Sourcepub fn compile(&self) -> Result<Vec<u8>, ProgramError>
pub fn compile(&self) -> Result<Vec<u8>, ProgramError>
Compiles the program to binary format for serialization.
Sourcepub fn load(
data: &[u8],
table: &'sym SymTable,
) -> Result<Program<'sym>, ProgramError>
pub fn load( data: &[u8], table: &'sym SymTable, ) -> Result<Program<'sym>, ProgramError>
Loads a program from binary data with the given symbol table.
The binary data must have been created with compile.
Sourcepub fn get_assembly(&self) -> String
pub fn get_assembly(&self) -> String
Returns a human-readable assembly representation of the program.
Trait Implementations§
Auto Trait Implementations§
impl<'sym> Freeze for Program<'sym>
impl<'sym> RefUnwindSafe for Program<'sym>
impl<'sym> Send for Program<'sym>
impl<'sym> Sync for Program<'sym>
impl<'sym> Unpin for Program<'sym>
impl<'sym> UnwindSafe for Program<'sym>
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