@grain/binaryen.ml 0.19.0 → 0.20.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.
Files changed (68) hide show
  1. binaryen-archive/CHANGELOG.md +38 -0
  2. binaryen-archive/README.md +0 -16
  3. binaryen-archive/binaryen.opam +5 -5
  4. binaryen-archive/dune-project +1 -1
  5. binaryen-archive/dune-workspace +1 -1
  6. binaryen-archive/esy.lock/index.json +285 -290
  7. binaryen-archive/esy.lock/opam/{base.v0.14.3 → base.v0.15.1}/opam +4 -4
  8. binaryen-archive/esy.lock/opam/{chrome-trace.3.5.0 → chrome-trace.3.6.1}/opam +5 -5
  9. binaryen-archive/esy.lock/opam/{dune-build-info.3.5.0 → dune-build-info.3.6.1}/opam +6 -6
  10. binaryen-archive/esy.lock/opam/{dune-configurator.3.5.0 → dune-configurator.3.6.1}/opam +5 -5
  11. binaryen-archive/esy.lock/opam/{dune-rpc.3.5.0 → dune-rpc.3.6.1}/opam +5 -5
  12. binaryen-archive/esy.lock/opam/{dune.3.5.0 → dune.3.6.1}/opam +6 -6
  13. binaryen-archive/esy.lock/opam/{dyn.3.5.0 → dyn.3.6.1}/opam +5 -5
  14. binaryen-archive/esy.lock/opam/{fiber.3.5.0 → fiber.3.6.1}/opam +5 -5
  15. binaryen-archive/esy.lock/opam/{js_of_ocaml-compiler.4.0.0 → js_of_ocaml-compiler.4.1.0}/opam +9 -10
  16. binaryen-archive/esy.lock/opam/menhir.20220210/opam +1 -1
  17. binaryen-archive/esy.lock/opam/menhirLib.20220210/opam +1 -1
  18. binaryen-archive/esy.lock/opam/menhirSdk.20220210/opam +1 -1
  19. binaryen-archive/esy.lock/opam/{ocaml-lsp-server.1.14.1 → ocaml-lsp-server.1.12.4}/opam +5 -5
  20. binaryen-archive/esy.lock/opam/{ocamlformat.0.20.1 → ocamlformat.0.24.1}/opam +12 -12
  21. binaryen-archive/esy.lock/opam/{odoc-parser.1.0.1 → odoc-parser.2.0.0}/opam +4 -4
  22. binaryen-archive/esy.lock/opam/{ordering.3.5.0 → ordering.3.6.1}/opam +5 -5
  23. binaryen-archive/esy.lock/opam/{sexplib0.v0.14.0 → sexplib0.v0.15.1}/opam +3 -3
  24. binaryen-archive/esy.lock/opam/{stdio.v0.14.0 → stdio.v0.15.0}/opam +4 -4
  25. binaryen-archive/esy.lock/opam/{stdune.3.5.0 → stdune.3.6.1}/opam +5 -5
  26. binaryen-archive/esy.lock/opam/{topkg.1.0.5 → topkg.1.0.6}/opam +22 -19
  27. binaryen-archive/esy.lock/opam/{xdg.3.5.0 → xdg.3.6.1}/opam +5 -5
  28. binaryen-archive/package.json +8 -8
  29. binaryen-archive/src/binaryen_stubs_expressions.c +43 -33
  30. binaryen-archive/src/binaryen_stubs_expressions.js +221 -42
  31. binaryen-archive/src/binaryen_stubs_features.c +6 -0
  32. binaryen-archive/src/binaryen_stubs_features.js +6 -0
  33. binaryen-archive/src/binaryen_stubs_heap_types.c +95 -0
  34. binaryen-archive/src/binaryen_stubs_heap_types.js +65 -0
  35. binaryen-archive/src/binaryen_stubs_imports.c +8 -6
  36. binaryen-archive/src/binaryen_stubs_imports.js +6 -6
  37. binaryen-archive/src/binaryen_stubs_memory.c +55 -16
  38. binaryen-archive/src/binaryen_stubs_memory.js +64 -15
  39. binaryen-archive/src/binaryen_stubs_modules.c +8 -6
  40. binaryen-archive/src/binaryen_stubs_modules.js +6 -6
  41. binaryen-archive/src/binaryen_stubs_packed_types.c +26 -0
  42. binaryen-archive/src/binaryen_stubs_packed_types.js +17 -0
  43. binaryen-archive/src/binaryen_stubs_type_system.c +40 -0
  44. binaryen-archive/src/binaryen_stubs_type_system.js +29 -0
  45. binaryen-archive/src/binaryen_stubs_types.c +44 -0
  46. binaryen-archive/src/binaryen_stubs_types.js +36 -0
  47. binaryen-archive/src/dune +35 -12
  48. binaryen-archive/src/expression.ml +21 -24
  49. binaryen-archive/src/expression.mli +9 -9
  50. binaryen-archive/src/heap_type.ml +15 -0
  51. binaryen-archive/src/heap_type.mli +12 -0
  52. binaryen-archive/src/import.ml +4 -2
  53. binaryen-archive/src/import.mli +2 -2
  54. binaryen-archive/src/memory.ml +19 -5
  55. binaryen-archive/src/memory.mli +9 -10
  56. binaryen-archive/src/module.ml +12 -2
  57. binaryen-archive/src/module.mli +3 -2
  58. binaryen-archive/src/ocaml_helpers.h +1 -0
  59. binaryen-archive/src/packed_type.ml +13 -0
  60. binaryen-archive/src/packed_type.mli +5 -0
  61. binaryen-archive/src/type.ml +19 -0
  62. binaryen-archive/src/type.mli +7 -0
  63. binaryen-archive/src/type_system.ml +7 -0
  64. binaryen-archive/src/type_system.mli +7 -0
  65. binaryen-archive/test/dune +19 -20
  66. binaryen-archive/test/test.expected +29 -5
  67. binaryen-archive/test/test.ml +33 -15
  68. binaryen-archive/esy.lock/overrides/opam__s__js__of__ocaml_compiler_opam__c__4.0.0_opam_override/package.json +0 -3
