pub struct Bytecode {Show 13 fields
pub version: u8,
pub entrypoint: RefFun,
pub ints: Vec<i32>,
pub floats: Vec<f64>,
pub strings: Vec<Str>,
pub bytes: Option<(Vec<u8>, Vec<usize>)>,
pub debug_files: Option<Vec<Str>>,
pub types: Vec<Type>,
pub globals: Vec<RefType>,
pub natives: Vec<Native>,
pub functions: Vec<Function>,
pub constants: Option<Vec<ConstantDef>>,
pub globals_initializers: HashMap<RefGlobal, usize>,
/* private fields */
}
Expand description
Bytecode structure containing all the information. Every field is public for flexibility, but you aren’t encouraged to modify them.
This type is like an arena, you usually work with custom
Fields§
§version: u8
Bytecode format version
entrypoint: RefFun
Program entrypoint
ints: Vec<i32>
i32 constant pool
floats: Vec<f64>
f64 constant pool
strings: Vec<Str>
String constant pool
bytes: Option<(Vec<u8>, Vec<usize>)>
Bytes constant pool
Since bytecode v5
debug_files: Option<Vec<Str>>
Debug file names constant pool
types: Vec<Type>
Types, contains every possible types expressed in the program
globals: Vec<RefType>
Globals, holding static variables and such
natives: Vec<Native>
Native functions references
functions: Vec<Function>
Code functions pool
constants: Option<Vec<ConstantDef>>
Constants, initializers for globals
Since bytecode v4
globals_initializers: HashMap<RefGlobal, usize>
Implementations§
source§impl Bytecode
impl Bytecode
sourcepub fn entrypoint(&self) -> &Function
pub fn entrypoint(&self) -> &Function
Get the entrypoint function.
sourcepub fn main(&self) -> &Function
pub fn main(&self) -> &Function
Get the main function. This will panic if there is no main function in the bytecode (there should always be one)
sourcepub fn function_by_name(&self, name: &str) -> Option<&Function>
pub fn function_by_name(&self, name: &str) -> Option<&Function>
Get a function by its name.
pub fn findex_max(&self) -> usize
pub fn functions<'a>(&'a self) -> impl Iterator<Item = FunPtr<'a>> + 'a
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Bytecode
impl Send for Bytecode
impl Sync for Bytecode
impl Unpin for Bytecode
impl UnwindSafe for Bytecode
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