Trait cranelift_wasm::ModuleEnvironment[][src]

pub trait ModuleEnvironment<'data>: TargetEnvironment {
    fn declare_type_func(
        &mut self,
        wasm_func_type: WasmFuncType,
        sig: Signature
    ) -> WasmResult<()>;
fn declare_func_import(
        &mut self,
        index: TypeIndex,
        module: &'data str,
        field: Option<&'data str>
    ) -> WasmResult<()>;
fn declare_table_import(
        &mut self,
        table: Table,
        module: &'data str,
        field: Option<&'data str>
    ) -> WasmResult<()>;
fn declare_memory_import(
        &mut self,
        memory: Memory,
        module: &'data str,
        field: Option<&'data str>
    ) -> WasmResult<()>;
fn declare_global_import(
        &mut self,
        global: Global,
        module: &'data str,
        field: Option<&'data str>
    ) -> WasmResult<()>;
fn declare_func_type(&mut self, index: TypeIndex) -> WasmResult<()>;
fn declare_table(&mut self, table: Table) -> WasmResult<()>;
fn declare_memory(&mut self, memory: Memory) -> WasmResult<()>;
fn declare_global(&mut self, global: Global) -> WasmResult<()>;
fn declare_func_export(
        &mut self,
        func_index: FuncIndex,
        name: &'data str
    ) -> WasmResult<()>;
fn declare_table_export(
        &mut self,
        table_index: TableIndex,
        name: &'data str
    ) -> WasmResult<()>;
fn declare_memory_export(
        &mut self,
        memory_index: MemoryIndex,
        name: &'data str
    ) -> WasmResult<()>;
fn declare_global_export(
        &mut self,
        global_index: GlobalIndex,
        name: &'data str
    ) -> WasmResult<()>;
fn declare_start_func(&mut self, index: FuncIndex) -> WasmResult<()>;
fn declare_table_elements(
        &mut self,
        table_index: TableIndex,
        base: Option<GlobalIndex>,
        offset: usize,
        elements: Box<[FuncIndex]>
    ) -> WasmResult<()>;
fn declare_passive_element(
        &mut self,
        index: ElemIndex,
        elements: Box<[FuncIndex]>
    ) -> WasmResult<()>;
fn declare_passive_data(
        &mut self,
        data_index: DataIndex,
        data: &'data [u8]
    ) -> WasmResult<()>;
fn define_function_body(
        &mut self,
        validator: FuncValidator<ValidatorResources>,
        body: FunctionBody<'data>
    ) -> WasmResult<()>;
fn declare_data_initialization(
        &mut self,
        memory_index: MemoryIndex,
        base: Option<GlobalIndex>,
        offset: usize,
        data: &'data [u8]
    ) -> WasmResult<()>; fn reserve_types(&mut self, _num: u32) -> WasmResult<()> { ... }
