pub struct Vm { /* private fields */ }Expand description
One command-dispatch table used to execute ACTION opcodes.
Implementations§
Source§impl Vm
impl Vm
Sourcepub fn define_command<F>(&mut self, command: u16, handler: F)
pub fn define_command<F>(&mut self, command: u16, handler: F)
Registers one command handler by its numeric action id.
Sourcepub fn define_simple_command<F>(&mut self, command: u16, handler: F)
pub fn define_simple_command<F>(&mut self, command: u16, handler: F)
Registers one zero-metadata command handler.
Sourcepub fn define_engine_structure<F>(&mut self, index: u8, factory: F)
pub fn define_engine_structure<F>(&mut self, index: u8, factory: F)
Registers one engine-structure default factory by its numeric type index.
Sourcepub fn define_engine_structure_default(
&mut self,
index: u8,
value: VmEngineStructureValue,
)
pub fn define_engine_structure_default( &mut self, index: u8, value: VmEngineStructureValue, )
Registers one fixed default engine-structure value by its numeric type index.
Sourcepub fn define_engine_structure_comparer<F>(&mut self, index: u8, comparer: F)
pub fn define_engine_structure_comparer<F>(&mut self, index: u8, comparer: F)
Registers one engine-structure equality hook by its numeric type index.
Sourcepub fn define_trace_hook<F>(&mut self, hook: F)
pub fn define_trace_hook<F>(&mut self, hook: F)
Registers one instruction trace hook invoked before each opcode executes.
Sourcepub fn clear_trace_hook(&mut self)
pub fn clear_trace_hook(&mut self)
Removes the currently registered instruction trace hook.
Sourcepub fn run_until_offset(
&self,
script: &mut VmScript,
offset: usize,
options: VmRunOptions,
) -> Result<VmStepOutcome, VmError>
pub fn run_until_offset( &self, script: &mut VmScript, offset: usize, options: VmRunOptions, ) -> Result<VmStepOutcome, VmError>
Continues execution until the script is about to execute the instruction
at offset.
If the script reaches the requested offset, this returns
VmStepOutcome::Running without executing that instruction.
§Errors
Returns VmError if execution fails or exceeds the configured
instruction budget.
Sourcepub fn step_over(
&self,
script: &mut VmScript,
options: VmRunOptions,
) -> Result<VmStepOutcome, VmError>
pub fn step_over( &self, script: &mut VmScript, options: VmRunOptions, ) -> Result<VmStepOutcome, VmError>
Executes the current instruction, stepping over user-function calls.
For non-JSR instructions this behaves like Vm::step. For JSR, it
runs until control returns to the caller, preserving a debugger-friendly
“step over” behavior.
§Errors
Returns VmError if execution fails or exceeds the configured
instruction budget.
Sourcepub fn step_out(
&self,
script: &mut VmScript,
options: VmRunOptions,
) -> Result<VmStepOutcome, VmError>
pub fn step_out( &self, script: &mut VmScript, options: VmRunOptions, ) -> Result<VmStepOutcome, VmError>
Sourcepub fn run_until_line(
&self,
script: &mut VmScript,
file_name: &str,
line_number: usize,
options: VmRunOptions,
) -> Result<VmStepOutcome, VmError>
pub fn run_until_line( &self, script: &mut VmScript, file_name: &str, line_number: usize, options: VmRunOptions, ) -> Result<VmStepOutcome, VmError>
Continues execution until the script is about to execute one instruction
mapped to file_name:line_number in attached NDB metadata.
If the script reaches the requested line, this returns
VmStepOutcome::Running without executing that instruction.
§Errors
Returns VmError if the script has no matching debug mapping,
execution fails, or the instruction budget is exceeded.
Sourcepub fn run_until_function(
&self,
script: &mut VmScript,
name: &str,
options: VmRunOptions,
) -> Result<VmStepOutcome, VmError>
pub fn run_until_function( &self, script: &mut VmScript, name: &str, options: VmRunOptions, ) -> Result<VmStepOutcome, VmError>
Continues execution until the script is about to execute one instruction
inside the named function from attached NDB metadata.
If the script reaches the requested function, this returns
VmStepOutcome::Running without executing that instruction.
§Errors
Returns VmError if the script has no matching debug mapping,
execution fails, or the instruction budget is exceeded.
Sourcepub fn run_with_options(
&self,
script: &mut VmScript,
options: VmRunOptions,
) -> Result<(), VmError>
pub fn run_with_options( &self, script: &mut VmScript, options: VmRunOptions, ) -> Result<(), VmError>
Sourcepub fn run_situation(
&self,
situation: &VmSituation,
) -> Result<VmScript, VmError>
pub fn run_situation( &self, situation: &VmSituation, ) -> Result<VmScript, VmError>
Sourcepub fn run_situation_with_options(
&self,
situation: &VmSituation,
options: VmRunOptions,
) -> Result<VmScript, VmError>
pub fn run_situation_with_options( &self, situation: &VmSituation, options: VmRunOptions, ) -> Result<VmScript, VmError>
Sourcepub fn run_bytes(
&self,
bytes: &[u8],
label: impl Into<String>,
) -> Result<VmScript, VmError>
pub fn run_bytes( &self, bytes: &[u8], label: impl Into<String>, ) -> Result<VmScript, VmError>
Sourcepub fn run_bytes_with_options(
&self,
bytes: &[u8],
label: impl Into<String>,
options: VmRunOptions,
) -> Result<VmScript, VmError>
pub fn run_bytes_with_options( &self, bytes: &[u8], label: impl Into<String>, options: VmRunOptions, ) -> Result<VmScript, VmError>
Sourcepub fn run_bytes_with_ndb(
&self,
bytes: &[u8],
label: impl Into<String>,
ndb: &Ndb,
) -> Result<VmScript, VmError>
pub fn run_bytes_with_ndb( &self, bytes: &[u8], label: impl Into<String>, ndb: &Ndb, ) -> Result<VmScript, VmError>
Decodes one script, attaches one NDB table, runs it, and returns the
finished runtime state.
This is the recommended path for compiled scripts that contain
user-function calls, because the VM uses NDB metadata to recover
callee stack shapes.
§Errors
Returns VmError if decoding, metadata attachment, or execution
fails.