pub struct Chunk {
pub code: Vec<u8>,
pub constants: Vec<Value>,
pub lines: Vec<usize>,
pub identifiers: Vec<String>,
}
Expand description
A chunk of bytecode representing a compiled program
Fields§
§code: Vec<u8>
The actual bytecode instructions
constants: Vec<Value>
Constant values used by the program
lines: Vec<usize>
Source code line numbers for debugging
identifiers: Vec<String>
Variable and function names used in the program
Implementations§
Source§impl Chunk
impl Chunk
Sourcepub fn write_byte(&mut self, byte: u8, line: usize)
pub fn write_byte(&mut self, byte: u8, line: usize)
Sourcepub fn write_op(&mut self, op: OpCode, line: usize)
pub fn write_op(&mut self, op: OpCode, line: usize)
Writes an opcode to the chunk
§Arguments
op
- The opcode to writeline
- The source code line number
Sourcepub fn add_constant(&mut self, value: Value) -> usize
pub fn add_constant(&mut self, value: Value) -> usize
Sourcepub fn add_identifier(&mut self, name: String) -> usize
pub fn add_identifier(&mut self, name: String) -> usize
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Chunk
impl RefUnwindSafe for Chunk
impl Send for Chunk
impl Sync for Chunk
impl Unpin 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