Debian Codegraph @

tests/snapshots/cli/stack-switching/fun-actor-lwt.wast/12.print

raw
1 (module $actor-as-lwt
2 (type $func (;0;) (func))
3 (type $cont (;1;) (cont $func))
4 (type $i-func (;2;) (func (param i32)))
5 (type $i-cont (;3;) (cont $i-func))
6 (type $icont-func (;4;) (func (param i32 (ref $cont))))
7 (type $icont-cont (;5;) (cont $icont-func))
8 (type (;6;) (func (param (ref $cont))))
9 (type (;7;) (func (param i32) (result i32)))
10 (type (;8;) (func (result i32)))
11 (type (;9;) (func (param i32 i32)))
12 (type (;10;) (func (param (ref $cont)) (result i32)))
13 (type (;11;) (func (param i32 i32 (ref $i-cont))))
14 (type (;12;) (func (result (ref $cont) (ref $i-cont))))
15 (type (;13;) (func (result i32 i32 (ref $cont))))
16 (import "spectest" "print_i32" (func $log (;0;) (type $i-func)))
17 (import "lwt" "yield" (tag $yield (;0;) (type $func)))
18 (import "lwt" "fork" (tag $fork (;1;) (type 6) (param (ref $cont))))
19 (import "mailboxes" "init" (func $init (;1;) (type $func)))
20 (import "mailboxes" "empty-mb" (func $empty-mb (;2;) (type 7)))
21 (import "mailboxes" "new-mb" (func $new-mb (;3;) (type 8)))
22 (import "mailboxes" "send-to-mb" (func $send-to-mb (;4;) (type 9)))
23 (import "mailboxes" "recv-from-mb" (func $recv-from-mb (;5;) (type 7)))
24 (import "actor" "self" (tag $self (;2;) (type 8) (result i32)))
25 (import "actor" "spawn" (tag $spawn (;3;) (type 10) (param (ref $cont)) (result i32)))
26 (import "actor" "send" (tag $send (;4;) (type 9) (param i32 i32)))
27 (import "actor" "recv" (tag $recv (;5;) (type 8) (result i32)))
28 (export "act" (func $act))
29 (elem (;0;) declare func $act-nullary $act-res)
30 (func $act-res (;6;) (type 11) (param $mine i32) (param $res i32) (param $ik (ref $i-cont))
31 (local $yours i32) (local $k (ref $cont)) (local $you (ref $cont))
32 block $on_self (result (ref $i-cont))
33 block $on_spawn (type 12) (result (ref $cont) (ref $i-cont))
34 block $on_send (type 13) (result i32 i32 (ref $cont))
35 block $on_recv (result (ref $i-cont))
36 local.get $res
37 local.get $ik
38 resume $i-cont (on $self $on_self) (on $spawn $on_spawn) (on $send $on_send) (on $recv $on_recv)
39 return
40 end
41 local.set $ik
42 loop $l
43 local.get $mine
44 call $empty-mb
45 if ;; label = @5
46 suspend $yield
47 br $l
48 end
49 end
50 local.get $mine
51 call $recv-from-mb
52 local.set $res
53 local.get $mine
54 local.get $res
55 local.get $ik
56 return_call $act-res
57 end
58 local.set $k
59 call $send-to-mb
60 local.get $mine
61 local.get $k
62 return_call $act-nullary
63 end
64 local.set $ik
65 local.set $you
66 call $new-mb
67 local.set $yours
68 local.get $yours
69 local.get $you
70 ref.func $act-nullary
71 cont.new $icont-cont
72 cont.bind $icont-cont $cont
73 suspend $fork
74 local.get $mine
75 local.get $yours
76 local.get $ik
77 return_call $act-res
78 end
79 local.set $ik
80 local.get $mine
81 local.get $mine
82 local.get $ik
83 return_call $act-res
84 )
85 (func $act-nullary (;7;) (type $icont-func) (param $mine i32) (param $k (ref $cont))
86 (local $res i32) (local $ik (ref $i-cont)) (local $you (ref $cont)) (local $yours i32)
87 block $on_self (result (ref $i-cont))
88 block $on_spawn (type 12) (result (ref $cont) (ref $i-cont))
89 block $on_send (type 13) (result i32 i32 (ref $cont))
90 block $on_recv (result (ref $i-cont))
91 local.get $k
92 resume $cont (on $self $on_self) (on $spawn $on_spawn) (on $send $on_send) (on $recv $on_recv)
93 return
94 end
95 local.set $ik
96 loop $l
97 local.get $mine
98 call $empty-mb
99 if ;; label = @5
100 suspend $yield
101 br $l
102 end
103 end
104 local.get $mine
105 call $recv-from-mb
106 local.set $res
107 local.get $mine
108 local.get $res
109 local.get $ik
110 return_call $act-res
111 end
112 local.set $k
113 call $send-to-mb
114 local.get $mine
115 local.get $k
116 return_call $act-nullary
117 end
118 local.set $ik
119 local.set $you
120 call $new-mb
121 local.set $yours
122 local.get $yours
123 local.get $you
124 ref.func $act-nullary
125 cont.new $icont-cont
126 cont.bind $icont-cont $cont
127 suspend $fork
128 local.get $mine
129 local.get $yours
130 local.get $ik
131 return_call $act-res
132 end
133 local.set $ik
134 local.get $mine
135 local.get $mine
136 local.get $ik
137 return_call $act-res
138 )
139 (func $act (;8;) (type 6) (param $k (ref $cont))
140 call $init
141 call $new-mb
142 local.get $k
143 call $act-nullary
144 )
145 )