comments update + remove empty space

This commit is contained in:
fro
2017-08-21 17:49:36 +03:00
parent b06a5a98c8
commit f06daece56
3 changed files with 17 additions and 10 deletions

View File

@ -18,6 +18,7 @@ fn main() {
// Intrepreter initialization. // Intrepreter initialization.
// parity_wasm::ProgramInstance can be parameterized with a custom User error which could be returned from imported functions // parity_wasm::ProgramInstance can be parameterized with a custom User error which could be returned from imported functions
// parity_wasm::DefaultProgramInstance parametrize ProgramInstance with a pre-defined "DummyUserError" // parity_wasm::DefaultProgramInstance parametrize ProgramInstance with a pre-defined "DummyUserError"
// Initializes a default "env" module also.
let program = parity_wasm::DefaultProgramInstance::with_env_params( let program = parity_wasm::DefaultProgramInstance::with_env_params(
interpreter::EnvParams { interpreter::EnvParams {
total_stack: 128*1024, total_stack: 128*1024,
@ -37,7 +38,7 @@ fn main() {
// Type section stores function types which are referenced by function_section entries // Type section stores function types which are referenced by function_section entries
let type_section = module.type_section().expect("No type section found"); let type_section = module.type_section().expect("No type section found");
// A given function name used to find export section entry which contains // Given function name used to find export section entry which contains
// an `internal` field which points to the index in the function index space // an `internal` field which points to the index in the function index space
let found_entry = export_section.entries().iter() let found_entry = export_section.entries().iter()
.find(|entry| func_name == entry.field()).expect(&format!("No export with name {} found", func_name)); .find(|entry| func_name == entry.field()).expect(&format!("No export with name {} found", func_name));
@ -81,7 +82,13 @@ fn main() {
interpreter::ExecutionParams::from(args) interpreter::ExecutionParams::from(args)
}; };
// Intialize deserialized module. // Intialize deserialized module. It adds module into It expects 3 parameters:
// - a name for the module
// - a module declaration
// - an optional HashMap of additional external modules (which takes priority over already initialized modules)
// to be:
// - formally validated
// - validated imports against these external modules
let module = program.add_module("main", module, None).expect("Failed to initialize module"); let module = program.add_module("main", module, None).expect("Failed to initialize module");
println!("Result: {:?}", module.execute_export(func_name, execution_params).expect("")); println!("Result: {:?}", module.execute_export(func_name, execution_params).expect(""));

View File

@ -474,7 +474,7 @@ impl<E> ModuleInstanceInterface<E> for ModuleInstance<E> where E: UserError {
}, },
}) })
.map(|i| *i) .map(|i| *i)
.ok_or(Error::Program(format!("unresolved import {}", name)))) .ok_or(Error::Program(format!("unresolved export {}", name))))
} }
fn table(&self, index: ItemIndex) -> Result<Arc<TableInstance<E>>, Error<E>> { fn table(&self, index: ItemIndex) -> Result<Arc<TableInstance<E>>, Error<E>> {