resolve module aliases

Ignore-this: 9b0c0f2de27ba128bfa3916a7db8631d

darcs-hash:20110727220954-c41ad-849890db65365f2ce3e0cb69f10882e6efa78661
This commit is contained in:
Jeremie Dimino 2011-07-28 00:09:54 +02:00
parent f7e913a26f
commit f171e7ec80
1 changed files with 32 additions and 22 deletions

View File

@ -131,33 +131,43 @@ let add_names_of_type decl acc =
| Type_abstract -> | Type_abstract ->
acc acc
let rec get_names_of_module_type = function
| Tmty_signature decls ->
List.fold_left
(fun acc decl -> match decl with
| Tsig_value(id, _)
| Tsig_exception(id, _)
| Tsig_module(id, _, _)
| Tsig_modtype(id, _)
| Tsig_class(id, _, _)
| Tsig_cltype(id, _, _) ->
add (Ident.name id) acc
| Tsig_type(id, decl, _) ->
add_names_of_type decl (add (Ident.name id) acc))
String_set.empty decls
| Tmty_ident path -> begin
match try Some (Env.find_modtype path !Toploop.toplevel_env) with Not_found -> None with
| Some Tmodtype_abstract -> String_set.empty
| Some Tmodtype_manifest module_type -> get_names_of_module_type module_type
| None -> String_set.empty
end
| _ ->
String_set.empty
(* List all names of the module with path [path] *) (* List all names of the module with path [path] *)
let get_names_of_module path = let get_names_of_module path =
try match
match try
match path with match path with
| Path path -> | Path path ->
Env.find_module path !Toploop.toplevel_env Some (Env.find_module path !Toploop.toplevel_env)
| Longident ident -> | Longident ident ->
snd (Env.lookup_module ident !Toploop.toplevel_env) Some (snd (Env.lookup_module ident !Toploop.toplevel_env))
with with Not_found ->
| Tmty_signature decls -> None
List.fold_left with
(fun acc decl -> match decl with | Some module_type -> get_names_of_module_type module_type
| Tsig_value(id, _) | None -> String_set.empty
| Tsig_exception(id, _)
| Tsig_module(id, _, _)
| Tsig_modtype(id, _)
| Tsig_class(id, _, _)
| Tsig_cltype(id, _, _) ->
add (Ident.name id) acc
| Tsig_type(id, decl, _) ->
add_names_of_type decl (add (Ident.name id) acc))
String_set.empty decls
| _ ->
String_set.empty
with Not_found ->
String_set.empty
let names_of_module path = let names_of_module path =
try try