summaryrefslogtreecommitdiff
path: root/parsing/depend.ml
diff options
context:
space:
mode:
authoroctachron <octa@polychoron.fr>2017-10-10 17:51:38 +0200
committerGabriel Scherer <gabriel.scherer@gmail.com>2017-10-19 14:40:15 +0200
commit86e35c1261136212a3735a8d14fd7c54599b1926 (patch)
tree7826ff921df55cb4fd03b5261c25f88bbe7a506e /parsing/depend.ml
parentcbf40e64ac2e4880caa28cfa75b064796f036e4d (diff)
downloadocaml-86e35c1261136212a3735a8d14fd7c54599b1926.tar.gz
ocamldep: refactorize uses of transparent_modules
Diffstat (limited to 'parsing/depend.ml')
-rw-r--r--parsing/depend.ml31
1 files changed, 12 insertions, 19 deletions
diff --git a/parsing/depend.ml b/parsing/depend.ml
index 7a4ce16637..99ceb6d52c 100644
--- a/parsing/depend.ml
+++ b/parsing/depend.ml
@@ -316,7 +316,9 @@ and add_modtype bv mty =
and add_module_alias bv l =
try
- add_parent bv l;
+ (* If we are in delayed dependencies mode, we delay the dependencies
+ induced by "Lident s" *)
+ (if !Clflags.transparent_modules then add_parent else addmodule) bv l;
lookup_map l.txt bv
with Not_found ->
match l.txt with
@@ -326,7 +328,6 @@ and add_module_alias bv l =
and add_modtype_binding bv mty =
match mty.pmty_desc with
Pmty_alias l ->
- if not !Clflags.transparent_modules then addmodule bv l;
add_module_alias bv l
| Pmty_signature s ->
make_node (add_signature_binding bv s)
@@ -387,20 +388,9 @@ and add_sig_item (bv, m) item =
and add_module_binding bv modl =
match modl.pmod_desc with
- Pmod_ident l ->
- if not !Clflags.transparent_modules then addmodule bv l;
- begin try
- add_parent bv l;
- lookup_map l.txt bv
- with Not_found ->
- match l.txt with
- Lident s -> make_leaf s
- | _ -> addmodule bv l; bound
- end
+ Pmod_ident l -> add_module_alias bv l
| Pmod_structure s ->
- let n = make_node (snd @@ add_structure_binding bv s) in
- if not !Clflags.transparent_modules then add_names (collect_free n);
- n
+ make_node (snd @@ add_structure_binding bv s)
| _ -> add_module bv modl; bound
and add_module bv modl =
@@ -468,8 +458,13 @@ and add_struct_item (bv, m) item : _ StringMap.t * _ StringMap.t =
| Pstr_class_type cdtl ->
List.iter (add_class_type_declaration bv) cdtl; (bv, m)
| Pstr_include incl ->
- let Node (s, m') = add_module_binding bv incl.pincl_mod in
- add_names s;
+ let Node (s, m') as n = add_module_binding bv incl.pincl_mod in
+ if !Clflags.transparent_modules then
+ add_names s
+ else
+ (* If we are not in the delayed dependency mode, we need to
+ collect all delayed dependencies imported by the include statement *)
+ add_names (collect_free n);
let add = StringMap.fold StringMap.add m' in
(add bv, add m)
| Pstr_attribute _ -> (bv, m)
@@ -481,9 +476,7 @@ and add_use_file bv top_phrs =
ignore (List.fold_left add_top_phrase bv top_phrs)
and add_implementation bv l =
- if !Clflags.transparent_modules then
ignore (add_structure_binding bv l)
- else ignore (add_structure bv l)
and add_implementation_binding bv l =
snd (add_structure_binding bv l)