-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split Import_info.t
into Import_info.{Intf,Impl}.t
#1746
Changes from all commits
a35803a
076aa77
123f159
97a1596
ed94e2b
3df9aa2
b80f7b6
2a667f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,106 +16,64 @@ module CU = Compilation_unit | |
|
||
module Intf = struct | ||
type t = | ||
| Normal of CU.t * Digest.t | ||
| Normal_no_crc of CU.t | ||
| Normal of CU.Name.t * Digest.t (* Unpacked, so compilation unit = name *) | ||
| Name_only of CU.Name.t (* Same but digest unknown *) | ||
| Other of CU.Name.t * (CU.t * Digest.t) option | ||
|
||
(* CR xclerc: Maybe introduce Other_no_crc to flatten the option *) | ||
(* Packed, so the CU isn't just the name *) | ||
|
||
let create cu_name ~crc_with_unit = | ||
match crc_with_unit with | ||
| None -> Other (cu_name, None) | ||
| Some (cu, crc) -> | ||
(* For the moment be conservative and only use the [Normal] constructor | ||
when there is no pack prefix at all. *) | ||
(* If there's no pack prefix, the CU is just the name, so we don't need to | ||
store both. *) | ||
if CU.Prefix.is_empty (CU.for_pack_prefix cu) | ||
&& CU.Name.equal (CU.name cu) cu_name | ||
then Normal (cu, crc) | ||
then Normal (cu_name, crc) | ||
else Other (cu_name, Some (cu, crc)) | ||
|
||
let create_normal cu ~crc = | ||
match crc with Some crc -> Normal (cu, crc) | None -> Normal_no_crc cu | ||
|
||
let name t = | ||
match t with | ||
| Normal (cu, _) | Normal_no_crc cu -> CU.name cu | ||
| Other (name, _) -> name | ||
match t with Normal (name, _) | Name_only name | Other (name, _) -> name | ||
|
||
let cu t = | ||
let impl t = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you clarify why the semantics of this was changed from that of the old There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because an |
||
match t with | ||
| Normal (cu, _) | Normal_no_crc cu | Other (_, Some (cu, _)) -> cu | ||
| Other (name, None) -> | ||
Misc.fatal_errorf | ||
"Cannot extract [Compilation_unit.t] from [Import_info.t] (for unit \ | ||
%a) that never received it" | ||
CU.Name.print name | ||
| Normal (name, _) -> | ||
let cu = CU.create CU.Prefix.empty name in | ||
Some cu | ||
| Name_only _ -> None | ||
| Other (_, Some (cu, _)) -> Some cu | ||
| Other (_, None) -> None | ||
|
||
let crc t = | ||
match t with | ||
| Normal (_, crc) -> Some crc | ||
| Normal_no_crc _ | Other (_, None) -> None | ||
| Name_only _ | Other (_, None) -> None | ||
| Other (_, Some (_, crc)) -> Some crc | ||
|
||
let crc_with_unit t = | ||
match t with | ||
| Normal (cu, crc) -> Some (cu, crc) | ||
| Normal_no_crc _ | Other (_, None) -> None | ||
| Normal (cu, crc) -> Some (CU.create CU.Prefix.empty cu, crc) | ||
| Name_only _ | Other (_, None) -> None | ||
| Other (_, some_cu_and_crc) -> some_cu_and_crc | ||
|
||
let has_name t ~name:name' = CU.Name.equal (name t) name' | ||
|
||
let dummy = Other (CU.Name.dummy, None) | ||
let dummy = Name_only CU.Name.dummy | ||
end | ||
|
||
module Impl = struct | ||
type t = | ||
| Normal of CU.t * Digest.t | ||
| Normal_no_crc of CU.t | ||
| Other of CU.Name.t * (CU.t * Digest.t) option | ||
|
||
(* CR xclerc: Maybe introduce Other_no_crc to flatten the option *) | ||
|
||
let create cu_name ~crc_with_unit = | ||
match crc_with_unit with | ||
| None -> Other (cu_name, None) | ||
| Some (cu, crc) -> | ||
(* For the moment be conservative and only use the [Normal] constructor | ||
when there is no pack prefix at all. *) | ||
if CU.Prefix.is_empty (CU.for_pack_prefix cu) | ||
&& CU.Name.equal (CU.name cu) cu_name | ||
then Normal (cu, crc) | ||
else Other (cu_name, Some (cu, crc)) | ||
| With_crc of CU.t * Digest.t | ||
| No_crc of CU.t | ||
|
||
let create_normal cu ~crc = | ||
match crc with Some crc -> Normal (cu, crc) | None -> Normal_no_crc cu | ||
let create cu ~crc = | ||
match crc with Some crc -> With_crc (cu, crc) | None -> No_crc cu | ||
|
||
let name t = | ||
match t with | ||
| Normal (cu, _) | Normal_no_crc cu -> CU.name cu | ||
| Other (name, _) -> name | ||
let cu (With_crc (cu, _) | No_crc cu) = cu | ||
|
||
let cu t = | ||
match t with | ||
| Normal (cu, _) | Normal_no_crc cu | Other (_, Some (cu, _)) -> cu | ||
| Other (name, None) -> | ||
Misc.fatal_errorf | ||
"Cannot extract [Compilation_unit.t] from [Import_info.t] (for unit \ | ||
%a) that never received it" | ||
CU.Name.print name | ||
let name t = CU.name (cu t) | ||
|
||
let crc t = | ||
match t with | ||
| Normal (_, crc) -> Some crc | ||
| Normal_no_crc _ | Other (_, None) -> None | ||
| Other (_, Some (_, crc)) -> Some crc | ||
|
||
let crc_with_unit t = | ||
match t with | ||
| Normal (cu, crc) -> Some (cu, crc) | ||
| Normal_no_crc _ | Other (_, None) -> None | ||
| Other (_, some_cu_and_crc) -> some_cu_and_crc | ||
|
||
let has_name t ~name:name' = CU.Name.equal (name t) name' | ||
let crc t = match t with With_crc (_, crc) -> Some crc | No_crc _ -> None | ||
|
||
let dummy = Other (CU.Name.dummy, None) | ||
let dummy = No_crc CU.dummy | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this comment apply for all three cases? If so maybe clarify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding comments to the other two