pub struct Chunk {
pub constants: Vec<Const>,
pub code: Vec<u8>,
pub functions: Vec<FuncMeta>,
pub top_locals: u16,
}Expand description
A compiled bytecode chunk — the unit of compilation and execution.
Fields§
§constants: Vec<Const>Constant pool (strings, IRIs).
code: Vec<u8>Bytecode instructions.
functions: Vec<FuncMeta>User-defined function metadata.
top_locals: u16Module-level local count (for top-level execution).
Implementations§
Source§impl Chunk
impl Chunk
Sourcepub fn add_string(&mut self, s: &str) -> u16
pub fn add_string(&mut self, s: &str) -> u16
Add a string constant and return its index.
Sourcepub fn find_function(&self, name: &str) -> Option<u16>
pub fn find_function(&self, name: &str) -> Option<u16>
Find a function by name. Returns its index in functions.
Sourcepub fn current_offset(&self) -> u16
pub fn current_offset(&self) -> u16
Current code offset (where the next instruction will be emitted).
Trait Implementations§
impl StructuralPartialEq for Chunk
Auto Trait Implementations§
impl Freeze for Chunk
impl RefUnwindSafe for Chunk
impl Send for Chunk
impl Sync for Chunk
impl Unpin for Chunk
impl UnsafeUnpin for Chunk
impl UnwindSafe for Chunk
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