pub struct VmScript { /* private fields */ }Expand description
One executable NCS script plus its VM runtime state.
Implementations§
Source§impl VmScript
impl VmScript
Sourcepub fn from_instructions(
instructions: Vec<NcsInstruction>,
label: impl Into<String>,
) -> Self
pub fn from_instructions( instructions: Vec<NcsInstruction>, label: impl Into<String>, ) -> Self
Builds a runnable script from decoded instructions.
Sourcepub fn from_bytes_with_ndb(
bytes: &[u8],
label: impl Into<String>,
ndb: &Ndb,
) -> Result<Self, VmError>
pub fn from_bytes_with_ndb( bytes: &[u8], label: impl Into<String>, ndb: &Ndb, ) -> Result<Self, VmError>
Sourcepub fn current_instruction(&self) -> Option<&NcsInstruction>
pub fn current_instruction(&self) -> Option<&NcsInstruction>
Returns the decoded instruction at the current instruction pointer.
Sourcepub fn instruction_at(&self, offset: usize) -> Option<&NcsInstruction>
pub fn instruction_at(&self, offset: usize) -> Option<&NcsInstruction>
Returns the decoded instruction at one byte offset, if present.
Sourcepub fn current_function(&self) -> Option<VmFunctionInfo>
pub fn current_function(&self) -> Option<VmFunctionInfo>
Returns the attached debug function that contains the current instruction pointer.
Sourcepub fn function_at(&self, offset: usize) -> Option<VmFunctionInfo>
pub fn function_at(&self, offset: usize) -> Option<VmFunctionInfo>
Returns the attached debug function that contains one byte offset.
Sourcepub fn current_source_location(&self) -> Option<VmSourceLocation>
pub fn current_source_location(&self) -> Option<VmSourceLocation>
Returns the attached source location for the current instruction pointer.
Sourcepub fn source_location_at(&self, offset: usize) -> Option<VmSourceLocation>
pub fn source_location_at(&self, offset: usize) -> Option<VmSourceLocation>
Returns the attached source location for one byte offset.
Sourcepub fn stack_string(&self) -> String
pub fn stack_string(&self) -> String
Returns a compact debugger-oriented stack rendering with ^ at the base
pointer and * at the top stack cell.
Sourcepub fn return_depth(&self) -> usize
pub fn return_depth(&self) -> usize
Returns the current return-frame depth.
Sourcepub fn saved_situation(&self) -> Option<&VmSituation>
pub fn saved_situation(&self) -> Option<&VmSituation>
Returns the last deferred action snapshot captured by STORESTATE.
Sourcepub fn take_saved_situation(&mut self) -> Option<VmSituation>
pub fn take_saved_situation(&mut self) -> Option<VmSituation>
Removes and returns the last deferred action snapshot captured by
STORESTATE.
Sourcepub fn prepare_function_call(
&mut self,
ndb: &Ndb,
name: &str,
args: &[VmValue],
) -> Result<(), VmError>
pub fn prepare_function_call( &mut self, ndb: &Ndb, name: &str, args: &[VmValue], ) -> Result<(), VmError>
Configures this script to call one named user function directly.
This bypasses the compiler-emitted loader.
If the script uses globals, the caller must initialize the loader/global frame first before invoking a named function directly.
§Errors
Returns VmError if the function cannot be found or the argument
types are unsupported.
Sourcepub fn function_return_value(
&self,
ndb: &Ndb,
name: &str,
) -> Result<Option<VmValue>, VmError>
pub fn function_return_value( &self, ndb: &Ndb, name: &str, ) -> Result<Option<VmValue>, VmError>
Sourcepub fn abort(&mut self)
pub fn abort(&mut self)
Requests that this script abort once control returns to the VM dispatcher.
Sourcepub fn push_float(&mut self, value: f32)
pub fn push_float(&mut self, value: f32)
Pushes one floating-point value.
Sourcepub fn push_string(&mut self, value: impl Into<String>)
pub fn push_string(&mut self, value: impl Into<String>)
Pushes one string value.
Sourcepub fn push_object(&mut self, value: VmObjectId)
pub fn push_object(&mut self, value: VmObjectId)
Pushes one object id.
Sourcepub fn push_engine_structure(
&mut self,
index: u8,
value: VmEngineStructureValue,
)
pub fn push_engine_structure( &mut self, index: u8, value: VmEngineStructureValue, )
Pushes one engine-structure value.
Sourcepub fn push_vector(&mut self, value: [f32; 3])
pub fn push_vector(&mut self, value: [f32; 3])
Pushes one vector value as three stack cells in x, y, z order.