Skip to content

Commit 2c20187

Browse files
committed
Add a switch example
1 parent 25cbd42 commit 2c20187

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

projects/runtime/tests/switch.wat

+6-6
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@
4141
(import "w:unstable/printer" "print-u32" (func $print_u32 (param $value i32)))
4242
(func $match (param $x i32) (result i32)
4343
(block $default
44-
(block
45-
(block
46-
(block
47-
(block
44+
(block $case-3
45+
(block $case-2
46+
(block $case-1
47+
(block $case-0
4848
(local.get $x)
49-
(br_table 3 2 1 0 $default)
49+
(br_table $case-0 $case-1 $case-2 $case-3 $default)
5050
(return (i32.const 99))
5151
)
5252
(return (i32.const 100))
@@ -60,7 +60,7 @@
6060
(i32.const 104)
6161
)
6262
(func $main
63-
(call $match i32.const 6)
63+
(call $match i32.const -1)
6464
(call $print_i32)
6565
)
6666
(start $main)

0 commit comments

Comments
 (0)