pub struct CompiledScript {Show 16 fields
pub name: String,
pub id: i32,
pub trigger: String,
pub source_path: String,
pub lookup_key: i32,
pub param_types: Vec<Type>,
pub instructions: Vec<Instruction>,
pub local_table: LocalTable,
pub int_local_count: u16,
pub string_local_count: u16,
pub long_local_count: u16,
pub int_arg_count: u16,
pub string_arg_count: u16,
pub long_arg_count: u16,
pub strings: Vec<Box<str>>,
pub switch_tables: Vec<Box<[(i32, usize)]>>,
}Expand description
Compiled bytecode for a single script.
Fields§
§name: String§id: i32§trigger: String§source_path: String§lookup_key: i32Lookup key for fast engine dispatch (-1 if not applicable).
param_types: Vec<Type>§instructions: Vec<Instruction>§local_table: LocalTable§int_local_count: u16§string_local_count: u16§long_local_count: u16§int_arg_count: u16§string_arg_count: u16§long_arg_count: u16§strings: Vec<Box<str>>String-literal / unknown-command-name payloads, referenced by
Operand::Str(index). Kept out of the instruction so Operand stays 8 B.
switch_tables: Vec<Box<[(i32, usize)]>>Switch-case tables (case_value, jump_target), referenced by
Operand::SwitchTable(index). Stored in instruction-encounter order.
Implementations§
Source§impl CompiledScript
impl CompiledScript
pub fn new(name: String, id: i32) -> Self
pub fn push(&mut self, instruction: Instruction)
Sourcepub fn intern_str(&mut self, value: String) -> u32
pub fn intern_str(&mut self, value: String) -> u32
Add a string payload to the pool and return its Operand::Str index.
Sourcepub fn push_string(&mut self, value: String)
pub fn push_string(&mut self, value: String)
Emit a PushConstantString whose literal is interned into the pool.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn patch_jump(&mut self, index: usize, target: usize)
pub fn patch_jump(&mut self, index: usize, target: usize)
Update a jump target at the given instruction index.
Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Release the spare capacity the growable codegen buffers left behind.
Compiled scripts are immutable after codegen but are held in memory for
the whole pointer-check + write phase, so reclaiming each Vec’s doubling
slack (often 25-50%) meaningfully lowers the resident footprint.