Skip to content

Commit

Permalink
Make P module a functor
Browse files Browse the repository at this point in the history
  • Loading branch information
epatrizio committed Jan 24, 2024
1 parent ebcf363 commit aa56715
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/choice_intf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module type Base = sig
val ( let* ) : 'a t -> ('a -> 'b t) -> 'b t
end

module type Complete = sig
module type Complete_without_run = sig
include Base

type thread
Expand All @@ -30,6 +30,10 @@ module type Complete = sig
val with_thread : (thread -> 'b) -> 'b t

val add_pc : V.vbool -> unit t
end

module type Complete = sig
include Complete_without_run

val run : 'a t -> thread -> ('a * thread) Seq.t
end
Expand Down
30 changes: 28 additions & 2 deletions src/symbolic.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,29 @@ open Types
module Def_value = Concrete_value
module Solver = Thread.Solver

module P = struct
module type Thread = sig
type t

type 'a solver_module = (module Encoding.Solver_intf.S with type t = 'a)
type solver = S : 'a solver_module * 'a -> solver

val memories : t -> Symbolic_memory.memories

val tables : t -> Symbolic_table.tables

val globals : t -> Symbolic_global.globals

val solver : t -> solver

val pc : t -> Symbolic_value.S.vbool list
end

module MakeP
(Thread : Thread)
(Choice : Choice_intf.Complete_without_run
with module V := Symbolic_value.S
and type thread := Thread.t) =
struct
module Value = struct
include Symbolic_value.S
end
Expand All @@ -33,7 +55,6 @@ module P = struct

type thread = Thread.t

module Choice = Symbolic_choice.MT
module Extern_func = Def_value.Make_extern_func (Value) (Choice)

let select (c : vbool) ~(if_true : Value.t) ~(if_false : Value.t) :
Expand Down Expand Up @@ -257,6 +278,11 @@ module P = struct
end
end

module P = struct
include MakeP (Thread) (Symbolic_choice.MT) [@@inlined hint]
module Choice = Symbolic_choice.MT
end

module P' : Interpret_intf.P = P

let convert_module_to_run (m : 'f Link.module_to_run) =
Expand Down

0 comments on commit aa56715

Please sign in to comment.