pub struct Vm<'a, Aux = ()>where
Aux: 'a,{
pub auxiliary_data: Aux,
pub max_instr: u64,
pub remaining_iters: u64,
pub runtime_data: Pin<Box<RuntimeData>>,
/* private fields */
}Expand description
Cao-Lang bytecode interpreter.
Aux is an auxiliary runtime structure passed to custom functions.
Fields§
§auxiliary_data: Aux§max_instr: u64Number of instructions run will execute before returning Timeout
remaining_iters: u64§runtime_data: Pin<Box<RuntimeData>>Implementations§
Source§impl<'a, Aux> Vm<'a, Aux>
impl<'a, Aux> Vm<'a, Aux>
pub fn new(auxiliary_data: Aux) -> Result<Self, ExecutionErrorPayload>where
Aux: 'static,
pub fn register_native_stdlib(&mut self) -> Result<(), ExecutionErrorPayload>where
Aux: 'static,
Sourcepub fn insert_value(
&mut self,
value: &OwnedValue,
) -> Result<Value, ExecutionErrorPayload>
pub fn insert_value( &mut self, value: &OwnedValue, ) -> Result<Value, ExecutionErrorPayload>
Inserts the given value into the VM’s runtime memory. Returns the inserted [Value]
pub fn init_native_function( &mut self, handle: Handle, ) -> Result<ObjectGcGuard, ExecutionErrorPayload>
pub fn init_function( &mut self, handle: Handle, arity: u32, ) -> Result<ObjectGcGuard, ExecutionErrorPayload>
pub fn init_closure( &mut self, handle: Handle, arity: u32, ) -> Result<ObjectGcGuard, ExecutionErrorPayload>
pub fn init_upvalue( &mut self, location: *mut Value, ) -> Result<ObjectGcGuard, ExecutionErrorPayload>
pub fn clear(&mut self)
pub fn read_var_by_name(&self, name: &str, vars: &Variables) -> Option<Value>
pub fn read_var(&self, name: VariableId) -> Option<Value>
pub fn with_max_iter(self, max_iter: u64) -> Self
pub fn get_aux(&self) -> &Aux
pub fn get_aux_mut(&mut self) -> &mut Aux
pub fn unwrap_aux(self) -> Aux
Sourcepub fn register_native_function<S, C>(
&mut self,
name: S,
f: C,
) -> Result<(), ExecutionErrorPayload>
pub fn register_native_function<S, C>( &mut self, name: S, f: C, ) -> Result<(), ExecutionErrorPayload>
Register a native function for use by Cao-Lang programs
pub fn stack_push<S>(&mut self, value: S) -> Result<(), ExecutionErrorPayload>
pub fn stack_pop(&mut self) -> Value
pub fn get_table( &self, value: Value, ) -> Result<&CaoLangTable, ExecutionErrorPayload>
pub fn get_table_mut( &self, value: Value, ) -> Result<&mut CaoLangTable, ExecutionErrorPayload>
Sourcepub fn init_table(&mut self) -> Result<ObjectGcGuard, ExecutionErrorPayload>
pub fn init_table(&mut self) -> Result<ObjectGcGuard, ExecutionErrorPayload>
Initializes a new FieldTable in this VM instance
Sourcepub fn init_string(
&mut self,
payload: &str,
) -> Result<ObjectGcGuard, ExecutionErrorPayload>
pub fn init_string( &mut self, payload: &str, ) -> Result<ObjectGcGuard, ExecutionErrorPayload>
Initializes a new string owned by this VM instance
Sourcepub fn run_function(
&mut self,
val: Value,
) -> Result<Value, ExecutionErrorPayload>
pub fn run_function( &mut self, val: Value, ) -> Result<Value, ExecutionErrorPayload>
Panics if no current program has been set
Sourcepub fn run(&mut self, program: &CaoCompiledProgram) -> ExecutionResult<()>
pub fn run(&mut self, program: &CaoCompiledProgram) -> ExecutionResult<()>
This mostly assumes that program is valid, produced by the compiler. As such running non-compiler emitted programs is very un-safe
Auto Trait Implementations§
impl<'a, Aux> Freeze for Vm<'a, Aux>where
Aux: Freeze,
impl<'a, Aux = ()> !RefUnwindSafe for Vm<'a, Aux>
impl<'a, Aux = ()> !Send for Vm<'a, Aux>
impl<'a, Aux = ()> !Sync for Vm<'a, Aux>
impl<'a, Aux> Unpin for Vm<'a, Aux>where
Aux: Unpin,
impl<'a, Aux = ()> !UnwindSafe for Vm<'a, Aux>
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