From 0cf77f7347d551437baff6bfb7c5768930c50198 Mon Sep 17 00:00:00 2001 From: Henry Gressmann Date: Wed, 6 Dec 2023 16:15:30 +0100 Subject: feat: support basic loops, br_if Signed-off-by: Henry Gressmann --- examples/wasm/loop.wat | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'examples/wasm') diff --git a/examples/wasm/loop.wat b/examples/wasm/loop.wat index 27c6d2e..02683e7 100644 --- a/examples/wasm/loop.wat +++ b/examples/wasm/loop.wat @@ -1,5 +1,5 @@ (module - (func $loopExample (export "loopExample") + (func $loop (export "loop") (result i32) (local i32) ;; Declare a local i32 variable, let's call it 'i' (i32.const 0) ;; Initialize 'i' to 0 (local.set 0) @@ -15,6 +15,8 @@ (i32.lt_s) ;; Check if 'i' is less than 10 (br_if $loopStart) ;; If 'i' < 10, continue the loop ) + + (local.get 0) ;; After the loop, get the value of 'i' to be returned + ;; The function will return the value of 'i' here ) ) - -- cgit v1.3.1