@@ -57,8 +57,6 @@ type kind =
57
57
  | RefTest
58
58
  | RefCast
59
59
  | BrOn
60
- | RttCanon
61
- | RttSub
62
60
  | StructNew
63
61
  | StructGet
64
62
  | StructSet
@@ -310,14 +308,6 @@ external id_br_on : unit -> int = "caml_binaryen_expression_id_br_on"
310
308
 
311
309
  let id_br_on = id_br_on ()
312
310
 
313
- external id_rtt_canon : unit -> int = "caml_binaryen_expression_id_rtt_canon"
314
-
315
- let id_rtt_canon = id_rtt_canon ()
316
-
317
- external id_rtt_sub : unit -> int = "caml_binaryen_expression_id_rtt_sub"
318
-
319
- let id_rtt_sub = id_rtt_sub ()
320
-
321
311
  external id_struct_new : unit -> int = "caml_binaryen_expression_id_struct_new"
322
312
 
323
313
  let id_struct_new = id_struct_new ()
@@ -409,8 +399,6 @@ let get_kind expr =
409
399
  | n when n = id_ref_test -> RefTest
410
400
  | n when n = id_ref_cast -> RefCast
411
401
  | n when n = id_br_on -> BrOn
412
- | n when n = id_rtt_canon -> RttCanon
413
- | n when n = id_rtt_sub -> RttSub
414
402
  | n when n = id_struct_new -> StructNew
415
403
  | n when n = id_struct_get -> StructGet
416
404
  | n when n = id_struct_set -> StructSet
@@ -630,10 +618,11 @@ module Global_set = struct
630
618
  end
631
619
 
632
620
  module Load = struct
633
- external make : Module.t -> int -> bool -> int -> int -> Type.t -> t -> t
621
+ external make :
622
+ Module.t -> int -> bool -> int -> int -> Type.t -> t -> string -> t
634
623
  = "caml_binaryen_load__bytecode" "caml_binaryen_load"
635
624
 
636
- (** Module, num_bytes, ?signed, offset, align, type, ptr. *)
625
+ (** Module, num_bytes, ?signed, offset, align, type, ptr, memory_name *)
637
626
  let make wasm_mod bytes ?(signed = false) offset align ty ptr =