fn declare_type_module(
        &mut self,
        imports: &[(&'data str, Option<&'data str>, EntityType)],
        exports: &[(&'data str, EntityType)]
    ) -> WasmResult<()> { ... }
fn declare_type_instance(
        &mut self,
        exports: &[(&'data str, EntityType)]
    ) -> WasmResult<()> { ... }
fn type_to_signature(&self, index: TypeIndex) -> WasmResult<SignatureIndex> { ... }
fn type_to_module_type(
        &self,
        index: TypeIndex
    ) -> WasmResult<ModuleTypeIndex> { ... }
fn type_to_instance_type(
        &self,
        index: TypeIndex
    ) -> WasmResult<InstanceTypeIndex> { ... }
fn reserve_imports(&mut self, _num: u32) -> WasmResult<()> { ... }
fn declare_event_import(
        &mut self,
        event: Event,
        module: &'data str,
        field: Option<&'data str>
    ) -> WasmResult<()> { ... }
fn declare_module_import(
        &mut self,
        ty_index: TypeIndex,
        module: &'data str,
        field: Option<&'data str>
    ) -> WasmResult<()> { ... }
fn declare_instance_import(
        &mut self,
        ty_index: TypeIndex,
        module: &'data str,
        field: Option<&'data str>
    ) -> WasmResult<()> { ... }
fn finish_imports(&mut self) -> WasmResult<()> { ... }
fn reserve_func_types(&mut self, _num: u32) -> WasmResult<()> { ... }
fn reserve_tables(&mut self, _num: u32) -> WasmResult<()> { ... }
fn reserve_memories(&mut self, _num: u32) -> WasmResult<()> { ... }
fn reserve_events(&mut self, _num: u32) -> WasmResult<()> { ... }
fn declare_event(&mut self, event: Event) -> WasmResult<()> { ... }
fn reserve_globals(&mut self, _num: u32) -> WasmResult<()> { ... }
fn reserve_exports(&mut self, _num: u32) -> WasmResult<()> { ... }
fn declare_event_export(
        &mut self,
        event_index: EventIndex,
        name: &'data str
    ) -> WasmResult<()> { ... }
fn declare_instance_export(
        &mut self,
        index: InstanceIndex,
        name: &'data str
    ) -> WasmResult<()> { ... }
fn declare_module_export(
        &mut self,
        index: ModuleIndex,
        name: &'data str
    ) -> WasmResult<()> { ... }
fn finish_exports(&mut self) -> WasmResult<()> { ... }
fn reserve_table_elements(&mut self, _num: u32) -> WasmResult<()> { ... }
fn reserve_passive_data(&mut self, count: u32) -> WasmResult<()> { ... }
fn reserve_function_bodies(&mut self, bodies: u32, code_section_offset: u64) { ... }
fn reserve_data_initializers(&mut self, _num: u32) -> WasmResult<()> { ... }
fn declare_module_name(&mut self, _name: &'data str) { ... }
fn declare_func_name(&mut self, _func_index: FuncIndex, _name: &'data str) { ... }
fn declare_local_name(
        &mut self,
        _func_index: FuncIndex,
        _local_index: u32,
        _name: &'data str
    ) { ... }
fn custom_section(
        &mut self,
        _name: &'data str,
        _data: &'data [u8]
    ) -> WasmResult<()> { ... }
fn wasm_features(&self) -> WasmFeatures { ... }
fn reserve_modules(&mut self, amount: u32) { ... }
fn module_start(&mut self) { ... }
fn module_end(&mut self) { ... }
fn reserve_instances(&mut self, amount: u32) { ... }
fn declare_instance(
        &mut self,
        module: ModuleIndex,
        args: Vec<(&'data str, EntityIndex)>
    ) -> WasmResult<()> { ... }
fn declare_alias(&mut self, alias: Alias<'data>) -> WasmResult<()> { ... } }

An object satisfying the ModuleEnvironment trait can be passed as argument to the translate_module function. These methods should not be called by the user, they are only for cranelift-wasm internal use.

Required methods

fn declare_type_func(
    &mut self,
    wasm_func_type: WasmFuncType,
    sig: Signature
) -> WasmResult<()>
[src]

Declares a function signature to the environment.

fn declare_func_import(
    &mut self,
    index: TypeIndex,
    module: &'data str,
    field: Option<&'data str>
) -> WasmResult<()>
[src]

Declares a function import to the environment.

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

Declares a table import to the environment.

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

Declares a memory import to the environment.

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

Declares a global import to the environment.

fn declare_func_type(&mut self, index: TypeIndex) -> WasmResult<()>[src]

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

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

Declares a table to the environment.

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

Declares a memory to the environment

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

Declares a global to the environment.

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

Declares a function export to the environment.

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

Declares a table export to the environment.

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

Declares a memory export to the environment.

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

Declares a global export to the environment.

fn declare_start_func(&mut self, index: FuncIndex) -> WasmResult<()>[src]

Declares the optional start function.

fn declare_table_elements(
    &mut self,
    table_index: TableIndex,
    base: Option<GlobalIndex>,
    offset: usize,
    elements: Box<[FuncIndex]>
) -> WasmResult<()>
[src]

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

fn declare_passive_element(
    &mut self,
    index: ElemIndex,
    elements: Box<[FuncIndex]>
) -> WasmResult<()>
[src]

Declare a passive element segment.

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

Declare a passive data segment.

fn define_function_body(
    &mut self,
    validator: FuncValidator<ValidatorResources>,
    body: FunctionBody<'data>
) -> WasmResult<()>
[src]

Provides the contents of a function body.

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

Fills a declared memory with bytes at module instantiation.

Loading content...

Provided methods

fn reserve_types(&mut self, _num: u32) -> WasmResult<()>[src]

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

fn declare_type_module(
    &mut self,
    imports: &[(&'data str, Option<&'data str>, EntityType)],
    exports: &[(&'data str, EntityType)]
) -> WasmResult<()>
[src]

Declares a module type signature to the environment.

fn declare_type_instance(
    &mut self,
    exports: &[(&'data str, EntityType)]
) -> WasmResult<()>
[src]

Declares an instance type signature to the environment.

fn type_to_signature(&self, index: TypeIndex) -> WasmResult<SignatureIndex>[src]

Translates a type index to its signature index, only called for type indices which point to functions.

fn type_to_module_type(&self, index: TypeIndex) -> WasmResult<ModuleTypeIndex>[src]

Translates a type index to its module type index, only called for type indices which point to modules.

fn type_to_instance_type(
    &self,
    index: TypeIndex
) -> WasmResult<InstanceTypeIndex>
[src]

Translates a type index to its instance type index, only called for type indices which point to instances.

fn reserve_imports(&mut self, _num: u32) -> WasmResult<()>[src]

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

fn declare_event_import(
    &mut self,
    event: Event,
    module: &'data str,
    field: Option<&'data str>
) -> WasmResult<()>
[src]

Declares an event import to the environment.

fn declare_module_import(
    &mut self,
    ty_index: TypeIndex,
    module: &'data str,
    field: Option<&'data str>
) -> WasmResult<()>
[src]

Declares a module import to the environment.

fn declare_instance_import(
    &mut self,
    ty_index: TypeIndex,
    module: &'data str,
    field: Option<&'data str>
) -> WasmResult<()>
[src]

Declares an instance import to the environment.

fn finish_imports(&mut self) -> WasmResult<()>[src]

Notifies the implementation that all imports have been declared.

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

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

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

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

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

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

fn reserve_events(&mut self, _num: u32) -> WasmResult<()>[src]

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

fn declare_event(&mut self, event: Event) -> WasmResult<()>[src]

Declares an event to the environment

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

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

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

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

fn declare_event_export(
    &mut self,
    event_index: EventIndex,
    name: &'data str
) -> WasmResult<()>
[src]

Declares an event export to the environment.

fn declare_instance_export(
    &mut self,
    index: InstanceIndex,
    name: &'data str
) -> WasmResult<()>
[src]

Declares an instance export to the environment.

fn declare_module_export(
    &mut self,
    index: ModuleIndex,
    name: &'data str
) -> WasmResult<()>
[src]

Declares an instance export to the environment.

fn finish_exports(&mut self) -> WasmResult<()>[src]

Notifies the implementation that all exports have been declared.

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

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

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

Provides the number of passive data segments up front.

By default this does nothing, but implementations may use this to pre-allocate memory if desired.

fn reserve_function_bodies(&mut self, bodies: u32, code_section_offset: u64)[src]

Indicates how many functions the code section reports and the byte offset of where the code sections starts.

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

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

fn declare_module_name(&mut self, _name: &'data str)[src]

Declares the name of a module to the environment.

By default this does nothing, but implementations can use this to read the module name subsection of the custom name section if desired.

fn declare_func_name(&mut self, _func_index: FuncIndex, _name: &'data str)[src]

Declares the name of a function to the environment.

By default this does nothing, but implementations can use this to read the function name subsection of the custom name section if desired.

fn declare_local_name(
    &mut self,
    _func_index: FuncIndex,
    _local_index: u32,
    _name: &'data str
)
[src]

Declares the name of a function’s local to the environment.

By default this does nothing, but implementations can use this to read the local name subsection of the custom name section if desired.

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

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

fn wasm_features(&self) -> WasmFeatures[src]

Returns the list of enabled wasm features this translation will be using.

fn reserve_modules(&mut self, amount: u32)[src]

Indicates that this module will have amount submodules.

Note that this is just child modules of this module, and each child module may have yet more submodules.

fn module_start(&mut self)[src]

Called at the beginning of translating a module.

Note that for nested modules this may be called multiple times.

fn module_end(&mut self)[src]

Called at the end of translating a module.

Note that for nested modules this may be called multiple times.

fn reserve_instances(&mut self, amount: u32)[src]

Indicates that this module will have amount instances.

fn declare_instance(
    &mut self,
    module: ModuleIndex,
    args: Vec<(&'data str, EntityIndex)>
) -> WasmResult<()>
[src]

Declares a new instance which this module will instantiate before it’s instantiated.

fn declare_alias(&mut self, alias: Alias<'data>) -> WasmResult<()>[src]

Declares a new alias being added to this module.

The alias comes from the instance specified (or the parent if None is supplied) and the index is either in the module’s own index spaces for the parent or an index into the exports for nested instances.

Loading content...

Implementors

impl<'data> ModuleEnvironment<'data> for DummyEnvironment[src]

Loading content...