Struct DummyEnvironment

Source
pub struct DummyEnvironment {
    pub info: DummyModuleInfo,
    pub func_bytecode_sizes: Vec<usize>,
    /* private fields */
}
Expand description

This ModuleEnvironment implementation is a “naïve” one, doing essentially nothing and emitting placeholders when forced to. Don’t try to execute code translated for this environment, essentially here for translation debug purposes.

Fields§

§info: DummyModuleInfo

Module information.

§func_bytecode_sizes: Vec<usize>

Vector of wasm bytecode size for each function.

Implementations§

Source§

impl DummyEnvironment

Source

pub fn new( config: TargetFrontendConfig, return_mode: ReturnMode, debug_info: bool, ) -> Self

Creates a new DummyEnvironment instance.

Source

pub fn func_env(&self) -> DummyFuncEnvironment<'_>

Return a DummyFuncEnvironment for translating functions within this DummyEnvironment.

Source

pub fn get_num_func_imports(&self) -> usize

Return the number of imported functions within this DummyEnvironment.

Source

pub fn get_func_name(&self, func_index: FuncIndex) -> Option<&str>

Return the name of the function, if a name for the function with the corresponding index exists.

Trait Implementations§

Source§

impl<'data> ModuleEnvironment<'data> for DummyEnvironment

Source§

fn declare_signature(&mut self, sig: Signature) -> WasmResult<()>

Declares a function signature to the environment.
Source§

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

Declares a function import to the environment.
Source§

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

Declares the type (signature) of a local function in the module.
Source§

fn declare_global(&mut self, global: Global) -> WasmResult<()>

Declares a global to the environment.
Source§

fn declare_global_import( &mut self, global: Global, module: &'data str, field: &'data str, ) -> WasmResult<()>

Declares a global import to the environment.
Source§

fn declare_table(&mut self, table: Table) -> WasmResult<()>

Declares a table to the environment.
Source§

fn declare_table_import( &mut self, table: Table, module: &'data str, field: &'data str, ) -> WasmResult<()>

Declares a table import to the environment.
Source§

fn declare_table_elements( &mut self, _table_index: TableIndex, _base: Option<GlobalIndex>, _offset: usize, _elements: Box<[FuncIndex]>, ) -> WasmResult<()>

Fills a declared table with references to functions in the module.
Source§

fn declare_passive_element( &mut self, _elem_index: PassiveElemIndex, _segments: Box<[FuncIndex]>, ) -> WasmResult<()>

Declare a passive element segment.
Source§

fn declare_passive_data( &mut self, _elem_index: PassiveDataIndex, _segments: &'data [u8], ) -> WasmResult<()>

Declare a passive data segment.
Source§

fn declare_memory(&mut self, memory: Memory) -> WasmResult<()>

Declares a memory to the environment
Source§

fn declare_memory_import( &mut self, memory: Memory, module: &'data str, field: &'data str, ) -> WasmResult<()>

Declares a memory import to the environment.
Source§

fn declare_data_initialization( &mut self, _memory_index: MemoryIndex, _base: Option<GlobalIndex>, _offset: usize, _data: &'data [u8], ) -> WasmResult<()>

Fills a declared memory with bytes at module instantiation.
Source§

fn declare_func_export( &mut self, func_index: FuncIndex, name: &'data str, ) -> WasmResult<()>

Declares a function export to the environment.
Source§

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

Declares a table export to the environment.
Source§

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

Declares a memory export to the environment.
Source§

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

Declares a global export to the environment.
Source§

fn declare_start_func(&mut self, func_index: FuncIndex) -> WasmResult<()>

Declares the optional start function.
Source§

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

Provides the contents of a function body. Read more
Source§

fn declare_func_name( &mut self, func_index: FuncIndex, name: &'data str, ) -> WasmResult<()>

Declares the name of a function to the environment. Read more
Source§

fn reserve_signatures(&mut self, _num: u32) -> WasmResult<()>

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

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§

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

Notifies the implementation that all imports have been declared.
Source§

fn reserve_func_types(&mut self, _num: u32) -> WasmResult<()>

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

fn reserve_tables(&mut self, _num: u32) -> WasmResult<()>

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

fn reserve_memories(&mut self, _num: u32) -> WasmResult<()>

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

fn reserve_globals(&mut self, _num: u32) -> WasmResult<()>

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

fn reserve_exports(&mut self, _num: u32) -> WasmResult<()>

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

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

Notifies the implementation that all exports have been declared.
Source§

fn reserve_table_elements(&mut self, _num: u32) -> WasmResult<()>

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

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

Provides the number of passive data segments up front. Read more
Source§

fn reserve_data_initializers(&mut self, _num: u32) -> WasmResult<()>

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

fn custom_section( &mut self, _name: &'data str, _data: &'data [u8], ) -> WasmResult<()>

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

impl TargetEnvironment for DummyEnvironment

Source§

fn target_config(&self) -> TargetFrontendConfig

Get the information needed to produce Cranelift IR for the given target.
Source§

fn pointer_type(&self) -> Type

Get the Cranelift integer type to use for native pointers. Read more
Source§

fn pointer_bytes(&self) -> u8

Get the size of a native pointer, in bytes.
Source§

fn reference_type(&self) -> Type

Get the Cranelift reference type to use for native references. Read more

Auto Trait Implementations§

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.