Skip to content

Commit 7ca7182

Browse files
committed
Store declaration dependencies in CMS files
1 parent fccf2f9 commit 7ca7182

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

file_formats/cms_format.ml

+10-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
(** cms and cmsi files format. *)
1919

20+
module Uid = Shape.Uid
21+
2022
let read_magic_number ic =
2123
let len_magic_number = String.length Config.cms_magic_number in
2224
really_input_string ic len_magic_number
@@ -32,7 +34,9 @@ type cms_infos = {
3234
cms_uid_to_attributes : Parsetree.attributes Shape.Uid.Tbl.t;
3335
cms_impl_shape : Shape.t option; (* None for mli *)
3436
cms_ident_occurrences :
35-
(Longident.t Location.loc * Shape_reduce.result) array
37+
(Longident.t Location.loc * Shape_reduce.result) array;
38+
cms_declaration_dependencies :
39+
(Cmt_format.dependency_kind * Uid.t * Uid.t) list;
3640
}
3741

3842
type error =
@@ -114,6 +118,9 @@ let save_cms target modname binary_annots initial_env shape =
114118
let cms_uid_to_loc, cms_uid_to_attributes =
115119
uid_tables_of_binary_annots binary_annots
116120
in
121+
let cms_declaration_dependencies =
122+
Cmt_format.get_declaration_dependencies ()
123+
in
117124
let cms =
118125
{
119126
cms_modname = modname;
@@ -125,7 +132,8 @@ let save_cms target modname binary_annots initial_env shape =
125132
cms_uid_to_loc;
126133
cms_uid_to_attributes;
127134
cms_impl_shape = shape;
128-
cms_ident_occurrences
135+
cms_ident_occurrences;
136+
cms_declaration_dependencies;
129137
}
130138
in
131139
output_cms oc cms)

file_formats/cms_format.mli

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
(** cms and cmsi files format. *)
1919

20+
module Uid = Shape.Uid
21+
2022
type cms_infos = {
2123
cms_modname : Compilation_unit.t;
2224
cms_comments : (string * Location.t) list;
@@ -28,7 +30,9 @@ type cms_infos = {
2830
cms_uid_to_attributes : Parsetree.attributes Shape.Uid.Tbl.t;
2931
cms_impl_shape : Shape.t option; (* None for mli *)
3032
cms_ident_occurrences :
31-
(Longident.t Location.loc * Shape_reduce.result) array
33+
(Longident.t Location.loc * Shape_reduce.result) array;
34+
cms_declaration_dependencies :
35+
(Cmt_format.dependency_kind * Uid.t * Uid.t) list;
3236
}
3337

3438
type error =

file_formats/cmt_format.ml

+2
Original file line numberDiff line numberDiff line change
@@ -518,3 +518,5 @@ let save_cmt target cu binary_annots initial_env cmi shape =
518518
output_cmt oc cmt)
519519
end;
520520
clear ()
521+
522+
let get_declaration_dependencies () = !uids_deps

file_formats/cmt_format.mli

+3
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,6 @@ val need_to_clear_env : bool
133133
val read_signature : 'a -> string -> Types.signature * 'b list * 'c list
134134
135135
*)
136+
137+
val get_declaration_dependencies :
138+
unit -> (dependency_kind * Uid.t * Uid.t) list

0 commit comments

Comments
 (0)