Struct nanowasm::loader::LoadedModule
[−]
[src]
pub struct LoadedModule { pub name: String, pub types: Vec<FuncType>, pub funcs: Vec<Func>, pub start: Option<FuncIdx>, pub tables: Option<Table>, pub table_initializers: Vec<(ConstExpr, Vec<FuncIdx>)>, pub mem: Option<Memory>, pub mem_initializers: Vec<(ConstExpr, Vec<u8>)>, pub globals: Vec<(Global, ConstExpr)>, pub exported_functions: Vec<Export<FuncIdx>>, pub exported_tables: Option<Export<()>>, pub exported_memories: Option<Export<()>>, pub exported_globals: Vec<Export<GlobalIdx>>, pub imported_functions: Vec<Import<TypeIdx>>, pub imported_tables: Option<Import<TableType>>, pub imported_memories: Option<Import<MemoryType>>, pub imported_globals: Vec<Import<GlobalType>>, }
A loaded wasm module
Fields
name: String
Module name. Not technically necessary, but handy.
types: Vec<FuncType>
Function type vector
funcs: Vec<Func>
Function value vector
start: Option<FuncIdx>
Index of start function, if any.
tables: Option<Table>
wasm 1.0 defines only a single table. Even if we import some other table we can only do it if there's not an existing one, I think.
table_initializers: Vec<(ConstExpr, Vec<FuncIdx>)>
Initializer code for table
(offset, values)
mem: Option<Memory>
wasm 1.0 defines only a single memory.
mem_initializers: Vec<(ConstExpr, Vec<u8>)>
Initializer code for data segments.
globals: Vec<(Global, ConstExpr)>
Global values.
exported_functions: Vec<Export<FuncIdx>>
Exported values
exported_tables: Option<Export<()>>
exported_memories: Option<Export<()>>
exported_globals: Vec<Export<GlobalIdx>>
imported_functions: Vec<Import<TypeIdx>>
Imported values
imported_tables: Option<Import<TableType>>
imported_memories: Option<Import<MemoryType>>
imported_globals: Vec<Import<GlobalType>>
Methods
impl LoadedModule
[src]
pub fn new(name: &str, module: Module) -> Result<Self, Error>
[src]
Instantiates and initializes a new module from the parity_wasm
module type.
This basically goes from a representation very close to the raw webassembly
binary format to a representation more convenient to be loaded into the interpreter's
runtime data.
Does NOT validate the module or run the start function though!
pub fn add_host_func<T>(
&mut self,
export_name: &str,
func: T,
params: &FuncType
) where
T: Fn(&mut Vec<Value>) + 'static,
[src]
&mut self,
export_name: &str,
func: T,
params: &FuncType
) where
T: Fn(&mut Vec<Value>) + 'static,
Adds a host function, plus an export for it. Not really ideal, but what can one do when parity-wasm doesn't handle them either? Hmmm.
pub fn validate(self) -> ValidatedModule
[src]
Validates the module: makes sure types are correct, all the indices into various parts of the module are valid, etc.
TODO: Currently does nothing
Trait Implementations
impl Debug for LoadedModule
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Clone for LoadedModule
[src]
fn clone(&self) -> LoadedModule
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more