Skip to content

Commit 86e8fc8

Browse files
alleystoughtonstrub
authored andcommitted
[internal]: make public some functions needed by external projects
1 parent d5d977d commit 86e8fc8

File tree

4 files changed

+67
-7
lines changed

4 files changed

+67
-7
lines changed

src/ecCommands.ml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ end = struct
188188
List.mem (norm p) ld.ld_stack
189189
end
190190

191+
(* -------------------------------------------------------------------- *)
192+
type loader = Loader.loader
193+
191194
(* -------------------------------------------------------------------- *)
192195
let process_search scope qs =
193196
EcScope.Search.search scope qs
@@ -441,7 +444,10 @@ and process_th_require1 ld scope (nm, (sysname, thname), io) =
441444

442445
try_finally (fun () ->
443446
let commands = EcIo.parseall (EcIo.from_file filename) in
444-
let commands = List.fold_left (process_internal subld) iscope commands in
447+
let commands =
448+
List.fold_left
449+
(fun scope g -> process_internal subld scope g.gl_action)
450+
iscope commands in
445451
commands)
446452
(fun () -> Pragma.set i_pragma)
447453
in
@@ -673,9 +679,14 @@ and process (ld : Loader.loader) (scope : EcScope.scope) g =
673679
scope
674680

675681
(* -------------------------------------------------------------------- *)
676-
and process_internal ld scope g =
677-
try odfl scope (process ld scope g.gl_action)
678-
with e -> raise (EcScope.toperror_of_exn ~gloc:(loc g.gl_action) e)
682+
and process_internal
683+
(ld : Loader.loader)
684+
(scope : EcScope.scope)
685+
(action : global_action located)
686+
: EcScope.scope
687+
=
688+
try odfl scope (process ld scope action)
689+
with e -> raise (EcScope.toperror_of_exn ~gloc:(loc action) e)
679690

680691
(* -------------------------------------------------------------------- *)
681692
let loader = Loader.create ()

src/ecCommands.mli

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ open EcLocation
55
exception Restart
66

77
(* -------------------------------------------------------------------- *)
8+
type loader
9+
10+
val loader : loader
811
val addidir : ?namespace:EcLoader.namespace -> ?recursive:bool -> string -> unit
912
val loadpath : unit -> (EcLoader.namespace option * string) list
1013

@@ -21,6 +24,8 @@ type checkmode = {
2124
cm_iterate : bool;
2225
}
2326

27+
val initial : checkmode:checkmode -> boot:bool -> EcScope.scope
28+
2429
val initialize :
2530
restart:bool
2631
-> undo:bool
@@ -31,6 +36,13 @@ val initialize :
3136
val current : unit -> EcScope.scope
3237
val addnotifier : notifier -> unit
3338

39+
(* -------------------------------------------------------------------- *)
40+
val process_internal :
41+
loader
42+
-> EcScope.scope
43+
-> EcParsetree.global_action located
44+
-> EcScope.scope
45+
3446
(* -------------------------------------------------------------------- *)
3547
val process : ?timed:bool -> ?break:bool ->
3648
EcParsetree.global_action located -> float option

src/ecScope.ml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -606,10 +606,10 @@ module Prover = struct
606606
}
607607

608608
(* -------------------------------------------------------------------- *)
609-
let mk_prover_info scope (options : smt_options) =
609+
let mk_prover_info_from_dft (dft : EcProvers.prover_infos)
610+
(options : smt_options) : EcProvers.prover_infos =
610611
let open EcProvers in
611612

612-
let dft = Prover_info.get scope.sc_options in
613613
let gn_debug = odfl dft.gn_debug options.gn_debug in
614614
let pr_maxprocs = odfl dft.pr_maxprocs options.po_nprovers in
615615
let pr_timelimit = max 0 (odfl dft.pr_timelimit options.po_timeout) in
@@ -637,11 +637,23 @@ module Prover = struct
637637
pr_dumpin ;
638638
gn_debug ; }
639639

640+
(* -------------------------------------------------------------------- *)
641+
let mk_prover_info scope (options : smt_options) =
642+
let dft = Prover_info.get scope.sc_options in
643+
mk_prover_info_from_dft dft options
644+
640645
(* -------------------------------------------------------------------- *)
641646
let do_prover_info scope ppr =
642647
let options = process_prover_option (env scope) ppr in
643648
mk_prover_info scope options
644649

650+
(* -------------------------------------------------------------------- *)
651+
let pprover_infos_to_prover_infos
652+
(env : EcEnv.env) (dft : EcProvers.prover_infos)
653+
(ppr : pprover_infos) : EcProvers.prover_infos =
654+
let options = process_prover_option env ppr in
655+
mk_prover_info_from_dft dft options
656+
645657
(* -------------------------------------------------------------------- *)
646658
let process scope ppr =
647659
let pi = do_prover_info scope ppr in
@@ -823,7 +835,7 @@ module Ax = struct
823835
PSCheck proof
824836
in
825837
let puc =
826-
let active =
838+
let active =
827839
{ puc_name = name
828840
; puc_started = false
829841
; puc_jdg = puc
@@ -2033,6 +2045,16 @@ module Theory = struct
20332045

20342046
| None -> assert false
20352047

2048+
(* ------------------------------------------------------------------ *)
2049+
let update_with_required ~(dst : scope) ~(src : scope) =
2050+
let dst =
2051+
let sc_loaded =
2052+
Msym.union
2053+
(fun _ x y -> assert (x ==(*phy*) y); Some x)
2054+
dst.sc_loaded src.sc_loaded
2055+
in { dst with sc_loaded }
2056+
in List.fold_right require_loaded src.sc_required dst
2057+
20362058
(* ------------------------------------------------------------------ *)
20372059
let add_clears clears scope =
20382060
let clears =

src/ecScope.mli

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ val attop : scope -> bool
6868
val goal : scope -> proof_auc option
6969
val xgoal : scope -> proof_uc option
7070

71+
(* Creates a scope that is identical to the supplied one except
72+
* that the environment and required theories are reset to the ones
73+
* from the prelude. *)
74+
val for_loading : scope -> scope
75+
7176
type topmode = [`InProof | `InActiveProof | `InTop]
7277

7378
val check_state : topmode -> string -> scope -> unit
@@ -135,6 +140,10 @@ module Theory : sig
135140

136141
exception TopScope
137142

143+
(* [update_with_required dst src] updates [dst] with the required
144+
* theories of [src] *)
145+
val update_with_required : dst:scope -> src:scope -> scope
146+
138147
(* [enter scope mode name] start a theory in scope [scope] with
139148
* name [name] and mode (abstract/concrete) [mode]. *)
140149
val enter : scope -> thmode -> symbol -> EcTypes.is_local -> scope
@@ -210,6 +219,12 @@ module Prover : sig
210219
val set_default : scope -> smt_options -> scope
211220
val full_check : scope -> scope
212221
val check_proof : scope -> bool -> scope
222+
223+
val pprover_infos_to_prover_infos :
224+
EcEnv.env
225+
-> EcProvers.prover_infos
226+
-> pprover_infos
227+
-> EcProvers.prover_infos
213228
end
214229

215230
(* -------------------------------------------------------------------- *)

0 commit comments

Comments
 (0)