| 1 |
(module $state |
| 2 |
(type $f (;0;) (func (param i32) (result i32))) |
| 3 |
(type $k (;1;) (cont $f)) |
| 4 |
(type (;2;) (func (result i32))) |
| 5 |
(type (;3;) (func (param i32 (ref $k)) (result i32))) |
| 6 |
(type (;4;) (func (result i32 (ref $k)))) |
| 7 |
(tag $get (;0;) (type 2) (result i32)) |
| 8 |
(tag $set (;1;) (type $f) (param i32) (result i32)) |
| 9 |
(export "run" (func 2)) |
| 10 |
(elem (;0;) declare func $f) |
| 11 |
(func $runner (;0;) (type 3) (param $s i32) (param $k (ref $k)) (result i32) |
| 12 |
loop $loop |
| 13 |
block $on_get (result (ref $k)) |
| 14 |
block $on_set (type 4) (result i32 (ref $k)) |
| 15 |
local.get $s |
| 16 |
local.get $k |
| 17 |
resume $k (on $get $on_get) (on $set $on_set) |
| 18 |
return |
| 19 |
end |
| 20 |
local.set $k |
| 21 |
local.set $s |
| 22 |
br $loop |
| 23 |
end |
| 24 |
local.set $k |
| 25 |
br $loop |
| 26 |
end |
| 27 |
unreachable |
| 28 |
) |
| 29 |
(func $f (;1;) (type $f) (param i32) (result i32) |
| 30 |
i32.const 7 |
| 31 |
suspend $set |
| 32 |
drop |
| 33 |
suspend $get |
| 34 |
i32.const 2 |
| 35 |
i32.const 3 |
| 36 |
suspend $set |
| 37 |
suspend $get |
| 38 |
i32.add |
| 39 |
i32.mul |
| 40 |
i32.add |
| 41 |
) |
| 42 |
(func (;2;) (type 2) (result i32) |
| 43 |
i32.const 0 |
| 44 |
ref.func $f |
| 45 |
cont.new $k |
| 46 |
call $runner |
| 47 |
) |
| 48 |
) |