Debian Codegraph @

tests/cli/component-model-async/abi.wast

raw
1 ;; RUN: wast --assert default --snapshot tests/snapshots % -f cm-async,cm-fixed-size-list,cm-async-stackful
2
3 ;; async lower
4 (component
5 (core module $libc (memory (export "memory") 1))
6 (core instance $libc (instantiate $libc))
7
8 ;; func()
9 (import "f1" (func $f1))
10 (core func $f1 (canon lower (func $f1) async))
11 (core module $m1 (func (import "" "f") (result i32)))
12 (core instance (instantiate $m1 (with "" (instance (export "f" (func $f1))))))
13
14 ;; func(x: u32)
15 (import "f2" (func $f2 (param "x" u32)))
16 (core func $f2 (canon lower (func $f2) async))
17 (core module $m2 (func (import "" "f") (param i32) (result i32)))
18 (core instance (instantiate $m2 (with "" (instance (export "f" (func $f2))))))
19
20 ;; func() -> u32
21 (import "f3" (func $f3 (result u32)))
22 (core func $f3 (canon lower (func $f3) async (memory $libc "memory")))
23 (core module $m3 (func (import "" "f") (param i32) (result i32)))
24 (core instance (instantiate $m3 (with "" (instance (export "f" (func $f3))))))
25
26 ;; func(x: u32, y: f32, z: string)
27 (import "f4" (func $f4 (param "x" u32) (param "y" f32) (param "z" string)))
28 (core func $f4 (canon lower (func $f4) async (memory $libc "memory")))
29 (core module $m4 (func (import "" "f") (param i32 f32 i32 i32) (result i32)))
30 (core instance (instantiate $m4 (with "" (instance (export "f" (func $f4))))))
31
32 ;; func() -> f32
33 (import "f5" (func $f5 (result f32)))
34 (core func $f5 (canon lower (func $f5) async (memory $libc "memory")))
35 (core module $m5 (func (import "" "f") (param i32) (result i32)))
36 (core instance (instantiate $m5 (with "" (instance (export "f" (func $f5))))))
37
38 ;; func(x: list<string; 4>) -> f32
39 (import "f6" (func $f6 (param "x" (list string 6)) (result f32)))
40 (core func $f6 (canon lower (func $f6) async (memory $libc "memory")))
41 (core module $m6 (func (import "" "f") (param i32 i32) (result i32)))
42 (core instance (instantiate $m6 (with "" (instance (export "f" (func $f6))))))
43 )
44
45 ;; async lift, callback abi
46 (component
47 ;; func()
48 (core module $m1
49 (func (export "cb") (param i32 i32 i32) (result i32) unreachable)
50 (func (export "f") (result i32) unreachable))
51 (core instance $m1 (instantiate $m1))
52 (func
53 (canon lift (core func $m1 "f") async (callback (func $m1 "cb"))))
54
55 ;; func(x: u32)
56 (core module $m2
57 (func (export "cb") (param i32 i32 i32) (result i32) unreachable)
58 (func (export "f") (param i32) (result i32) unreachable))
59 (core instance $m2 (instantiate $m2))
60 (func (param "x" u32)
61 (canon lift (core func $m2 "f") async (callback (func $m2 "cb"))))
62
63 ;; func() -> u32
64 (core module $m3
65 (func (export "cb") (param i32 i32 i32) (result i32) unreachable)
66 (func (export "f") (result i32) unreachable))
67 (core instance $m3 (instantiate $m3))
68 (func (result u32)
69 (canon lift (core func $m3 "f") async (callback (func $m3 "cb"))))
70
71 ;; func(x: f32)
72 (core module $m4
73 (func (export "cb") (param i32 i32 i32) (result i32) unreachable)
74 (func (export "f") (param f32) (result i32) unreachable))
75 (core instance $m4 (instantiate $m4))
76 (func (param "x" f32)
77 (canon lift (core func $m4 "f") async (callback (func $m4 "cb"))))
78
79 ;; func(x: f32, y: string)
80 (core module $m5
81 (memory (export "memory") 1)
82 (func (export "cb") (param i32 i32 i32) (result i32) unreachable)
83 (func (export "realloc") (param i32 i32 i32 i32) (result i32) unreachable)
84 (func (export "f") (param f32 i32 i32) (result i32) unreachable))
85 (core instance $m5 (instantiate $m5))
86 (func (param "x" f32) (param "y" string)
87 (canon lift (core func $m5 "f") async (callback (func $m5 "cb"))
88 (memory $m5 "memory") (realloc (func $m5 "realloc"))))
89
90 ;; func(x: list<string; 4>)
91 (core module $m6
92 (memory (export "memory") 1)
93 (func (export "cb") (param i32 i32 i32) (result i32) unreachable)
94 (func (export "realloc") (param i32 i32 i32 i32) (result i32) unreachable)
95 (func (export "f") (param i32 i32 i32 i32 i32 i32 i32 i32) (result i32) unreachable))
96 (core instance $m6 (instantiate $m6))
97 (func (param "x" (list string 4))
98 (canon lift (core func $m6 "f") async (callback (func $m6 "cb"))
99 (memory $m6 "memory") (realloc (func $m6 "realloc"))))
100
101 ;; func(x: list<string; 10>)
102 (core module $m7
103 (memory (export "memory") 1)
104 (func (export "cb") (param i32 i32 i32) (result i32) unreachable)
105 (func (export "realloc") (param i32 i32 i32 i32) (result i32) unreachable)
106 (func (export "f") (param i32) (result i32) unreachable))
107 (core instance $m7 (instantiate $m7))
108 (func (param "x" (list string 10))
109 (canon lift (core func $m7 "f") async (callback (func $m7 "cb"))
110 (memory $m7 "memory") (realloc (func $m7 "realloc"))))
111 )
112
113 ;; async lift, stackful abi
114 (component
115 ;; func()
116 (core module $m1
117 (func (export "f") unreachable))
118 (core instance $m1 (instantiate $m1))
119 (func
120 (canon lift (core func $m1 "f") async))
121
122 ;; func(x: u32)
123 (core module $m2
124 (func (export "f") (param i32) unreachable))
125 (core instance $m2 (instantiate $m2))
126 (func (param "x" u32)
127 (canon lift (core func $m2 "f") async))
128
129 ;; func() -> u32
130 (core module $m3
131 (func (export "f") unreachable))
132 (core instance $m3 (instantiate $m3))
133 (func (result u32)
134 (canon lift (core func $m3 "f") async))
135
136 ;; func(x: f32)
137 (core module $m4
138 (func (export "f") (param f32) unreachable))
139 (core instance $m4 (instantiate $m4))
140 (func (param "x" f32)
141 (canon lift (core func $m4 "f") async))
142
143 ;; func(x: f32, y: string)
144 (core module $m5
145 (memory (export "memory") 1)
146 (func (export "realloc") (param i32 i32 i32 i32) (result i32) unreachable)
147 (func (export "f") (param f32 i32 i32) unreachable))
148 (core instance $m5 (instantiate $m5))
149 (func (param "x" f32) (param "y" string)
150 (canon lift (core func $m5 "f") async
151 (memory $m5 "memory") (realloc (func $m5 "realloc"))))
152
153 ;; func(x: list<string; 4>)
154 (core module $m6
155 (memory (export "memory") 1)
156 (func (export "realloc") (param i32 i32 i32 i32) (result i32) unreachable)
157 (func (export "f") (param i32 i32 i32 i32 i32 i32 i32 i32) unreachable))
158 (core instance $m6 (instantiate $m6))
159 (func (param "x" (list string 4))
160 (canon lift (core func $m6 "f") async
161 (memory $m6 "memory") (realloc (func $m6 "realloc"))))
162
163 ;; func(x: list<string; 10>)
164 (core module $m7
165 (memory (export "memory") 1)
166 (func (export "realloc") (param i32 i32 i32 i32) (result i32) unreachable)
167 (func (export "f") (param i32) unreachable))
168 (core instance $m7 (instantiate $m7))
169 (func (param "x" (list string 10))
170 (canon lift (core func $m7 "f") async
171 (memory $m7 "memory") (realloc (func $m7 "realloc"))))
172 )