638
627
  make wasm_mod bytes signed offset align ty ptr
639
628
 
@@ -642,9 +631,10 @@ module Load = struct
642
631
  end
643
632
 
644
633
  module Store = struct
645
- external make : Module.t -> int -> int -> int -> t -> t -> Type.t -> t
634
+ external make :
635
+ Module.t -> int -> int -> int -> t -> t -> Type.t -> string -> t
646
636
  = "caml_binaryen_store__bytecode" "caml_binaryen_store"
647
- (** Module, num_bytes, offset, align, ptr, value, type. *)
637
+ (** Module, num_bytes, offset, align, ptr, value, type, memory_name *)
648
638
 
649
639
  external get_ptr : t -> t = "caml_binaryen_store_get_ptr"
650
640
  external set_ptr : t -> t -> unit = "caml_binaryen_store_set_ptr"
@@ -698,18 +688,23 @@ module Return = struct
698
688
  end
699
689
 
700
690
  module Memory_size = struct
701
- external make : Module.t -> t = "caml_binaryen_memory_size"
691
+ external make : Module.t -> string -> bool -> t = "caml_binaryen_memory_size"
692
+ (** Module, memory_name, memory_is_64 *)
702
693
  end
703
694
 
704
695
  module Memory_grow = struct
705
- external make : Module.t -> t -> t = "caml_binaryen_memory_grow"
696
+ external make : Module.t -> t -> string -> bool -> t
697
+ = "caml_binaryen_memory_grow"
698
+ (** Module, delta, memory_name, memory_is_64 *)
699
+
706
700
  external get_delta : t -> t = "caml_binaryen_memory_grow_get_delta"
707
701
  external set_delta : t -> t -> unit = "caml_binaryen_memory_grow_set_delta"
708
702
  end
709
703
 
710
704
  module Memory_init = struct
711
- external make : Module.t -> int -> t -> t -> t = "caml_binaryen_memory_init"
712
- (** Module, segment, destination, offset, size. *)
705
+ external make : Module.t -> int -> t -> t -> t -> string -> t
706
+ = "caml_binaryen_memory_init__bytecode" "caml_binaryen_memory_init"
707
+ (** Module, segment, destination, offset, size, memory_name *)
713
708
 
714
709
  external get_segment : t -> int = "caml_binaryen_memory_init_get_segment"
715
710
 
@@ -735,8 +730,9 @@ module Data_drop = struct
735
730
  end
736
731
 
737
732
  module Memory_copy = struct
738
- external make : Module.t -> t -> t -> t -> t = "caml_binaryen_memory_copy"
739
- (** Module, destination, source, size. *)
733
+ external make : Module.t -> t -> t -> t -> string -> string -> t
734
+ = "caml_binaryen_memory_copy__bytecode" "caml_binaryen_memory_copy"
735
+ (** Module, destination, source, size, dest_memory, source_memory *)
740
736
 
741
737
  external get_dest : t -> t = "caml_binaryen_memory_copy_get_dest"
742
738
  external set_dest : t -> t -> unit = "caml_binaryen_memory_copy_set_dest"
@@ -747,8 +743,9 @@ module Memory_copy = struct
747
743
  end
748
744
 
749
745
  module Memory_fill = struct
750
- external make : Module.t -> t -> t -> t -> t = "caml_binaryen_memory_fill"
751
- (** Module, destination, value, size. *)
746
+ external make : Module.t -> t -> t -> t -> string -> t
747
+ = "caml_binaryen_memory_fill"
748
+ (** Module, destination, value, size, memory_name *)
752
749
 
753
750
  external get_dest : t -> t = "caml_binaryen_memory_fill_get_dest"
754
751
  external set_dest : t -> t -> unit = "caml_binaryen_memory_fill_set_dest"
@@ -57,8 +57,6 @@ type kind =
57
57
  | RefTest
58
58
  | RefCast
59
59
  | BrOn
60
- | RttCanon
61
- | RttSub
62
60
  | StructNew
63
61
  | StructGet
64
62
  | StructSet
@@ -192,13 +190,15 @@ module Global_set : sig
192
190
  end
