Struct Store

Source
pub struct Store<'b> {
    pub functions: Vec<FuncInst>,
    pub memories: Vec<MemInst>,
    pub globals: Vec<GlobalInst>,
    pub data: Vec<DataInst>,
    pub tables: Vec<TableInst>,
    pub elements: Vec<ElemInst>,
    pub modules: Vec<ModuleInst<'b>>,
    pub module_names: BTreeMap<String, usize>,
}
Expand description

The store represents all global state that can be manipulated by WebAssembly programs. It consists of the runtime representation of all instances of functions, tables, memories, and globals, element segments, and data segments that have been allocated during the life time of the abstract machine. https://webassembly.github.io/spec/core/exec/runtime.html#store

Fields§

§functions: Vec<FuncInst>§memories: Vec<MemInst>§globals: Vec<GlobalInst>§data: Vec<DataInst>§tables: Vec<TableInst>§elements: Vec<ElemInst>§modules: Vec<ModuleInst<'b>>§module_names: BTreeMap<String, usize>

Implementations§

Source§

impl<'b> Store<'b>

Source

pub fn add_module( &mut self, name: &str, validation_info: &ValidationInfo<'b>, ) -> CustomResult<()>

instantiates a validated module with validation_info as validation evidence with name name with the steps in https://webassembly.github.io/spec/core/exec/modules.html#instantiation this method roughly matches the suggested embedder functionmodule_instantiate https://webassembly.github.io/spec/core/appendix/embedding.html#modules except external values for module instantiation are retrieved from self.

Source

fn alloc_func( &mut self, func: (usize, (Span, usize)), module_inst: &ModuleInst<'_>, module_addr: usize, ) -> usize

roughly matches https://webassembly.github.io/spec/core/exec/modules.html#functions with the addition of sidetable pointer to the input signature

Source

fn alloc_table(&mut self, table_type: TableType, reff: Ref) -> usize

Source

fn alloc_mem(&mut self, mem_type: MemType) -> usize

Source

fn alloc_global(&mut self, global_type: GlobalType, val: Value) -> usize

Source

fn alloc_elem(&mut self, ref_type: RefType, refs: Vec<Ref>) -> usize

Source

fn alloc_data(&mut self, bytes: &[u8]) -> usize

Source

pub fn invoke<Param: InteropValueList, Returns: InteropValueList>( &mut self, func_addr: usize, params: Param, ) -> Result<Returns, RuntimeError>

Source

pub fn invoke_dynamic( &mut self, func_addr: usize, params: Vec<Value>, ret_types: &[ValType], ) -> Result<Vec<Value>, RuntimeError>

Source

pub fn invoke_dynamic_unchecked_return_ty( &mut self, func_addr: usize, params: Vec<Value>, ) -> Result<Vec<Value>, RuntimeError>

Source

pub fn get_module_idx_from_name( &self, module_name: &str, ) -> Result<usize, RuntimeError>

Source

pub fn get_global_function_idx_by_name( &self, module_addr: usize, function_name: &str, ) -> Option<usize>

Source

pub fn register_alias(&mut self, alias_name: String, module_idx: usize)

Source

pub fn lookup_function( &self, target_module: &str, target_function: &str, ) -> Option<usize>

Trait Implementations§

Source§

impl<'b> Debug for Store<'b>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'b> Default for Store<'b>

Source§

fn default() -> Store<'b>

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

Auto Trait Implementations§

§

impl<'b> Freeze for Store<'b>

§

impl<'b> !RefUnwindSafe for Store<'b>

§

impl<'b> Send for Store<'b>

§

impl<'b> !Sync for Store<'b>

§

impl<'b> Unpin for Store<'b>

§

impl<'b> UnwindSafe for Store<'b>

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.