diff options
Diffstat (limited to 'driver/compile.ml')
-rw-r--r-- | driver/compile.ml | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/driver/compile.ml b/driver/compile.ml index bc9201e26..3b5d2ae07 100644 --- a/driver/compile.ml +++ b/driver/compile.ml @@ -21,17 +21,17 @@ open Compenv (* Keep in sync with the copy in optcompile.ml *) +let tool_name = "ocamlc" + let interface ppf sourcefile outputprefix = Compmisc.init_path false; - let modulename = - String.capitalize(Filename.basename(chop_extension_if_any sourcefile)) in - check_unit_name ppf sourcefile modulename; + let modulename = module_of_filename ppf sourcefile outputprefix in Env.set_unit_name modulename; let initial_env = Compmisc.initial_env () in - let ast = Pparse.parse_interface ppf sourcefile in + let ast = Pparse.parse_interface ~tool_name ppf sourcefile in if !Clflags.dump_parsetree then fprintf ppf "%a@." Printast.interface ast; if !Clflags.dump_source then fprintf ppf "%a@." Pprintast.signature ast; - let tsg = Typemod.transl_signature initial_env ast in + let tsg = Typemod.type_interface initial_env ast in if !Clflags.dump_typedtree then fprintf ppf "%a@." Printtyped.interface tsg; let sg = tsg.sig_type in if !Clflags.print_types then @@ -57,9 +57,7 @@ let (++) x f = f x let implementation ppf sourcefile outputprefix = Compmisc.init_path false; - let modulename = - String.capitalize(Filename.basename(chop_extension_if_any sourcefile)) in - check_unit_name ppf sourcefile modulename; + let modulename = module_of_filename ppf sourcefile outputprefix in Env.set_unit_name modulename; let env = Compmisc.initial_env() in if !Clflags.print_types then begin @@ -74,7 +72,7 @@ let implementation ppf sourcefile outputprefix = Warnings.check_fatal (); Stypes.dump (Some (outputprefix ^ ".annot")) in - try comp (Pparse.parse_implementation ppf sourcefile) + try comp (Pparse.parse_implementation ~tool_name ppf sourcefile) with x -> Stypes.dump (Some (outputprefix ^ ".annot")); raise x @@ -94,12 +92,12 @@ let implementation ppf sourcefile outputprefix = ++ print_if ppf Clflags.dump_lambda Printlambda.lambda ++ Bytegen.compile_implementation modulename ++ print_if ppf Clflags.dump_instr Printinstr.instrlist - ++ Emitcode.to_file oc modulename; + ++ Emitcode.to_file oc modulename objfile; Warnings.check_fatal (); close_out oc; Stypes.dump (Some (outputprefix ^ ".annot")) in - try comp (Pparse.parse_implementation ppf sourcefile) + try comp (Pparse.parse_implementation ~tool_name ppf sourcefile) with x -> close_out oc; remove_file objfile; |