193
191
 
194
192
  module Load : sig
195
- val make : Module.t -> int -> ?signed:bool -> int -> int -> Type.t -> t -> t
193
+ val make :
194
+ Module.t -> int -> ?signed:bool -> int -> int -> Type.t -> t -> string -> t
195
+
196
196
  val get_ptr : t -> t
197
197
  val set_ptr : t -> t -> unit
198
198
  end
199
199
 
200
200
  module Store : sig
201
- val make : Module.t -> int -> int -> int -> t -> t -> Type.t -> t
201
+ val make : Module.t -> int -> int -> int -> t -> t -> Type.t -> string -> t
202
202
  val get_ptr : t -> t
203
203
  val set_ptr : t -> t -> unit
204
204
  val get_value : t -> t
@@ -246,17 +246,17 @@ module Return : sig
246
246
  end
247
247
 
248
248
  module Memory_size : sig
249
- val make : Module.t -> t
249
+ val make : Module.t -> string -> bool -> t
250
250
  end
251
251
 
252
252
  module Memory_grow : sig
253
- val make : Module.t -> t -> t
253
+ val make : Module.t -> t -> string -> bool -> t
254
254
  val get_delta : t -> t
255
255
  val set_delta : t -> t -> unit
256
256
  end
257
257
 
258
258
  module Memory_init : sig
259
- val make : Module.t -> int -> t -> t -> t
259
+ val make : Module.t -> int -> t -> t -> t -> string -> t
260
260
  val get_segment : t -> int
261
261
  val set_segment : t -> int -> unit
262
262
  val get_dest : t -> t
@@ -274,7 +274,7 @@ module Data_drop : sig
274
274
  end
275
275
 
276
276
  module Memory_copy : sig
277
- val make : Module.t -> t -> t -> t -> t
277
+ val make : Module.t -> t -> t -> t -> string -> string -> t
278
278
  val get_dest : t -> t
279
279
  val set_dest : t -> t -> unit
280
280
  val get_source : t -> t
@@ -284,7 +284,7 @@ module Memory_copy : sig
284
284
  end
285
285
 
286
286
  module Memory_fill : sig
287
- val make : Module.t -> t -> t -> t -> t
287
+ val make : Module.t -> t -> t -> t -> string -> t
288
288
  val get_dest : t -> t
289
289
  val set_dest : t -> t -> unit
290
290
  val get_value : t -> t
@@ -0,0 +1,15 @@
1
+ type t
2
+
3
+ external ext : unit -> t = "caml_binaryen_heap_type_ext"
4
+ external func : unit -> t = "caml_binaryen_heap_type_func"
5
+ external any : unit -> t = "caml_binaryen_heap_type_any"
6
+ external eq : unit -> t = "caml_binaryen_heap_type_eq"
7
+ external i31 : unit -> t = "caml_binaryen_heap_type_i31"
8
+ external data : unit -> t = "caml_binaryen_heap_type_data"
9
+ external string : unit -> t = "caml_binaryen_heap_type_string"
10
+ external stringview_wtf8 : unit -> t = "caml_binaryen_heap_type_stringview_wtf8"
11
+
12
+ external stringview_wtf16 : unit -> t
13
+ = "caml_binaryen_heap_type_stringview_wtf16"
14
+
15
+ external stringview_iter : unit -> t = "caml_binaryen_heap_type_stringview_iter"
@@ -0,0 +1,12 @@
1
+ type t
2
+
3
+ val ext : unit -> t
4
+ val func : unit -> t
5
+ val any : unit -> t
6
+ val eq : unit -> t
7
+ val i31 : unit -> t
8
+ val data : unit -> t
9
+ val string : unit -> t
10
+ val stringview_wtf8 : unit -> t
11
+ val stringview_wtf16 : unit -> t
12
+ val stringview_iter : unit -> t
@@ -20,7 +20,8 @@ external add_global_import :
20
20
  external function_import_get_module : Function.t -> string
21
21
  = "caml_binaryen_function_import_get_module"
22
22
 
