Skip to content

Commit a890e8b

Browse files
authored
Merge pull request #33 from grain-lang/fix-breaking-binaryen-changes
Update bindings for breaking changes
2 parents 365cc49 + 7762666 commit a890e8b

11 files changed

+30
-41
lines changed

js/expression.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ let drop wasm_mod value = meth_call wasm_mod "drop" [| inject value |]
145145

146146
let return wasm_mod value = meth_call wasm_mod "return" [| inject value |]
147147

148+
let memory_grow wasm_mod value =
149+
meth_call wasm_mod "memory_grow" [| inject value |]
150+
151+
let memory_size wasm_mod = meth_call wasm_mod "memory_size" [||]
152+
148153
let nop wasm_mod = meth_call wasm_mod "nop" [||]
149154

150155
let unreachable wasm_mod = meth_call wasm_mod "unreachable" [||]

js/type.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ let funcref : t = global##.binaryen##.funcref
1919

2020
let externref : t = global##.binaryen##.externref
2121

22-
let nullref : t = global##.binaryen##.nullref
23-
2422
let exnref : t = global##.binaryen##.exnref
2523

2624
let unreachable : t = global##.binaryen##.unreachable

src/binaryen_stubs_expressions.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,23 @@ caml_binaryen_return(value _module, value _p1) {
298298
CAMLreturn(alloc_BinaryenExpressionRef(exp));
299299
}
300300

301+
CAMLprim value
302+
caml_binaryen_memory_size(value _module) {
303+
CAMLparam1(_module);
304+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
305+
BinaryenExpressionRef exp = BinaryenMemorySize(module);
306+
CAMLreturn(alloc_BinaryenExpressionRef(exp));
307+
}
308+
309+
CAMLprim value
310+
caml_binaryen_memory_grow(value _module, value _p1) {
311+
CAMLparam2(_module, _p1);
312+
BinaryenModuleRef module = BinaryenModuleRef_val(_module);
313+
BinaryenExpressionRef p1 = BinaryenExpressionRef_val(_p1);
314+
BinaryenExpressionRef exp = BinaryenMemoryGrow(module, p1);
315+
CAMLreturn(alloc_BinaryenExpressionRef(exp));
316+
}
317+
301318
CAMLprim value
302319
caml_binaryen_nop(value _module) {
303320
CAMLparam1(_module);

src/binaryen_stubs_ops.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -910,20 +910,6 @@ caml_binaryen_binaryen_ge_float64(value unit) {
910910
CAMLreturn(alloc_BinaryenOp(op));
911911
}
912912

913-
CAMLprim value
914-
caml_binaryen_binaryen_memory_size(value unit) {
915-
CAMLparam1(unit);
916-
BinaryenOp op = BinaryenMemorySize();
917-
CAMLreturn(alloc_BinaryenOp(op));
918-
}
919-
920-
CAMLprim value
921-
caml_binaryen_binaryen_memory_grow(value unit) {
922-
CAMLparam1(unit);
923-
BinaryenOp op = BinaryenMemoryGrow();
924-
CAMLreturn(alloc_BinaryenOp(op));
925-
}
926-
927913
CAMLprim value
928914
caml_binaryen_binaryen_atomic_rmw_add(value unit) {
929915
CAMLparam1(unit);

src/binaryen_stubs_types.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,6 @@ caml_binaryen_type_externref(value unit) {
7171
CAMLreturn(alloc_BinaryenType(ty));
7272
}
7373

74-
CAMLprim value
75-
caml_binaryen_type_nullref(value unit) {
76-
CAMLparam1(unit);
77-
BinaryenType ty = BinaryenTypeNullref();
78-
CAMLreturn(alloc_BinaryenType(ty));
79-
}
80-
8174
CAMLprim value
8275
caml_binaryen_type_exnref(value unit) {
8376
CAMLparam1(unit);

src/expression.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ external drop : Module.t -> t -> t = "caml_binaryen_drop"
7070

7171
external return : Module.t -> t -> t = "caml_binaryen_return"
7272

73+
external memory_grow : Module.t -> t -> t = "caml_binaryen_memory_grow"
74+
75+
external memory_size : Module.t -> t = "caml_binaryen_memory_size"
76+
7377
external nop : Module.t -> t = "caml_binaryen_nop"
7478

7579
external unreachable : Module.t -> t = "caml_binaryen_unreachable"

src/op.ml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -537,14 +537,6 @@ external ge_float64 : unit -> t = "caml_binaryen_binaryen_ge_float64"
537537

538538
let ge_float64 = ge_float64 ()
539539

540-
external memory_size : unit -> t = "caml_binaryen_binaryen_memory_size"
541-
542-
let memory_size = memory_size ()
543-
544-
external memory_grow : unit -> t = "caml_binaryen_binaryen_memory_grow"
545-
546-
let memory_grow = memory_grow ()
547-
548540
external atomic_rmw_add : unit -> t = "caml_binaryen_binaryen_atomic_rmw_add"
549541

550542
let atomic_rmw_add = atomic_rmw_add ()

src/type.ml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ external externref : unit -> t = "caml_binaryen_type_externref"
3232

3333
let externref = externref ()
3434

35-
external nullref : unit -> t = "caml_binaryen_type_nullref"
36-
37-
let nullref = nullref ()
38-
3935
external exnref : unit -> t = "caml_binaryen_type_exnref"
4036

4137
let exnref = exnref ()

virtual/expression.mli

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ val drop : Module.t -> t -> t
4444

4545
val return : Module.t -> t -> t
4646

47+
val memory_grow : Module.t -> t -> t
48+
49+
val memory_size : Module.t -> t
50+
4751
val nop : Module.t -> t
4852

4953
val unreachable : Module.t -> t

virtual/op.mli

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,6 @@ val gt_float64 : t
256256

257257
val ge_float64 : t
258258

259-
val memory_size : t
260-
261-
val memory_grow : t
262-
263259
val atomic_rmw_add : t
264260

265261
val atomic_rmw_sub : t

virtual/type.mli

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ val funcref : t
1616

1717
val externref : t
1818

19-
val nullref : t
20-
2119
val exnref : t
2220

2321
val unreachable : t

0 commit comments

Comments
 (0)