Debian Codegraph @

tests/snapshots/cli/stack-switching/pipes.wast/2.print

raw
1 (module
2 (type $pfun (;0;) (func (result i32)))
3 (type $cfun (;1;) (func (param i32) (result i32)))
4 (type $producer (;2;) (cont $pfun))
5 (type $consumer (;3;) (cont $cfun))
6 (type (;4;) (func (param i32)))
7 (type (;5;) (func (param (ref $producer) (ref $consumer))))
8 (import "pipes" "send" (tag $send (;0;) (type 4) (param i32)))
9 (import "pipes" "receive" (tag $receive (;1;) (type $pfun) (result i32)))
10 (import "pipes" "pipe" (func $pipe (;0;) (type 5)))
11 (import "spectest" "print_i32" (func $log (;1;) (type 4)))
12 (export "run" (func 4))
13 (elem (;0;) declare func $nats $sum)
14 (func $nats (;2;) (type $cfun) (param $n i32) (result i32)
15 loop $l
16 i32.const -1
17 call $log
18 local.get $n
19 call $log
20 local.get $n
21 suspend $send
22 local.get $n
23 i32.const 1
24 i32.add
25 local.set $n
26 br $l
27 end
28 unreachable
29 )
30 (func $sum (;3;) (type $cfun) (param $dummy i32) (result i32)
31 (local $i i32) (local $a i32)
32 i32.const 10
33 local.set $i
34 i32.const 0
35 local.set $a
36 loop $l
37 local.get $a
38 suspend $receive
39 i32.add
40 local.set $a
41 i32.const -2
42 call $log
43 local.get $a
44 call $log
45 local.get $i
46 i32.const 1
47 i32.sub
48 local.set $i
49 local.get $i
50 i32.const 0
51 i32.ne
52 br_if $l
53 end
54 local.get $a
55 return
56 )
57 (func (;4;) (type 4) (param $n i32)
58 local.get $n
59 ref.func $nats
60 cont.new $consumer
61 cont.bind $consumer $producer
62 ref.func $sum
63 cont.new $consumer
64 call $pipe
65 )
66 )