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
module type M = sig
  type t

  type address

  val address : Smtml.Expr.t -> address Symbolic_choice_without_memory.t

  val address_i32 : Int32.t -> address

  val make : unit -> t

  val clone : t -> t

  val loadn : t -> address -> int -> Smtml.Expr.t

  val storen : t -> address -> Smtml.Expr.t -> int -> unit

  (** [validate_address m a range] verifies whether an operation starting at
      address [a] is valid within the address range [a] to [a + range - 1]
      (inclusive). *)
  val validate_address :
       t
    -> Smtml.Expr.t
    -> int
    -> (Smtml.Expr.t, Trap.t) result Symbolic_choice_without_memory.t

  val realloc :
       t
    -> ptr:Smtml.Expr.t
    -> size:Smtml.Expr.t
    -> Smtml.Expr.t Symbolic_choice_without_memory.t

  val free : t -> Smtml.Expr.t -> Smtml.Expr.t Symbolic_choice_without_memory.t
end

module type S = sig
  type t

  type collection

  val init : unit -> collection

  val clone : collection -> collection

  val get_memory : Env_id.t -> Concrete_memory.t -> collection -> int -> t

  (* val check_within_bounds : *)
  (*   t -> Smtml.Expr.t -> (Smtml.Expr.t * Symbolic_value.int32, Trap.t) result *)

  val realloc :
       t
    -> ptr:Smtml.Expr.t
    -> size:Smtml.Expr.t
    -> Smtml.Expr.t Symbolic_choice_without_memory.t

  val free :
    t -> Smtml.Expr.t -> Symbolic_value.int32 Symbolic_choice_without_memory.t

  val load_8_s :
    t -> Smtml.Expr.t -> Symbolic_value.int32 Symbolic_choice_without_memory.t

  val load_8_u :
    t -> Smtml.Expr.t -> Symbolic_value.int32 Symbolic_choice_without_memory.t

  val load_16_s :
    t -> Smtml.Expr.t -> Symbolic_value.int32 Symbolic_choice_without_memory.t

  val load_16_u :
    t -> Smtml.Expr.t -> Symbolic_value.int32 Symbolic_choice_without_memory.t

  val load_32 :
    t -> Smtml.Expr.t -> Symbolic_value.int32 Symbolic_choice_without_memory.t

  val load_64 :
    t -> Smtml.Expr.t -> Symbolic_value.int32 Symbolic_choice_without_memory.t

  val store_8 :
       t
    -> addr:Smtml.Expr.t
    -> Smtml.Expr.t
    -> unit Symbolic_choice_without_memory.t

  val store_16 :
       t
    -> addr:Smtml.Expr.t
    -> Smtml.Expr.t
    -> unit Symbolic_choice_without_memory.t

  val store_32 :
       t
    -> addr:Smtml.Expr.t
    -> Smtml.Expr.t
    -> unit Symbolic_choice_without_memory.t

  val store_64 :
       t
    -> addr:Smtml.Expr.t
    -> Smtml.Expr.t
    -> unit Symbolic_choice_without_memory.t

  val grow : t -> Smtml.Expr.t -> unit

  val fill : t -> pos:Smtml.Expr.t -> len:Smtml.Expr.t -> char -> Smtml.Expr.t

  val blit :
       t
    -> src:Smtml.Expr.t
    -> dst:Smtml.Expr.t
    -> len:Smtml.Expr.t
    -> Smtml.Expr.t

  val blit_string :
       t
    -> string
    -> src:Smtml.Expr.t
    -> dst:Smtml.Expr.t
    -> len:Smtml.Expr.t
    -> Smtml.Expr.t

  val size : t -> Smtml.Expr.t

  val size_in_pages : t -> Smtml.Expr.t

  val get_limit_max : t -> Smtml.Expr.t option

  module ITbl : sig
    type 'a t

    type key

    val iter : (key -> 'a -> unit) -> 'a t -> unit
  end

  val iter : (t ITbl.t -> unit) -> collection -> unit
end

module type Intf = sig
  module type M = M

  module type S = S

  module Make (_ : M) : S
end