summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorHenry Gressmann <mail@henrygressmann.de>2023-12-06 16:15:30 +0100
committerHenry Gressmann <mail@henrygressmann.de>2023-12-06 16:15:30 +0100
commit0cf77f7347d551437baff6bfb7c5768930c50198 (patch)
tree7b8e63f4e326a574ed6b7cc2b7832873225fe9f6 /examples
parent7d167c2fadb370a33dd65b387dbab9d053f103a9 (diff)
feat: support basic loops, br_if
Signed-off-by: Henry Gressmann <mail@henrygressmann.de>
Diffstat (limited to 'examples')
-rw-r--r--examples/wasm/loop.wat6
1 files changed, 4 insertions, 2 deletions
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
)
)
-