23
- external memory_import_get_module : Module.t -> string = "caml_binaryen_memory_import_get_module"
23
+ external memory_import_get_module : Module.t -> string -> string
24
+ = "caml_binaryen_memory_import_get_module"
24
25
 
25
26
  external global_import_get_module : Global.t -> string
26
27
  = "caml_binaryen_global_import_get_module"
@@ -28,7 +29,8 @@ external global_import_get_module : Global.t -> string
28
29
  external function_import_get_base : Function.t -> string
29
30
  = "caml_binaryen_function_import_get_base"
30
31
 
31
- external memory_import_get_base : Module.t -> string = "caml_binaryen_memory_import_get_base"
32
+ external memory_import_get_base : Module.t -> string -> string
33
+ = "caml_binaryen_memory_import_get_base"
32
34
 
33
35
  external global_import_get_base : Global.t -> string
34
36
  = "caml_binaryen_global_import_get_base"
@@ -8,8 +8,8 @@ val add_global_import :
8
8
  Module.t -> string -> string -> string -> Type.t -> bool -> unit
9
9
 
10
10
  val function_import_get_module : Function.t -> string
11
- val memory_import_get_module : Module.t -> string
11
+ val memory_import_get_module : Module.t -> string -> string
12
12
  val global_import_get_module : Global.t -> string
13
13
  val function_import_get_base : Function.t -> string
14
- val memory_import_get_base : Module.t -> string
14
+ val memory_import_get_base : Module.t -> string -> string
15
15
  val global_import_get_base : Global.t -> string
@@ -8,6 +8,7 @@ external set_memory :
8
8
  Expression.t list ->
9
9
  int list ->
10
10
  bool ->
11
+ string ->
11
12
  unit = "caml_binaryen_set_memory__bytecode" "caml_binaryen_set_memory"
12
13
 
13
14
  type segment = { data : bytes; kind : segment_kind; size : int }
@@ -41,12 +42,25 @@ let set_memory wasm_mod initial maximum export_name (segments : segment list)
41
42
 
42
43
  external has_memory : Module.t -> bool = "caml_binaryen_has_memory"
43
44
 
44
- external get_initial : Module.t -> int = "caml_binaryen_memory_get_initial"
45
-
46
- external has_max : Module.t -> bool = "caml_binaryen_memory_has_max"
45
+ external get_initial : Module.t -> string -> int
46
+ = "caml_binaryen_memory_get_initial"
47
47
 
48
- external get_max : Module.t -> int = "caml_binaryen_memory_get_max"
48
+ external has_max : Module.t -> string -> bool = "caml_binaryen_memory_has_max"
49
+ external get_max : Module.t -> string -> int = "caml_binaryen_memory_get_max"
49
50
 
50
- external is_shared : Module.t -> bool = "caml_binaryen_memory_is_shared"
51
+ external is_shared : Module.t -> string -> bool
52
+ = "caml_binaryen_memory_is_shared"
51
53
 
52
54
  let unlimited = -1
55
+
56
+ external get_num_segments : Module.t -> int
57
+ = "caml_binaryen_get_num_memory_segments"
58
+
59
+ external get_segment_byte_offset : Module.t -> int -> int
60
+ = "caml_binaryen_get_memory_segment_byte_offset"
61
+
62
+ external get_segment_passive : Module.t -> int -> bool
63
+ = "caml_binaryen_get_memory_segment_passive"
64
+
65
+ external get_segment_data : Module.t -> int -> bytes
66
+ = "caml_binaryen_get_memory_segment_data"
@@ -2,16 +2,15 @@ type segment = { data : bytes; kind : segment_kind; size : int }
2
2
  and segment_kind = Passive | Active of { offset : Expression.t }
3
3
 
4
4
  val set_memory :
5
- Module.t -> int -> int -> string -> segment list -> bool -> unit
5
+ Module.t -> int -> int -> string -> segment list -> bool -> string -> unit
6
6
 
7
7
  val has_memory : Module.t -> bool
8
-
9
- val get_initial : Module.t -> int
10
-
11
- val has_max : Module.t -> bool
12
-
13
- val get_max : Module.t -> int
14
-
15
- val is_shared : Module.t -> bool
16
-
8
+ val get_initial : Module.t -> string -> int
9
+ val has_max : Module.t -> string -> bool
10
+ val get_max : Module.t -> string -> int
11
+ val is_shared : Module.t -> string -> bool
17
12
  val unlimited : int
