diff -Naur ocaml-3.09.2/asmcomp/asmpackager.ml ocaml-3.09.2-patched/asmcomp/asmpackager.ml --- ocaml-3.09.2/asmcomp/asmpackager.ml 2005-12-17 18:49:57.000000000 +0200 +++ ocaml-3.09.2-patched/asmcomp/asmpackager.ml 2006-07-13 03:07:44.000000000 +0300 @@ -161,7 +161,7 @@ (* The entry point *) -let package_files ppf files targetcmx = +let package_files ppf files targetcmx exports = let files = List.map (fun f -> @@ -177,7 +177,7 @@ (* Set the name of the current compunit *) Compilenv.reset ?packname:!Clflags.for_package targetname; try - let coercion = Typemod.package_units files targetcmi targetname in + let coercion = Typemod.package_units files targetcmi targetname exports in package_object_files ppf files targetcmx targetobj targetname coercion with x -> remove_file targetcmx; remove_file targetobj; diff -Naur ocaml-3.09.2/asmcomp/asmpackager.mli ocaml-3.09.2-patched/asmcomp/asmpackager.mli --- ocaml-3.09.2/asmcomp/asmpackager.mli 2005-08-01 18:51:09.000000000 +0300 +++ ocaml-3.09.2-patched/asmcomp/asmpackager.mli 2006-07-13 03:07:52.000000000 +0300 @@ -15,7 +15,7 @@ (* "Package" a set of .cmx/.o files into one .cmx/.o file having the original compilation units as sub-modules. *) -val package_files: Format.formatter -> string list -> string -> unit +val package_files: Format.formatter -> string list -> string -> string list -> unit type error = Illegal_renaming of string * string diff -Naur ocaml-3.09.2/bytecomp/bytepackager.ml ocaml-3.09.2-patched/bytecomp/bytepackager.ml --- ocaml-3.09.2/bytecomp/bytepackager.ml 2004-04-09 16:32:27.000000000 +0300 +++ ocaml-3.09.2-patched/bytecomp/bytepackager.ml 2006-07-10 15:17:50.000000000 +0300 @@ -217,7 +217,7 @@ (* The entry point *) -let package_files files targetfile = +let package_files files targetfile exports = let files = List.map (fun f -> @@ -228,7 +228,7 @@ let targetcmi = prefix ^ ".cmi" in let targetname = String.capitalize(Filename.basename prefix) in try - let coercion = Typemod.package_units files targetcmi targetname in + let coercion = Typemod.package_units files targetcmi targetname exports in package_object_files files targetfile targetname coercion with x -> remove_file targetfile; raise x diff -Naur ocaml-3.09.2/bytecomp/bytepackager.mli ocaml-3.09.2-patched/bytecomp/bytepackager.mli --- ocaml-3.09.2/bytecomp/bytepackager.mli 2002-02-08 18:55:42.000000000 +0200 +++ ocaml-3.09.2-patched/bytecomp/bytepackager.mli 2006-07-10 13:35:35.000000000 +0300 @@ -15,7 +15,7 @@ (* "Package" a set of .cmo files into one .cmo file having the original compilation units as sub-modules. *) -val package_files: string list -> string -> unit +val package_files: string list -> string -> string list -> unit type error = Forward_reference of string * Ident.t diff -Naur ocaml-3.09.2/bytecomp/byteretyper.ml ocaml-3.09.2-patched/bytecomp/byteretyper.ml --- ocaml-3.09.2/bytecomp/byteretyper.ml 1970-01-01 02:00:00.000000000 +0200 +++ ocaml-3.09.2-patched/bytecomp/byteretyper.ml 2006-07-13 00:35:44.000000000 +0300 @@ -0,0 +1,182 @@ +open Misc +open Instruct +open Emitcode + +type error = + No_file_given + | Too_many_files + | File_not_found of string + | Not_an_object_file of string + | Illegal_renaming of string * string + | Forward_reference of string * Ident.t + +exception Error of error + +let events = ref ([] : debug_event list) +let primitives = ref ([] : string list) +let force_link = ref false +let relocs = ref ([] : (reloc_info * int) list) + +type member = + { pm_file: string; + pm_name: string; + pm_cu: compilation_unit } + +(* Record a debugging event *) + +let accumulate_debug ev = + events := ev :: !events + +let build_global_target oc input_name target_name member coercion pos acc_id = + let component = Some acc_id in + let lam = + Translmod.transl_retyping component (Ident.create_persistent target_name) + coercion in + let instrs = Bytegen.compile_implementation target_name lam in + let rel = Emitcode.to_packed_file oc instrs in + relocs := List.map (fun (r, ofs) -> (r, pos + ofs)) rel @ !relocs + +(* Read the bytecode from a .cmo file. + Write bytecode to channel [oc]. + Accumulate relocs, debug info, etc. + Return size of bytecode. *) + +let append_bytecode targetname oc objfile compunit = + let ic = open_in_bin objfile in + try + Bytelink.check_consistency objfile compunit; + primitives := compunit.cu_primitives @ !primitives; + if compunit.cu_force_link then force_link := true; + seek_in ic compunit.cu_pos; + Misc.copy_file_chunk ic oc compunit.cu_codesize; + if !Clflags.debug && compunit.cu_debug > 0 then begin + seek_in ic compunit.cu_debug; + List.iter accumulate_debug (input_value ic); + end; + close_in ic; + compunit.cu_codesize + with x -> close_in ic; raise x + +let read_member_info file = + let name = + String.capitalize(Filename.basename(chop_extension_if_any file)) in + let kind = + if Filename.check_suffix file ".cmo" then begin + let ic = open_in_bin file in + try + let buffer = String.create (String.length Config.cmo_magic_number) in + really_input ic buffer 0 (String.length Config.cmo_magic_number); + if buffer <> Config.cmo_magic_number then + raise(Error(Not_an_object_file file)); + let compunit_pos = input_binary_int ic in + seek_in ic compunit_pos; + let compunit = (input_value ic : compilation_unit) in + if compunit.cu_name <> name then + raise(Error(Illegal_renaming(file, compunit.cu_name))); + close_in ic; + compunit + with x -> + close_in ic; + raise x + end else + raise(Error(Not_an_object_file file)) in + { pm_file = file; pm_name = name; pm_cu = kind } + +let artif_id id = + String.contains (Ident.name id) '.' + +let rename_relocations inputname relocs acc_id= + List.map (fun(rinfo, n) -> let rinfo = + match rinfo with + Reloc_setglobal id -> + if id = Ident.create_persistent inputname then + Reloc_setglobal acc_id + else if artif_id id then + Reloc_setglobal (Ident.create_persistent (inputname ^ "." ^ (Ident.name id))) + else + rinfo + | Reloc_getglobal id -> + if id = Ident.create_persistent inputname then + Reloc_getglobal acc_id + else if artif_id id then + Reloc_getglobal (Ident.create_persistent (inputname ^ "." ^ (Ident.name id))) + else + rinfo + | _ -> rinfo in + (rinfo, n)) relocs + +let retype_object_file file targetfile targetname coercion = + let member = read_member_info file in + let oc = open_out_bin targetfile in + try + output_string oc Config.cmo_magic_number; + let pos_depl = pos_out oc in + output_binary_int oc 0; + let pos_code = pos_out oc in + let ofs = append_bytecode targetname oc member.pm_file member.pm_cu in + let input_name = String.capitalize(Filename.basename(chop_extension_if_any file)) in + let acc_id = Ident.create_persistent "module." in + build_global_target oc input_name targetname member coercion ofs acc_id; + let pos_debug = pos_out oc in + if !Clflags.debug && !events <> [] then begin + output_value oc (List.rev !events); + end; + let pos_final = pos_out oc in + let imports = List.map + (fun (name, crc) -> if (name <> input_name) then (name, crc) + else (targetname, Env.crc_of_unit targetname)) + member.pm_cu.cu_imports in + let relocs = (rename_relocations input_name member.pm_cu.cu_reloc acc_id) @ !relocs in + let compunit = + { cu_name = targetname; + cu_pos = pos_code; + cu_codesize = pos_debug - pos_code; + cu_reloc = relocs; + cu_imports = imports; + cu_primitives = !primitives; + cu_force_link = !force_link; + cu_debug = if pos_final > pos_debug then pos_debug else 0; + cu_debugsize = pos_final - pos_debug } in + output_value oc compunit; + seek_out oc pos_depl; + output_binary_int oc pos_final; + close_out oc + with x -> + close_out oc; + raise x + +let retype_file file targetfile = + let file = try find_in_path !Config.load_path file + with Not_found -> raise(Error(File_not_found file)) in + let prefix = chop_extension_if_any targetfile in + let targetcmi = prefix ^ ".cmi" in + let targetname = String.capitalize(Filename.basename prefix) in + try + let coercion = Typemod.retype_unit file targetcmi targetname in + retype_object_file file targetfile targetname coercion + with x -> + remove_file targetfile; raise x + +let retype_files filelist targetfile = + match filelist with + [] -> raise(Error(No_file_given)) + | [file] -> retype_file file targetfile + | _ -> raise(Error(Too_many_files)) + +open Format + +let report_error ppf = function + No_file_given -> + fprintf ppf "%s" "No input file given" + | Too_many_files -> + fprintf ppf "%s" "Cannot retype more than one file a time" + | File_not_found file -> + fprintf ppf "File %s not found" file + | Not_an_object_file typ -> + fprintf ppf "%s is not an object type" typ + | Illegal_renaming (name1, name2) -> + fprintf ppf "illegal renaming: %s" (name1 ^ " -> " ^ name2) + | Forward_reference(file, ident) -> + fprintf ppf "Forward reference to %s in file %s" (Ident.name ident) file + + diff -Naur ocaml-3.09.2/bytecomp/byteretyper.mli ocaml-3.09.2-patched/bytecomp/byteretyper.mli --- ocaml-3.09.2/bytecomp/byteretyper.mli 1970-01-01 02:00:00.000000000 +0200 +++ ocaml-3.09.2-patched/bytecomp/byteretyper.mli 2006-07-06 21:34:06.000000000 +0300 @@ -0,0 +1,13 @@ +val retype_files : string list -> string -> unit + +type error = + No_file_given + | Too_many_files + | File_not_found of string + | Not_an_object_file of string + | Illegal_renaming of string * string + | Forward_reference of string * Ident.t + +exception Error of error + +val report_error: Format.formatter -> error -> unit diff -Naur ocaml-3.09.2/bytecomp/translmod.ml ocaml-3.09.2-patched/bytecomp/translmod.ml --- ocaml-3.09.2/bytecomp/translmod.ml 2004-08-12 15:55:11.000000000 +0300 +++ ocaml-3.09.2-patched/bytecomp/translmod.ml 2006-09-04 23:24:04.000000000 +0300 @@ -651,6 +651,10 @@ assert false in Lprim(Psetglobal target_name, [Lprim(Pmakeblock(0, Immutable), components)]) +let transl_retyping component_name target_name coercion = + let component = apply_coercion coercion (get_component component_name) in + Lprim(Psetglobal target_name, [component]) + let transl_store_package component_names target_name coercion = let rec make_sequence fn pos arg = match arg with diff -Naur ocaml-3.09.2/bytecomp/translmod.mli ocaml-3.09.2-patched/bytecomp/translmod.mli --- ocaml-3.09.2/bytecomp/translmod.mli 2004-04-09 16:32:27.000000000 +0300 +++ ocaml-3.09.2-patched/bytecomp/translmod.mli 2006-07-06 21:34:37.000000000 +0300 @@ -24,6 +24,8 @@ val transl_toplevel_definition: structure -> lambda val transl_package: Ident.t option list -> Ident.t -> module_coercion -> lambda +val transl_retyping: + Ident.t option -> Ident.t -> module_coercion -> lambda val transl_store_package: Ident.t option list -> Ident.t -> module_coercion -> int * lambda diff -Naur ocaml-3.09.2/.depend ocaml-3.09.2-patched/.depend --- ocaml-3.09.2/.depend 2006-01-24 15:39:53.000000000 +0200 +++ ocaml-3.09.2-patched/.depend 2006-07-06 23:08:20.000000000 +0300 @@ -264,6 +264,7 @@ bytecomp/bytegen.cmi: bytecomp/lambda.cmi bytecomp/instruct.cmi bytecomp/bytelink.cmi: bytecomp/symtable.cmi bytecomp/emitcode.cmi bytecomp/bytepackager.cmi: typing/ident.cmi +bytecomp/byteretyper.cmi: typing/ident.cmi bytecomp/emitcode.cmi: bytecomp/lambda.cmi bytecomp/instruct.cmi \ typing/ident.cmi bytecomp/instruct.cmi: typing/types.cmi parsing/location.cmi \ @@ -318,6 +319,14 @@ utils/misc.cmx bytecomp/instruct.cmx typing/ident.cmx typing/env.cmx \ bytecomp/emitcode.cmx utils/config.cmx utils/clflags.cmx \ bytecomp/bytelink.cmx bytecomp/bytegen.cmx bytecomp/bytepackager.cmi +bytecomp/byteretyper.cmo: typing/typemod.cmi bytecomp/translmod.cmi \ + utils/misc.cmi bytecomp/instruct.cmi typing/ident.cmi typing/env.cmi \ + bytecomp/emitcode.cmi utils/config.cmi utils/clflags.cmi \ + bytecomp/bytelink.cmi bytecomp/bytegen.cmi bytecomp/byteretyper.cmi +bytecomp/byteretyper.cmx: typing/typemod.cmx bytecomp/translmod.cmx \ + utils/misc.cmx bytecomp/instruct.cmx typing/ident.cmx typing/env.cmx \ + bytecomp/emitcode.cmx utils/config.cmx utils/clflags.cmx \ + bytecomp/bytelink.cmx bytecomp/bytegen.cmx bytecomp/byteretyper.cmi bytecomp/bytesections.cmo: utils/config.cmi bytecomp/bytesections.cmi bytecomp/bytesections.cmx: utils/config.cmx bytecomp/bytesections.cmi bytecomp/dll.cmo: utils/misc.cmi utils/config.cmi bytecomp/dll.cmi @@ -439,8 +448,8 @@ asmcomp/clambda.cmi: bytecomp/lambda.cmi typing/ident.cmi \ parsing/asttypes.cmi asmcomp/closure.cmi: bytecomp/lambda.cmi asmcomp/clambda.cmi -asmcomp/cmm.cmi: typing/ident.cmi asmcomp/cmmgen.cmi: asmcomp/cmm.cmi asmcomp/clambda.cmi +asmcomp/cmm.cmi: typing/ident.cmi asmcomp/codegen.cmi: asmcomp/cmm.cmi asmcomp/comballoc.cmi: asmcomp/mach.cmi asmcomp/compilenv.cmi: typing/ident.cmi asmcomp/clambda.cmi @@ -454,8 +463,8 @@ asmcomp/printmach.cmi: asmcomp/reg.cmi asmcomp/mach.cmi asmcomp/proc.cmi: asmcomp/reg.cmi asmcomp/mach.cmi asmcomp/reg.cmi: asmcomp/cmm.cmi -asmcomp/reload.cmi: asmcomp/mach.cmi asmcomp/reloadgen.cmi: asmcomp/reg.cmi asmcomp/mach.cmi +asmcomp/reload.cmi: asmcomp/mach.cmi asmcomp/schedgen.cmi: asmcomp/mach.cmi asmcomp/linearize.cmi asmcomp/scheduling.cmi: asmcomp/linearize.cmi asmcomp/selectgen.cmi: utils/tbl.cmi asmcomp/reg.cmi asmcomp/mach.cmi \ @@ -463,8 +472,8 @@ asmcomp/selection.cmi: asmcomp/mach.cmi asmcomp/cmm.cmi asmcomp/spill.cmi: asmcomp/mach.cmi asmcomp/split.cmi: asmcomp/mach.cmi -asmcomp/arch.cmo: utils/misc.cmi -asmcomp/arch.cmx: utils/misc.cmx +asmcomp/arch.cmo: utils/misc.cmi utils/config.cmi +asmcomp/arch.cmx: utils/misc.cmx utils/config.cmx asmcomp/asmgen.cmo: asmcomp/split.cmi asmcomp/spill.cmi asmcomp/selection.cmi \ asmcomp/scheduling.cmi asmcomp/reload.cmi asmcomp/reg.cmi \ asmcomp/proc.cmi asmcomp/printmach.cmi asmcomp/printlinear.cmi \ @@ -519,8 +528,6 @@ utils/misc.cmx bytecomp/lambda.cmx typing/ident.cmx asmcomp/compilenv.cmx \ utils/clflags.cmx asmcomp/clambda.cmx parsing/asttypes.cmi \ asmcomp/closure.cmi -asmcomp/cmm.cmo: typing/ident.cmi asmcomp/arch.cmo asmcomp/cmm.cmi -asmcomp/cmm.cmx: typing/ident.cmx asmcomp/arch.cmx asmcomp/cmm.cmi asmcomp/cmmgen.cmo: typing/types.cmi bytecomp/switch.cmi asmcomp/proc.cmi \ typing/primitive.cmi utils/misc.cmi bytecomp/lambda.cmi typing/ident.cmi \ utils/config.cmi asmcomp/compilenv.cmi asmcomp/cmm.cmi utils/clflags.cmi \ @@ -531,6 +538,8 @@ utils/config.cmx asmcomp/compilenv.cmx asmcomp/cmm.cmx utils/clflags.cmx \ asmcomp/clambda.cmx parsing/asttypes.cmi asmcomp/arch.cmx \ asmcomp/cmmgen.cmi +asmcomp/cmm.cmo: typing/ident.cmi asmcomp/arch.cmo asmcomp/cmm.cmi +asmcomp/cmm.cmx: typing/ident.cmx asmcomp/arch.cmx asmcomp/cmm.cmi asmcomp/codegen.cmo: asmcomp/split.cmi asmcomp/spill.cmi asmcomp/reload.cmi \ asmcomp/reg.cmi asmcomp/printmach.cmi asmcomp/printlinear.cmi \ asmcomp/printcmm.cmi asmcomp/liveness.cmi asmcomp/linearize.cmi \ @@ -551,16 +560,16 @@ utils/config.cmi asmcomp/clambda.cmi asmcomp/compilenv.cmi asmcomp/compilenv.cmx: utils/misc.cmx typing/ident.cmx typing/env.cmx \ utils/config.cmx asmcomp/clambda.cmx asmcomp/compilenv.cmi +asmcomp/emitaux.cmo: asmcomp/emitaux.cmi +asmcomp/emitaux.cmx: asmcomp/emitaux.cmi asmcomp/emit.cmo: asmcomp/reg.cmi asmcomp/proc.cmi utils/misc.cmi \ asmcomp/mach.cmi parsing/location.cmi asmcomp/linearize.cmi \ asmcomp/emitaux.cmi utils/config.cmi asmcomp/compilenv.cmi \ - asmcomp/cmm.cmi asmcomp/arch.cmo asmcomp/emit.cmi + asmcomp/cmm.cmi utils/clflags.cmi asmcomp/arch.cmo asmcomp/emit.cmi asmcomp/emit.cmx: asmcomp/reg.cmx asmcomp/proc.cmx utils/misc.cmx \ asmcomp/mach.cmx parsing/location.cmx asmcomp/linearize.cmx \ asmcomp/emitaux.cmx utils/config.cmx asmcomp/compilenv.cmx \ - asmcomp/cmm.cmx asmcomp/arch.cmx asmcomp/emit.cmi -asmcomp/emitaux.cmo: asmcomp/emitaux.cmi -asmcomp/emitaux.cmx: asmcomp/emitaux.cmi + asmcomp/cmm.cmx utils/clflags.cmx asmcomp/arch.cmx asmcomp/emit.cmi asmcomp/interf.cmo: asmcomp/reg.cmi asmcomp/proc.cmi utils/misc.cmi \ asmcomp/mach.cmi asmcomp/interf.cmi asmcomp/interf.cmx: asmcomp/reg.cmx asmcomp/proc.cmx utils/misc.cmx \ @@ -595,32 +604,34 @@ asmcomp/arch.cmx asmcomp/proc.cmi asmcomp/reg.cmo: asmcomp/cmm.cmi asmcomp/reg.cmi asmcomp/reg.cmx: asmcomp/cmm.cmx asmcomp/reg.cmi -asmcomp/reload.cmo: asmcomp/reloadgen.cmi asmcomp/reload.cmi -asmcomp/reload.cmx: asmcomp/reloadgen.cmx asmcomp/reload.cmi asmcomp/reloadgen.cmo: asmcomp/reg.cmi utils/misc.cmi asmcomp/mach.cmi \ asmcomp/reloadgen.cmi asmcomp/reloadgen.cmx: asmcomp/reg.cmx utils/misc.cmx asmcomp/mach.cmx \ asmcomp/reloadgen.cmi +asmcomp/reload.cmo: asmcomp/reloadgen.cmi asmcomp/reg.cmi asmcomp/mach.cmi \ + asmcomp/cmm.cmi asmcomp/arch.cmo asmcomp/reload.cmi +asmcomp/reload.cmx: asmcomp/reloadgen.cmx asmcomp/reg.cmx asmcomp/mach.cmx \ + asmcomp/cmm.cmx asmcomp/arch.cmx asmcomp/reload.cmi asmcomp/schedgen.cmo: asmcomp/reg.cmi utils/misc.cmi asmcomp/mach.cmi \ asmcomp/linearize.cmi asmcomp/cmm.cmi asmcomp/arch.cmo \ asmcomp/schedgen.cmi asmcomp/schedgen.cmx: asmcomp/reg.cmx utils/misc.cmx asmcomp/mach.cmx \ asmcomp/linearize.cmx asmcomp/cmm.cmx asmcomp/arch.cmx \ asmcomp/schedgen.cmi -asmcomp/scheduling.cmo: asmcomp/schedgen.cmi asmcomp/mach.cmi \ - asmcomp/arch.cmo asmcomp/scheduling.cmi -asmcomp/scheduling.cmx: asmcomp/schedgen.cmx asmcomp/mach.cmx \ - asmcomp/arch.cmx asmcomp/scheduling.cmi +asmcomp/scheduling.cmo: asmcomp/schedgen.cmi asmcomp/scheduling.cmi +asmcomp/scheduling.cmx: asmcomp/schedgen.cmx asmcomp/scheduling.cmi asmcomp/selectgen.cmo: utils/tbl.cmi asmcomp/reg.cmi asmcomp/proc.cmi \ utils/misc.cmi asmcomp/mach.cmi typing/ident.cmi asmcomp/cmm.cmi \ asmcomp/arch.cmo asmcomp/selectgen.cmi asmcomp/selectgen.cmx: utils/tbl.cmx asmcomp/reg.cmx asmcomp/proc.cmx \ utils/misc.cmx asmcomp/mach.cmx typing/ident.cmx asmcomp/cmm.cmx \ asmcomp/arch.cmx asmcomp/selectgen.cmi -asmcomp/selection.cmo: asmcomp/selectgen.cmi asmcomp/reg.cmi utils/misc.cmi \ - asmcomp/mach.cmi asmcomp/cmm.cmi asmcomp/arch.cmo asmcomp/selection.cmi -asmcomp/selection.cmx: asmcomp/selectgen.cmx asmcomp/reg.cmx utils/misc.cmx \ - asmcomp/mach.cmx asmcomp/cmm.cmx asmcomp/arch.cmx asmcomp/selection.cmi +asmcomp/selection.cmo: asmcomp/selectgen.cmi asmcomp/reg.cmi asmcomp/proc.cmi \ + utils/misc.cmi asmcomp/mach.cmi asmcomp/cmm.cmi asmcomp/arch.cmo \ + asmcomp/selection.cmi +asmcomp/selection.cmx: asmcomp/selectgen.cmx asmcomp/reg.cmx asmcomp/proc.cmx \ + utils/misc.cmx asmcomp/mach.cmx asmcomp/cmm.cmx asmcomp/arch.cmx \ + asmcomp/selection.cmi asmcomp/spill.cmo: asmcomp/reg.cmi asmcomp/proc.cmi utils/misc.cmi \ asmcomp/mach.cmi asmcomp/spill.cmi asmcomp/spill.cmx: asmcomp/reg.cmx asmcomp/proc.cmx utils/misc.cmx \ @@ -650,25 +661,27 @@ bytecomp/translmod.cmi bytecomp/translcore.cmi bytecomp/translclass.cmi \ parsing/syntaxerr.cmi bytecomp/symtable.cmi driver/pparse.cmi \ parsing/location.cmi parsing/lexer.cmi typing/includemod.cmi \ - typing/env.cmi typing/ctype.cmi bytecomp/bytepackager.cmi \ - bytecomp/bytelink.cmi bytecomp/bytelibrarian.cmi driver/errors.cmi + typing/env.cmi typing/ctype.cmi bytecomp/byteretyper.cmi \ + bytecomp/bytepackager.cmi bytecomp/bytelink.cmi \ + bytecomp/bytelibrarian.cmi driver/errors.cmi driver/errors.cmx: utils/warnings.cmx typing/typetexp.cmx typing/typemod.cmx \ typing/typedecl.cmx typing/typecore.cmx typing/typeclass.cmx \ bytecomp/translmod.cmx bytecomp/translcore.cmx bytecomp/translclass.cmx \ parsing/syntaxerr.cmx bytecomp/symtable.cmx driver/pparse.cmx \ parsing/location.cmx parsing/lexer.cmx typing/includemod.cmx \ - typing/env.cmx typing/ctype.cmx bytecomp/bytepackager.cmx \ - bytecomp/bytelink.cmx bytecomp/bytelibrarian.cmx driver/errors.cmi + typing/env.cmx typing/ctype.cmx bytecomp/byteretyper.cmx \ + bytecomp/bytepackager.cmx bytecomp/bytelink.cmx \ + bytecomp/bytelibrarian.cmx driver/errors.cmi +driver/main_args.cmo: driver/main_args.cmi +driver/main_args.cmx: driver/main_args.cmi driver/main.cmo: utils/warnings.cmi utils/misc.cmi driver/main_args.cmi \ driver/errors.cmi utils/config.cmi driver/compile.cmi utils/clflags.cmi \ - bytecomp/bytepackager.cmi bytecomp/bytelink.cmi \ + bytecomp/byteretyper.cmi bytecomp/bytepackager.cmi bytecomp/bytelink.cmi \ bytecomp/bytelibrarian.cmi driver/main.cmi driver/main.cmx: utils/warnings.cmx utils/misc.cmx driver/main_args.cmx \ driver/errors.cmx utils/config.cmx driver/compile.cmx utils/clflags.cmx \ - bytecomp/bytepackager.cmx bytecomp/bytelink.cmx \ + bytecomp/byteretyper.cmx bytecomp/bytepackager.cmx bytecomp/bytelink.cmx \ bytecomp/bytelibrarian.cmx driver/main.cmi -driver/main_args.cmo: driver/main_args.cmi -driver/main_args.cmx: driver/main_args.cmi driver/optcompile.cmo: utils/warnings.cmi typing/unused_var.cmi \ typing/typemod.cmi typing/typedtree.cmi bytecomp/translmod.cmi \ bytecomp/simplif.cmi typing/printtyp.cmi bytecomp/printlambda.cmi \ diff -Naur ocaml-3.09.2/driver/errors.ml ocaml-3.09.2-patched/driver/errors.ml --- ocaml-3.09.2/driver/errors.ml 2005-11-09 17:58:47.000000000 +0200 +++ ocaml-3.09.2-patched/driver/errors.ml 2006-07-06 21:35:18.000000000 +0300 @@ -60,6 +60,8 @@ Bytelibrarian.report_error ppf code | Bytepackager.Error code -> Bytepackager.report_error ppf code + | Byteretyper.Error code -> + Byteretyper.report_error ppf code | Sys_error msg -> fprintf ppf "I/O error: %s" msg | Warnings.Errors (n) -> diff -Naur ocaml-3.09.2/driver/main_args.ml ocaml-3.09.2-patched/driver/main_args.ml --- ocaml-3.09.2/driver/main_args.ml 2005-12-28 19:27:03.000000000 +0200 +++ ocaml-3.09.2-patched/driver/main_args.ml 2006-07-13 03:05:52.000000000 +0300 @@ -24,6 +24,7 @@ val _dllib : string -> unit val _dllpath : string -> unit val _dtypes : unit -> unit + val _export : string -> unit val _g : unit -> unit val _i : unit -> unit val _I : string -> unit @@ -42,6 +43,7 @@ val _pack : unit -> unit val _pp : string -> unit val _principal : unit -> unit + val _retype : unit -> unit val _rectypes : unit -> unit val _thread : unit -> unit val _vmthread : unit -> unit @@ -79,6 +81,7 @@ "-dllpath", Arg.String F._dllpath, "
";
@@ -1250,7 +1252,9 @@
bs b "";
bs b (self#create_fully_qualified_module_idents_links father a.mta_name);
bs b ""
- | Module_type_with (k, s) ->
+ | Module_type_with (k, s)
+ | Module_type_without (k, s)
+ | Module_type_using (k, s) ->
self#html_of_module_type_kind b father ?modu ?mt k;
bs b " ";
bs b (self#create_fully_qualified_module_idents_links father s);
diff -Naur ocaml-3.09.2/ocamldoc/odoc_info.mli ocaml-3.09.2-patched/ocamldoc/odoc_info.mli
--- ocaml-3.09.2/ocamldoc/odoc_info.mli 2005-11-10 16:44:36.000000000 +0200
+++ ocaml-3.09.2-patched/ocamldoc/odoc_info.mli 2006-07-06 21:42:45.000000000 +0300
@@ -437,6 +437,10 @@
| Module_with of module_type_kind * string
(** A module whose type is a with ... constraint.
Should appear in interface files only. *)
+ | Module_without of module_type_kind * string
+ (** A module whose type is filtere with without.... constrains. *)
+ | Module_using of module_type_kind * string
+ (** A module whose type is filtere with using.... constrains. *)
| Module_constraint of module_kind * module_type_kind
(** A module constraint by a module type. *)
@@ -471,6 +475,10 @@
(** Complete alias name and corresponding module type if we found it. *)
| Module_type_with of module_type_kind * string
(** The module type kind and the code of the with constraint. *)
+ | Module_type_without of module_type_kind * string
+ (** The module type kind and the code of the without constraint. *)
+ | Module_type_using of module_type_kind * string
+ (** The module type kind and the code of the using constraint. *)
(** Representation of a module type. *)
and t_module_type = Odoc_module.t_module_type =
diff -Naur ocaml-3.09.2/ocamldoc/odoc_latex.ml ocaml-3.09.2-patched/ocamldoc/odoc_latex.ml
--- ocaml-3.09.2/ocamldoc/odoc_latex.ml 2005-11-10 16:44:36.000000000 +0200
+++ ocaml-3.09.2-patched/ocamldoc/odoc_latex.ml 2006-06-29 22:48:35.000000000 +0300
@@ -603,7 +603,9 @@
| Module_type_alias a ->
self#latex_of_text fmt
[Code (self#relative_module_idents father a.mta_name)]
- | Module_type_with (k, s) ->
+ | Module_type_with (k, s)
+ | Module_type_without (k, s)
+ | Module_type_using (k, s) ->
self#latex_of_module_type_kind fmt father k;
self#latex_of_text fmt
[ Code " ";
@@ -629,7 +631,9 @@
self#latex_of_text fmt [Code "("];
self#latex_of_module_kind fmt father k2;
self#latex_of_text fmt [Code ")"]
- | Module_with (k, s) ->
+ | Module_with (k, s)
+ | Module_without (k, s)
+ | Module_using (k, s) ->
(* TODO: à modifier quand Module_with sera plus détaillé *)
self#latex_of_module_type_kind fmt father k;
self#latex_of_text fmt
diff -Naur ocaml-3.09.2/ocamldoc/odoc_module.ml ocaml-3.09.2-patched/ocamldoc/odoc_module.ml
--- ocaml-3.09.2/ocamldoc/odoc_module.ml 2005-11-10 16:44:36.000000000 +0200
+++ ocaml-3.09.2-patched/ocamldoc/odoc_module.ml 2006-07-06 21:43:16.000000000 +0300
@@ -59,6 +59,8 @@
| Module_functor of module_parameter * module_kind
| Module_apply of module_kind * module_kind
| Module_with of module_type_kind * string
+ | Module_without of module_type_kind * string
+ | Module_using of module_type_kind * string
| Module_constraint of module_kind * module_type_kind
(** Representation of a module. *)
@@ -87,6 +89,9 @@
| Module_type_functor of module_parameter * module_type_kind
| Module_type_alias of module_type_alias (** complete name and corresponding module type if we found it *)
| Module_type_with of module_type_kind * string (** the module type kind and the code of the with constraint *)
+ | Module_type_without of module_type_kind * string (** the module type kind and the code of the without constraint *)
+ | Module_type_using of module_type_kind * string (** the module type kind and the code of the using constraint *)
+
(** Representation of a module type. *)
and t_module_type = {
@@ -229,6 +234,20 @@
mt_is_interface = false ; mt_file = "" ; mt_kind = Some tk ;
mt_loc = Odoc_types.dummy_loc ;
}
+ | Module_without (tk,_) ->
+ print_DEBUG "Odoc_module.module_element: Module_without";
+ module_type_elements ~trans: trans
+ { mt_name = "" ; mt_info = None ; mt_type = None ;
+ mt_is_interface = false ; mt_file = "" ; mt_kind = Some tk ;
+ mt_loc = Odoc_types.dummy_loc ;
+ }
+ | Module_using (tk,_) ->
+ print_DEBUG "Odoc_module.module_element: Module_using";
+ module_type_elements ~trans: trans
+ { mt_name = "" ; mt_info = None ; mt_type = None ;
+ mt_is_interface = false ; mt_file = "" ; mt_kind = Some tk ;
+ mt_loc = Odoc_types.dummy_loc ;
+ }
| Module_constraint (k, tk) ->
print_DEBUG "Odoc_module.module_element: Module_constraint";
(* A VOIR : utiliser k ou tk ? *)
@@ -259,7 +278,9 @@
| None -> []
| Some (Module_type_struct l) -> l
| Some (Module_type_functor (_, k)) -> iter_kind (Some k)
- | Some (Module_type_with (k, _)) ->
+ | Some (Module_type_with (k, _))
+ | Some (Module_type_without (k, _))
+ | Some (Module_type_using (k, _)) ->
if trans then
iter_kind (Some k)
else
@@ -351,7 +372,9 @@
| Some mt2 -> module_type_parameters ~trans mt2
else
[]
- | Some (Module_type_with (k, _)) ->
+ | Some (Module_type_with (k, _))
+ | Some (Module_type_without (k, _))
+ | Some (Module_type_using (k, _))->
if trans then
iter (Some k)
else
@@ -398,7 +421,9 @@
mt_loc = Odoc_types.dummy_loc }
| Module_struct _
| Module_apply _
- | Module_with _ ->
+ | Module_with _
+ | Module_without _
+ | Module_using _ ->
[]
in
iter m.m_kind
@@ -423,7 +448,9 @@
None -> false
| Some mtyp -> module_type_is_functor mtyp
)
- | Some (Module_type_with (k, _)) ->
+ | Some (Module_type_with (k, _))
+ | Some (Module_type_without (k, _))
+ | Some (Module_type_using (k, _)) ->
iter (Some k)
| Some (Module_type_struct _)
| None -> false
diff -Naur ocaml-3.09.2/ocamldoc/odoc_sig.ml ocaml-3.09.2-patched/ocamldoc/odoc_sig.ml
--- ocaml-3.09.2/ocamldoc/odoc_sig.ml 2005-11-10 16:44:36.000000000 +0200
+++ ocaml-3.09.2-patched/ocamldoc/odoc_sig.ml 2006-07-19 23:14:16.000000000 +0300
@@ -868,6 +868,9 @@
"??"
| Parsetree.Pmty_with (mt, _) ->
f mt.Parsetree.pmty_desc
+ | Parsetree.Pmty_without (mt, _)
+ | Parsetree.Pmty_using (mt, _) ->
+ f mt.Parsetree.pmty_desc
in
let name = (f module_type.Parsetree.pmty_desc) in
let full_name = Odoc_env.full_module_or_module_type_name env name in
@@ -1095,6 +1098,24 @@
let k = analyse_module_type_kind env current_module_name module_type2 sig_module_type in
Module_type_with (k, s)
)
+ | Parsetree.Pmty_without (module_type2, _) ->
+ (* of module_type * without_constraint list *)
+ (
+ let loc_start = module_type2.Parsetree.pmty_loc.Location.loc_end.Lexing.pos_cnum in
+ let loc_end = module_type.Parsetree.pmty_loc.Location.loc_end.Lexing.pos_cnum in
+ let s = get_string_of_file loc_start loc_end in
+ let k = analyse_module_type_kind env current_module_name module_type2 sig_module_type in
+ Module_type_without (k, s)
+ )
+ | Parsetree.Pmty_using (module_type2, _) ->
+ (* of module_type * using_constraint list *)
+ (
+ let loc_start = module_type2.Parsetree.pmty_loc.Location.loc_end.Lexing.pos_cnum in
+ let loc_end = module_type.Parsetree.pmty_loc.Location.loc_end.Lexing.pos_cnum in
+ let s = get_string_of_file loc_start loc_end in
+ let k = analyse_module_type_kind env current_module_name module_type2 sig_module_type in
+ Module_type_using (k, s)
+ )
(** Analyse of a Parsetree.module_type and a Types.module_type.*)
and analyse_module_kind env current_module_name module_type sig_module_type =
@@ -1159,6 +1180,24 @@
let k = analyse_module_type_kind env current_module_name module_type2 sig_module_type in
Module_with (k, s)
)
+ | Parsetree.Pmty_without (module_type2, _) -> (* skopiowane z powyzej - zrobic co nalezy *)
+ (*of module_type * (Longident.t * with_constraint) list*)
+ (
+ let loc_start = module_type2.Parsetree.pmty_loc.Location.loc_end.Lexing.pos_cnum in
+ let loc_end = module_type.Parsetree.pmty_loc.Location.loc_end.Lexing.pos_cnum in
+ let s = get_string_of_file loc_start loc_end in
+ let k = analyse_module_type_kind env current_module_name module_type2 sig_module_type in
+ Module_without (k, s)
+ )
+ | Parsetree.Pmty_using (module_type2, _) -> (* skopiowane z powyzej - zrobic co nalezy *)
+ (*of module_type * (Longident.t * with_constraint) list*)
+ (
+ let loc_start = module_type2.Parsetree.pmty_loc.Location.loc_end.Lexing.pos_cnum in
+ let loc_end = module_type.Parsetree.pmty_loc.Location.loc_end.Lexing.pos_cnum in
+ let s = get_string_of_file loc_start loc_end in
+ let k = analyse_module_type_kind env current_module_name module_type2 sig_module_type in
+ Module_using (k, s)
+ )
(** Analyse of a Parsetree.class_type and a Types.class_type to return a couple
(class parameters, class_kind).*)
diff -Naur ocaml-3.09.2/ocamldoc/odoc_to_text.ml ocaml-3.09.2-patched/ocamldoc/odoc_to_text.ml
--- ocaml-3.09.2/ocamldoc/odoc_to_text.ml 2004-08-20 20:04:35.000000000 +0300
+++ ocaml-3.09.2-patched/ocamldoc/odoc_to_text.ml 2006-06-29 22:46:11.000000000 +0300
@@ -519,7 +519,9 @@
(self#text_of_module_kind ~with_def_syntax: false k2) @
[Code " ) "]
- | Module_with (tk, code) ->
+ | Module_with (tk, code)
+ | Module_without (tk, code)
+ | Module_using (tk, code) ->
(if with_def_syntax then [Code " : "] else []) @
(self#text_of_module_type_kind ~with_def_syntax: false tk) @
[Code code]
@@ -557,7 +559,9 @@
let t2 = self#text_of_module_type_kind ~with_def_syntax: false k in
(if with_def_syntax then [Code " = "] else []) @ t1 @ t2
- | Module_type_with (tk2, code) ->
+ | Module_type_with (tk2, code)
+ | Module_type_without (tk2, code)
+ | Module_type_using (tk2, code) ->
let t = self#text_of_module_type_kind ~with_def_syntax: false tk2 in
(if with_def_syntax then [Code " = "] else []) @
t @ [Code code]
diff -Naur ocaml-3.09.2/otherlibs/labltk/browser/searchpos.ml ocaml-3.09.2-patched/otherlibs/labltk/browser/searchpos.ml
--- ocaml-3.09.2/otherlibs/labltk/browser/searchpos.ml 2005-03-23 05:08:37.000000000 +0200
+++ ocaml-3.09.2-patched/otherlibs/labltk/browser/searchpos.ml 2006-07-19 23:16:07.000000000 +0300
@@ -239,6 +239,9 @@
_, Pwith_type t -> search_pos_type_decl t ~pos ~env
| _ -> ()
end
+ | Pmty_without (m, l)
+ | Pmty_using (m, l) ->
+ search_pos_module m ~pos ~env
end
end
diff -Naur ocaml-3.09.2/parsing/parser.mly ocaml-3.09.2-patched/parsing/parser.mly
--- ocaml-3.09.2/parsing/parser.mly 2006-01-24 15:47:51.000000000 +0200
+++ ocaml-3.09.2-patched/parsing/parser.mly 2006-07-20 01:17:05.000000000 +0300
@@ -496,6 +496,13 @@
{ mkmty(Pmty_functor($3, $5, $8)) }
| module_type WITH with_constraints
{ mkmty(Pmty_with($1, List.rev $3)) }
+ | module_type LIDENT LPAREN modtype_fields RPAREN
+ { if $2 = "using" then
+ mkmty(Pmty_using($1, List.rev $4))
+ else if $2 = "without" then
+ mkmty(Pmty_without($1, List.rev $4))
+ else
+ raise(Syntaxerr.Error(Syntaxerr.Other (rhs_loc 2))) }
| LPAREN module_type RPAREN
{ $2 }
| LPAREN module_type error
@@ -506,6 +513,19 @@
| signature signature_item { $2 :: $1 }
| signature signature_item SEMISEMI { $2 :: $1 }
;
+modtype_fields:
+ modtype_field { [$1] }
+ | modtype_fields AND modtype_field { $3 :: $1 }
+;
+modtype_field:
+ VAL val_ident { Pfield_val $2 }
+ | TYPE LIDENT { Pfield_type $2 }
+ | EXCEPTION UIDENT { Pfield_exception $2}
+ | MODULE UIDENT { Pfield_module $2 }
+ | MODULE TYPE ident { Pfield_module_type $3 }
+ | CLASS LIDENT { Pfield_class $2 }
+ | CLASS TYPE LIDENT { Pfield_class_type $3 }
+;
signature_item:
VAL val_ident_colon core_type
{ mksig(Psig_value($2, {pval_type = $3; pval_prim = []})) }
diff -Naur ocaml-3.09.2/parsing/parsetree.mli ocaml-3.09.2-patched/parsing/parsetree.mli
--- ocaml-3.09.2/parsing/parsetree.mli 2005-03-23 05:08:37.000000000 +0200
+++ ocaml-3.09.2-patched/parsing/parsetree.mli 2006-07-06 23:05:47.000000000 +0300
@@ -199,6 +199,8 @@
| Pmty_signature of signature
| Pmty_functor of string * module_type * module_type
| Pmty_with of module_type * (Longident.t * with_constraint) list
+ | Pmty_without of module_type * modtype_field list
+ | Pmty_using of module_type * modtype_field list
and signature = signature_item list
@@ -222,6 +224,15 @@
Pmodtype_abstract
| Pmodtype_manifest of module_type
+and modtype_field =
+ Pfield_val of string
+ | Pfield_type of string
+ | Pfield_exception of string
+ | Pfield_module of string
+ | Pfield_module_type of string
+ | Pfield_class of string
+ | Pfield_class_type of string
+
and with_constraint =
Pwith_type of type_declaration
| Pwith_module of Longident.t
diff -Naur ocaml-3.09.2/parsing/printast.ml ocaml-3.09.2-patched/parsing/printast.ml
--- ocaml-3.09.2/parsing/printast.ml 2005-11-16 18:01:12.000000000 +0200
+++ ocaml-3.09.2-patched/parsing/printast.ml 2006-07-12 20:09:58.000000000 +0300
@@ -477,6 +477,14 @@
line i ppf "Pmty_with\n";
module_type i ppf mt;
list i longident_x_with_constraint ppf l;
+ | Pmty_without (mt, l) ->
+ line i ppf "Pmty_without\n";
+ module_type i ppf mt;
+ list i modtype_field ppf l;
+ | Pmty_using (mt, l) ->
+ line i ppf "Pmty_using\n";
+ module_type i ppf mt;
+ list i modtype_field ppf l;
and signature i ppf x = list i signature_item ppf x
@@ -527,6 +535,23 @@
type_declaration (i+1) ppf td;
| Pwith_module (li) -> line i ppf "Pwith_module %a\n" fmt_longident li;
+and modtype_field i ppf x =
+ match x with
+ | Pfield_val (id) ->
+ line i ppf "Pfield_val \"%s\"\n" id;
+ | Pfield_type (id) ->
+ line i ppf "Pfield_type \"%s\"\n" id;
+ | Pfield_exception (id) ->
+ line i ppf "Pfield_exceptioon \"%s\"\n" id;
+ | Pfield_module (id) ->
+ line i ppf "Pfield_module \"%s\"\n" id;
+ | Pfield_module_type (id) ->
+ line i ppf "Pfield_module_type \"%s\"\n" id;
+ | Pfield_class (id) ->
+ line i ppf "Pfield_class \"%s\"\n" id;
+ | Pfield_class_type (id) ->
+ line i ppf "Pfield_class_type \"%s\"\n" id;
+
and module_expr i ppf x =
line i ppf "module_expr %a\n" fmt_location x.pmod_loc;
let i = i+1 in
diff -Naur ocaml-3.09.2/stdlib/sys.ml ocaml-3.09.2-patched/stdlib/sys.ml
--- ocaml-3.09.2/stdlib/sys.ml 2006-04-14 12:53:48.000000000 +0300
+++ ocaml-3.09.2-patched/stdlib/sys.ml 2006-07-12 19:21:56.000000000 +0300
@@ -78,4 +78,4 @@
(* OCaml version string, must be in the format described in sys.mli. *)
-let ocaml_version = "3.09.2";;
+let ocaml_version = "3.09.2+PWpatches";;
diff -Naur ocaml-3.09.2/tools/depend.ml ocaml-3.09.2-patched/tools/depend.ml
--- ocaml-3.09.2/tools/depend.ml 2005-03-23 05:08:37.000000000 +0200
+++ ocaml-3.09.2-patched/tools/depend.ml 2006-07-19 23:46:26.000000000 +0300
@@ -171,6 +171,9 @@
(function (_, Pwith_type td) -> add_type_declaration bv td
| (_, Pwith_module lid) -> addmodule bv lid)
cstrl
+ | Pmty_without(mty, _)
+ | Pmty_using(mty, _) ->
+ add_modtype bv mty
and add_signature bv = function
[] -> ()
diff -Naur ocaml-3.09.2/tools/ocamlcp.ml ocaml-3.09.2-patched/tools/ocamlcp.ml
--- ocaml-3.09.2/tools/ocamlcp.ml 2005-05-09 16:39:17.000000000 +0300
+++ ocaml-3.09.2-patched/tools/ocamlcp.ml 2006-07-10 13:38:58.000000000 +0300
@@ -52,6 +52,7 @@
let _dllib = option_with_arg "-dllib"
let _dllpath = option_with_arg "-dllpath"
let _dtypes = option "-dtypes"
+ let _export s = option_with_arg "-export" s
let _g = option "-g"
let _i = option "-i"
let _I s = option_with_arg "-I" s
@@ -70,6 +71,7 @@
let _pack = option "-pack"
let _pp s = incompatible "-pp"
let _principal = option "-principal"
+ let _retype = option "-retype"
let _rectypes = option "-rectypes"
let _thread () = option "-thread" ()
let _vmthread () = option "-vmthread" ()
diff -Naur ocaml-3.09.2/typing/env.ml ocaml-3.09.2-patched/typing/env.ml
--- ocaml-3.09.2/typing/env.ml 2005-08-13 23:59:37.000000000 +0300
+++ ocaml-3.09.2-patched/typing/env.ml 2006-07-19 23:09:25.000000000 +0300
@@ -146,7 +146,7 @@
(* Reading persistent structures from .cmi files *)
-let read_pers_struct modname filename =
+let read_pers_struct modname filename cache =
let ic = open_in_bin filename in
try
let buffer = String.create (String.length cmi_magic_number) in
@@ -169,8 +169,10 @@
ps_filename = filename } in
if ps.ps_name <> modname then
raise(Error(Illegal_renaming(ps.ps_name, filename)));
- check_consistency filename ps.ps_crcs;
- Hashtbl.add persistent_structures modname ps;
+ if cache then begin
+ check_consistency filename ps.ps_crcs;
+ Hashtbl.add persistent_structures modname ps;
+ end;
ps
with End_of_file | Failure _ ->
close_in ic;
@@ -180,7 +182,7 @@
try
Hashtbl.find persistent_structures name
with Not_found ->
- read_pers_struct name (find_in_path_uncap !load_path (name ^ ".cmi"))
+ read_pers_struct name (find_in_path_uncap !load_path (name ^ ".cmi")) true
let reset_cache () =
current_unit := "";
@@ -254,7 +256,8 @@
let find_modtype_expansion path env =
match find_modtype path env with
Tmodtype_abstract -> raise Not_found
- | Tmodtype_manifest mty -> mty
+ | Tmodtype_manifest mty
+ | Tmodtype_external mty -> mty
let find_module path env =
match path with
@@ -342,6 +345,28 @@
raise Not_found
end
+let lookup_module_type proj1 proj2 lid env =
+ match lid with
+ Lident s ->
+ begin try
+ Ident.find_name s (proj1 env)
+ with Not_found ->
+ if s = !current_unit then raise Not_found;
+ let ps = find_pers_struct s in
+ (Pident(Ident.create s), Types.Tmodtype_external(Types.Tmty_signature ps.ps_sig))
+ end
+ | Ldot(l, s) ->
+ let (p, desc) = lookup_module_descr l env in
+ begin match Lazy.force desc with
+ Structure_comps c ->
+ let (data, pos) = Tbl.find s (proj2 c) in
+ (Pdot(p, s, pos), data)
+ | Functor_comps f ->
+ raise Not_found
+ end
+ | Lapply(l1, l2) ->
+ raise Not_found
+
let lookup proj1 proj2 lid env =
match lid with
Lident s ->
@@ -383,7 +408,7 @@
and lookup_type =
lookup (fun env -> env.types) (fun sc -> sc.comp_types)
and lookup_modtype =
- lookup (fun env -> env.modtypes) (fun sc -> sc.comp_modtypes)
+ lookup_module_type (fun env -> env.modtypes) (fun sc -> sc.comp_modtypes)
and lookup_class =
lookup (fun env -> env.classes) (fun sc -> sc.comp_classes)
and lookup_cltype =
@@ -717,7 +742,10 @@
(* Read a signature from a file *)
let read_signature modname filename =
- let ps = read_pers_struct modname filename in ps.ps_sig
+ let ps = read_pers_struct modname filename true in ps.ps_sig
+
+let read_signature_no_cache modname filename =
+ let ps = read_pers_struct modname filename false in ps.ps_sig
(* Return the CRC of the interface of the given compilation unit *)
diff -Naur ocaml-3.09.2/typing/env.mli ocaml-3.09.2-patched/typing/env.mli
--- ocaml-3.09.2/typing/env.mli 2005-08-13 23:59:37.000000000 +0300
+++ ocaml-3.09.2-patched/typing/env.mli 2006-07-06 21:38:23.000000000 +0300
@@ -86,6 +86,8 @@
val read_signature: string -> string -> signature
(* Arguments: module name, file name. Results: signature. *)
+val read_signature_no_cache: string -> string -> signature
+ (* Arguments: module name, file name. Results: signature. *)
val save_signature: signature -> string -> string -> unit
(* Arguments: signature, module name, file name. *)
val save_signature_with_imports:
diff -Naur ocaml-3.09.2/typing/includemod.ml ocaml-3.09.2-patched/typing/includemod.ml
--- ocaml-3.09.2/typing/includemod.ml 2005-08-13 23:59:37.000000000 +0300
+++ ocaml-3.09.2-patched/typing/includemod.ml 2006-07-19 23:10:01.000000000 +0300
@@ -283,6 +283,13 @@
check_modtype_equiv env mty1 mty2
| (Tmodtype_abstract, Tmodtype_manifest mty2) ->
check_modtype_equiv env (Tmty_ident(Pident id)) mty2
+ | (Tmodtype_external mty1, Tmodtype_abstract) -> ()
+ | (Tmodtype_external mty1, Tmodtype_external mty2)
+ | (Tmodtype_external mty1, Tmodtype_manifest mty2)
+ | (Tmodtype_manifest mty1, Tmodtype_external mty2) ->
+ check_modtype_equiv env mty1 mty2
+ | (Tmodtype_abstract, Tmodtype_external mty2) ->
+ check_modtype_equiv env (Tmty_ident(Pident id)) mty2
with Error reasons ->
raise(Error(Modtype_infos(id, info1, info2) :: reasons))
diff -Naur ocaml-3.09.2/typing/mtype.ml ocaml-3.09.2-patched/typing/mtype.ml
--- ocaml-3.09.2/typing/mtype.ml 2005-09-28 10:18:30.000000000 +0300
+++ ocaml-3.09.2-patched/typing/mtype.ml 2006-07-19 23:10:26.000000000 +0300
@@ -66,8 +66,9 @@
match decl with
Tmodtype_abstract ->
Tmodtype_manifest(Tmty_ident(Pdot(p, Ident.name id, nopos)))
- | Tmodtype_manifest _ ->
- decl in
+ | Tmodtype_manifest _
+ | Tmodtype_external _ ->
+ decl in
Tsig_modtype(id, newdecl) ::
strengthen_sig (Env.add_modtype id decl env) rem p
(* Need to add the module type in case it is manifest *)
@@ -130,6 +131,7 @@
and nondep_modtype_decl = function
Tmodtype_abstract -> Tmodtype_abstract
| Tmodtype_manifest mty -> Tmodtype_manifest(nondep_mty Strict mty)
+ | Tmodtype_external mty -> Tmodtype_external(nondep_mty Strict mty)
in
nondep_mty Co mty
diff -Naur ocaml-3.09.2/typing/printtyp.ml ocaml-3.09.2-patched/typing/printtyp.ml
--- ocaml-3.09.2/typing/printtyp.ml 2006-02-09 03:19:26.000000000 +0200
+++ ocaml-3.09.2-patched/typing/printtyp.ml 2006-07-19 23:11:46.000000000 +0300
@@ -812,7 +812,8 @@
let mty =
match decl with
| Tmodtype_abstract -> Omty_abstract
- | Tmodtype_manifest mty -> tree_of_modtype mty
+ | Tmodtype_manifest mty
+ | Tmodtype_external mty -> tree_of_modtype mty
in
Osig_modtype (Ident.name id, mty)
diff -Naur ocaml-3.09.2/typing/subst.ml ocaml-3.09.2-patched/typing/subst.ml
--- ocaml-3.09.2/typing/subst.ml 2005-12-05 15:18:43.000000000 +0200
+++ ocaml-3.09.2-patched/typing/subst.ml 2006-07-06 21:39:51.000000000 +0300
@@ -295,3 +295,4 @@
and modtype_declaration s = function
Tmodtype_abstract -> Tmodtype_abstract
| Tmodtype_manifest mty -> Tmodtype_manifest(modtype s mty)
+ | Tmodtype_external mty -> Tmodtype_external (modtype s mty)
diff -Naur ocaml-3.09.2/typing/typemod.ml ocaml-3.09.2-patched/typing/typemod.ml
--- ocaml-3.09.2/typing/typemod.ml 2005-08-08 12:41:51.000000000 +0300
+++ ocaml-3.09.2-patched/typing/typemod.ml 2006-08-30 22:10:54.000000000 +0300
@@ -31,6 +31,8 @@
| Signature_expected
| Structure_expected of module_type
| With_no_component of Longident.t
+ | Field_not_found of string * string * string
+ | Inconsistent_modtype of string
| With_mismatch of Longident.t * Includemod.error list
| Repeated_name of string * string
| Non_generalizable of type_expr
@@ -167,8 +169,10 @@
let (id, newenv) = Env.enter_module param arg env in
let res = approx_mty newenv sres in
Tmty_functor(id, arg, res)
- | Pmty_with(sbody, constraints) ->
- approx_mty env sbody
+ | Pmty_with(sbody, _)
+ | Pmty_without(sbody, _)
+ | Pmty_using(sbody, _) ->
+ approx_mty env sbody
and approx_sig env ssg =
match ssg with
@@ -263,14 +267,80 @@
check "module type" loc modtype_names (Ident.name id)
| _ -> ()
+let error_constr kind constr loc =
+ let (ftype, id) =
+ match constr with
+ Pfield_val str -> ("value", str)
+ | Pfield_type str -> ("type", str)
+ | Pfield_exception str -> ("exception", str)
+ | Pfield_module str -> ("module", str)
+ | Pfield_module_type str -> ("module type", str)
+ | Pfield_class str -> ("class", str)
+ | Pfield_class_type str -> ("class type", str)
+ in raise(Error(loc, Field_not_found(kind, ftype, id)))
+
+let filter_sig_field constr sig_field =
+ match (sig_field, constr) with
+ (Tsig_value(id, _), Pfield_val str)
+ | (Tsig_type(id, _, _), Pfield_type str)
+ | (Tsig_exception(id, _), Pfield_exception str)
+ | (Tsig_module(id, _, _), Pfield_module str)
+ | (Tsig_modtype(id, _), Pfield_module_type str)
+ | (Tsig_class (id, _, _), Pfield_class str)
+ | (Tsig_cltype (id, _, _), Pfield_class_type str) ->
+ not (Ident.name id = str)
+ | _ -> true
+
+let do_without loc (sg, rem) constr =
+ let (res, removed) = List.partition (filter_sig_field constr) sg in
+ if removed = [] then error_constr "without" constr loc
+ else (res, removed @ rem)
+
+let do_using loc (used, sg) constr =
+ let (left, use) = List.partition (filter_sig_field constr) sg in
+ if use = [] then error_constr "using" constr loc
+ else (use @ used, left)
+
+
+let sig_item_id = function
+ Tsig_value (id, _)
+ | Tsig_type (id, _, _)
+ | Tsig_exception (id, _)
+ | Tsig_module (id, _, _)
+ | Tsig_modtype (id, _)
+ | Tsig_class (id, _, _)
+ | Tsig_cltype (id, _, _) -> id
+
+let do_nondep env loc mod_type sig_item =
+ let id = sig_item_id sig_item in
+ try
+ Mtype.nondep_supertype env id mod_type
+ with Not_found ->
+ raise(Error(loc, Inconsistent_modtype (Ident.name id)))
+
+let filter_sig_using sg usings env loc =
+ let (result, removed) = List.fold_left (do_using loc) ([], sg) usings in
+ let result = List.fold_left (do_nondep env loc) (Tmty_signature result) removed
+ in
+ result
+
+let filter_sig_without sg withouts env loc =
+ let (result, removed) = List.fold_left (do_without loc) (sg, []) withouts in
+ let result = List.fold_left (do_nondep env loc) (Tmty_signature result) removed
+ in
+ result
+
(* Check and translate a module type expression *)
let rec transl_modtype env smty =
match smty.pmty_desc with
Pmty_ident lid ->
begin try
- let (path, info) = Env.lookup_modtype lid env in
- Tmty_ident path
+ let (path, info) = Env.lookup_modtype lid env in begin
+ match info with
+ Tmodtype_external s -> s
+ | _ -> Tmty_ident path
+ end
with Not_found ->
raise(Error(smty.pmty_loc, Unbound_modtype lid))
end
@@ -290,6 +360,16 @@
merge_constraint env smty.pmty_loc sg lid sdecl)
init_sg constraints in
Mtype.freshen (Tmty_signature final_sg)
+ | Pmty_without(sbody, withouts) ->
+ let body = transl_modtype env sbody in
+ let init_sg = extract_sig env sbody.pmty_loc body in
+ let final_sg = filter_sig_without init_sg withouts env smty.pmty_loc in
+ Mtype.freshen final_sg
+ | Pmty_using(sbody, usings) ->
+ let body = transl_modtype env sbody in
+ let init_sg = extract_sig env sbody.pmty_loc body in
+ let final_sg = filter_sig_using init_sg usings env smty.pmty_loc in
+ Mtype.freshen final_sg
and transl_signature env sg =
let type_names = ref StringSet.empty
@@ -813,16 +893,26 @@
(* "Packaging" of several compilation units into one unit
having them as sub-modules. *)
-let rec package_signatures subst = function
- [] -> []
- | (name, sg) :: rem ->
- let sg' = Subst.signature subst sg in
- let oldid = Ident.create_persistent name
- and newid = Ident.create name in
- Tsig_module(newid, Tmty_signature sg', Trec_not) ::
- package_signatures (Subst.add_module oldid (Pident newid) subst) rem
+let package_signatures subst exports units =
+ let (sg, _, rest) = List.fold_left (fun (sigs, subst, rest) (name, sg) ->
+ let oldid = Ident.create_persistent name
+ and newid = Ident.create name in
+ let new_subst = Subst.add_module oldid (Pident newid) subst in
+ if exports == [] || List.mem name exports then
+ let sg' = Subst.signature subst sg in
+ (Tsig_module(newid, Tmty_signature sg', Trec_not) :: sigs,
+ new_subst, rest)
+ else (sigs, new_subst, newid :: rest))
+ ([], Subst.identity, []) units
+ in (List.rev sg, rest)
+
+let check_consistency sg rest =
+ List.iter (fun id -> try
+ let _ = Mtype.nondep_supertype Env.empty id (Tmty_signature sg) in ()
+ with Not_found ->
+ raise(Error(Location.none, Inconsistent_modtype (Ident.name id)))) rest
-let package_units objfiles cmifile modulename =
+let package_units objfiles cmifile modulename exports =
(* Read the signatures of the units *)
let units =
List.map
@@ -837,7 +927,7 @@
objfiles in
(* Compute signature of packaged unit *)
Ident.reinit();
- let sg = package_signatures Subst.identity units in
+ let (sg_base, _) = package_signatures Subst.identity [] units in
(* See if explicit interface is provided *)
let mlifile =
chop_extension_if_any cmifile ^ !Config.interface_suffix in
@@ -846,8 +936,10 @@
raise(Error(Location.in_file mlifile, Interface_not_compiled mlifile))
end;
let dclsig = Env.read_signature modulename cmifile in
- Includemod.compunit "(obtained by packing)" sg mlifile dclsig
+ Includemod.compunit "(obtained by packing)" sg_base mlifile dclsig
end else begin
+ let (sg, rest) = package_signatures Subst.identity exports units in
+ check_consistency sg rest;
(* Determine imports *)
let unit_names = List.map fst units in
let imports =
@@ -856,9 +948,28 @@
(Env.imported_units()) in
(* Write packaged signature *)
Env.save_signature_with_imports sg modulename cmifile imports;
- Tcoerce_none
+ Includemod.compunit "(obtained by packing)" sg_base mlifile sg
end
+let retype_unit objfile cmifile modulename =
+ let pref = chop_extension_if_any objfile in
+ let modname = String.capitalize(Filename.basename pref) in
+ let sg = Env.read_signature_no_cache modname (pref ^ ".cmi") in
+ if Filename.check_suffix objfile ".cmi" then
+ raise(Error(Location.none, Implementation_is_required objfile));
+ let mlifile =
+ chop_extension_if_any cmifile ^ !Config.interface_suffix in
+ if Sys.file_exists cmifile then begin
+ let dclsig = Env.read_signature modulename cmifile in
+ let coercion = Includemod.compunit "(obtained by retyping)" sg mlifile dclsig
+ in coercion
+ end else begin
+ if Sys.file_exists mlifile then begin
+ raise(Error(Location.in_file mlifile, Interface_not_compiled mlifile))
+ end;
+ raise(Error(Location.none, Signature_expected))
+ end
+
(* Error report *)
open Printtyp
@@ -893,6 +1004,13 @@
in the constrained signature:@]@ \
%a@]"
longident lid Includemod.report_error explanation
+ | Field_not_found(kind, field, id) ->
+ fprintf ppf
+ "@[The signature constrained with `%s' has no %s named %s@]" kind field id
+ | Inconsistent_modtype str ->
+ fprintf ppf
+ "@[The constrained signature is inconsistent: `%s' \
+ referenced but not defined @]" str
| Repeated_name(kind, name) ->
fprintf ppf
"@[Multiple definition of the %s name %s.@ \
diff -Naur ocaml-3.09.2/typing/typemod.mli ocaml-3.09.2-patched/typing/typemod.mli
--- ocaml-3.09.2/typing/typemod.mli 2005-08-08 12:41:52.000000000 +0300
+++ ocaml-3.09.2-patched/typing/typemod.mli 2006-07-20 00:22:44.000000000 +0300
@@ -32,7 +32,11 @@
val simplify_signature: signature -> signature
val package_units:
- string list -> string -> string -> Typedtree.module_coercion
+ string list -> string -> string -> string list -> Typedtree.module_coercion
+
+val retype_unit:
+ string -> string -> string -> Typedtree.module_coercion
+
type error =
Unbound_module of Longident.t
@@ -43,6 +47,8 @@
| Signature_expected
| Structure_expected of module_type
| With_no_component of Longident.t
+ | Field_not_found of string * string * string
+ | Inconsistent_modtype of string
| With_mismatch of Longident.t * Includemod.error list
| Repeated_name of string * string
| Non_generalizable of type_expr
diff -Naur ocaml-3.09.2/typing/types.ml ocaml-3.09.2-patched/typing/types.ml
--- ocaml-3.09.2/typing/types.ml 2004-12-09 14:40:53.000000000 +0200
+++ ocaml-3.09.2-patched/typing/types.ml 2006-07-06 21:40:34.000000000 +0300
@@ -194,6 +194,7 @@
and modtype_declaration =
Tmodtype_abstract
| Tmodtype_manifest of module_type
+ | Tmodtype_external of module_type
and rec_status =
Trec_not
diff -Naur ocaml-3.09.2/typing/types.mli ocaml-3.09.2-patched/typing/types.mli
--- ocaml-3.09.2/typing/types.mli 2004-12-09 14:40:53.000000000 +0200
+++ ocaml-3.09.2-patched/typing/types.mli 2006-07-06 21:40:38.000000000 +0300
@@ -196,6 +196,7 @@
and modtype_declaration =
Tmodtype_abstract
| Tmodtype_manifest of module_type
+ | Tmodtype_external of module_type
and rec_status =
Trec_not (* not recursive *)
diff -Naur ocaml-3.09.2/utils/clflags.ml ocaml-3.09.2-patched/utils/clflags.ml
--- ocaml-3.09.2/utils/clflags.ml 2005-08-01 18:51:09.000000000 +0300
+++ ocaml-3.09.2-patched/utils/clflags.ml 2006-07-10 13:26:16.000000000 +0300
@@ -52,6 +52,8 @@
and dllpaths = ref ([] : string list) (* -dllpath *)
and make_package = ref false (* -pack *)
and for_package = ref (None: string option) (* -for-pack *)
+and export = ref ([] : string list) (* -export *)
+and retype = ref false (* -retype *)
let dump_parsetree = ref false (* -dparsetree *)
and dump_rawlambda = ref false (* -drawlambda *)
and dump_lambda = ref false (* -dlambda *)
diff -Naur ocaml-3.09.2/utils/clflags.mli ocaml-3.09.2-patched/utils/clflags.mli
--- ocaml-3.09.2/utils/clflags.mli 2005-10-26 16:23:27.000000000 +0300
+++ ocaml-3.09.2-patched/utils/clflags.mli 2006-07-10 13:25:40.000000000 +0300
@@ -48,7 +48,9 @@
val no_auto_link : bool ref
val dllpaths : string list ref
val make_package : bool ref
+val export : string list ref
val for_package : string option ref
+val retype : bool ref
val dump_parsetree : bool ref
val dump_rawlambda : bool ref
val dump_lambda : bool ref