Skip to content

Commit

Permalink
[wip] [fleche] Basic .vo load cache.
Browse files Browse the repository at this point in the history
  • Loading branch information
ejgallego committed Jun 3, 2024
1 parent a4115a8 commit 684f601
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions fleche/memo.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
module CS = Stats

(* XXX: We are missing good error handling here! Fix upstream. *)
module Intern = struct
let hc :
( Names.DirPath.t
, Library.library_t * Library.Intern.Provenance.t )
Hashtbl.t =
Hashtbl.create 1000

let use_cache = true

let intern dp =
if use_cache then
match Hashtbl.find_opt hc dp with
| Some lib -> lib
| None ->
let file = Loadpath.try_locate_absolute_library dp in
let lib = (Library.intern_from_file file, ("file", file)) in
let () = Hashtbl.add hc dp lib in
lib
else Vernacinterp.fs_intern dp
end

let intern = Intern.intern

(* Regular memo table *)
module Stats = struct
type t =
{ stats : Stats.t
Expand Down Expand Up @@ -287,9 +312,7 @@ module VernacEval = struct

type output = Coq.State.t

let eval ~token (st, stm) =
let intern = Vernacinterp.fs_intern in
Coq.Interp.interp ~token ~intern ~st stm
let eval ~token (st, stm) = Coq.Interp.interp ~token ~intern ~st stm
end

module Interp = CEval (VernacEval)
Expand Down Expand Up @@ -318,7 +341,6 @@ module RequireEval = struct
type output = Coq.State.t

let eval ~token (st, files, stm) =
let intern = Vernacinterp.fs_intern in
Coq.Interp.Require.interp ~token ~intern ~st files stm
end

Expand Down Expand Up @@ -350,7 +372,6 @@ module InitEval = struct
type output = Coq.State.t

let eval ~token (root_state, workspace, uri) =
let intern = Vernacinterp.fs_intern in
Coq.Init.doc_init ~token ~intern ~root_state ~workspace ~uri

let input_info (st, ws, file) =
Expand Down

0 comments on commit 684f601

Please sign in to comment.