You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/interpret.rs
+14-11Lines changed: 14 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -4,14 +4,14 @@ extern crate wasmi;
4
4
5
5
use std::env::args;
6
6
use std::fs::File;
7
-
use wasmi::{ModuleInstance,NopExternals,RuntimeValue,ImportsBuilder,Module};
7
+
use wasmi::{ImportsBuilder,Module,ModuleInstance,NopExternals,RuntimeValue};
8
8
9
9
fnload_from_file(filename:&str) -> Module{
10
-
use std::io::prelude::*;
11
-
letmut file = File::open(filename).unwrap();
12
-
letmut buf = Vec::new();
13
-
file.read_to_end(&mut buf).unwrap();
14
-
Module::from_buffer(buf).unwrap()
10
+
use std::io::prelude::*;
11
+
letmut file = File::open(filename).unwrap();
12
+
letmut buf = Vec::new();
13
+
file.read_to_end(&mut buf).unwrap();
14
+
Module::from_buffer(buf).unwrap()
15
15
}
16
16
17
17
fnmain(){
@@ -27,10 +27,10 @@ fn main() {
27
27
let module = load_from_file(&args[1]);
28
28
29
29
// Intialize deserialized module. It adds module into It expects 3 parameters:
30
-
// - a name for the module
31
-
// - a module declaration
32
-
// - "main" module doesn't import native module(s) this is why we don't need to provide external native modules here
33
-
// This test shows how to implement native module https://github.com/NikVolf/parity-wasm/blob/master/src/interpreter/tests/basics.rs#L197
30
+
// - a name for the module
31
+
// - a module declaration
32
+
// - "main" module doesn't import native module(s) this is why we don't need to provide external native modules here
33
+
// This test shows how to implement native module https://github.com/NikVolf/parity-wasm/blob/master/src/interpreter/tests/basics.rs#L197
34
34
let main = ModuleInstance::new(&module,&ImportsBuilder::default())
35
35
.expect("Failed to instantiate module")
36
36
.run_start(&mutNopExternals)
@@ -40,5 +40,8 @@ fn main() {
40
40
let argument:i32 = args[2].parse().expect("Integer argument required");
41
41
42
42
// "_call" export of function to be executed with an i32 argument and prints the result of execution
0 commit comments