diff options
| author | Henry Gressmann <mail@henrygressmann.de> | 2025-12-08 21:58:16 +0100 |
|---|---|---|
| committer | Henry Gressmann <mail@henrygressmann.de> | 2025-12-08 21:58:16 +0100 |
| commit | 2911204b3b2508c729c2584016cccd3ef57ffc91 (patch) | |
| tree | a261be9b88891a6509b4f9f2498713e724fecc93 /examples | |
| parent | f7f77cd3026e39a2c29faf539575ef57165c81db (diff) | |
chore: update everything, more simd stuff
Signed-off-by: Henry Gressmann <mail@henrygressmann.de>
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/simple2.rs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/examples/simple2.rs b/examples/simple2.rs new file mode 100644 index 0000000..a3124f8 --- /dev/null +++ b/examples/simple2.rs @@ -0,0 +1,21 @@ +use eyre::Result; +use tinywasm::{Module, Store}; + +const WASM: &str = r#" +(module + (func $return (param $lhs i32) (param $rhs i64) (result i32 i64) + local.get $lhs + local.get $rhs) + (export "return" (func $return))) +"#; + +fn main() -> Result<()> { + let wasm = wat::parse_str(WASM).expect("failed to parse wat"); + let module = Module::parse_bytes(&wasm)?; + let mut store = Store::default(); + let instance = module.instantiate(&mut store, None)?; + let add = instance.exported_func::<(i32, i64), (i32, i64)>(&store, "return")?; + + assert_eq!(add.call(&mut store, (1, 2))?, (1, 2)); + Ok(()) +} |
