pub struct RegChunk {
pub code: Vec<RegInstruction>,
pub constants: Vec<JsValue>,
pub names: Vec<String>,
pub locals: Vec<RegLocal>,
pub register_count: u32,
}Expand description
A compiled chunk of register bytecode with its constant pool.
Fields§
§code: Vec<RegInstruction>The register bytecode instructions.
constants: Vec<JsValue>Constant pool — holds literal values.
names: Vec<String>Deduplicated name table for variable/property names.
locals: Vec<RegLocal>Local register table (name index -> register index).
register_count: u32Register count required by this chunk.
Implementations§
Source§impl RegChunk
impl RegChunk
pub fn new() -> Self
Sourcepub fn emit(&mut self, instr: RegInstruction) -> usize
pub fn emit(&mut self, instr: RegInstruction) -> usize
Emit an instruction and return its index.
Sourcepub fn add_constant(&mut self, value: JsValue) -> u32
pub fn add_constant(&mut self, value: JsValue) -> u32
Add a constant to the pool and return its index.
Sourcepub fn add_name(&mut self, s: &str) -> u32
pub fn add_name(&mut self, s: &str) -> u32
Add a name to the deduplicated name table and return its index.
Sourcepub fn add_local(&mut self, name_idx: u32, reg: u32) -> u32
pub fn add_local(&mut self, name_idx: u32, reg: u32) -> u32
Add a local register for a name index and return its local index.
Sourcepub fn get_local_name(&self, local_idx: u32) -> &str
pub fn get_local_name(&self, local_idx: u32) -> &str
Get a local register’s name.
Sourcepub fn set_register_count(&mut self, count: u32)
pub fn set_register_count(&mut self, count: u32)
Update the register count for this chunk.
Sourcepub fn disassemble(&self, name: &str) -> String
pub fn disassemble(&self, name: &str) -> String
Disassemble the chunk for debugging.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RegChunk
impl !RefUnwindSafe for RegChunk
impl !Send for RegChunk
impl !Sync for RegChunk
impl Unpin for RegChunk
impl !UnwindSafe for RegChunk
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