wasmtime_environ

Struct Module

source
pub struct Module {
Show 21 fields pub name: Option<String>, pub initializers: Vec<Initializer>, pub exports: IndexMap<String, EntityIndex>, pub start_func: Option<FuncIndex>, pub table_initialization: TableInitialization, pub memory_initialization: MemoryInitialization, pub passive_elements: Vec<TableSegmentElements>, pub passive_elements_map: BTreeMap<ElemIndex, usize>, pub passive_data_map: BTreeMap<DataIndex, Range<u32>>, pub types: PrimaryMap<TypeIndex, ModuleInternedTypeIndex>, pub num_imported_funcs: usize, pub num_imported_tables: usize, pub num_imported_memories: usize, pub num_imported_globals: usize, pub num_escaped_funcs: usize, pub num_call_indirect_caches: usize, pub functions: PrimaryMap<FuncIndex, FunctionType>, pub tables: PrimaryMap<TableIndex, Table>, pub memories: PrimaryMap<MemoryIndex, Memory>, pub globals: PrimaryMap<GlobalIndex, Global>, pub global_initializers: PrimaryMap<DefinedGlobalIndex, ConstExpr>,
}
Expand description

A translated WebAssembly module, excluding the function bodies and memory initializers.

Fields§

§name: Option<String>

The name of this wasm module, often found in the wasm file.

§initializers: Vec<Initializer>

All import records, in the order they are declared in the module.

§exports: IndexMap<String, EntityIndex>

Exported entities.

§start_func: Option<FuncIndex>

The module “start” function, if present.

§table_initialization: TableInitialization

WebAssembly table initialization data, per table.

§memory_initialization: MemoryInitialization

WebAssembly linear memory initializer.

§passive_elements: Vec<TableSegmentElements>

WebAssembly passive elements.

§passive_elements_map: BTreeMap<ElemIndex, usize>

The map from passive element index (element segment index space) to index in passive_elements.

§passive_data_map: BTreeMap<DataIndex, Range<u32>>

The map from passive data index (data segment index space) to index in passive_data.

§types: PrimaryMap<TypeIndex, ModuleInternedTypeIndex>

Types declared in the wasm module.

§num_imported_funcs: usize

Number of imported or aliased functions in the module.

§num_imported_tables: usize

Number of imported or aliased tables in the module.

§num_imported_memories: usize

Number of imported or aliased memories in the module.

§num_imported_globals: usize

Number of imported or aliased globals in the module.

§num_escaped_funcs: usize

Number of functions that “escape” from this module may need to have a VMFuncRef constructed for them.

This is also the number of functions in the functions array below with an func_ref index (and is the maximum func_ref index).

§num_call_indirect_caches: usize

Number of call-indirect caches.

§functions: PrimaryMap<FuncIndex, FunctionType>

Types of functions, imported and local.

§tables: PrimaryMap<TableIndex, Table>

WebAssembly tables.

§memories: PrimaryMap<MemoryIndex, Memory>

WebAssembly linear memory plans.

§globals: PrimaryMap<GlobalIndex, Global>

WebAssembly global variables.

§global_initializers: PrimaryMap<DefinedGlobalIndex, ConstExpr>

WebAssembly global initializers for locally-defined globals.

Implementations§

source§

impl Module

source

pub fn new() -> Self

Allocates the module data structures.

source

pub fn func_index(&self, defined_func: DefinedFuncIndex) -> FuncIndex

Convert a DefinedFuncIndex into a FuncIndex.

source

pub fn defined_func_index(&self, func: FuncIndex) -> Option<DefinedFuncIndex>

Convert a FuncIndex into a DefinedFuncIndex. Returns None if the index is an imported function.

source

pub fn is_imported_function(&self, index: FuncIndex) -> bool

Test whether the given function index is for an imported function.

source

pub fn table_index(&self, defined_table: DefinedTableIndex) -> TableIndex

Convert a DefinedTableIndex into a TableIndex.

source

pub fn defined_table_index( &self, table: TableIndex, ) -> Option<DefinedTableIndex>

Convert a TableIndex into a DefinedTableIndex. Returns None if the index is an imported table.

source

pub fn is_imported_table(&self, index: TableIndex) -> bool

Test whether the given table index is for an imported table.

source

pub fn memory_index(&self, defined_memory: DefinedMemoryIndex) -> MemoryIndex

Convert a DefinedMemoryIndex into a MemoryIndex.

source

pub fn defined_memory_index( &self, memory: MemoryIndex, ) -> Option<DefinedMemoryIndex>

Convert a MemoryIndex into a DefinedMemoryIndex. Returns None if the index is an imported memory.

source

pub fn owned_memory_index(&self, memory: DefinedMemoryIndex) -> OwnedMemoryIndex

Convert a DefinedMemoryIndex into an OwnedMemoryIndex. Returns None if the index is an imported memory.

source

pub fn is_imported_memory(&self, index: MemoryIndex) -> bool

Test whether the given memory index is for an imported memory.

source

pub fn global_index(&self, defined_global: DefinedGlobalIndex) -> GlobalIndex

Convert a DefinedGlobalIndex into a GlobalIndex.

source

pub fn defined_global_index( &self, global: GlobalIndex, ) -> Option<DefinedGlobalIndex>

Convert a GlobalIndex into a DefinedGlobalIndex. Returns None if the index is an imported global.

source

pub fn is_imported_global(&self, index: GlobalIndex) -> bool

Test whether the given global index is for an imported global.

source

pub fn imports(&self) -> impl ExactSizeIterator<Item = (&str, &str, EntityType)>

Returns an iterator of all the imports in this module, along with their module name, field name, and type that’s being imported.

source

pub fn type_of(&self, index: EntityIndex) -> EntityType

Returns the type of an item based on its index

source

pub fn push_function(&mut self, signature: ModuleInternedTypeIndex) -> FuncIndex

Appends a new function to this module with the given type information, used for functions that either don’t escape or aren’t certain whether they escape yet.

source

pub fn defined_func_indices(&self) -> impl Iterator<Item = DefinedFuncIndex>

Returns an iterator over all of the defined function indices in this module.

source

pub fn num_defined_tables(&self) -> usize

Returns the number of tables defined by this module itself: all tables minus imported tables.

source

pub fn num_defined_memories(&self) -> usize

Returns the number of memories defined by this module itself: all memories minus imported memories.

Trait Implementations§

source§

impl Debug for Module

source§

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

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

impl Default for Module

source§

fn default() -> Module

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

impl<'de> Deserialize<'de> for Module

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Serialize for Module

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Module

§

impl RefUnwindSafe for Module

§

impl Send for Module

§

impl Sync for Module

§

impl Unpin for Module

§

impl UnwindSafe for Module

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.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,