-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a generic option manager for the dolmen state
- Loading branch information
Showing
6 changed files
with
204 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
(**************************************************************************) | ||
(* *) | ||
(* Alt-Ergo: The SMT Solver For Software Verification *) | ||
(* Copyright (C) 2013-2023 --- OCamlPro SAS *) | ||
(* *) | ||
(* This file is distributed under the terms of OCamlPro *) | ||
(* Non-Commercial Purpose License, version 1. *) | ||
(* *) | ||
(* As an exception, Alt-Ergo Club members at the Gold level can *) | ||
(* use this file under the terms of the Apache Software License *) | ||
(* version 2.0. *) | ||
(* *) | ||
(* --------------------------------------------------------------- *) | ||
(* *) | ||
(* The Alt-Ergo theorem prover *) | ||
(* *) | ||
(* Sylvain Conchon, Evelyne Contejean, Francois Bobot *) | ||
(* Mohamed Iguernelala, Stephane Lescuyer, Alain Mebsout *) | ||
(* *) | ||
(* CNRS - INRIA - Universite Paris Sud *) | ||
(* *) | ||
(* Until 2013, some parts of this code were released under *) | ||
(* the Apache Software License version 2.0. *) | ||
(* *) | ||
(* --------------------------------------------------------------- *) | ||
(* *) | ||
(* More details can be found in the directory licenses/ *) | ||
(* *) | ||
(**************************************************************************) | ||
|
||
module O = Options | ||
module State = D_loop.State | ||
module Typer = D_loop.Typer | ||
|
||
module type Input = sig | ||
type k | ||
|
||
type t | ||
|
||
val get : unit -> k | ||
|
||
val key : string | ||
|
||
val on_update : k -> unit | ||
|
||
val map : k -> t | ||
end | ||
|
||
module type S = sig | ||
type k | ||
|
||
type t | ||
|
||
val set : k -> Typer.state -> Typer.state | ||
|
||
val get : Typer.state -> t | ||
|
||
val reset : Typer.state -> Typer.state | ||
end | ||
|
||
module Make(O:Input) : S with type k = O.k and type t = O.t = struct | ||
type k = O.k | ||
type t = O.t | ||
|
||
let key = State.create_key ~pipe:"" O.key | ||
|
||
let set opt st = | ||
let st = State.set key (O.map opt) st in | ||
O.on_update opt; | ||
st | ||
|
||
let get st = | ||
try State.get key st with | ||
| State.Key_not_found _ -> O.map (O.get ()) | ||
|
||
let reset = set (O.get ()) | ||
end | ||
|
||
let create_opt | ||
(type k) | ||
(type t) | ||
?(on_update=ignore) | ||
key | ||
(get : unit -> k) | ||
(map : (k -> t)) = | ||
(module ( | ||
Make ( | ||
struct | ||
type nonrec k = k | ||
type nonrec t = t | ||
let key = key | ||
let get = get | ||
let on_update = on_update | ||
let map = map | ||
end) | ||
) : S with type k = k and type t = t) | ||
|
||
module ProduceAssignment = | ||
(val (create_opt "produce_assignment" (fun _ -> false)) Fun.id) | ||
|
||
module Optimize = | ||
(val (create_opt "optimize" O.get_optimize) Fun.id) | ||
|
||
let msatsolver = | ||
let map s = | ||
let module SatCont = | ||
(val (Sat_solver.get s) : Sat_solver_sig.SatContainer) in | ||
let module TH = | ||
(val | ||
(if Options.get_no_theory() then (module Theory.Main_Empty : Theory.S) | ||
else (module Theory.Main_Default : Theory.S)) : Theory.S ) in | ||
s, | ||
(module SatCont.Make(TH) : Sat_solver_sig.S) | ||
in | ||
(create_opt "sat_solver" O.get_sat_solver map) | ||
|
||
module SatSolver = (val msatsolver) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
(**************************************************************************) | ||
(* *) | ||
(* Alt-Ergo: The SMT Solver For Software Verification *) | ||
(* Copyright (C) 2013-2023 --- OCamlPro SAS *) | ||
(* *) | ||
(* This file is distributed under the terms of OCamlPro *) | ||
(* Non-Commercial Purpose License, version 1. *) | ||
(* *) | ||
(* As an exception, Alt-Ergo Club members at the Gold level can *) | ||
(* use this file under the terms of the Apache Software License *) | ||
(* version 2.0. *) | ||
(* *) | ||
(* --------------------------------------------------------------- *) | ||
(* *) | ||
(* The Alt-Ergo theorem prover *) | ||
(* *) | ||
(* Sylvain Conchon, Evelyne Contejean, Francois Bobot *) | ||
(* Mohamed Iguernelala, Stephane Lescuyer, Alain Mebsout *) | ||
(* *) | ||
(* CNRS - INRIA - Universite Paris Sud *) | ||
(* *) | ||
(* Until 2013, some parts of this code were released under *) | ||
(* the Apache Software License version 2.0. *) | ||
(* *) | ||
(* --------------------------------------------------------------- *) | ||
(* *) | ||
(* More details can be found in the directory licenses/ *) | ||
(* *) | ||
(**************************************************************************) | ||
|
||
module type S = sig | ||
(** The type of options. It should match the type in the module Options. *) | ||
type k | ||
|
||
(** The data saved in the state. May differ from the saved option. *) | ||
type t | ||
|
||
(** Sets the option on the dolmen state, with a transformation from k to t. *) | ||
val set : k -> D_loop.Typer.state -> D_loop.Typer.state | ||
|
||
(** Returns the option stored in the state. If it has not been registered, | ||
fetches the default option in the module Options. *) | ||
val get : D_loop.Typer.state -> t | ||
|
||
(** Resets the option to its default value in Options. *) | ||
val reset : D_loop.Typer.state -> D_loop.Typer.state | ||
end | ||
|
||
module ProduceAssignment : S with type k = bool and type t = bool | ||
module Optimize : S with type k = bool and type t = bool | ||
module SatSolver : S with type k = Util.sat_solver | ||
and type t = Util.sat_solver * (module Sat_solver_sig.S) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters