Trait cranelift_wasm::ModuleEnvironment
source · pub trait ModuleEnvironment<'data> {
Show 20 methods
fn target_config(&self) -> &TargetFrontendConfig;
fn get_func_name(&self, func_index: FuncIndex) -> ExternalName;
fn declare_signature(&mut self, sig: &Signature);
fn get_signature(&self, sig_index: SignatureIndex) -> &Signature;
fn declare_func_import(
&mut self,
sig_index: SignatureIndex,
module: &'data str,
field: &'data str
);
fn get_num_func_imports(&self) -> usize;
fn declare_func_type(&mut self, sig_index: SignatureIndex);
fn get_func_type(&self, func_index: FuncIndex) -> SignatureIndex;
fn declare_global(&mut self, global: Global);
fn get_global(&self, global_index: GlobalIndex) -> &Global;
fn declare_table(&mut self, table: Table);
fn declare_table_elements(
&mut self,
table_index: TableIndex,
base: Option<GlobalIndex>,
offset: usize,
elements: Vec<FuncIndex>
);
fn declare_memory(&mut self, memory: Memory);
fn declare_data_initialization(
&mut self,
memory_index: MemoryIndex,
base: Option<GlobalIndex>,
offset: usize,
data: &'data [u8]
);
fn declare_func_export(&mut self, func_index: FuncIndex, name: &'data str);
fn declare_table_export(&mut self, table_index: TableIndex, name: &'data str);
fn declare_memory_export(
&mut self,
memory_index: MemoryIndex,
name: &'data str
);
fn declare_global_export(
&mut self,
global_index: GlobalIndex,
name: &'data str
);
fn declare_start_func(&mut self, index: FuncIndex);
fn define_function_body(&mut self, body_bytes: &'data [u8]) -> WasmResult<()>;
}
Expand description
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
sourcefn target_config(&self) -> &TargetFrontendConfig
fn target_config(&self) -> &TargetFrontendConfig
Get the information needed to produce Cranelift IR for the current target.
sourcefn get_func_name(&self, func_index: FuncIndex) -> ExternalName
fn get_func_name(&self, func_index: FuncIndex) -> ExternalName
Return the name for the given function index.
sourcefn declare_signature(&mut self, sig: &Signature)
fn declare_signature(&mut self, sig: &Signature)
Declares a function signature to the environment.
sourcefn get_signature(&self, sig_index: SignatureIndex) -> &Signature
fn get_signature(&self, sig_index: SignatureIndex) -> &Signature
Return the signature with the given index.
sourcefn declare_func_import(
&mut self,
sig_index: SignatureIndex,
module: &'data str,
field: &'data str
)
fn declare_func_import(
&mut self,
sig_index: SignatureIndex,
module: &'data str,
field: &'data str
)
Declares a function import to the environment.
sourcefn get_num_func_imports(&self) -> usize
fn get_num_func_imports(&self) -> usize
Return the number of imported funcs.
sourcefn declare_func_type(&mut self, sig_index: SignatureIndex)
fn declare_func_type(&mut self, sig_index: SignatureIndex)
Declares the type (signature) of a local function in the module.
sourcefn get_func_type(&self, func_index: FuncIndex) -> SignatureIndex
fn get_func_type(&self, func_index: FuncIndex) -> SignatureIndex
Return the signature index for the given function index.
sourcefn declare_global(&mut self, global: Global)
fn declare_global(&mut self, global: Global)
Declares a global to the environment.
sourcefn get_global(&self, global_index: GlobalIndex) -> &Global
fn get_global(&self, global_index: GlobalIndex) -> &Global
Return the global for the given global index.
sourcefn declare_table(&mut self, table: Table)
fn declare_table(&mut self, table: Table)
Declares a table to the environment.
sourcefn declare_table_elements(
&mut self,
table_index: TableIndex,
base: Option<GlobalIndex>,
offset: usize,
elements: Vec<FuncIndex>
)
fn declare_table_elements(
&mut self,
table_index: TableIndex,
base: Option<GlobalIndex>,
offset: usize,
elements: Vec<FuncIndex>
)
Fills a declared table with references to functions in the module.
sourcefn declare_memory(&mut self, memory: Memory)
fn declare_memory(&mut self, memory: Memory)
Declares a memory to the environment
sourcefn declare_data_initialization(
&mut self,
memory_index: MemoryIndex,
base: Option<GlobalIndex>,
offset: usize,
data: &'data [u8]
)
fn declare_data_initialization(
&mut self,
memory_index: MemoryIndex,
base: Option<GlobalIndex>,
offset: usize,
data: &'data [u8]
)
Fills a declared memory with bytes at module instantiation.
sourcefn declare_func_export(&mut self, func_index: FuncIndex, name: &'data str)
fn declare_func_export(&mut self, func_index: FuncIndex, name: &'data str)
Declares a function export to the environment.
sourcefn declare_table_export(&mut self, table_index: TableIndex, name: &'data str)
fn declare_table_export(&mut self, table_index: TableIndex, name: &'data str)
Declares a table export to the environment.
sourcefn declare_memory_export(&mut self, memory_index: MemoryIndex, name: &'data str)
fn declare_memory_export(&mut self, memory_index: MemoryIndex, name: &'data str)
Declares a memory export to the environment.
sourcefn declare_global_export(&mut self, global_index: GlobalIndex, name: &'data str)
fn declare_global_export(&mut self, global_index: GlobalIndex, name: &'data str)
Declares a global export to the environment.
sourcefn declare_start_func(&mut self, index: FuncIndex)
fn declare_start_func(&mut self, index: FuncIndex)
Declares a start function.
sourcefn define_function_body(&mut self, body_bytes: &'data [u8]) -> WasmResult<()>
fn define_function_body(&mut self, body_bytes: &'data [u8]) -> WasmResult<()>
Provides the contents of a function body.