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
(* SPDX-License-Identifier: AGPL-3.0-or-later *)
(* Copyright © 2021-2026 OCamlPro *)
(* Written by the Owi programmers *)

module type T = sig
  type i32

  type i64

  type f32

  type f64

  type v128

  type 'a m

  type memory

  type _ telt = private
    | I32 : i32 telt
    | I64 : i64 telt
    | F32 : f32 telt
    | F64 : f64 telt
    | V128 : v128 telt
    | Externref : 'a Type.Id.t -> 'a telt

  type (_, _) atype = private
    | Mem : int * ('b, 'r) atype -> (memory -> 'b, 'r) atype
    | UArg : ('b, 'r) atype -> (unit -> 'b, 'r) atype
    | Arg : 'a telt * ('b, 'r) atype -> ('a -> 'b, 'r) atype
    | Res : ('r, 'r) atype

  type _ rtype = private
    | R0 : unit rtype
    | R1 : 'a telt -> 'a rtype
    | R2 : 'a telt * 'b telt -> ('a * 'b) rtype
    | R3 : 'a telt * 'b telt * 'c telt -> ('a * 'b * 'c) rtype
    | R4 : 'a telt * 'b telt * 'c telt * 'd telt -> ('a * 'b * 'c * 'd) rtype

  type _ func_type = private
    | Func : ('f, 'r m) atype * 'r rtype -> 'f func_type

  type t = Extern_func : 'a func_type * 'a -> t

  val to_func_type : t -> Binary.func_type

  module Syntax : sig
    type l

    type lr

    type elt

    type (_, _, _) t

    val i32 : (lr, elt, i32) t

    val i64 : (lr, elt, i64) t

    val f32 : (lr, elt, f32) t

    val f64 : (lr, elt, f64) t

    val v128 : (lr, elt, v128) t

    val externref : 'a Type.Id.t -> (lr, elt, 'a) t

    val unit : (lr, unit, unit) t

    val memory : int -> (l, memory, memory) t

    val ( ^-> ) : ('r, 'k, 'a) t -> 'b func_type -> ('a -> 'b) func_type

    val ( ^->. ) : ('r, 'k, 'a) t -> (lr, 'kk, 'b) t -> ('a -> 'b m) func_type

    val ( ^->.. ) :
         ('ll, 'k, 'a) t
      -> (lr, elt, 'b1) t * (lr, elt, 'b2) t
      -> ('a -> ('b1 * 'b2) m) func_type

    val ( ^->... ) :
         ('ll, 'k, 'a) t
      -> (lr, elt, 'b1) t * (lr, elt, 'b2) t * (lr, elt, 'b3) t
      -> ('a -> ('b1 * 'b2 * 'b3) m) func_type

    val ( ^->.... ) :
         ('ll, 'k, 'a) t
      -> (lr, elt, 'b1) t
         * (lr, elt, 'b2) t
         * (lr, elt, 'b3) t
         * (lr, elt, 'b4) t
      -> ('a -> ('b1 * 'b2 * 'b3 * 'b4) m) func_type
  end
end

module type Func = sig
  val fresh : unit -> unit

  include T
end