@grain/binaryen.ml 0.33.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- binaryen-archive/CHANGELOG.md +30 -0
- binaryen-archive/binaryen.opam +2 -2
- binaryen-archive/esy.lock/index.json +392 -293
- binaryen-archive/esy.lock/opam/base.v0.17.3/opam +4 -2
- binaryen-archive/esy.lock/opam/{chrome-trace.3.20.2 → chrome-trace.3.21.1}/opam +5 -5
- binaryen-archive/esy.lock/opam/{dune-build-info.3.20.2 → dune-build-info.3.21.1}/opam +5 -5
- binaryen-archive/esy.lock/opam/{dune-configurator.3.20.2 → dune-configurator.3.21.1}/opam +5 -5
- binaryen-archive/esy.lock/opam/{dune-rpc.3.20.2 → dune-rpc.3.21.1}/opam +5 -5
- binaryen-archive/esy.lock/opam/{dune.3.20.2 → dune.3.21.1}/opam +6 -5
- binaryen-archive/esy.lock/opam/{dyn.3.20.2 → dyn.3.21.1}/opam +6 -6
- binaryen-archive/esy.lock/opam/fs-io.3.21.1/opam +41 -0
- binaryen-archive/esy.lock/opam/{menhir.20250912 → menhir.20260209}/opam +6 -4
- binaryen-archive/esy.lock/opam/{menhirCST.20250912 → menhirCST.20260209}/opam +4 -3
- binaryen-archive/esy.lock/opam/menhirGLR.20260209/opam +30 -0
- binaryen-archive/esy.lock/opam/{menhirLib.20250912 → menhirLib.20260209}/opam +5 -4
- binaryen-archive/esy.lock/opam/{menhirSdk.20250912 → menhirSdk.20260209}/opam +5 -4
- binaryen-archive/esy.lock/opam/ocaml_intrinsics_kernel.v0.17.1/opam +2 -0
- binaryen-archive/esy.lock/opam/{ocamlc-loc.3.20.2 → ocamlc-loc.3.21.1}/opam +6 -6
- binaryen-archive/esy.lock/opam/ocamlfind.1.9.8/opam +1 -1
- binaryen-archive/esy.lock/opam/{ordering.3.20.2 → ordering.3.21.1}/opam +6 -6
- binaryen-archive/esy.lock/opam/ppx_yojson_conv_lib.v0.17.0/opam +2 -0
- binaryen-archive/esy.lock/opam/sexplib0.v0.17.0/opam +2 -0
- binaryen-archive/esy.lock/opam/stdio.v0.17.0/opam +3 -1
- binaryen-archive/esy.lock/opam/{stdune.3.20.2 → stdune.3.21.1}/opam +9 -7
- binaryen-archive/esy.lock/opam/top-closure.3.21.1/opam +40 -0
- binaryen-archive/esy.lock/opam/{xdg.3.20.2 → xdg.3.21.1}/opam +5 -5
- binaryen-archive/package.json +2 -2
- binaryen-archive/src/dune +2 -0
- binaryen-archive/src/export.c +10 -0
- binaryen-archive/src/export.js +13 -0
- binaryen-archive/src/export.ml +4 -0
- binaryen-archive/src/export.mli +1 -0
- binaryen-archive/src/expression.c +291 -0
- binaryen-archive/src/expression.js +182 -0
- binaryen-archive/src/expression.ml +118 -0
- binaryen-archive/src/expression.mli +87 -0
- binaryen-archive/src/function.c +8 -0
- binaryen-archive/src/function.js +5 -0
- binaryen-archive/src/function.ml +1 -0
- binaryen-archive/src/function.mli +1 -0
- binaryen-archive/src/import.c +32 -0
- binaryen-archive/src/import.js +47 -0
- binaryen-archive/src/import.ml +12 -0
- binaryen-archive/src/import.mli +5 -0
- binaryen-archive/src/module.js +2 -2
- binaryen-archive/src/ocaml_helpers.c +8 -0
- binaryen-archive/src/ocaml_helpers.h +4 -0
- binaryen-archive/src/passes.ml +95 -21
- binaryen-archive/src/passes.mli +91 -21
- binaryen-archive/src/tag.c +61 -0
- binaryen-archive/src/tag.js +43 -0
- binaryen-archive/src/tag.ml +11 -0
- binaryen-archive/src/tag.mli +8 -0
- binaryen-archive/src/type.js +4 -7
- binaryen-archive/test/test.expected +158 -31
- binaryen-archive/test/test.ml +95 -2
|
@@ -7,11 +7,12 @@
|
|
|
7
7
|
(i32.const 0)
|
|
8
8
|
)
|
|
9
9
|
(module
|
|
10
|
-
(type $0 (func (param i32
|
|
11
|
-
(type $1 (func))
|
|
12
|
-
(type $2 (func
|
|
13
|
-
(type $3 (func (param anyref) (result i32)))
|
|
14
|
-
(
|
|
10
|
+
(type $0 (func (param i32)))
|
|
11
|
+
(type $1 (func (param i32 i32) (result i32)))
|
|
12
|
+
(type $2 (func))
|
|
13
|
+
(type $3 (func (param anyref i32 i32) (result i32)))
|
|
14
|
+
(type $4 (func (param anyref) (result i32)))
|
|
15
|
+
(import "future-wasi" "write" (func $write (type $3) (param anyref i32 i32) (result i32)))
|
|
15
16
|
(global $max_int64 i64 (i64.const 9223372036854775807))
|
|
16
17
|
(global $max_int64_mut (mut i64) (i64.const 9223372036854775807))
|
|
17
18
|
(global $test_float64_bits f64 (f64.const 1.23))
|
|
@@ -20,11 +21,14 @@
|
|
|
20
21
|
(data $world "world")
|
|
21
22
|
(table $table 1 1 funcref)
|
|
22
23
|
(elem $elem (i32.const 0) $adder)
|
|
24
|
+
(tag $foo (type $0) (param i32))
|
|
25
|
+
(tag $bar (type $0) (param i32))
|
|
23
26
|
(export "adder" (func $adder))
|
|
24
27
|
(export "memory" (memory $0))
|
|
25
28
|
(export "hello" (func $hello))
|
|
29
|
+
(export "try" (func $try))
|
|
26
30
|
(start $start)
|
|
27
|
-
(func $adder (type $
|
|
31
|
+
(func $adder (type $1) (param $0 i32) (param $1 i32) (result i32)
|
|
28
32
|
(block $add (result i32)
|
|
29
33
|
(if
|
|
30
34
|
(i32.const 0)
|
|
@@ -44,7 +48,7 @@
|
|
|
44
48
|
)
|
|
45
49
|
)
|
|
46
50
|
)
|
|
47
|
-
(func $start (type $
|
|
51
|
+
(func $start (type $2)
|
|
48
52
|
(block $start
|
|
49
53
|
(memory.init $world
|
|
50
54
|
(i32.const 2048)
|
|
@@ -52,7 +56,7 @@
|
|
|
52
56
|
(i32.const 5)
|
|
53
57
|
)
|
|
54
58
|
(drop
|
|
55
|
-
(call_indirect $table (type $
|
|
59
|
+
(call_indirect $table (type $1)
|
|
56
60
|
(i32.const 3)
|
|
57
61
|
(i32.const 5)
|
|
58
62
|
(i32.const 0)
|
|
@@ -60,30 +64,102 @@
|
|
|
60
64
|
)
|
|
61
65
|
)
|
|
62
66
|
)
|
|
63
|
-
(func $hello (type $
|
|
67
|
+
(func $hello (type $4) (param $0 anyref) (result i32)
|
|
64
68
|
(call $write
|
|
65
69
|
(local.get $0)
|
|
66
70
|
(i32.const 0)
|
|
67
71
|
(i32.const 1)
|
|
68
72
|
)
|
|
69
73
|
)
|
|
74
|
+
(func $try (type $2)
|
|
75
|
+
(block $blk
|
|
76
|
+
(drop
|
|
77
|
+
(try $tc1 (result i32)
|
|
78
|
+
(do
|
|
79
|
+
(throw $foo
|
|
80
|
+
(i32.const 1)
|
|
81
|
+
)
|
|
82
|
+
)
|
|
83
|
+
(catch $foo
|
|
84
|
+
(block $tc1blk2 (result i32)
|
|
85
|
+
(drop
|
|
86
|
+
(pop i32)
|
|
87
|
+
)
|
|
88
|
+
(i32.const 2)
|
|
89
|
+
)
|
|
90
|
+
)
|
|
91
|
+
(catch $bar
|
|
92
|
+
(block $tc1blk3 (result i32)
|
|
93
|
+
(drop
|
|
94
|
+
(pop i32)
|
|
95
|
+
)
|
|
96
|
+
(i32.const 3)
|
|
97
|
+
)
|
|
98
|
+
)
|
|
99
|
+
)
|
|
100
|
+
)
|
|
101
|
+
(try $tc2
|
|
102
|
+
(do
|
|
103
|
+
(throw $foo
|
|
104
|
+
(i32.const 1)
|
|
105
|
+
)
|
|
106
|
+
)
|
|
107
|
+
(catch $foo
|
|
108
|
+
(block $tc2blk2
|
|
109
|
+
(drop
|
|
110
|
+
(pop i32)
|
|
111
|
+
)
|
|
112
|
+
)
|
|
113
|
+
)
|
|
114
|
+
(catch $bar
|
|
115
|
+
(block $tc2blk3
|
|
116
|
+
(drop
|
|
117
|
+
(pop i32)
|
|
118
|
+
)
|
|
119
|
+
)
|
|
120
|
+
)
|
|
121
|
+
)
|
|
122
|
+
(drop
|
|
123
|
+
(try $tc3 (result i32)
|
|
124
|
+
(do
|
|
125
|
+
(i32.const 1)
|
|
126
|
+
)
|
|
127
|
+
(catch $foo
|
|
128
|
+
(block $tc3blk2 (result i32)
|
|
129
|
+
(drop
|
|
130
|
+
(pop i32)
|
|
131
|
+
)
|
|
132
|
+
(i32.const 2)
|
|
133
|
+
)
|
|
134
|
+
)
|
|
135
|
+
(catch_all
|
|
136
|
+
(i32.const 3)
|
|
137
|
+
)
|
|
138
|
+
)
|
|
139
|
+
)
|
|
140
|
+
)
|
|
141
|
+
)
|
|
70
142
|
)
|
|
71
143
|
(module
|
|
72
|
-
(type $0 (func (param i32
|
|
144
|
+
(type $0 (func (param i32)))
|
|
73
145
|
(type $1 (func))
|
|
74
|
-
(type $2 (func (param
|
|
75
|
-
(type $3 (func (param anyref) (result i32)))
|
|
76
|
-
(
|
|
146
|
+
(type $2 (func (param i32 i32) (result i32)))
|
|
147
|
+
(type $3 (func (param anyref i32 i32) (result i32)))
|
|
148
|
+
(type $4 (func (param anyref) (result i32)))
|
|
149
|
+
(import "future-wasi" "write" (func $write (type $3) (param anyref i32 i32) (result i32)))
|
|
77
150
|
(memory $0 1)
|
|
78
151
|
(data $hello (i32.const 0) "hello")
|
|
79
152
|
(data $world "world")
|
|
80
153
|
(table $table 1 1 funcref)
|
|
81
154
|
(elem $elem (i32.const 0) $adder)
|
|
155
|
+
(tag $foo (type $0) (param i32))
|
|
156
|
+
(tag $bar (type $0) (param i32))
|
|
82
157
|
(export "adder" (func $adder))
|
|
83
158
|
(export "memory" (memory $0))
|
|
84
159
|
(export "hello" (func $hello))
|
|
160
|
+
(export "try" (func $try))
|
|
85
161
|
(start $start)
|
|
86
|
-
(func $adder (type $
|
|
162
|
+
(func $adder (type $2) (param $0 i32) (param $1 i32) (result i32)
|
|
87
163
|
(i32.add
|
|
88
164
|
(select
|
|
89
165
|
(local.get $0)
|
|
@@ -108,20 +184,60 @@
|
|
|
108
184
|
)
|
|
109
185
|
)
|
|
110
186
|
)
|
|
111
|
-
(func $hello (type $
|
|
187
|
+
(func $hello (type $4) (param $0 anyref) (result i32)
|
|
112
188
|
(call $write
|
|
113
189
|
(local.get $0)
|
|
114
190
|
(i32.const 0)
|
|
115
191
|
(i32.const 1)
|
|
116
192
|
)
|
|
117
193
|
)
|
|
194
|
+
(func $try (type $1)
|
|
195
|
+
(drop
|
|
196
|
+
(try (result i32)
|
|
197
|
+
(do
|
|
198
|
+
(throw $foo
|
|
199
|
+
(i32.const 1)
|
|
200
|
+
)
|
|
201
|
+
)
|
|
202
|
+
(catch $foo
|
|
203
|
+
(drop
|
|
204
|
+
(pop i32)
|
|
205
|
+
)
|
|
206
|
+
(i32.const 2)
|
|
207
|
+
)
|
|
208
|
+
(catch $bar
|
|
209
|
+
(drop
|
|
210
|
+
(pop i32)
|
|
211
|
+
)
|
|
212
|
+
(i32.const 3)
|
|
213
|
+
)
|
|
214
|
+
)
|
|
215
|
+
)
|
|
216
|
+
(try
|
|
217
|
+
(do
|
|
218
|
+
(throw $foo
|
|
219
|
+
(i32.const 1)
|
|
220
|
+
)
|
|
221
|
+
)
|
|
222
|
+
(catch $foo
|
|
223
|
+
(drop
|
|
224
|
+
(pop i32)
|
|
225
|
+
)
|
|
226
|
+
)
|
|
227
|
+
(catch $bar
|
|
228
|
+
(drop
|
|
229
|
+
(pop i32)
|
|
230
|
+
)
|
|
231
|
+
)
|
|
232
|
+
)
|
|
233
|
+
)
|
|
118
234
|
)
|
|
119
235
|
(module
|
|
120
|
-
(type $
|
|
121
|
-
(type $type_1 (func (param i32 i32) (result i32)))
|
|
122
|
-
(type $type_2 (func))
|
|
123
|
-
(type $
|
|
124
|
-
(import "future-wasi" "write" (func $fimport$0 (type $
|
|
236
|
+
(type $type_3 (func))
|
|
237
|
+
(type $type_1 (func (param anyref i32 i32) (result i32)))
|
|
238
|
+
(type $type_2 (func (param i32 i32) (result i32)))
|
|
239
|
+
(type $type_4 (func (param anyref) (result i32)))
|
|
240
|
+
(import "future-wasi" "write" (func $fimport$0 (type $type_1) (param anyref i32 i32) (result i32)))
|
|
125
241
|
(memory $0 1)
|
|
126
242
|
(data $0 (i32.const 0) "hello")
|
|
127
243
|
(data $1 "world")
|
|
@@ -130,8 +246,9 @@
|
|
|
130
246
|
(export "adder" (func $0))
|
|
131
247
|
(export "memory" (memory $0))
|
|
132
248
|
(export "hello" (func $2))
|
|
249
|
+
(export "try" (func $3))
|
|
133
250
|
(start $1)
|
|
134
|
-
(func $0 (type $
|
|
251
|
+
(func $0 (type $type_2) (param $0 i32) (param $1 i32) (result i32)
|
|
135
252
|
(i32.add
|
|
136
253
|
(select
|
|
137
254
|
(local.get $0)
|
|
@@ -143,7 +260,7 @@
|
|
|
143
260
|
(local.get $1)
|
|
144
261
|
)
|
|
145
262
|
)
|
|
146
|
-
(func $1 (type $
|
|
263
|
+
(func $1 (type $type_3)
|
|
147
264
|
(memory.init $1
|
|
148
265
|
(i32.const 2048)
|
|
149
266
|
(i32.const 0)
|
|
@@ -156,20 +273,26 @@
|
|
|
156
273
|
)
|
|
157
274
|
)
|
|
158
275
|
)
|
|
159
|
-
(func $2 (type $
|
|
276
|
+
(func $2 (type $type_4) (param $0 anyref) (result i32)
|
|
160
277
|
(call $fimport$0
|
|
161
278
|
(local.get $0)
|
|
162
279
|
(i32.const 0)
|
|
163
280
|
(i32.const 1)
|
|
164
281
|
)
|
|
165
282
|
)
|
|
283
|
+
(func $3 (type $type_3)
|
|
284
|
+
(drop
|
|
285
|
+
(unreachable)
|
|
286
|
+
)
|
|
287
|
+
(unreachable)
|
|
288
|
+
)
|
|
166
289
|
)
|
|
167
290
|
(module
|
|
168
|
-
(type $
|
|
169
|
-
(type $type_1 (func (param i32 i32) (result i32)))
|
|
170
|
-
(type $type_2 (func))
|
|
171
|
-
(type $
|
|
172
|
-
(import "future-wasi" "write" (func $fimport$0 (type $
|
|
291
|
+
(type $type_3 (func))
|
|
292
|
+
(type $type_1 (func (param anyref i32 i32) (result i32)))
|
|
293
|
+
(type $type_2 (func (param i32 i32) (result i32)))
|
|
294
|
+
(type $type_4 (func (param anyref) (result i32)))
|
|
295
|
+
(import "future-wasi" "write" (func $fimport$0 (type $type_1) (param anyref i32 i32) (result i32)))
|
|
173
296
|
(memory $0 1)
|
|
174
297
|
(data $0 (i32.const 0) "hello")
|
|
175
298
|
(data $1 "world")
|
|
@@ -178,8 +301,9 @@
|
|
|
178
301
|
(export "adder" (func $0))
|
|
179
302
|
(export "memory" (memory $0))
|
|
180
303
|
(export "hello" (func $2))
|
|
304
|
+
(export "try" (func $3))
|
|
181
305
|
(start $1)
|
|
182
|
-
(func $0 (type $
|
|
306
|
+
(func $0 (type $type_2) (param $0 i32) (param $1 i32) (result i32)
|
|
183
307
|
local.get $0
|
|
184
308
|
local.get $1
|
|
185
309
|
i32.load
|
|
@@ -188,7 +312,7 @@
|
|
|
188
312
|
local.get $1
|
|
189
313
|
i32.add
|
|
190
314
|
)
|
|
191
|
-
(func $1 (type $
|
|
315
|
+
(func $1 (type $type_3)
|
|
192
316
|
i32.const 2048
|
|
193
317
|
i32.const 0
|
|
194
318
|
i32.const 5
|
|
@@ -198,10 +322,13 @@
|
|
|
198
322
|
call $0
|
|
199
323
|
drop
|
|
200
324
|
)
|
|
201
|
-
(func $2 (type $
|
|
325
|
+
(func $2 (type $type_4) (param $0 anyref) (result i32)
|
|
202
326
|
local.get $0
|
|
203
327
|
i32.const 0
|
|
204
328
|
i32.const 1
|
|
205
329
|
call $fimport$0
|
|
206
330
|
)
|
|
331
|
+
(func $3 (type $type_3)
|
|
332
|
+
unreachable
|
|
333
|
+
)
|
|
207
334
|
)
|
binaryen-archive/test/test.ml
CHANGED
|
@@ -170,12 +170,14 @@ let start =
|
|
|
170
170
|
|
|
171
171
|
let _ = Export.add_function_export wasm_mod "adder" "adder"
|
|
172
172
|
let _ = Table.add_table wasm_mod "table" 1 1 Type.funcref
|
|
173
|
-
|
|
173
|
+
|
|
174
|
+
(* TODO(#240): Re-enable after type-builder api is merged *)
|
|
175
|
+
(* let funcref_expr1 = Expression.Ref.func wasm_mod "adder" (Heap_type.func ())
|
|
174
176
|
|
|
175
177
|
let _ =
|
|
176
178
|
Expression.Table.set wasm_mod "table"
|
|
177
179
|
(Expression.Const.make wasm_mod (Literal.int32 0l))
|
|
178
|
-
funcref_expr1
|
|
180
|
+
funcref_expr1 *)
|
|
179
181
|
|
|
180
182
|
let funcref_expr2 =
|
|
181
183
|
Expression.Table.get wasm_mod "table"
|
|
@@ -212,6 +214,8 @@ let _ =
|
|
|
212
214
|
(Expression.Const.make wasm_mod (Literal.int32 0l))
|
|
213
215
|
|
|
214
216
|
let _ = Function.set_start wasm_mod start
|
|
217
|
+
let start_func = Function.get_start wasm_mod
|
|
218
|
+
let _ = assert (Function.get_name start_func = "start")
|
|
215
219
|
|
|
216
220
|
let segment : Binaryen.Memory.segment =
|
|
217
221
|
let data = Bytes.of_string "hello" in
|
|
@@ -250,6 +254,84 @@ let _ =
|
|
|
250
254
|
(Memory.get_segment_data wasm_mod "world")
|
|
251
255
|
(Bytes.of_string "world"))
|
|
252
256
|
|
|
257
|
+
let _ = Tag.add_tag wasm_mod "foo" Type.int32 Type.none
|
|
258
|
+
let _ = Tag.add_tag wasm_mod "bar" Type.int32 Type.none
|
|
259
|
+
|
|
260
|
+
(* Exception handling *)
|
|
261
|
+
let body =
|
|
262
|
+
Expression.Throw.make wasm_mod "foo"
|
|
263
|
+
[ Expression.Const.make wasm_mod (Literal.int32 1l) ]
|
|
264
|
+
|
|
265
|
+
let try_catch_1 =
|
|
266
|
+
Expression.Try.make wasm_mod (Some "tc1") body
|
|
267
|
+
[
|
|
268
|
+
( "foo",
|
|
269
|
+
Expression.Block.make wasm_mod "tc1blk2"
|
|
270
|
+
[
|
|
271
|
+
Expression.Drop.make wasm_mod
|
|
272
|
+
(Expression.Pop.make wasm_mod Type.int32);
|
|
273
|
+
Expression.Const.make wasm_mod (Literal.int32 2l);
|
|
274
|
+
] );
|
|
275
|
+
( "bar",
|
|
276
|
+
Expression.Block.make wasm_mod "tc1blk3"
|
|
277
|
+
[
|
|
278
|
+
Expression.Drop.make wasm_mod
|
|
279
|
+
(Expression.Pop.make wasm_mod Type.int32);
|
|
280
|
+
Expression.Const.make wasm_mod (Literal.int32 3l);
|
|
281
|
+
] );
|
|
282
|
+
]
|
|
283
|
+
None
|
|
284
|
+
|
|
285
|
+
let _ = assert (Expression.Try.get_name try_catch_1 = Some "tc1")
|
|
286
|
+
let _ = Expression.Try.set_name try_catch_1 "renamed_tc1"
|
|
287
|
+
let _ = assert (Expression.Try.get_name try_catch_1 = Some "renamed_tc1")
|
|
288
|
+
let _ = Expression.Try.set_name try_catch_1 "tc1"
|
|
289
|
+
|
|
290
|
+
let _ =
|
|
291
|
+
assert (
|
|
292
|
+
Expression.get_kind (Expression.Try.get_body try_catch_1)
|
|
293
|
+
= Expression.get_kind body)
|
|
294
|
+
|
|
295
|
+
let _ = assert (Expression.Try.get_num_catch_tags try_catch_1 = 2)
|
|
296
|
+
let _ = assert (Expression.Try.get_num_catch_bodies try_catch_1 = 2)
|
|
297
|
+
|
|
298
|
+
let try_catch_2 =
|
|
299
|
+
Expression.Try.make wasm_mod (Some "tc2")
|
|
300
|
+
(Expression.Throw.make wasm_mod "foo"
|
|
301
|
+
[ Expression.Const.make wasm_mod (Literal.int32 1l) ])
|
|
302
|
+
[
|
|
303
|
+
( "foo",
|
|
304
|
+
Expression.Block.make wasm_mod "tc2blk2"
|
|
305
|
+
[
|
|
306
|
+
Expression.Drop.make wasm_mod
|
|
307
|
+
(Expression.Pop.make wasm_mod Type.int32);
|
|
308
|
+
] );
|
|
309
|
+
( "bar",
|
|
310
|
+
Expression.Block.make wasm_mod "tc2blk3"
|
|
311
|
+
[
|
|
312
|
+
Expression.Drop.make wasm_mod
|
|
313
|
+
(Expression.Pop.make wasm_mod Type.int32);
|
|
314
|
+
] );
|
|
315
|
+
]
|
|
316
|
+
None
|
|
317
|
+
|
|
318
|
+
let _ = assert (Expression.Try.get_name try_catch_2 = Some "tc2")
|
|
319
|
+
|
|
320
|
+
(* Test catch_all *)
|
|
321
|
+
let try_catch_all_1 =
|
|
322
|
+
Expression.Try.make wasm_mod (Some "tc3")
|
|
323
|
+
(Expression.Const.make wasm_mod (Literal.int32 1l))
|
|
324
|
+
[
|
|
325
|
+
( "foo",
|
|
326
|
+
Expression.Block.make wasm_mod "tc3blk2"
|
|
327
|
+
[
|
|
328
|
+
Expression.Drop.make wasm_mod
|
|
329
|
+
(Expression.Pop.make wasm_mod Type.int32);
|
|
330
|
+
Expression.Const.make wasm_mod (Literal.int32 2l);
|
|
331
|
+
] );
|
|
332
|
+
]
|
|
333
|
+
(Some (Expression.Const.make wasm_mod (Literal.int32 3l)))
|
|
334
|
+
|
|
253
335
|
(* Create an imported "write" function i32 (externref, i32, i32) *)
|
|
254
336
|
(* Similar to the example here: https://bytecodealliance.org/articles/reference-types-in-wasmtime *)
|
|
255
337
|
|
|
@@ -269,7 +351,18 @@ let _ =
|
|
|
269
351
|
]
|
|
270
352
|
Type.int32)
|
|
271
353
|
|
|
354
|
+
(* Create a function with try *)
|
|
355
|
+
let _ =
|
|
356
|
+
Function.add_function wasm_mod "try" Type.none Type.none [||]
|
|
357
|
+
(Expression.Block.make wasm_mod "blk"
|
|
358
|
+
[
|
|
359
|
+
Expression.Drop.make wasm_mod try_catch_1;
|
|
360
|
+
try_catch_2;
|
|
361
|
+
Expression.Drop.make wasm_mod try_catch_all_1;
|
|
362
|
+
])
|
|
363
|
+
|
|
272
364
|
let _ = Export.add_function_export wasm_mod "hello" "hello"
|
|
365
|
+
let _ = Export.add_function_export wasm_mod "try" "try"
|
|
273
366
|
let _ = Module.validate wasm_mod
|
|
274
367
|
|
|
275
368
|
(* Shouldn't actually do anything since we aren't doing function renames *)
|