mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-07-31 06:11:58 +00:00
Validate before instantiate
This commit is contained in:
@@ -17,12 +17,14 @@ fn main() {
|
||||
// `deserialize_file` function (which works only with modules)
|
||||
let module = parity_wasm::deserialize_file(&args[1]).expect("Failed to load module");
|
||||
|
||||
let validated_module = parity_wasm::validate_module(module).expect("Failed to validate module");
|
||||
|
||||
// Intialize deserialized module. It adds module into It expects 3 parameters:
|
||||
// - a name for the module
|
||||
// - a module declaration
|
||||
// - "main" module doesn't import native module(s) this is why we don't need to provide external native modules here
|
||||
// This test shows how to implement native module https://github.com/NikVolf/parity-wasm/blob/master/src/interpreter/tests/basics.rs#L197
|
||||
let main = ModuleInstance::new(&module)
|
||||
let main = ModuleInstance::new(&validated_module)
|
||||
.run_start(&mut EmptyExternals)
|
||||
.expect("Failed to initialize module");
|
||||
|
||||
|
Reference in New Issue
Block a user