@@ -42,18 +42,25 @@ exception Not_an_interface
4242
4343exception Make_root_error of string
4444
45+ #if OCAML_VERSION > = (4 , 14 , 0 )
4546(* * [cmt_info.cmt_annots = Implementation _] *)
4647let read_cmt_infos' source_id_opt id cmt_info =
4748 match Odoc_model.Compat. shape_of_cmt_infos cmt_info with
48- | Some shape -> begin
49- let uid_to_loc = cmt_info.cmt_uid_to_loc in
50- match source_id_opt, cmt_info.cmt_annots with
51- | Some source_id , Implementation impl ->
52- let (map, source_infos) = Implementation. of_cmt source_id id impl uid_to_loc in
53- (Some shape, map, Some { Odoc_model.Lang.Source_info. id= source_id; infos = source_infos})
54- | _ , _ ->
55- (Some shape, Odoc_model.Compat. empty_map, None )
56- end
49+ | Some shape -> (
50+ let uid_to_loc = cmt_info.cmt_uid_to_loc in
51+ match (source_id_opt, cmt_info.cmt_annots) with
52+ | Some source_id , Implementation impl ->
53+ let map, source_infos =
54+ Implementation. of_cmt source_id id impl uid_to_loc
55+ in
56+ ( Some shape,
57+ map,
58+ Some
59+ {
60+ Odoc_model.Lang.Source_info. id = source_id;
61+ infos = source_infos;
62+ } )
63+ | _ , _ -> (Some shape, Odoc_model.Compat. empty_map, None ))
5764 | None -> (None , Odoc_model.Compat. empty_map, None )
5865
5966let read_cmt_infos source_id_opt id ~filename () =
@@ -64,6 +71,13 @@ let read_cmt_infos source_id_opt id ~filename () =
6471 | Implementation _ -> read_cmt_infos' source_id_opt id cmt_info
6572 | _ -> raise Not_an_implementation )
6673
74+ #else
75+
76+ let read_cmt_infos _source_id_opt _id ~filename :_ () =
77+ (None , Odoc_model.Compat. empty_map, None )
78+
79+ #endif
80+
6781let make_compilation_unit ~make_root ~imports ~interface ?sourcefile ~name ~id
6882 ?canonical ?shape ~uid_to_id ~source_info content =
6983 let open Odoc_model.Lang.Compilation_unit in
@@ -106,6 +120,7 @@ let make_compilation_unit ~make_root ~imports ~interface ?sourcefile ~name ~id
106120 uid_to_id;
107121 }
108122
123+
109124let compilation_unit_of_sig ~make_root ~imports ~interface ?sourcefile ~name ~id
110125 ?canonical ?shape ~uid_to_id sg =
111126 let content = Odoc_model.Lang.Compilation_unit. Module sg in
@@ -126,15 +141,15 @@ let read_cmti ~make_root ~parent ~filename ~cmt_filename_opt ~source_id_opt () =
126141 cmt_info.cmt_builddir )
127142 in
128143 let id, sg, canonical = Cmti. read_interface parent name intf in
129- let ( shape, uid_to_id, source_info) =
144+ let shape, uid_to_id, source_info =
130145 match cmt_filename_opt with
131146 | Some cmt_filename ->
132- read_cmt_infos source_id_opt id ~filename: cmt_filename ()
133- | None ->
134- (None , Odoc_model.Compat. empty_map, None )
147+ read_cmt_infos source_id_opt id ~filename: cmt_filename ()
148+ | None -> (None , Odoc_model.Compat. empty_map, None )
135149 in
136150 compilation_unit_of_sig ~make_root ~imports: cmt_info.cmt_imports
137- ~interface ~sourcefile ~name ~id ?shape ~uid_to_id ~source_info ?canonical sg)
151+ ~interface ~sourcefile ~name ~id ?shape ~uid_to_id ~source_info
152+ ?canonical sg)
138153 | _ -> raise Not_an_interface
139154
140155let read_cmt ~make_root ~parent ~filename ~source_id_opt () =
@@ -176,14 +191,15 @@ let read_cmt ~make_root ~parent ~filename ~source_id_opt () =
176191 items
177192 in
178193 let content = Odoc_model.Lang.Compilation_unit. Pack items in
179- make_compilation_unit ~make_root ~imports ~interface ~sourcefile
180- ~name ~id ~uid_to_id: Odoc_model.Compat. empty_map ~source_info: None content
194+ make_compilation_unit ~make_root ~imports ~interface ~sourcefile ~name
195+ ~id ~uid_to_id: Odoc_model.Compat. empty_map ~source_info: None content
181196 | Implementation impl ->
182197 let id, sg, canonical = Cmt. read_implementation parent name impl in
183- let (shape, uid_to_id, source_info) =
184- read_cmt_infos source_id_opt id ~filename () in
198+ let shape, uid_to_id, source_info =
199+ read_cmt_infos source_id_opt id ~filename ()
200+ in
185201 compilation_unit_of_sig ~make_root ~imports ~interface ~sourcefile
186- ~name ~id ?canonical ?shape ~uid_to_id ~source_info sg
202+ ~name ~id ?canonical ?shape ~uid_to_id ~source_info sg
187203 | _ -> raise Not_an_implementation )
188204
189205let read_cmi ~make_root ~parent ~filename () =
@@ -194,7 +210,8 @@ let read_cmi ~make_root ~parent ~filename () =
194210 Cmi. read_interface parent name
195211 (Odoc_model.Compat. signature cmi_info.cmi_sign)
196212 in
197- compilation_unit_of_sig ~make_root ~imports ~interface ~name ~id ~source_info: None ~uid_to_id: Odoc_model.Compat. empty_map sg
213+ compilation_unit_of_sig ~make_root ~imports ~interface ~name ~id
214+ ~source_info: None ~uid_to_id: Odoc_model.Compat. empty_map sg
198215 | _ -> raise Corrupted
199216
200217(* * Catch errors from reading the object files and some internal errors *)
@@ -211,7 +228,8 @@ let wrap_errors ~filename f =
211228 | Make_root_error m -> error_msg filename m)
212229
213230let read_cmti ~make_root ~parent ~filename ~source_id_opt ~cmt_filename_opt =
214- wrap_errors ~filename (read_cmti ~make_root ~parent ~filename ~source_id_opt ~cmt_filename_opt )
231+ wrap_errors ~filename
232+ (read_cmti ~make_root ~parent ~filename ~source_id_opt ~cmt_filename_opt )
215233
216234let read_cmt ~make_root ~parent ~filename ~source_id_opt =
217235 wrap_errors ~filename (read_cmt ~make_root ~parent ~filename ~source_id_opt )
0 commit comments