pub struct ModuleEnvironment<'data> {
    pub module: ModuleInfo,
    pub function_body_inputs: PrimaryMap<LocalFunctionIndex, FunctionBodyData<'data>>,
    pub data_initializers: Vec<DataInitializer<'data>>,
    pub module_translation_state: Option<ModuleTranslationState>,
}
Expand description

The result of translating via ModuleEnvironment. Function bodies are not yet translated, and data initializers have not yet been copied out of the original buffer. The function bodies will be translated by a specific compiler backend.

Fields§

§module: ModuleInfo

ModuleInfo information.

§function_body_inputs: PrimaryMap<LocalFunctionIndex, FunctionBodyData<'data>>

References to the function bodies.

§data_initializers: Vec<DataInitializer<'data>>

References to the data initializers.

§module_translation_state: Option<ModuleTranslationState>

The decoded Wasm types for the module.

Implementations§

source§

impl<'data> ModuleEnvironment<'data>

source

pub fn new() -> Self

Allocates the environment data structures.

source

pub fn translate(self, data: &'data [u8]) -> WasmResult<Self>

Translate a wasm module using this environment. This consumes the ModuleEnvironment and produces a ModuleInfoTranslation.

source

pub(crate) fn declare_export( &mut self, export: ExportIndex, name: &str, ) -> WasmResult<()>

source

pub(crate) fn declare_import( &mut self, import: ImportIndex, module: &str, field: &str, ) -> WasmResult<()>

source

pub(crate) fn reserve_signatures(&mut self, num: u32) -> WasmResult<()>

source

pub(crate) fn declare_signature(&mut self, sig: FunctionType) -> WasmResult<()>

source

pub(crate) fn declare_func_import( &mut self, sig_index: SignatureIndex, module: &str, field: &str, ) -> WasmResult<()>

source

pub(crate) fn declare_table_import( &mut self, table: TableType, module: &str, field: &str, ) -> WasmResult<()>

source

pub(crate) fn declare_memory_import( &mut self, memory: MemoryType, module: &str, field: &str, ) -> WasmResult<()>

source

pub(crate) fn declare_global_import( &mut self, global: GlobalType, module: &str, field: &str, ) -> WasmResult<()>

source

pub(crate) fn finish_imports(&mut self) -> WasmResult<()>

source

pub(crate) fn reserve_func_types(&mut self, num: u32) -> WasmResult<()>

source

pub(crate) fn declare_func_type( &mut self, sig_index: SignatureIndex, ) -> WasmResult<()>

source

pub(crate) fn reserve_tables(&mut self, num: u32) -> WasmResult<()>

source

pub(crate) fn declare_table(&mut self, table: TableType) -> WasmResult<()>

source

pub(crate) fn reserve_memories(&mut self, num: u32) -> WasmResult<()>

source

pub(crate) fn declare_memory(&mut self, memory: MemoryType) -> WasmResult<()>

source

pub(crate) fn reserve_globals(&mut self, num: u32) -> WasmResult<()>

source

pub(crate) fn declare_global( &mut self, global: GlobalType, initializer: GlobalInit, ) -> WasmResult<()>

source

pub(crate) fn reserve_exports(&mut self, num: u32) -> WasmResult<()>

source

pub(crate) fn declare_func_export( &mut self, func_index: FunctionIndex, name: &str, ) -> WasmResult<()>

source

pub(crate) fn declare_table_export( &mut self, table_index: TableIndex, name: &str, ) -> WasmResult<()>

source

pub(crate) fn declare_memory_export( &mut self, memory_index: MemoryIndex, name: &str, ) -> WasmResult<()>

source

pub(crate) fn declare_global_export( &mut self, global_index: GlobalIndex, name: &str, ) -> WasmResult<()>

source

pub(crate) fn declare_start_function( &mut self, func_index: FunctionIndex, ) -> WasmResult<()>

source

pub(crate) fn reserve_table_initializers(&mut self, num: u32) -> WasmResult<()>

source

pub(crate) fn declare_table_initializers( &mut self, table_index: TableIndex, base: Option<GlobalIndex>, offset: usize, elements: Box<[FunctionIndex]>, ) -> WasmResult<()>

source

pub(crate) fn declare_passive_element( &mut self, elem_index: ElemIndex, segments: Box<[FunctionIndex]>, ) -> WasmResult<()>

source

pub(crate) fn define_function_body( &mut self, _module_translation_state: &ModuleTranslationState, body_bytes: &'data [u8], body_offset: usize, ) -> WasmResult<()>

source

pub(crate) fn reserve_data_initializers(&mut self, num: u32) -> WasmResult<()>

source

pub(crate) fn declare_data_initialization( &mut self, memory_index: MemoryIndex, base: Option<GlobalIndex>, offset: usize, data: &'data [u8], ) -> WasmResult<()>

source

pub(crate) fn reserve_passive_data(&mut self, count: u32) -> WasmResult<()>

source

pub(crate) fn declare_passive_data( &mut self, data_index: DataIndex, data: &'data [u8], ) -> WasmResult<()>

source

pub(crate) fn declare_module_name(&mut self, name: &'data str) -> WasmResult<()>

source

pub(crate) fn declare_function_name( &mut self, func_index: FunctionIndex, name: &'data str, ) -> WasmResult<()>

source

pub(crate) fn reserve_imports(&mut self, _num: u32) -> WasmResult<()>

Provides the number of imports up front. By default this does nothing, but implementations can use this to preallocate memory if desired.

source

pub(crate) fn finish_exports(&mut self) -> WasmResult<()>

Notifies the implementation that all exports have been declared.

source

pub(crate) fn custom_section( &mut self, name: &'data str, data: &'data [u8], ) -> WasmResult<()>

Indicates that a custom section has been found in the wasm file

Auto Trait Implementations§

§

impl<'data> Freeze for ModuleEnvironment<'data>

§

impl<'data> RefUnwindSafe for ModuleEnvironment<'data>

§

impl<'data> Send for ModuleEnvironment<'data>

§

impl<'data> Sync for ModuleEnvironment<'data>

§

impl<'data> Unpin for ModuleEnvironment<'data>

§

impl<'data> UnwindSafe for ModuleEnvironment<'data>

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
§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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.

§

impl<T> LayoutRaw for T

§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
§

impl<T> Pointee for T

§

type Metadata = ()

The metadata type for pointers and references to this type.
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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> Upcastable for T
where T: Any + Send + Sync + 'static,

source§

fn upcast_any_ref(&self) -> &(dyn Any + 'static)

upcast ref
source§

fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)

upcast mut ref
source§

fn upcast_any_box(self: Box<T>) -> Box<dyn Any>

upcast boxed dyn