Debian Codegraph @

tests/snapshots/cli/stack-switching/async-await.wast/8.print

raw
1 (module $scheduler
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 (;4;) (func (param i32 i32)))
7 (type (;5;) (func (param (ref $i-cont)) (result i32)))
8 (type (;6;) (func (param i32) (result i32)))
9 (type (;7;) (func (result i32)))
10 (type (;8;) (func (result (ref null $cont))))
11 (type (;9;) (func (param (ref null $cont))))
12 (type (;10;) (func (param i32 (ref $i-cont))))
13 (type (;11;) (func (param i32 i32) (result (ref null $cont))))
14 (type (;12;) (func (result i32 i32 (ref $cont))))
15 (type (;13;) (func (result (ref $i-cont) (ref $i-cont))))
16 (type (;14;) (func (result i32 (ref $i-cont))))
17 (import "async-await" "yield" (tag $yield (;0;) (type $func)))
18 (import "async-await" "fulfill" (tag $fulfill (;1;) (type 4) (param i32 i32)))
19 (import "async-await" "async" (tag $async (;2;) (type 5) (param (ref $i-cont)) (result i32)))
20 (import "async-await" "await" (tag $await (;3;) (type 6) (param i32) (result i32)))
21 (import "queue" "queue-empty" (func $queue-empty (;0;) (type 7)))
22 (import "queue" "dequeue" (func $dequeue (;1;) (type 8)))
23 (import "queue" "enqueue" (func $enqueue (;2;) (type 9)))
24 (import "promise" "new" (func $new-promise (;3;) (type 7)))
25 (import "promise" "fulfilled" (func $promise-fulfilled (;4;) (type 6)))
26 (import "promise" "read" (func $promise-value (;5;) (type 6)))
27 (import "promise" "await" (func $await-promise (;6;) (type 10)))
28 (import "promise" "fulfill" (func $fulfill-promise (;7;) (type 11)))
29 (export "run" (func $run))
30 (func $run (;8;) (type 9) (param $nextk (ref null $cont))
31 (local $p i32) (local $v i32) (local $ik (ref $i-cont)) (local $ak (ref $i-cont)) (local $k (ref null $cont))
32 loop $l
33 local.get $nextk
34 ref.is_null
35 if ;; label = @2
36 return
37 end
38 block $on_yield (result (ref $cont))
39 block $on_fulfill (type 12) (result i32 i32 (ref $cont))
40 block $on_async (type 13) (result (ref $i-cont) (ref $i-cont))
41 block $on_await (type 14) (result i32 (ref $i-cont))
42 local.get $nextk
43 resume $cont (on $yield $on_yield) (on $fulfill $on_fulfill) (on $async $on_async) (on $await $on_await)
44 call $dequeue
45 local.set $nextk
46 br $l
47 end
48 local.set $ik
49 local.set $p
50 local.get $p
51 call $promise-fulfilled
52 if ;; label = @5
53 local.get $p
54 call $promise-value
55 local.get $ik
56 cont.bind $i-cont $cont
57 local.set $nextk
58 else
59 local.get $p
60 local.get $ik
61 call $await-promise
62 call $dequeue
63 local.set $nextk
64 end
65 br $l
66 end
67 local.set $ik
68 local.set $ak
69 call $new-promise
70 local.set $p
71 local.get $p
72 local.get $ik
73 cont.bind $i-cont $cont
74 call $enqueue
75 local.get $p
76 local.get $ak
77 cont.bind $i-cont $cont
78 local.set $nextk
79 br $l
80 end
81 local.set $nextk
82 local.set $v
83 local.set $p
84 local.get $p
85 local.get $v
86 call $fulfill-promise
87 local.set $k
88 local.get $k
89 ref.is_null
90 if ;; label = @3
91 else
92 local.get $k
93 call $enqueue
94 end
95 br $l
96 end
97 call $enqueue
98 call $dequeue
99 local.set $nextk
100 br $l
101 end
102 )
103 )