13
+ val get_num_segments : Module.t -> int
14
+ val get_segment_byte_offset : Module.t -> int -> int
15
+ val get_segment_passive : Module.t -> int -> bool
16
+ val get_segment_data : Module.t -> int -> bytes
@@ -73,6 +73,10 @@ module Feature = struct
73
73
 
74
74
  let extended_const = extended_const ()
75
75
 
76
+ external strings : unit -> t = "caml_binaryen_feature_strings"
77
+
78
+ let strings = strings ()
79
+
76
80
  external all : unit -> t = "caml_binaryen_feature_all"
77
81
 
78
82
  let all = all ()
@@ -87,7 +91,10 @@ external add_custom_section : t -> string -> string -> unit
87
91
  external parse : string -> t = "caml_binaryen_module_parse"
88
92
  external print : t -> unit = "caml_binaryen_module_print"
89
93
  external print_asmjs : t -> unit = "caml_binaryen_module_print_asmjs"
90
- external print_stack_ir : t -> unit = "caml_binaryen_module_print_stack_ir"
94
+
95
+ external print_stack_ir : t -> bool -> unit
96
+ = "caml_binaryen_module_print_stack_ir"
97
+
91
98
  external validate : t -> int = "caml_binaryen_module_validate"
92
99
  external optimize : t -> unit = "caml_binaryen_module_optimize"
93
100
  external get_features : t -> int = "caml_binaryen_module_get_features"
@@ -118,7 +125,10 @@ external write : t -> string option -> bytes * string option
118
125
  = "caml_binaryen_module_write"
119
126
 
120
127
  external write_text : t -> string = "caml_binaryen_module_write_text"
121
- external write_stack_ir : t -> string = "caml_binaryen_module_write_stack_ir"
128
+
129
+ external write_stack_ir : t -> bool -> string
130
+ = "caml_binaryen_module_write_stack_ir"
131
+
122
132
  external read : bytes -> t = "caml_binaryen_module_read"
123
133
  external interpret : t -> unit = "caml_binaryen_module_interpret"
124
134
 
@@ -19,6 +19,7 @@ module Feature : sig
19
19
  val typed_function_references : t
20
20
  val relaxed_simd : t
21
21
  val extended_const : t
22
+ val strings : t
22
23
  val all : t
23
24
  end
24
25
 
@@ -28,7 +29,7 @@ val add_custom_section : t -> string -> string -> unit
28
29
  val parse : string -> t
29
30
  val print : t -> unit
30
31
  val print_asmjs : t -> unit
31
- val print_stack_ir : t -> unit
32
+ val print_stack_ir : t -> bool -> unit
32
33
  val validate : t -> int
33
34
  val optimize : t -> unit
34
35
  val get_features : t -> Feature.t list
@@ -37,7 +38,7 @@ val run_passes : t -> Passes.t list -> unit
37
38
  val auto_drop : t -> unit
38
39
  val write : t -> string option -> bytes * string option
39
40
  val write_text : t -> string
40
- val write_stack_ir : t -> string
41
+ val write_stack_ir : t -> bool -> string
41
42
  val read : bytes -> t
42
43
  val interpret : t -> unit
43
44
  val add_debug_info_filename : t -> string -> int
