From 2717520215f17d6239ec84d60ca05b50f149529f Mon Sep 17 00:00:00 2001 From: Glenn Skrzypczak <81387843+skyz1@users.noreply.github.com> Date: Sun, 24 Mar 2024 19:29:21 +0100 Subject: [PATCH] wasm example --- packages/Wasm/_.candy | 0 packages/Wasm/_package.candy | 0 packages/Wasm/example.candy | 22 ++++++++++++++++++++++ 3 files changed, 22 insertions(+) create mode 100644 packages/Wasm/_.candy create mode 100644 packages/Wasm/_package.candy create mode 100644 packages/Wasm/example.candy diff --git a/packages/Wasm/_.candy b/packages/Wasm/_.candy new file mode 100644 index 000000000..e69de29bb diff --git a/packages/Wasm/_package.candy b/packages/Wasm/_package.candy new file mode 100644 index 000000000..e69de29bb diff --git a/packages/Wasm/example.candy b/packages/Wasm/example.candy new file mode 100644 index 000000000..44c107f30 --- /dev/null +++ b/packages/Wasm/example.candy @@ -0,0 +1,22 @@ +[print] = use "Builtins" +[struct, result] = use "Core" + +main := { environment -> + wat = '" + (module + (type $t0 (func (param i32) (result i32))) + (func $add_one (export "add_one") (type $t0) (param $p0 i32) (result i32) + get_local $p0 + i32.const 1 + i32.add)) + "' + + module = wat | environment.wasm.compile | result.unwrap + instance = [] | module.instantiate | result.unwrap + add_one = instance | struct.get "add_one" | result.unwrap + + num = 42 + res = add_one num + (res,) = res | result.unwrap + print "{num} + 1 = {res}" +}