* Tidy up the `hello` example for `wasmtime` * Remove the `*.wat` and `*.wasm` files and instead just inline the `*.wat` into the example. * Touch up comments so they're not just a repeat of the `println!` below. * Move `*.wat` for `memory` example inline No need to handle auxiliary files with the ability to parse it inline! * Move `multi.wasm` inline into `multi.rs` example * Move `*.wasm` for gcd example inline * Move `*.wat` inline with `import_calling_export` test * Remove checked in `lightbeam/test.wasm` Instead move the `*.wat` into the source and parse it into wasm there. * Run rustfmt
17 lines
376 B
Rust
17 lines
376 B
Rust
use lightbeam::translate;
|
|
|
|
const WAT: &str = r#"
|
|
(module
|
|
(func (param i32) (param i32) (result i32) (i32.add (get_local 0) (get_local 1)))
|
|
)
|
|
"#;
|
|
|
|
fn main() -> anyhow::Result<()> {
|
|
let data = wat::parse_str(WAT)?;
|
|
let translated = translate(&data)?;
|
|
let result: u32 = translated.execute_func(0, (5u32, 3u32))?;
|
|
println!("f(5, 3) = {}", result);
|
|
|
|
Ok(())
|
|
}
|