Trait cton_wasm::ModuleEnvironment
[−]
[src]
pub trait ModuleEnvironment<'data> { fn get_func_name(&self, func_index: FunctionIndex) -> 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: FunctionIndex) -> 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<FunctionIndex>
); 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: FunctionIndex,
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: FunctionIndex); fn define_function_body(
&mut self,
body_bytes: &'data [u8]
) -> Result<(), String>; }
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 cretonne-wasm
internal use.
Required Methods
fn get_func_name(&self, func_index: FunctionIndex) -> ExternalName
Return the name for the given function index.
fn declare_signature(&mut self, sig: &Signature)
Declares a function signature to the environment.
fn get_signature(&self, sig_index: SignatureIndex) -> &Signature
Return the signature with the given index.
fn declare_func_import(
&mut self,
sig_index: SignatureIndex,
module: &'data str,
field: &'data str
)
&mut self,
sig_index: SignatureIndex,
module: &'data str,
field: &'data str
)
Declares a function import to the environment.
fn get_num_func_imports(&self) -> usize
Return the number of imported funcs.
fn declare_func_type(&mut self, sig_index: SignatureIndex)
Declares the type (signature) of a local function in the module.
fn get_func_type(&self, func_index: FunctionIndex) -> SignatureIndex
Return the signature index for the given function index.
fn declare_global(&mut self, global: Global)
Declares a global to the environment.
fn get_global(&self, global_index: GlobalIndex) -> &Global
Return the global for the given global index.
fn declare_table(&mut self, table: Table)
Declares a table to the environment.
fn declare_table_elements(
&mut self,
table_index: TableIndex,
base: Option<GlobalIndex>,
offset: usize,
elements: Vec<FunctionIndex>
)
&mut self,
table_index: TableIndex,
base: Option<GlobalIndex>,
offset: usize,
elements: Vec<FunctionIndex>
)
Fills a declared table with references to functions in the module.
fn declare_memory(&mut self, memory: Memory)
Declares a memory to the environment
fn declare_data_initialization(
&mut self,
memory_index: MemoryIndex,
base: Option<GlobalIndex>,
offset: usize,
data: &'data [u8]
)
&mut self,
memory_index: MemoryIndex,
base: Option<GlobalIndex>,
offset: usize,
data: &'data [u8]
)
Fills a declared memory with bytes at module instantiation.
fn declare_func_export(&mut self, func_index: FunctionIndex, name: &'data str)
Declares a function export to the environment.
fn declare_table_export(&mut self, table_index: TableIndex, name: &'data str)
Declares a table export to the environment.
fn declare_memory_export(&mut self, memory_index: MemoryIndex, name: &'data str)
Declares a memory export to the environment.
fn declare_global_export(&mut self, global_index: GlobalIndex, name: &'data str)
Declares a global export to the environment.
fn declare_start_func(&mut self, index: FunctionIndex)
Declares a start function.
fn define_function_body(
&mut self,
body_bytes: &'data [u8]
) -> Result<(), String>
&mut self,
body_bytes: &'data [u8]
) -> Result<(), String>
Provides the contents of a function body.
Implementors
impl<'data> ModuleEnvironment<'data> for DummyEnvironment