Skip to content
Snippets Groups Projects
Commit f5bb71ef authored by Kilyan Le Gallic's avatar Kilyan Le Gallic Committed by Allan Blanchard
Browse files

[wp] Added caching pattern to import_theory

parent 9aa687fe
No related branches found
No related tags found
No related merge requests found
...@@ -267,48 +267,48 @@ let li_of_ls (env:env) (menv : menv) (ls : W.Term.lsymbol) : C.logic_info = ...@@ -267,48 +267,48 @@ let li_of_ls (env:env) (menv : menv) (ls : W.Term.lsymbol) : C.logic_info =
let import_theory (env : env) thname = let import_theory (env : env) thname =
let theory_name, theory_path = extract_path thname in let theory_name, theory_path = extract_path thname in
try try
if not (Datatype.String.Hashtbl.mem env.menv thname) then try ignore (Datatype.String.Hashtbl.find env.menv thname) with Not_found ->
begin let menv : menv = {li = []; lti = []} in
let menv : menv = {li = []; lti = []} in let theory = W.Env.read_theory env.wenv theory_path theory_name in
let theory = W.Env.read_theory env.wenv theory_path theory_name in List.iter (fun (tdecl : T.tdecl) ->
List.iter (fun (tdecl : T.tdecl) -> match tdecl.td_node with
match tdecl.td_node with | Decl decl ->
| Decl decl -> begin
begin match decl.d_node with
match decl.d_node with | Dtype ts ->
| Dtype ts -> L.debug ~dkey "Decl and type %a" pp_id ts.ts_name;
L.debug ~dkey "Decl and type %a" pp_id ts.ts_name; L.debug ~dkey "Location %a" pp_id_loc ts.ts_name;
L.debug ~dkey "Location %a" pp_id_loc ts.ts_name; let lti = lti_of_ts env menv ts in
let lti = lti_of_ts env menv ts in L.debug ~dkey "Correspondign LTI %a" pp_lti lti;
L.debug ~dkey "Correspondign LTI %a" pp_lti lti; | Ddata ddatas ->
| Ddata ddatas -> List.iter
List.iter (fun ((ts, _) : W.Decl.data_decl) ->
(fun ((ts, _) : W.Decl.data_decl) -> L.debug ~dkey "Decl and data %a" pp_id ts.ts_name;
L.debug ~dkey "Decl and data %a" pp_id ts.ts_name; L.debug ~dkey "Location %a" pp_id_loc ts.ts_name;
L.debug ~dkey "Location %a" pp_id_loc ts.ts_name; let lti = lti_of_ts env menv ts in
let lti = lti_of_ts env menv ts in L.debug ~dkey "Correspondign data LTI %a" pp_lti lti;
L.debug ~dkey "Correspondign data LTI %a" pp_lti lti; ) ddatas
) ddatas | Dparam ls ->
| Dparam ls -> L.debug ~dkey "Decl and dparam %a" pp_id ls.ls_name;
L.debug ~dkey "Decl and dparam %a" pp_id ls.ls_name; L.debug ~dkey "Location %a" pp_id_loc ls.ls_name
L.debug ~dkey "Location %a" pp_id_loc ls.ls_name | Dlogic dlogics ->
| Dlogic dlogics -> List.iter
List.iter (fun ((ls,_):W.Decl.logic_decl) ->
(fun ((ls,_):W.Decl.logic_decl) -> L.debug ~dkey "Decl and dlogic %a" pp_id ls.ls_name;
L.debug ~dkey "Decl and dlogic %a" pp_id ls.ls_name; L.debug ~dkey "Location %a" pp_id_loc ls.ls_name;
L.debug ~dkey "Location %a" pp_id_loc ls.ls_name; let li = li_of_ls env menv ls in
let li = li_of_ls env menv ls in L.debug ~dkey "Corresponding dlogic LTI %a" pp_li li;
L.debug ~dkey "Corresponding dlogic LTI %a" pp_li li; ) dlogics
) dlogics | _ -> L.debug ~dkey "Other type of Decl"
| _ -> L.debug ~dkey "Other type of Decl" end
end | Use _| Clone _| Meta _ -> L.debug ~dkey ""
| Use _| Clone _| Meta _ -> L.debug ~dkey "" ) theory.th_decls;
) theory.th_decls; Datatype.String.Hashtbl.add env.menv thname
Datatype.String.Hashtbl.add env.menv thname { logics = List.rev menv.li;
{ logics = List.rev menv.li; types = List.rev menv.lti;
types = List.rev menv.lti; paths = theory_path };
paths = theory_path };
end
with W.Env.LibraryNotFound _ -> with W.Env.LibraryNotFound _ ->
L.error "Library %s not found" thname L.error "Library %s not found" thname
...@@ -349,6 +349,9 @@ let loader (ctxt: Logic_typing.module_builder) (_: C.location) (m: string list) ...@@ -349,6 +349,9 @@ let loader (ctxt: Logic_typing.module_builder) (_: C.location) (m: string list)
L.result "Successfully imported theory at %s" L.result "Successfully imported theory at %s"
@@ String.concat "::" current_module.paths; @@ String.concat "::" current_module.paths;
(*LB.add_builtin*)
end end
let () = let () =
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment