2019-03-01 23:48:43 +00:00
|
|
|
use wasmer_runtime::{compile, error, imports, Func, Value};
|
2019-02-28 21:18:00 +00:00
|
|
|
|
|
|
|
use wabt::wat2wasm;
|
|
|
|
|
|
|
|
static WAT: &'static str = r#"
|
|
|
|
(module
|
2019-03-02 04:23:21 +00:00
|
|
|
(type (;0;) (func (param i32) (result i32)))
|
|
|
|
(func (;0;) (type 0) (param i32) (result i32)
|
|
|
|
unreachable)
|
|
|
|
(export "select_trap_l" (func 0))
|
2019-02-28 21:18:00 +00:00
|
|
|
)
|
|
|
|
"#;
|
|
|
|
|
|
|
|
fn get_wasm() -> Vec<u8> {
|
|
|
|
wat2wasm(WAT).unwrap()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() -> Result<(), error::Error> {
|
|
|
|
let wasm = get_wasm();
|
|
|
|
|
|
|
|
let module = compile(&wasm)?;
|
|
|
|
|
|
|
|
let imports = imports! {};
|
|
|
|
|
2019-03-01 23:48:43 +00:00
|
|
|
println!("instantiating");
|
2019-02-28 21:18:00 +00:00
|
|
|
let instance = module.instantiate(&imports)?;
|
|
|
|
|
2019-03-02 04:23:21 +00:00
|
|
|
let foo = instance.dyn_func("select_trap_l")?;
|
2019-02-28 21:18:00 +00:00
|
|
|
|
2019-03-02 04:23:21 +00:00
|
|
|
let result = foo.call(&[Value::I32(0)]);
|
2019-02-28 21:18:00 +00:00
|
|
|
|
|
|
|
println!("result: {:?}", result);
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|