@@ -23,6 +23,7 @@ static struct custom_operations binaryen_ops = {
23
23
 
24
24
  #define BinaryenModuleRef_val(v) (*((BinaryenModuleRef*) Data_custom_val(v)))
25
25
  #define BinaryenType_val(v) (*((BinaryenType*) Data_custom_val(v)))
26
+ #define BinaryenHeapType_val(v) (*((BinaryenHeapType*) Data_custom_val(v)))
26
27
  #define BinaryenExpressionRef_val(v) (*((BinaryenExpressionRef*) Data_custom_val(v)))
27
28
  #define BinaryenOp_val(v) (*((BinaryenOp*) Data_custom_val(v)))
28
29
  #define BinaryenLiteral_val(v) (*((struct BinaryenLiteral*) Data_custom_val(v)))
@@ -0,0 +1,13 @@
1
+ type t = int
2
+
3
+ external not_packed : unit -> t = "caml_binaryen_packed_type_not_packed"
4
+
5
+ let not_packed = not_packed ()
6
+
7
+ external int8 : unit -> t = "caml_binaryen_packed_type_int8"
8
+
9
+ let int8 = int8 ()
10
+
11
+ external int16 : unit -> t = "caml_binaryen_packed_type_int16"
12
+
13
+ let int16 = int16 ()
@@ -0,0 +1,5 @@
1
+ type t
2
+
3
+ val not_packed : t
4
+ val int8 : t
5
+ val int16 : t
@@ -44,6 +44,22 @@ external dataref : unit -> t = "caml_binaryen_type_dataref"
44
44
 
45
45
  let dataref = dataref ()
46
46
 
47
+ external stringref : unit -> t = "caml_binaryen_type_stringref"
48
+
49
+ let stringref = stringref ()
50
+
51
+ external stringview_wtf8 : unit -> t = "caml_binaryen_type_stringview_wtf8"
52
+
53
+ let stringview_wtf8 = stringview_wtf8 ()
54
+
55
+ external stringview_wtf16 : unit -> t = "caml_binaryen_type_stringview_wtf16"
56
+
57
+ let stringview_wtf16 = stringview_wtf16 ()
58
+
59
+ external stringview_iter : unit -> t = "caml_binaryen_type_stringview_iter"
60
+
61
+ let stringview_iter = stringview_iter ()
62
+
47
63
  external unreachable : unit -> t = "caml_binaryen_type_unreachable"
48
64
 
49
65
  let unreachable = unreachable ()
@@ -54,3 +70,6 @@ let auto = auto ()
54
70
 
55
71
  external create : t array -> t = "caml_binaryen_type_create"
56
72
  external expand : t -> t array = "caml_binaryen_type_expand"
73
+ external is_nullable : t -> bool = "caml_binaryen_type_is_nullable"
74
+ external from_heap_type : Heap_type.t -> t = "caml_binaryen_type_from_heap_type"
75
+ external get_heap_type : t -> Heap_type.t = "caml_binaryen_type_get_heap_type"
@@ -11,7 +11,14 @@ val anyref : t
11
11
  val eqref : t
12
12
  val i31ref : t
13
13
  val dataref : t
14
+ val stringref : t
15
+ val stringview_wtf8 : t
16
+ val stringview_wtf16 : t
17
+ val stringview_iter : t
14
18
  val unreachable : t
15
19
  val auto : t
16
20
  val create : t array -> t
17
21
  val expand : t -> t array
22
+ val is_nullable : t -> bool
23
+ val from_heap_type : Heap_type.t -> t
24
+ val get_heap_type : t -> Heap_type.t
@@ -0,0 +1,7 @@
1
+ type t = int
2
+
3
+ external equirecursive : unit -> t = "caml_binaryen_type_system_equirecursive"
4
+ external nominal : unit -> t = "caml_binaryen_type_system_nominal"
5
+ external isorecursive : unit -> t = "caml_binaryen_type_system_isorecursive"
6
+ external get_type_system : unit -> t = "caml_binaryen_get_type_system"
7
+ external set_type_system : t -> unit = "caml_binaryen_set_type_system"
@@ -0,0 +1,7 @@
1
+ type t
2
+
3
+ val equirecursive : unit -> t
4
+ val nominal : unit -> t
5
+ val isorecursive : unit -> t
6
+ val get_type_system : unit -> t
7
+ val set_type_system : t -> unit
@@ -1,30 +1,29 @@
1
- (test
1
+ (executable
2
2
  (name test)
3
- (modules test)
4
3
  (libraries binaryen)
5
- (ocamlopt_flags
4
+ (modes exe js)
5
+ (flags
6
+ :standard
6
7
  (:include ./config/ocamlopt_flags.sexp))
7
- (action
8
- (run %{test})))
9
-
10
- ; Tests for binaryen.js implementation
8
+ (js_of_ocaml
9
+ (flags --no-sourcemap)))
11
10
 
12
11
  (rule
13
- (target test_js.ml)
12
+ (alias runtest)
14
13
  (action
15
14
  (progn
16
- (copy %{dep:test.ml} %{target})
17
- (copy test.expected test_js.expected))))
15
+ (with-stdout-to
16
+ test.out
17
+ (run %{exe:test.exe}))
18
+ (diff test.out test.expected))))
18
19
 
