blob: e3a0052a6d6d295778b4258975bcf8cd3f2b53e3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
;; Functions
(module (func) (export "a" (func 0)))
(module (func) (export "a" (func 0)) (export "b" (func 0)))
(module (func) (func) (export "a" (func 0)) (export "b" (func 1)))
(module (func (export "a")))
(module (func) (export "a" (func 0)))
(module (func $a (export "a")))
(module (func $a) (export "a" (func $a)))
(module (export "a" (func 0)) (func))
(module (export "a" (func $a)) (func $a))
(module $Func
(export "e" (func $f))
(func $f (param $n i32) (result i32)
(return (i32.add (get_local $n) (i32.const 1)))
)
)
(assert_return (invoke "e" (i32.const 42)) (i32.const 43))
(assert_return (invoke $Func "e" (i32.const 42)) (i32.const 43))
(module)
(module $Other1)
(assert_return (invoke $Func "e" (i32.const 42)) (i32.const 43))
(assert_invalid
(module (func) (export "a" (func 1)))
"unknown function"
)
(assert_invalid
(module (func) (export "a" (func 0)) (export "a" (func 0)))
"duplicate export name"
)
(assert_invalid
(module (func) (func) (export "a" (func 0)) (export "a" (func 1)))
"duplicate export name"
)
(assert_invalid
(module (func) (global i32 (i32.const 0)) (export "a" (func 0)) (export "a" (global 0)))
"duplicate export name"
)
(assert_invalid
(module (func) (table 0 anyfunc) (export "a" (func 0)) (export "a" (table 0)))
"duplicate export name"
)
(assert_invalid
(module (func) (memory 0) (export "a" (func 0)) (export "a" (memory 0)))
"duplicate export name"
)
;; Globals
(module (global i32 (i32.const 0)) (export "a" (global 0)))
(module (global i32 (i32.const 0)) (export "a" (global 0)) (export "b" (global 0)))
(module (global i32 (i32.const 0)) (global i32 (i32.const 0)) (export "a" (global 0)) (export "b" (global 1)))
(module (global (export "a") i32 (i32.const 0)))
(module (global i32 (i32.const 0)) (export "a" (global 0)))
(module (global $a (export "a") i32 (i32.const 0)))
(module (global $a i32 (i32.const 0)) (export "a" (global $a)))
(module (export "a" (global 0)) (global i32 (i32.const 0)))
(module (export "a" (global $a)) (global $a i32 (i32.const 0)))
(module $Global
(export "e" (global $g))
(global $g i32 (i32.const 42))
)
(assert_return (get "e") (i32.const 42))
(assert_return (get $Global "e") (i32.const 42))
(module)
(module $Other2)
(assert_return (get $Global "e") (i32.const 42))
(assert_invalid
(module (global i32 (i32.const 0)) (export "a" (global 1)))
"unknown global"
)
(assert_invalid
(module (global i32 (i32.const 0)) (export "a" (global 0)) (export "a" (global 0)))
"duplicate export name"
)
(assert_invalid
(module (global i32 (i32.const 0)) (global i32 (i32.const 0)) (export "a" (global 0)) (export "a" (global 1)))
"duplicate export name"
)
(assert_invalid
(module (global i32 (i32.const 0)) (func) (export "a" (global 0)) (export "a" (func 0)))
"duplicate export name"
)
(assert_invalid
(module (global i32 (i32.const 0)) (table 0 anyfunc) (export "a" (global 0)) (export "a" (table 0)))
"duplicate export name"
)
(assert_invalid
(module (global i32 (i32.const 0)) (memory 0) (export "a" (global 0)) (export "a" (memory 0)))
"duplicate export name"
)
;; Tables
(module (table 0 anyfunc) (export "a" (table 0)))
(module (table 0 anyfunc) (export "a" (table 0)) (export "b" (table 0)))
;; No multiple tables yet.
;; (module (table 0 anyfunc) (table 0 anyfunc) (export "a" (table 0)) (export "b" (table 1)))
(module (table (export "a") 0 anyfunc))
(module (table (export "a") 0 1 anyfunc))
(module (table 0 anyfunc) (export "a" (table 0)))
(module (table 0 1 anyfunc) (export "a" (table 0)))
(module (table $a (export "a") 0 anyfunc))
(module (table $a (export "a") 0 1 anyfunc))
(module (table $a 0 anyfunc) (export "a" (table $a)))
(module (table $a 0 1 anyfunc) (export "a" (table $a)))
(module (export "a" (table 0)) (table 0 anyfunc))
(module (export "a" (table 0)) (table 0 1 anyfunc))
(module (export "a" (table $a)) (table $a 0 anyfunc))
(module (export "a" (table $a)) (table $a 0 1 anyfunc))
(; TODO: access table ;)
(assert_invalid
(module (table 0 anyfunc) (export "a" (table 1)))
"unknown table"
)
(assert_invalid
(module (table 0 anyfunc) (export "a" (table 0)) (export "a" (table 0)))
"duplicate export name"
)
;; No multiple tables yet.
;; (assert_invalid
;; (module (table 0 anyfunc) (table 0 anyfunc) (export "a" (table 0)) (export "a" (table 1)))
;; "duplicate export name"
;; )
(assert_invalid
(module (table 0 anyfunc) (func) (export "a" (table 0)) (export "a" (func 0)))
"duplicate export name"
)
(assert_invalid
(module (table 0 anyfunc) (global i32 (i32.const 0)) (export "a" (table 0)) (export "a" (global 0)))
"duplicate export name"
)
(assert_invalid
(module (table 0 anyfunc) (memory 0) (export "a" (table 0)) (export "a" (memory 0)))
"duplicate export name"
)
;; Memories
(module (memory 0) (export "a" (memory 0)))
(module (memory 0) (export "a" (memory 0)) (export "b" (memory 0)))
;; No multiple memories yet.
;; (module (memory 0) (memory 0) (export "a" (memory 0)) (export "b" (memory 1)))
(module (memory (export "a") 0))
(module (memory (export "a") 0 1))
(module (memory 0) (export "a" (memory 0)))
(module (memory 0 1) (export "a" (memory 0)))
(module (memory $a (export "a") 0))
(module (memory $a (export "a") 0 1))
(module (memory $a 0) (export "a" (memory $a)))
(module (memory $a 0 1) (export "a" (memory $a)))
(module (export "a" (memory 0)) (memory 0))
(module (export "a" (memory 0)) (memory 0 1))
(module (export "a" (memory $a)) (memory $a 0))
(module (export "a" (memory $a)) (memory $a 0 1))
(; TODO: access memory ;)
(assert_invalid
(module (memory 0) (export "a" (memory 1)))
"unknown memory"
)
(assert_invalid
(module (memory 0) (export "a" (memory 0)) (export "a" (memory 0)))
"duplicate export name"
)
;; No multiple memories yet.
;; (assert_invalid
;; (module (memory 0) (memory 0) (export "a" (memory 0)) (export "a" (memory 1)))
;; "duplicate export name"
;; )
(assert_invalid
(module (memory 0) (func) (export "a" (memory 0)) (export "a" (func 0)))
"duplicate export name"
)
(assert_invalid
(module (memory 0) (global i32 (i32.const 0)) (export "a" (memory 0)) (export "a" (global 0)))
"duplicate export name"
)
(assert_invalid
(module (memory 0) (table 0 anyfunc) (export "a" (memory 0)) (export "a" (table 0)))
"duplicate export name"
)
|