slvm::vm

Struct GVm

Source
pub struct GVm<ENV> { /* private fields */ }

Implementations§

Source§

impl<ENV> GVm<ENV>

Source

pub fn clear_err_frame(&mut self)

Source

pub fn err_frame(&self) -> &Option<CallFrame>

Source

pub fn get_registers(&self, start: usize, end: usize) -> &[Value]

Source

pub fn get_current_registers(&self) -> &[Value]

Source

pub fn get_stack(&self, idx: usize) -> Value

Source

pub fn stack_max(&self) -> usize

Source

pub fn get_interned(&self, i: Interned) -> &'static str

Source

pub fn intern_static(&mut self, string: &'static str) -> Interned

Source

pub fn intern(&mut self, string: &str) -> Interned

Source

pub fn get_if_interned(&self, string: &str) -> Option<Interned>

Source

pub fn set_global(&mut self, slot: u32, value: Value)

Source

pub fn reserve_global(&mut self) -> u32

Source

pub fn get_call_stack(&self) -> CallStackIter<'_, ENV>

Source

pub fn sizeof_heap_object() -> usize

Source

pub fn alloc_pair(&mut self, car: Value, cdr: Value) -> Value

Source

pub fn alloc_pair_ro(&mut self, car: Value, cdr: Value) -> Value

Source

pub fn alloc_string(&mut self, s: String) -> Value

Source

pub fn alloc_string_ro(&mut self, s: String) -> Value

Source

pub fn alloc_char(&mut self, ch: &str) -> Value

Source

pub fn alloc_vector(&mut self, v: Vec<Value>) -> Value

Source

pub fn alloc_vector_ro(&mut self, v: Vec<Value>) -> Value

Source

pub fn alloc_map(&mut self, map: VMHashMap) -> Value

Source

pub fn alloc_map_ro(&mut self, map: VMHashMap) -> Value

Source

pub fn alloc_list_ro(&mut self, v: Vec<Value>) -> Value

Source

pub fn alloc_bytes(&mut self, v: Vec<u8>) -> Value

Source

pub fn alloc_lambda(&mut self, l: Arc<Chunk>) -> Value

Source

pub fn alloc_closure(&mut self, l: Arc<Chunk>, v: Vec<Handle>) -> Value

Source

pub fn alloc_continuation(&mut self, k: Continuation) -> Value

Source

pub fn alloc_callframe(&mut self, frame: CallFrame) -> Value

Source

pub fn alloc_value(&mut self, val: Value) -> Value

Allocate a Value on the heap. Moving a value to the heap is useful for captured variable for instance.

Source

pub fn alloc_error(&mut self, err: Error) -> Value

Allocate an Error on the heap.

Source

pub fn alloc_io(&mut self, io: HeapIo) -> Value

Allocate a Value on the heap. Moving a value to the heap is useful for captured variable for instance.

Source

pub fn heap_immutable(&mut self, val: Value)

Source

pub fn heap_sticky(&mut self, val: Value)

Source

pub fn heap_unsticky(&mut self, val: Value)

Source

pub fn pause_gc(&mut self)

Pause garbage collection. Each pause_gc must have an unpause_gc before GC resumes (it is a counter that must be 0).

Source

pub fn unpause_gc(&mut self)

UnPause garbage collection. Each pause_gc must have an unpause_gc before GC resumes (it is a counter that must be 0).

Source

pub fn get_heap_property(&self, key_val: Value, prop: &str) -> Option<Value>

Source

pub fn set_heap_property(&mut self, key_val: Value, prop: &str, value: Value)

Source

pub fn get_heap_property_interned( &self, key_val: Value, prop: Interned, ) -> Option<Value>

Source

pub fn set_heap_property_interned( &mut self, key_val: Value, prop: Interned, value: Value, )

Source

pub fn get_global_property(&self, global: u32, prop: Interned) -> Option<Value>

Source

pub fn set_global_property(&mut self, global: u32, prop: Interned, value: Value)

Source

pub fn get_global(&self, idx: u32) -> Value

Source

pub fn get_string(&self, handle: Handle) -> &str

Source

pub fn get_string_mut(&mut self, handle: Handle) -> VMResult<&mut String>

Source

pub fn get_vector(&self, handle: Handle) -> &[Value]

Source

pub fn get_vector_mut(&mut self, handle: Handle) -> VMResult<&mut Vec<Value>>

Source

pub fn get_map(&self, handle: Handle) -> &VMHashMap

Source

pub fn get_map_mut(&mut self, handle: Handle) -> VMResult<&mut VMHashMap>

Source

pub fn get_bytes(&self, handle: Handle) -> &[u8]

Source

pub fn get_pair(&self, handle: Handle) -> (Value, Value)

Source

pub fn get_pair_mut( &mut self, handle: Handle, ) -> VMResult<(&mut Value, &mut Value)>

Source

pub fn get_pair_mut_override( &mut self, handle: Handle, ) -> (&mut Value, &mut Value)

Source

pub fn get_lambda(&self, handle: Handle) -> Arc<Chunk>

Source

pub fn get_closure(&self, handle: Handle) -> (Arc<Chunk>, &[Handle])

Source

pub fn get_continuation(&self, handle: Handle) -> &Continuation

Source

pub fn get_callframe(&self, handle: Handle) -> &CallFrame

Source

pub fn get_value(&self, handle: Handle) -> Value

Source

pub fn get_value_mut(&mut self, handle: Handle) -> &mut Value

Source

pub fn get_error(&self, handle: Handle) -> Error

Source

pub fn get_io(&self, handle: Handle) -> &HeapIo

Source

pub fn new_upval(&mut self, val: Value) -> Value

Source

pub fn call_frame(&self) -> Option<&CallFrame>

Source

pub fn make_err(&mut self, key: &'static str, data: Value) -> Value

Source§

impl<ENV> GVm<ENV>

Source

pub fn make_call( &mut self, lambda: Value, chunk: Arc<Chunk>, first_reg: u16, num_args: u16, tail_call: bool, ) -> Result<Arc<Chunk>, (VMError, Arc<Chunk>)>

Main function to match and execute anything that is callable.

Source§

impl GVm<()>

Source

pub fn new() -> Self

Source§

impl<ENV> GVm<ENV>

Source

pub fn new_with_env(env: ENV) -> Self

Source

pub fn this_fn(&self) -> Option<Value>

Source

pub fn stack(&self, idx: usize) -> Value

Source

pub fn stack_mut(&mut self, idx: usize) -> &mut Value

Source

pub fn stack_slice(&self) -> &[Value]

Source

pub fn stack_slice_mut(&mut self) -> &mut [Value]

Source

pub fn register(&self, idx: usize) -> Value

Return the register for idx.

Source

pub fn register_slice<'b>(&self) -> &'b [Value]

Source

pub fn register_int(&self, idx: usize) -> VMResult<i64>

Return the int representation of register idx or error if not an integral type.

Source

pub fn register_unref(&self, idx: usize) -> Value

Return the current register for idx, if it is stored on heap then dereference it first.

Source

pub fn register_mut<'b>(&self, idx: usize) -> &'b mut Value

Source

pub fn env(&self) -> &ENV

Source

pub fn env_mut(&mut self) -> &mut ENV

Source

pub fn add_builtin(&mut self, func: CallFuncSig<ENV>) -> Value

Source

pub fn get_builtin(&self, idx: u32) -> &CallFuncSig<ENV>

Return the builtin function at idx. Note, will panic if idx is not a valid builtin index.

Source

pub fn is_equal_pair(&self, val1: Value, val2: Value) -> VMResult<Value>

Source

pub fn do_call( &mut self, chunk: Arc<Chunk>, params: &[Value], caps: Option<&[Handle]>, ) -> VMResult<Value>

Runs a lambda. Will save and restore the VM state even on error, chunk is expected to be a callable with params and any captures (closure) in caps. This is useful for macro expansion, eval and things like that. It can be safely used while the VM is currently executing bytecode.

Source

pub fn execute(&mut self, chunk: Arc<Chunk>) -> VMResult<Value>

Executes chunk. Will save the current VM state and restore on success or leave it on error. This allows a debugger to work with the “broken” image.

Source

pub fn reset(&mut self)

Reset the VM to default settings. Useful for cleaning up if you want to abort an execute() that errored out.

Trait Implementations§

Source§

impl Default for GVm<()>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<ENV> Freeze for GVm<ENV>
where ENV: Freeze,

§

impl<ENV> RefUnwindSafe for GVm<ENV>
where ENV: RefUnwindSafe,

§

impl<ENV> !Send for GVm<ENV>

§

impl<ENV> !Sync for GVm<ENV>

§

impl<ENV> Unpin for GVm<ENV>
where ENV: Unpin,

§

impl<ENV> UnwindSafe for GVm<ENV>
where ENV: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.