19
- (test
20
- (name test_js)
20
+ (rule
21
+ (alias runtest)
21
22
  (enabled_if
22
- (<> %{system} mingw64))
23
- (modules test_js)
24
- (modes
25
- (byte js))
26
- (libraries binaryen)
23
+ (= %{bin-available:node} true))
27
24
  (action
28
- (run node %{dep:test_js.bc.js}))
29
- (js_of_ocaml
30
- (flags --no-sourcemap --disable share)))
25
+ (progn
26
+ (with-stdout-to
27
+ test_js.out
28
+ (run node %{dep:test.bc.js}))
29
+ (diff test_js.out test.expected))))
@@ -43,11 +43,18 @@
43
43
  )
44
44
  )
45
45
  (func $start
46
- (drop
47
- (call_indirect $table (type $i32_i32_=>_i32)
48
- (i32.const 3)
49
- (i32.const 5)
46
+ (block $start
47
+ (memory.init 1
48
+ (i32.const 2048)
50
49
  (i32.const 0)
50
+ (i32.const 5)
51
+ )
52
+ (drop
53
+ (call_indirect $table (type $i32_i32_=>_i32)
54
+ (i32.const 3)
55
+ (i32.const 5)
56
+ (i32.const 0)
57
+ )
51
58
  )
52
59
  )
53
60
  )
@@ -67,6 +74,7 @@
67
74
  (import "future-wasi" "write" (func $write (param anyref i32 i32) (result i32)))
68
75
  (memory $0 1)
69
76
  (data (i32.const 0) "hello")
77
+ (data "world")
70
78
  (table $table 1 1 funcref)
71
79
  (elem $elem (i32.const 0) $adder)
72
80
  (export "adder" (func $adder))
@@ -86,6 +94,11 @@
86
94
  )
87
95
  )
88
96
  (func $start (; has Stack IR ;)
97
+ (memory.init 1
98
+ (i32.const 2048)
99
+ (i32.const 0)
100
+ (i32.const 5)
101
+ )
89
102
  (drop
90
103
  (call $adder
91
104
  (i32.const 3)
@@ -109,6 +122,7 @@
109
122
  (import "future-wasi" "write" (func $fimport$0 (param anyref i32 i32) (result i32)))
110
123
  (memory $0 1)
111
124
  (data (i32.const 0) "hello")
125
+ (data "world")
112
126
  (table $0 1 1 funcref)
113
127
  (elem (i32.const 0) $0)
114
128
  (export "adder" (func $0))
@@ -128,6 +142,11 @@
128
142
  )
129
143
  )
130
144
  (func $1
145
+ (memory.init 1
146
+ (i32.const 2048)
147
+ (i32.const 0)
148
+ (i32.const 5)
149
+ )
131
150
  (drop
132
151
  (call $0
133
152
  (i32.const 3)
@@ -151,6 +170,7 @@
151
170
  (import "future-wasi" "write" (func $fimport$0 (param anyref i32 i32) (result i32)))
152
171
  (memory $0 1)
153
172
  (data (i32.const 0) "hello")
173
+ (data "world")
154
174
  (table $0 1 1 funcref)
155
175
  (elem (i32.const 0) $0)
156
176
  (export "adder" (func $0))
@@ -160,13 +180,17 @@
160
180
  (func $0 (param $0 i32) (param $1 i32) (result i32)
161
181
  local.get $0
162
182
  local.get $1
163
- i32.load8_s
183
+ i32.load8_s $0
164
184
  i32.const 1
165
185
  select
166
186
  local.get $1
167
187
  i32.add
168
188
  )
169
189
  (func $1
190
+ i32.const 2048
191
+ i32.const 0
192
+ i32.const 5
193
+ memory.init $0 1
170
194
  i32.const 3
171
195
  i32.const 5
172
196
  call $0