Make calling functions safe

This commit is contained in:
Jef
2019-01-14 18:45:14 +01:00
parent 1eebc65c9e
commit 8312730377
5 changed files with 201 additions and 95 deletions

View File

@@ -22,7 +22,7 @@ fn read_to_end<P: AsRef<Path>>(path: P) -> io::Result<Vec<u8>> {
fn maybe_main() -> Result<(), String> {
let data = read_to_end("test.wasm").map_err(|e| e.to_string())?;
let translated = translate(&data).map_err(|e| e.to_string())?;
let result: u32 = unsafe { translated.execute_func(0, (5u32, 3u32)) };
let result: u32 = translated.execute_func(0, (5u32, 3u32)).unwrap();
println!("f(5, 3) = {}", result);
Ok(())