Commit 3cd1a52f authored by Pietro Abate's avatar Pietro Abate

[r2005-06-13 12:30:03 by afrisch] Import nested OCaml modules

Original author: afrisch
Date: 2005-06-13 12:30:03+00:00
parent 44f030a7
......@@ -598,7 +598,7 @@ let gen_wrapper vals =
try (s,fst (Mltypes.find_value s)) :: accu
with Not_found ->
let vals =
try Mltypes.load_cmi s
try Mltypes.load_module s
with Not_found ->
failwith ("Cannot resolve " ^ s)
in
......
......@@ -196,13 +196,10 @@ let find_value v =
Config.load_path := Config.standard_library :: !Librarian.obj_path;
let li = Longident.parse v in
ocaml_env := Env.initial;
let (p,vd) = Env.lookup_value li Env.initial in
let (_,vd) = Env.lookup_value li Env.initial in
unfold vd.val_type
let load_cmi name =
Config.load_path := Config.standard_library :: !Librarian.obj_path;
let filename = Misc.find_in_path_uncap !Config.load_path (name ^ ".cmi") in
let sg = Env.read_signature name filename in
let values_of_sig name sg =
List.fold_left
(fun accu v -> match v with
| Tsig_value (id,_) ->
......@@ -216,8 +213,25 @@ let load_cmi name =
| _ -> accu
) [] sg
let load_cmi name =
try load_cmi name
let load_module name =
Config.load_path := Config.standard_library :: !Librarian.obj_path;
let li = Longident.parse name in
ocaml_env := Env.initial;
let (_,mty) = Env.lookup_module li Env.initial in
match mty with
| Tmty_signature sg -> values_of_sig name sg
| _ -> raise (Loc.Generic
(Printf.sprintf "Module %s is not a structure" name))
(*
let filename = Misc.find_in_path_uncap !Config.load_path (name ^ ".cmi") in
let sg = Env.read_signature name filename in
values_of_sig sg
*)
let load_module name =
try load_module name
with Env.Error e ->
Env.report_error Format.str_formatter e;
let s = Format.flush_str_formatter () in
......
......@@ -19,7 +19,7 @@ and def =
(* Load an external .cmi *)
val has_cmi: string -> bool
val load_cmi: string -> (string * t) list
val load_module: string -> (string * t) list
(* Load the .cmi corresponding to a CDuce compilation unit *)
val read_cmi: string -> string * (string * Types.type_expr * t) list
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment