diff --git a/compiler/analysis.file.m b/compiler/analysis.file.m index 7d812fabe..bc62c7b0e 100644 --- a/compiler/analysis.file.m +++ b/compiler/analysis.file.m @@ -177,22 +177,6 @@ version_number = 6. -:- func analysis_registry_ext = other_ext. - -analysis_registry_ext = other_ext(".analysis"). - -:- func analysis_registry_status_ext = other_ext. - -analysis_registry_status_ext = other_ext(".analysis_status"). - -:- func imdg_ext = other_ext. - -imdg_ext = other_ext(".imdg"). - -:- func request_ext = other_ext. - -request_ext = other_ext(".request"). - %---------------------------------------------------------------------------% :- pred analysis_status_to_string(analysis_status, string). @@ -215,8 +199,7 @@ analysis_status_to_string(optimal, "optimal"). read_module_overall_status(Compiler, Globals, ModuleName, ModuleStatus, !IO) :- module_name_to_read_file_name(Compiler, Globals, - analysis_registry_status_ext, newext_analysis(ext_an_status), - ModuleName, MaybeFileName, !IO), + newext_analysis(ext_an_status), ModuleName, MaybeFileName, !IO), ( MaybeFileName = ok(FileName), read_module_overall_status_2(FileName, ModuleStatus0, !IO) @@ -229,7 +212,7 @@ read_module_overall_status(Compiler, Globals, ModuleName, ModuleStatus, !IO) :- ( ModuleStatus0 = optimal, module_name_to_read_file_name(Compiler, Globals, - request_ext, newext_analysis(ext_an_request), + newext_analysis(ext_an_request), ModuleName, MaybeRequestFileName, !IO), ( % There are outstanding requests for this module. @@ -287,8 +270,7 @@ read_module_overall_status_2(FileName, ModuleStatus, !IO) :- write_module_overall_status(Info, Globals, ModuleName, Status, !IO) :- module_name_to_write_file_name(Info ^ compiler, Globals, - analysis_registry_status_ext, newext_analysis(ext_an_status), - ModuleName, FileName, !IO), + newext_analysis(ext_an_status), ModuleName, FileName, !IO), io.open_output(FileName, OpenResult, !IO), ( OpenResult = ok(Stream), @@ -320,7 +302,7 @@ read_module_analysis_results(Info, Globals, ModuleName, ModuleResults, % as we want to know which results change after we reanalyse the module. Compiler = Info ^ compiler, module_name_to_read_file_name(Compiler, Globals, - analysis_registry_ext, newext_analysis(ext_an_analysis), + newext_analysis(ext_an_analysis), ModuleName, MaybeAnalysisFileName, !IO), ( MaybeAnalysisFileName = ok(AnalysisFileName), @@ -482,8 +464,7 @@ write_module_analysis_results(Info, Globals, ModuleName, ModuleResults, !IO) :- [s(sym_name_to_string(ModuleName))], !IO) ), find_and_write_analysis_file(Info ^ compiler, Globals, - add_dot_temp, write_result_entry, - analysis_registry_ext, newext_analysis(ext_an_analysis), + add_dot_temp, write_result_entry, newext_analysis(ext_an_analysis), ModuleName, ModuleResults, FileName, !IO), update_interface_return_changed(Globals, ModuleName, FileName, UpdateResult, !IO), @@ -528,7 +509,7 @@ read_module_analysis_requests(Info, Globals, ModuleName, ModuleRequests, !Specs, !IO) :- find_and_read_analysis_file(Info ^ compiler, Globals, parse_request_entry(Info ^ compiler), - request_ext, newext_analysis(ext_an_request), ModuleName, + newext_analysis(ext_an_request), ModuleName, map.init, ModuleRequests, !Specs, !IO). :- pred parse_request_entry(Compiler::in, varset::in, term::in, @@ -584,8 +565,7 @@ write_module_analysis_requests(Info, Globals, ModuleName, ModuleRequests, !IO) :- Compiler = Info ^ compiler, module_name_to_write_file_name(Compiler, Globals, - request_ext, newext_analysis(ext_an_request), - ModuleName, AnalysisFileName, !IO), + newext_analysis(ext_an_request), ModuleName, AnalysisFileName, !IO), get_debug_analysis_stream(MaybeDebugStream, !IO), ( MaybeDebugStream = no @@ -666,9 +646,8 @@ write_request_entry(Compiler, OutStream, AnalysisName, FuncId, Request, !IO) :- read_module_imdg(Info, Globals, ModuleName, ModuleEntries, Specs, !IO) :- find_and_read_analysis_file(Info ^ compiler, Globals, - parse_imdg_arc(Info ^ compiler), - imdg_ext, newext_analysis(ext_an_imdg), ModuleName, - map.init, ModuleEntries, [], Specs, !IO). + parse_imdg_arc(Info ^ compiler), newext_analysis(ext_an_imdg), + ModuleName, map.init, ModuleEntries, [], Specs, !IO). :- pred parse_imdg_arc(Compiler::in, varset::in, term::in, module_analysis_map(imdg_arc)::in, module_analysis_map(imdg_arc)::out, @@ -723,7 +702,7 @@ parse_imdg_arc(Compiler, VarSet, Term, !Arcs, !Specs) :- write_module_imdg(Info, Globals, ModuleName, ModuleEntries, !IO) :- find_and_write_analysis_file(Info ^ compiler, Globals, do_not_add_dot_temp, write_imdg_arc(Info ^ compiler), - imdg_ext, newext_analysis(ext_an_imdg), ModuleName, + newext_analysis(ext_an_imdg), ModuleName, ModuleEntries, _FileName, !IO). :- pred write_imdg_arc(Compiler::in, io.text_output_stream::in, @@ -780,15 +759,14 @@ try_parse_module_name(Term, ModuleName) :- %---------------------% :- pred find_and_read_analysis_file(Compiler::in, globals::in, - parse_entry(T)::in(parse_entry), other_ext::in, newext::in, - module_name::in, T::in, T::out, - list(error_spec)::in, list(error_spec)::out, + parse_entry(T)::in(parse_entry), newext::in, module_name::in, + T::in, T::out, list(error_spec)::in, list(error_spec)::out, io::di, io::uo) is det <= compiler(Compiler). find_and_read_analysis_file(Compiler, Globals, ParseEntry, - OtherExt, NewExt, ModuleName, !ModuleResults, !Specs, !IO) :- + NewExt, ModuleName, !ModuleResults, !Specs, !IO) :- module_name_to_read_file_name(Compiler, Globals, - OtherExt, NewExt, ModuleName, MaybeAnalysisFileName, !IO), + NewExt, ModuleName, MaybeAnalysisFileName, !IO), ( MaybeAnalysisFileName = ok(AnalysisFileName), read_analysis_file(AnalysisFileName, ParseEntry, @@ -800,10 +778,9 @@ find_and_read_analysis_file(Compiler, Globals, ParseEntry, MaybeDebugStream = no ; MaybeDebugStream = yes(DebugStream), - OtherExtStr = extension_to_string(Globals, - ext_other(OtherExt), NewExt), + ExtStr = extension_to_string(Globals, NewExt), io.format(DebugStream, "Couldn't find %s file for module %s: %s\n", - [s(OtherExtStr), s(sym_name_to_string(ModuleName)), + [s(ExtStr), s(sym_name_to_string(ModuleName)), s(Message)], !IO) ) % XXX Why is not being able to find a file *less* fatal than @@ -943,13 +920,13 @@ func_id_to_string(FuncId) = String :- :- pred find_and_write_analysis_file(Compiler::in, globals::in, maybe_add_dot_temp::in, write_entry(T)::in(write_entry), - other_ext::in, newext::in, module_name::in, + newext::in, module_name::in, module_analysis_map(T)::in, string::out, io::di, io::uo) is det <= compiler(Compiler). find_and_write_analysis_file(Compiler, Globals, ToTmp, WriteEntry, - OtherExt, NewExt, ModuleName, ModuleResults, FileName, !IO) :- - module_name_to_write_file_name(Compiler, Globals, OtherExt, NewExt, + NewExt, ModuleName, ModuleResults, FileName, !IO) :- + module_name_to_write_file_name(Compiler, Globals, NewExt, ModuleName, FileName, !IO), ( ToTmp = add_dot_temp, @@ -1011,8 +988,7 @@ write_module_analysis_func(OutStream, WriteEntry, AnalysisName, FuncId, empty_request_file(Info, Globals, ModuleName, !IO) :- module_name_to_write_file_name(Info ^ compiler, Globals, - request_ext, newext_analysis(ext_an_request), - ModuleName, RequestFileName, !IO), + newext_analysis(ext_an_request), ModuleName, RequestFileName, !IO), get_debug_analysis_stream(MaybeDebugStream, !IO), ( MaybeDebugStream = no diff --git a/compiler/analysis.m b/compiler/analysis.m index bd7d732b4..d10d8e969 100644 --- a/compiler/analysis.m +++ b/compiler/analysis.m @@ -60,15 +60,14 @@ % ModuleName, MaybeFileName, !IO) % pred module_name_to_read_file_name(Compiler::in, globals::in, - other_ext::in, newext::in, module_name::in, maybe_error(string)::out, + newext::in, module_name::in, maybe_error(string)::out, io::di, io::uo) is det, % module_name_to_write_file_name(Compiler, Globals, Ext, % ModuleName, FileName, !IO) % pred module_name_to_write_file_name(Compiler::in, globals::in, - other_ext::in, newext::in, module_name::in, string::out, - io::di, io::uo) is det + newext::in, module_name::in, string::out, io::di, io::uo) is det ]. :- type analysis_name == string. @@ -1403,8 +1402,7 @@ write_analysis_files(Compiler, ModuleInfo, ImportedModules0, % Touch a timestamp file to indicate the last time that this module was % analysed. module_name_to_write_file_name(Compiler, Globals, - other_ext(".analysis_date"), newext_analysis(ext_an_date), - ThisModule, TimestampFileName, !IO), + newext_analysis(ext_an_date), ThisModule, TimestampFileName, !IO), get_progress_output_stream(ModuleInfo, ProgressStream, !IO), get_error_output_stream(ModuleInfo, ErrorStream, !IO), touch_datestamp(Globals, ProgressStream, ErrorStream, diff --git a/compiler/compile_target_code.m b/compiler/compile_target_code.m index 80a95ebdc..d69675fde 100644 --- a/compiler/compile_target_code.m +++ b/compiler/compile_target_code.m @@ -167,24 +167,22 @@ %-----------------------------------------------------------------------------% - % maybe_pic_object_file_extension(Globals, PIC, OtherExt, - % NewExtObj, NewExtInitObj): + % maybe_pic_object_file_extension(PIC, ExtObj, ExtInitObj): % - % OtherExt is the old-style extension and NewExtObj is the new-style - % extension which should be used on object files according to the value - % of PIC. The value of PIC should be obtained from a call to - % `get_object_code_type'. In particular, on architectures for which - % no special handling for PIC is necessary, only a value of `non_pic' - % should be used. + % ExtObj is the extension which should be used on object files + % according to the value of PIC. The value of PIC should be obtained + % from a call to `get_object_code_type'. In particular, on architectures + % for which no special handling for PIC is necessary, only a value of + % `non_pic' should be used. % - % The value of NewExtInitObj will specify the new-style extension - % of _init's object file, whose "pic-ness' is handled + % The value of ExtInitObj will specify the extension of + % _init's object file, whose "pic-ness' is handled % the same way as the other extensions we return. % -:- pred maybe_pic_object_file_extension(globals::in, pic::in, - other_ext::out, ext_obj::out, ext_init_obj::out) is det. +:- pred maybe_pic_object_file_extension(pic::in, + ext_obj::out, ext_init_obj::out) is det. - % This predicate is the converse of pic_object_file_extension. + % This predicate is sort-of the converse of pic_object_file_extension. % It tests whether the given extension string is an object file extension % or not, and if it is, it tells you whether such object files are % PIC or not. @@ -268,12 +266,10 @@ compile_c_file(Globals, ProgressStream, ErrorStream, PIC, ModuleName, Succeeded, !IO) :- module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".c")), newext_target_c_cs(ext_target_c), - ModuleName, C_File, !IO), - maybe_pic_object_file_extension(Globals, PIC, ObjOtherExt, NewExtObj, _), + newext_target_c_cs(ext_target_c), ModuleName, C_File, !IO), + maybe_pic_object_file_extension(PIC, NewExtObj, _), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(ObjOtherExt), newext_target_obj(NewExtObj), - ModuleName, O_File, !IO), + newext_target_obj(NewExtObj), ModuleName, O_File, !IO), do_compile_c_file(Globals, ProgressStream, ErrorStream, PIC, C_File, O_File, Succeeded, !IO). @@ -1056,7 +1052,6 @@ compile_csharp_file(Globals, ProgressStream, ErrorStream, ModuleAndImports, list.map_foldl( ( pred(Mod::in, Result::out, IO0::di, IO::uo) is det :- module_name_to_file_name(Globals, $pred, do_not_create_dirs, - ext_other(other_ext(".dll")), newext_lib_gs(ext_lib_gs_dll), Mod, FileName, IO0, IO), Result = [Prefix, FileName, " "] ), set.to_sorted_list(ReferencedDlls), ReferencedDllsList, !IO), @@ -1107,15 +1102,14 @@ make_library_init_file(Globals, ProgressStream, ErrorStream, MainModuleName, AllModules, Succeeded, !IO) :- globals.lookup_string_option(Globals, mkinit_command, MkInit), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".init")), newext_lib_gs(ext_lib_gs_init), - MainModuleName, InitFileName, !IO), + newext_lib_gs(ext_lib_gs_init), MainModuleName, InitFileName, !IO), TmpInitFileName = InitFileName ++ ".tmp", io.open_output(TmpInitFileName, InitFileRes, !IO), ( InitFileRes = ok(InitFileStream), list.map_foldl( module_name_to_file_name(Globals, $pred, do_not_create_dirs, - ext_other(other_ext(".c")), newext_target_c_cs(ext_target_c)), + newext_target_c_cs(ext_target_c)), AllModules, AllTargetFilesList, !IO), invoke_mkinit(Globals, ProgressStream, ErrorStream, InitFileStream, cmd_verbose_commands, MkInit, " -k ", AllTargetFilesList, @@ -1157,8 +1151,7 @@ make_library_init_file(Globals, ProgressStream, ErrorStream, globals.set_option(use_grade_subdirs, bool(no), NoSubdirGlobals0, NoSubdirGlobals), module_name_to_file_name(NoSubdirGlobals, $pred, - do_not_create_dirs, ext_other(other_ext(".init")), - newext_lib_gs(ext_lib_gs_init), + do_not_create_dirs, newext_lib_gs(ext_lib_gs_init), MainModuleName, UserDirFileName, !IO), % Remove the target of the symlink/copy in case it already % exists. @@ -1263,20 +1256,15 @@ do_make_init_obj_file(Globals, ProgressStream, ErrorStream, MustCompile, globals.lookup_string_option(Globals, mkinit_command, MkInit), make_init_target_file(Globals, ProgressStream, ErrorStream, MkInit, ModuleName, ModuleNames, - other_ext(".c"), newext_target_c_cs(ext_target_c), - other_ext("_init.c"), newext_target_init_c(ext_init_c), + newext_target_c_cs(ext_target_c), newext_target_init_c(ext_init_c), StdInitFileNames, StdTraceInitFileNames, SourceDebugInitFileNames, MaybeInitTargetFile, !IO), get_object_code_type(Globals, executable, PIC), - maybe_pic_object_file_extension(Globals, PIC, ObjOtherExt, - _, NewExtInitObj), + maybe_pic_object_file_extension(PIC, _, NewExtInitObj), - % XXX EXT - ObjOtherExt = other_ext(ObjExtStr), - InitObjOtherExt = other_ext("_init" ++ ObjExtStr), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(InitObjOtherExt), newext_target_init_obj(NewExtInitObj), + newext_target_init_obj(NewExtInitObj), ModuleName, InitObjFileName, !IO), CompileCInitFile = ( pred(InitTargetFileName::in, Res::out, IO0::di, IO::uo) is det :- @@ -1288,15 +1276,12 @@ do_make_init_obj_file(Globals, ProgressStream, ErrorStream, MustCompile, :- pred make_init_target_file(globals::in, io.text_output_stream::in, io.text_output_stream::in, - string::in, module_name::in, list(module_name)::in, - other_ext::in, newext::in, other_ext::in, newext::in, + string::in, module_name::in, list(module_name)::in, newext::in, newext::in, list(file_name)::in, list(file_name)::in, list(file_name)::in, maybe(file_name)::out, io::di, io::uo) is det. make_init_target_file(Globals, ProgressStream, ErrorStream, MkInit, - ModuleName, ModuleNames, - TargetOtherExt, TargetOtherNewExt, - InitTargetOtherExt, InitTargetOtherNewExt, + ModuleName, ModuleNames, TargetOtherNewExt, InitTargetOtherNewExt, StdInitFileNames, StdTraceInitFileNames, SourceDebugInitFileNames, MaybeInitTargetFile, !IO) :- globals.lookup_bool_option(Globals, verbose, Verbose), @@ -1307,12 +1292,11 @@ make_init_target_file(Globals, ProgressStream, ErrorStream, MkInit, compute_grade(Globals, Grade), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(InitTargetOtherExt), InitTargetOtherNewExt, - ModuleName, InitTargetFileName, !IO), + InitTargetOtherNewExt, ModuleName, InitTargetFileName, !IO), list.map_foldl( module_name_to_file_name(Globals, $pred, do_not_create_dirs, - ext_other(TargetOtherExt), TargetOtherNewExt), + TargetOtherNewExt), ModuleNames, TargetFileNameList, !IO), globals.lookup_accumulating_option(Globals, init_file_directories, @@ -1534,10 +1518,9 @@ link_module_list(ProgressStream, ErrorStream, Modules, ExtraObjFiles, TargetType = executable ), get_object_code_type(Globals, TargetType, PIC), - maybe_pic_object_file_extension(Globals, PIC, ObjOtherExt, ObjNewExt, _), + maybe_pic_object_file_extension(PIC, ObjNewExt, _), - join_module_list(Globals, - ext_other(ObjOtherExt), newext_target_obj(ObjNewExt), + join_module_list(Globals, newext_target_obj(ObjNewExt), Modules, ObjectsList, !IO), ( TargetType = executable, @@ -1581,7 +1564,7 @@ link(Globals, ProgressStream, ErrorStream, LinkTargetType, globals.lookup_bool_option(Globals, statistics, Stats), maybe_write_string(ProgressStream, Verbose, "% Linking...\n", !IO), - link_output_filename(Globals, LinkTargetType, ModuleName, _Ext, _NewExt, + link_output_filename(Globals, LinkTargetType, ModuleName, _NewExt, OutputFileName, !IO), ( LinkTargetType = executable, @@ -1624,74 +1607,59 @@ link(Globals, ProgressStream, ErrorStream, LinkTargetType, ). :- pred link_output_filename(globals::in, linked_target_type::in, - module_name::in, other_ext::out, newext::out, string::out, - io::di, io::uo) is det. + module_name::in, newext::out, string::out, io::di, io::uo) is det. -link_output_filename(Globals, LinkTargetType, ModuleName, OtherExt, NewExt, +link_output_filename(Globals, LinkTargetType, ModuleName, NewExt, OutputFileName, !IO) :- ( LinkTargetType = executable, - globals.lookup_string_option(Globals, executable_file_extension, - ExtStr), - OtherExt = other_ext(ExtStr), NewExt = newext_exec_gs(ext_exec_exec_opt), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(OtherExt), NewExt, ModuleName, OutputFileName, !IO) + NewExt, ModuleName, OutputFileName, !IO) ; LinkTargetType = static_library, - globals.lookup_string_option(Globals, library_extension, ExtStr), - OtherExt = other_ext(ExtStr), NewExt = newext_lib_gs(ext_lib_gs_lib_opt), module_name_to_lib_file_name(Globals, $pred, do_create_dirs, - "lib", OtherExt, NewExt, ModuleName, OutputFileName, !IO) + "lib", NewExt, ModuleName, OutputFileName, !IO) ; LinkTargetType = shared_library, - globals.lookup_string_option(Globals, shared_library_extension, - ExtStr), - OtherExt = other_ext(ExtStr), NewExt = newext_lib_gs(ext_lib_gs_sh_lib_opt), module_name_to_lib_file_name(Globals, $pred, do_create_dirs, - "lib", OtherExt, NewExt, ModuleName, OutputFileName, !IO) + "lib", NewExt, ModuleName, OutputFileName, !IO) ; LinkTargetType = csharp_executable, - OtherExt = other_ext(".exe"), NewExt = newext_exec(ext_exec_exe), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(OtherExt), NewExt, ModuleName, OutputFileName, !IO) + NewExt, ModuleName, OutputFileName, !IO) ; LinkTargetType = csharp_library, - OtherExt = other_ext(".dll"), NewExt = newext_lib_gs(ext_lib_gs_dll), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(OtherExt), NewExt, ModuleName, OutputFileName, !IO) + NewExt, ModuleName, OutputFileName, !IO) ; ( LinkTargetType = java_executable ; LinkTargetType = java_archive ), - OtherExt = other_ext(".jar"), NewExt = newext_lib_gs(ext_lib_gs_jar), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(OtherExt), NewExt, ModuleName, OutputFileName, !IO) + NewExt, ModuleName, OutputFileName, !IO) ). -:- pred get_launcher_script_extension(globals::in, - other_ext::out, newext::out) is det. +:- pred get_launcher_script_extension(globals::in, newext::out) is det. -get_launcher_script_extension(Globals, OtherExt, NewExt) :- +get_launcher_script_extension(Globals, NewExt) :- globals.get_target_env_type(Globals, TargetEnvType), ( % XXX we should actually generate a .ps1 file for PowerShell. ( TargetEnvType = env_type_win_cmd ; TargetEnvType = env_type_powershell ), - OtherExt = other_ext(".bat"), NewExt = newext_exec_gs(ext_exec_gs_bat) ; ( TargetEnvType = env_type_posix ; TargetEnvType = env_type_cygwin ; TargetEnvType = env_type_msys ), - OtherExt = other_ext(""), NewExt = newext_exec_gs(ext_exec_gs_noext) ). @@ -2012,9 +1980,6 @@ get_mercury_std_libs(Globals, TargetType, StdLibs) :- ; TargetType = static_library ; TargetType = shared_library ), - globals.lookup_string_option(Globals, library_extension, - LibExtStr), - LibOtherExt = other_ext(LibExtStr), LibNewExt = newext_lib_gs(ext_lib_gs_lib_opt), globals.lookup_string_option(Globals, mercury_linkage, MercuryOrCsharpLinkage) @@ -2022,7 +1987,6 @@ get_mercury_std_libs(Globals, TargetType, StdLibs) :- ( TargetType = csharp_executable ; TargetType = csharp_library ), - LibOtherExt = other_ext(".dll"), LibNewExt = newext_lib_gs(ext_lib_gs_dll), MercuryOrCsharpLinkage = "csharp" ; @@ -2083,7 +2047,7 @@ get_mercury_std_libs(Globals, TargetType, StdLibs) :- GCGrade = GCGrade2 ), link_lib_args(Globals, TargetType, StdLibDir, "", - LibOtherExt, LibNewExt, GCGrade, StaticGCLibs, SharedGCLibs) + LibNewExt, GCGrade, StaticGCLibs, SharedGCLibs) ; GCMethod = gc_accurate, StaticGCLibs = "", @@ -2100,16 +2064,13 @@ get_mercury_std_libs(Globals, TargetType, StdLibs) :- ; TraceEnabled = exec_trace_is_enabled, link_lib_args(Globals, TargetType, StdLibDir, GradeDir, - LibOtherExt, LibNewExt, "mer_trace", StaticTraceLib, TraceLib), + LibNewExt, "mer_trace", StaticTraceLib, TraceLib), link_lib_args(Globals, TargetType, StdLibDir, GradeDir, - LibOtherExt, LibNewExt, "mer_eventspec", - StaticEventSpecLib, EventSpecLib), + LibNewExt, "mer_eventspec", StaticEventSpecLib, EventSpecLib), link_lib_args(Globals, TargetType, StdLibDir, GradeDir, - LibOtherExt, LibNewExt, "mer_browser", - StaticBrowserLib, BrowserLib), + LibNewExt, "mer_browser", StaticBrowserLib, BrowserLib), link_lib_args(Globals, TargetType, StdLibDir, GradeDir, - LibOtherExt, LibNewExt, "mer_mdbcomp", - StaticMdbCompLib, MdbCompLib), + LibNewExt, "mer_mdbcomp", StaticMdbCompLib, MdbCompLib), StaticTraceLibs = string.join_list(" ", [StaticTraceLib, StaticEventSpecLib, StaticBrowserLib, StaticMdbCompLib]), @@ -2122,13 +2083,11 @@ get_mercury_std_libs(Globals, TargetType, StdLibs) :- ( SourceDebug = yes, link_lib_args(Globals, TargetType, StdLibDir, GradeDir, - LibOtherExt, LibNewExt, "mer_ssdb", StaticSsdbLib, SsdbLib), + LibNewExt, "mer_ssdb", StaticSsdbLib, SsdbLib), link_lib_args(Globals, TargetType, StdLibDir, GradeDir, - LibOtherExt, LibNewExt, "mer_browser", - StaticBrowserLib2, BrowserLib2), + LibNewExt, "mer_browser", StaticBrowserLib2, BrowserLib2), link_lib_args(Globals, TargetType, StdLibDir, GradeDir, - LibOtherExt, LibNewExt, "mer_mdbcomp", - StaticMdbCompLib2, MdbCompLib2), + LibNewExt, "mer_mdbcomp", StaticMdbCompLib2, MdbCompLib2), StaticSourceDebugLibs = string.join_list(" ", [StaticSsdbLib, StaticBrowserLib2, StaticMdbCompLib2]), SharedSourceDebugLibs = string.join_list(" ", @@ -2140,9 +2099,9 @@ get_mercury_std_libs(Globals, TargetType, StdLibs) :- ), link_lib_args(Globals, TargetType, StdLibDir, GradeDir, - LibOtherExt, LibNewExt, "mer_std", StaticStdLib, StdLib), + LibNewExt, "mer_std", StaticStdLib, StdLib), link_lib_args(Globals, TargetType, StdLibDir, GradeDir, - LibOtherExt, LibNewExt, "mer_rt", StaticRuntimeLib, RuntimeLib), + LibNewExt, "mer_rt", StaticRuntimeLib, RuntimeLib), ( if MercuryOrCsharpLinkage = "static" then StdLibs = string.join_list(" ", [ StaticTraceLibs, @@ -2174,10 +2133,9 @@ get_mercury_std_libs(Globals, TargetType, StdLibs) :- ). :- pred link_lib_args(globals::in, linked_target_type::in, string::in, - string::in, other_ext::in, newext::in, string::in, - string::out, string::out) is det. + string::in, newext::in, string::in, string::out, string::out) is det. -link_lib_args(Globals, TargetType, StdLibDir, GradeDir, LibOtherExt, NewExt, +link_lib_args(Globals, TargetType, StdLibDir, GradeDir, NewExt, Name, StaticArg, SharedArg) :- ( ( TargetType = executable @@ -2196,8 +2154,7 @@ link_lib_args(Globals, TargetType, StdLibDir, GradeDir, LibOtherExt, NewExt, ), unexpected($pred, string(TargetType)) ), - StaticLibName = LibPrefix ++ Name ++ - extension_to_string(Globals, ext_other(LibOtherExt), NewExt), + StaticLibName = LibPrefix ++ Name ++ extension_to_string(Globals, NewExt), StaticArg = quote_shell_cmd_arg(StdLibDir/"lib"/GradeDir/StaticLibName), make_link_lib(Globals, TargetType, Name, SharedArg). @@ -2440,7 +2397,7 @@ post_link_make_symlink_or_copy(Globals, ProgressStream, ErrorStream, ( UseGradeSubdirs = yes, link_output_filename(Globals, LinkTargetType, ModuleName, - OtherExt, NewExt, OutputFileName, !IO), + NewExt, OutputFileName, !IO), % Link/copy the executable into the user's directory. globals.set_option(use_subdirs, bool(no), Globals, NoSubdirGlobals0), @@ -2454,14 +2411,13 @@ post_link_make_symlink_or_copy(Globals, ProgressStream, ErrorStream, ; LinkTargetType = java_archive ), module_name_to_file_name(NoSubdirGlobals, $pred, - do_not_create_dirs, ext_other(OtherExt), NewExt, - ModuleName, UserDirFileName, !IO) + do_not_create_dirs, NewExt, ModuleName, UserDirFileName, !IO) ; ( LinkTargetType = static_library ; LinkTargetType = shared_library ), module_name_to_lib_file_name(NoSubdirGlobals, $pred, - do_not_create_dirs, "lib", OtherExt, NewExt, + do_not_create_dirs, "lib", NewExt, ModuleName, UserDirFileName, !IO) ), @@ -2495,13 +2451,12 @@ post_link_make_symlink_or_copy(Globals, ProgressStream, ErrorStream, LinkTargetType = java_executable ) then - get_launcher_script_extension(Globals, - ScriptOtherExt, ScriptNewExt), + get_launcher_script_extension(Globals, ScriptNewExt), module_name_to_file_name(Globals, $pred, - do_not_create_dirs, ext_other(ScriptOtherExt), ScriptNewExt, + do_not_create_dirs, ScriptNewExt, ModuleName, OutputScriptName, !IO), module_name_to_file_name(NoSubdirGlobals, $pred, - do_not_create_dirs, ext_other(ScriptOtherExt), ScriptNewExt, + do_not_create_dirs, ScriptNewExt, ModuleName, UserDirScriptName, !IO), same_timestamp(OutputScriptName, UserDirScriptName, @@ -2658,13 +2613,10 @@ process_link_library(Globals, MercuryLibDirs, LibName, LinkerOpt, % If we are linking statically with Mercury libraries, pass the % absolute pathname of the `.a' file for the library. file_name_to_module_name(LibName, LibModuleName), - globals.lookup_string_option(Globals, library_extension, LibExtStr), - globals.set_option(use_grade_subdirs, bool(no), Globals, NoSubDirGlobals), module_name_to_lib_file_name(NoSubDirGlobals, $pred, - do_not_create_dirs, "lib", - other_ext(LibExtStr), newext_lib_gs(ext_lib_gs_lib_opt), + do_not_create_dirs, "lib", newext_lib_gs(ext_lib_gs_lib_opt), LibModuleName, LibFileName, !IO), search_for_file_returning_dir(MercuryLibDirs, @@ -3082,16 +3034,16 @@ join_quoted_string_list(Strings, Prefix, Suffix, Separator, Result) :- % (This conversion ensures that we follow the usual file naming % conventions.) % -:- pred join_module_list(globals::in, ext::in, newext::in, +:- pred join_module_list(globals::in, newext::in, list(string)::in, list(string)::out, io::di, io::uo) is det. -join_module_list(_Globals, _Ext, _NewExt, [], [], !IO). -join_module_list(Globals, Ext, NewExt, +join_module_list(_Globals, _NewExt, [], [], !IO). +join_module_list(Globals, NewExt, [Module | Modules], [FileName | FileNames], !IO) :- file_name_to_module_name(dir.det_basename(Module), ModuleName), - module_name_to_file_name(Globals, $pred, do_not_create_dirs, Ext, NewExt, + module_name_to_file_name(Globals, $pred, do_not_create_dirs, NewExt, ModuleName, FileName, !IO), - join_module_list(Globals, Ext, NewExt, Modules, FileNames, !IO). + join_module_list(Globals, NewExt, Modules, FileNames, !IO). %-----------------------------------------------------------------------------% @@ -3105,27 +3057,18 @@ make_all_module_command(Command0, MainModule, AllModules, Command, !IO) :- %-----------------------------------------------------------------------------% -maybe_pic_object_file_extension(Globals, PIC, - OtherExt, NewExtObj, NewExtInitObj) :- - % The code of pic_object_file_extension and - % is_pic_object_file_extension should be kept in sync. +maybe_pic_object_file_extension(PIC, NewExtObj, NewExtInitObj) :- ( PIC = non_pic, NewExtObj = ext_obj_obj_opt, - NewExtInitObj = ext_init_obj_obj_opt, - globals.lookup_string_option(Globals, object_file_extension, ExtStr) + NewExtInitObj = ext_init_obj_obj_opt ; PIC = pic, NewExtObj = ext_obj_pic_obj_opt, - NewExtInitObj = ext_init_obj_pic_obj_opt, - globals.lookup_string_option(Globals, pic_object_file_extension, - ExtStr) - ), - OtherExt = other_ext(ExtStr). + NewExtInitObj = ext_init_obj_pic_obj_opt + ). is_maybe_pic_object_file_extension(Globals, ExtStr, PIC) :- - % The code of pic_object_file_extension and - % is_pic_object_file_extension should be kept in sync. ( if % This test must come first -- if the architecture doesn't need % special treatment for PIC, we should always return `non_pic'. @@ -3290,11 +3233,9 @@ make_standalone_int_body(Globals, ProgressStream, ErrorStream, ( MkInitCmdSucceeded = succeeded, get_object_code_type(Globals, executable, PIC), - maybe_pic_object_file_extension(Globals, PIC, ObjOtherExt, - NewExtObj, _), - Ext = ext_other(ObjOtherExt), + maybe_pic_object_file_extension(PIC, NewExtObj, _), NewExt = newext_target_obj(NewExtObj), - ObjFileName = BaseName ++ extension_to_string(Globals, Ext, NewExt), + ObjFileName = BaseName ++ extension_to_string(Globals, NewExt), do_compile_c_file(Globals, ProgressStream, ErrorStream, PIC, CFileName, ObjFileName, CompileSucceeded, !IO), ( diff --git a/compiler/du_type_layout.m b/compiler/du_type_layout.m index 405b2943c..26eb387eb 100644 --- a/compiler/du_type_layout.m +++ b/compiler/du_type_layout.m @@ -4479,7 +4479,6 @@ maybe_show_type_repns(ModuleInfo, TypeCtorsTypeDefns, !IO) :- module_info_get_name(ModuleInfo, ModuleName), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".type_repns")), newext_user_ngs(ext_user_ngs_type_repns), ModuleName, TypeRepnFileName, !IO), io.open_output(TypeRepnFileName, TypeRepnFileResult, !IO), diff --git a/compiler/export.m b/compiler/export.m index b9076c1e3..5388f9da8 100644 --- a/compiler/export.m +++ b/compiler/export.m @@ -646,8 +646,7 @@ produce_header_file(ModuleInfo, ForeignExportDecls, ModuleName, !IO) :- % modules. so we need to produce a .mh file even if it contains nothing. module_info_get_globals(ModuleInfo, Globals), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".mh")), newext_mh(ext_mh_mh), - ModuleName, FileName, !IO), + newext_mh(ext_mh_mh), ModuleName, FileName, !IO), MaybeThisFileName = yes(FileName), TmpFileName = FileName ++ ".tmp", io.open_output(TmpFileName, Result, !IO), diff --git a/compiler/fact_table.m b/compiler/fact_table.m index 58716b931..e66d0f590 100644 --- a/compiler/fact_table.m +++ b/compiler/fact_table.m @@ -582,8 +582,7 @@ fact_table_compile_facts(ModuleInfo, FileName, Context, GenInfo, ( FileResult = ok(FileStream), fact_table_file_name(Globals, $pred, do_create_dirs, - other_ext(".c"), newext_target_c_cs(ext_target_c), - FileName, OutputFileName, !IO), + newext_target_c_cs(ext_target_c), FileName, OutputFileName, !IO), io.open_output(OutputFileName, OpenResult, !IO), ( OpenResult = ok(OutputStream), diff --git a/compiler/file_kind.m b/compiler/file_kind.m index a45b9b437..61bd71c7f 100644 --- a/compiler/file_kind.m +++ b/compiler/file_kind.m @@ -48,12 +48,11 @@ ---> ofk_opt ; ofk_trans_opt. -:- pred file_kind_to_extension(file_kind::in, string::out, - ext::out, newext::out) is det. +:- pred file_kind_to_extension(file_kind::in, string::out, newext::out) is det. :- pred int_file_kind_to_extension(int_file_kind::in, - string::out, other_ext::out, newext::out) is det. + string::out, newext::out) is det. :- pred opt_file_kind_to_extension(opt_file_kind::in, - string::out, other_ext::out, newext::out) is det. + string::out, newext::out) is det. :- pred extension_to_file_kind(string::in, file_kind::out) is semidet. @@ -61,27 +60,21 @@ :- implementation. -file_kind_to_extension(fk_src, ".m", ext_src, newext_src). -file_kind_to_extension(fk_int(IntFileKind), ExtStr, - ext_other(OtherExt), NewExt) :- - int_file_kind_to_extension(IntFileKind, ExtStr, OtherExt, NewExt). -file_kind_to_extension(fk_opt(OptFileKind), ExtStr, - ext_other(OtherExt), NewExt) :- - opt_file_kind_to_extension(OptFileKind, ExtStr, OtherExt, NewExt). +file_kind_to_extension(fk_src, ".m", newext_src). +file_kind_to_extension(fk_int(IntFileKind), ExtStr, NewExt) :- + int_file_kind_to_extension(IntFileKind, ExtStr, NewExt). +file_kind_to_extension(fk_opt(OptFileKind), ExtStr, NewExt) :- + opt_file_kind_to_extension(OptFileKind, ExtStr, NewExt). -int_file_kind_to_extension(ifk_int0, ".int0", - other_ext(".int0"), newext_int(ext_int_int0)). -int_file_kind_to_extension(ifk_int1, ".int", - other_ext(".int"), newext_int(ext_int_int1)). -int_file_kind_to_extension(ifk_int2, ".int2", - other_ext(".int2"), newext_int(ext_int_int2)). -int_file_kind_to_extension(ifk_int3, ".int3", - other_ext(".int3"), newext_int(ext_int_int3)). +int_file_kind_to_extension(ifk_int0, ".int0", newext_int(ext_int_int0)). +int_file_kind_to_extension(ifk_int1, ".int", newext_int(ext_int_int1)). +int_file_kind_to_extension(ifk_int2, ".int2", newext_int(ext_int_int2)). +int_file_kind_to_extension(ifk_int3, ".int3", newext_int(ext_int_int3)). opt_file_kind_to_extension(ofk_opt, ".opt", - other_ext(".opt"), newext_opt(ext_opt_plain)). + newext_opt(ext_opt_plain)). opt_file_kind_to_extension(ofk_trans_opt, ".trans_opt", - other_ext(".trans_opt"), newext_opt(ext_opt_trans)). + newext_opt(ext_opt_trans)). extension_to_file_kind(ExtStr, FileKind) :- ( diff --git a/compiler/file_names.m b/compiler/file_names.m index 151b13361..7ffebc7c3 100644 --- a/compiler/file_names.m +++ b/compiler/file_names.m @@ -52,29 +52,6 @@ % exist) should be separated from calls that construct a file name % to write the file. % -% XXX Given the wide variety of uses cases that choose_file_name has -% to handle for its callers, the only way to ensure that a diff implementing -% the above ideas handles *all* of those uses cases correctly is probably to -% -% - Gather a list of all the extensions choose_file_name is called with. -% -% - Set up a test environment with distinctively named directories in -% all the relevant directory search options. -% -% - Invoke choose_file_name and module_name_to_file_name_ext -% with all possible combinations of -% -% --use-grade-subdirs, --use-subdirs or neither -% empty and distinctive nonempty base parent dirs -% unqualified and qualified module names -% extension -% maybe_search -% maybe_create_dirs -% -% and record the results as the baseline. -% -% - Repeat the exercise with the proposed replacement code, and -% compare the results to the baseline. % If the proper place for a file is in a subdirectory (e.g. Mercury/css), % but the subdirectory does not exist, which in this case may mean either @@ -121,28 +98,6 @@ ---> do_search ; do_not_search. - % This type is intended to represent an extension at the end of a filename. - % However, we currently also use it to represent an extension at the end - % of the name of an mmake target. Some of those uses include references - % to the values of mmake variables. - % - % We can partition the set of extensions we handle, along the lines - % described above, by adding more function symbols to this type, - % and specifying what suffixes correspond to each function symbol. -:- type ext - ---> ext_src - % The extension string is ".m". - ; ext_other(other_ext). - % The general case. The extension string must not be covered - % by any of the other cases above. - -:- type other_ext - ---> other_ext(string). - -:- func extension_to_string(globals, ext, newext) = string. - -:- func make_module_dep_file_extension = other_ext is det. - %---------------------% :- type newext @@ -259,13 +214,9 @@ % for a long-ago attempt at a bytecode based Mercury debugger. ; newext_misc_ngs(ext_misc_ngs) - ; newext_misc_gs(ext_misc_gs) + ; newext_misc_gs(ext_misc_gs). % XXX Document me. - ; newext_other(other_newext). - % The general case. The extension string must not be covered - % by any of the other cases above. - :- type ext_int ---> ext_int_int0 ; ext_int_int1 @@ -410,6 +361,8 @@ :- type other_newext ---> other_newext(string). +:- func extension_to_string(globals, newext) = string. + %---------------------% % XXX Most of the predicates below take a "from" string argument, @@ -436,8 +389,8 @@ % targets that do not have corresponding files, e.g. `.clean'. % :- pred module_name_to_file_name(globals::in, string::in, - maybe_create_dirs::in, ext::in, newext::in, - module_name::in, file_name::out, io::di, io::uo) is det. + maybe_create_dirs::in, newext::in, module_name::in, file_name::out, + io::di, io::uo) is det. % module_name_to_search_file_name(Globals, Ext, Module, FileName, !IO): % @@ -457,8 +410,7 @@ % which would be used when writing or removing the `.mih' file. % :- pred module_name_to_search_file_name(globals::in, string::in, - ext::in, newext::in, module_name::in, file_name::out, - io::di, io::uo) is det. + newext::in, module_name::in, file_name::out, io::di, io::uo) is det. % module_name_to_lib_file_name(Globals, MkDir, Prefix, Ext, % Module, FileName, !IO): @@ -467,7 +419,7 @@ % Used for creating library names, e.g. `lib.$A' and `lib.so'. % :- pred module_name_to_lib_file_name(globals::in, string::in, - maybe_create_dirs::in, string::in, other_ext::in, newext::in, + maybe_create_dirs::in, string::in, newext::in, module_name::in, file_name::out, io::di, io::uo) is det. % fact_table_file_name(Globals, MkDir, Ext, FactTableFileName, @@ -477,8 +429,7 @@ % If `MkDir' is do_create_dirs, then create any directories needed. % :- pred fact_table_file_name(globals::in, string::in, maybe_create_dirs::in, - other_ext::in, newext::in, file_name::in, file_name::out, - io::di, io::uo) is det. + newext::in, file_name::in, file_name::out, io::di, io::uo) is det. %---------------------------------------------------------------------------% @@ -522,14 +473,6 @@ % :- pred make_include_file_path(string::in, string::in, string::out) is det. -%---------------------------------------------------------------------------% - - % Test whether a proposed replacement for module_name_to_file_name_ext - % generates the same outputs as the original. - % -:- pred test_file_name_extensions(globals::in, io.text_output_stream::in, - io::di, io::uo) is det. - %---------------------------------------------------------------------------% % This predicate is intended to output profiling data that can later @@ -540,7 +483,7 @@ % both the right trace flag at compile time and the right environment % variable at runtime. % -:- pred write_translations_record_if_any(io::di, io::uo) is det. +:- pred write_translations_record_if_any(globals::in, io::di, io::uo) is det. %---------------------------------------------------------------------------% %---------------------------------------------------------------------------% @@ -552,57 +495,20 @@ :- import_module parse_tree.java_names. :- import_module parse_tree.source_file_map. -:- import_module assoc_list. :- import_module bool. :- import_module dir. -:- import_module getopt. :- import_module int. :- import_module library. :- import_module list. :- import_module map. :- import_module maybe. -:- import_module pair. :- import_module require. :- import_module set_tree234. :- import_module string. %---------------------------------------------------------------------------% -:- func old_extension_to_string(ext) = string. - -old_extension_to_string(Ext) = ExtStr :- - ( - Ext = ext_src, - ExtStr = ".m" - ; - Ext = ext_other(OtherExt), - ExtStr = other_extension_to_string(OtherExt) - ). - -:- func other_extension_to_string(other_ext) = string. - -other_extension_to_string(OtherExt) = ExtStr :- - OtherExt = other_ext(ExtStr). - -extension_to_string(Globals, Ext, NewExt) = ExtStr :- - ExtStr = old_extension_to_string(Ext), - trace [run_time(not(env("NO_EXT_CHECKS"))), io(!TIO)] - ( - NewExtStr = newext_to_string(Globals, NewExt), - ( if ExtStr = NewExtStr then - true - else - ExtRawStr = string.string(Ext), - NewExtRawStr = string.string(NewExt), - string.format("EXT_TO_STRING MISMATCH for %s/%s: %s vs %s\n", - [s(ExtRawStr), s(NewExtRawStr), s(ExtStr), s(NewExtStr)], Msg), - unexpected($pred, Msg) - ) - ). - -:- func newext_to_string(globals, newext) = string. - -newext_to_string(Globals, Ext) = ExtStr :- +extension_to_string(Globals, Ext) = ExtStr :- ( Ext = newext_src, ExtStr = ".m" @@ -672,29 +578,10 @@ newext_to_string(Globals, Ext) = ExtStr :- ; Ext = newext_misc_gs(ExtMiscGs), ext_misc_gs_extension_dir(ExtMiscGs, ExtStr, _SubDirName) - ; - Ext = newext_other(_), - unexpected($pred, "newext_other") ). %---------------------------------------------------------------------------% -:- pred valid_other_ext(other_ext::in) is semidet. - -valid_other_ext(other_ext(ExtStr)) :- - % We define what string is valid as an argument of ext/1 negatively: - % any extension string is valid as an argument of ext/1 *unless* - % it has some other representation. - not ( - ExtStr = ".m" % ext_src - ). - -%---------------------------------------------------------------------------% - -make_module_dep_file_extension = other_ext(".module_dep"). - -%---------------------------------------------------------------------------% - module_name_to_source_file_name(ModuleName, SourceFileName, !IO) :- % Look up the module in the module->file mapping. source_file_map.lookup_module_source_file(ModuleName, MaybeFileName, !IO), @@ -736,173 +623,29 @@ module_name_to_source_file_name(ModuleName, SourceFileName, !IO) :- %---------------------------------------------------------------------------% -:- pred newext_uses_option(newext::in) is semidet. - -newext_uses_option(Ext) :- - require_complete_switch [Ext] - ( - ( Ext = newext_src - ; Ext = newext_analysis(_) - ; Ext = newext_bytecode(_) - ; Ext = newext_exec(_) - ; Ext = newext_int(_) - ; Ext = newext_lib(_) - ; Ext = newext_mh(_) - ; Ext = newext_mih(_) - ; Ext = newext_misc_gs(_) - ; Ext = newext_misc_ngs(_) - ; Ext = newext_mmake_fragment(_) - ; Ext = newext_mmake_target(_) - ; Ext = newext_opt(_) - ; Ext = newext_other(_) - ; Ext = newext_target_c_cs(_) - ; Ext = newext_target_date(_) - ; Ext = newext_target_init_c(_) - ; Ext = newext_target_java(_) - ; Ext = newext_user(_) - ; Ext = newext_user_ngs(_) - ), - fail - ; - Ext = newext_target_obj(ExtObj), - require_complete_switch [ExtObj] - ( - ( ExtObj = ext_obj_dollar_o - ; ExtObj = ext_obj_dollar_efpo - ; ExtObj = ext_obj_o - ; ExtObj = ext_obj_pic_o - ), - fail - ; - ( ExtObj = ext_obj_obj_opt - ; ExtObj = ext_obj_pic_obj_opt - ) - ) - ; - Ext = newext_target_init_obj(ExtInitObj), - ( - ( ExtInitObj = ext_init_obj_dollar_o - ; ExtInitObj = ext_init_obj_o - ; ExtInitObj = ext_init_obj_pic_o - ), - fail - ; - ( ExtInitObj = ext_init_obj_obj_opt - ; ExtInitObj = ext_init_obj_pic_obj_opt - ) - ) - ; - Ext = newext_exec_gs(ExtExecGs), - ( - ( ExtExecGs = ext_exec_gs_noext - ; ExtExecGs = ext_exec_gs_bat - ), - fail - ; - ExtExecGs = ext_exec_exec_opt - ) - ; - Ext = newext_lib_gs(ExtLibGs), - ( - ( ExtLibGs = ext_lib_gs_dollar_a - ; ExtLibGs = ext_lib_gs_archive - ; ExtLibGs = ext_lib_gs_dll - ; ExtLibGs = ext_lib_gs_init - ; ExtLibGs = ext_lib_gs_jar - ), - fail - ; - ( ExtLibGs = ext_lib_gs_lib_opt - ; ExtLibGs = ext_lib_gs_sh_lib_opt - ) - ) - ). - -module_name_to_file_name(Globals, From, MkDir, Ext, NewExt, +module_name_to_file_name(Globals, From, MkDir, NewExt, ModuleName, FileName, !IO) :- - module_name_to_file_name_ext(Globals, From, do_not_search, MkDir, - Ext, ModuleName, FileName, !IO), - trace [run_time(not(env("NO_EXT_CHECKS"))), io(!TIO)] - ( - module_name_to_file_name_ext_new(Globals, From, do_not_search, MkDir, - NewExt, ModuleName, NewFileName, !TIO), - ( if ( newext_uses_option(NewExt) ; FileName = NewFileName ) then - true - else - ExtStr = string.string(Ext), - NewExtStr = string.string(NewExt), - string.format("FILENAME MISMATCH 1 for %s/%s: %s vs %s\n", - [s(ExtStr), s(NewExtStr), s(FileName), s(NewFileName)], Msg), - unexpected($pred, Msg) - ) - ). + module_name_to_file_name_ext_new(Globals, From, do_not_search, MkDir, + NewExt, ModuleName, FileName, !IO). -module_name_to_search_file_name(Globals, From, Ext, NewExt, +module_name_to_search_file_name(Globals, From, NewExt, ModuleName, FileName, !IO) :- - module_name_to_file_name_ext(Globals, From, do_search, do_not_create_dirs, - Ext, ModuleName, FileName, !IO), - trace [run_time(not(env("NO_EXT_CHECKS"))), io(!TIO)] - ( - module_name_to_file_name_ext_new(Globals, From, do_search, - do_not_create_dirs, NewExt, ModuleName, NewFileName, !TIO), - ( if ( newext_uses_option(NewExt) ; FileName = NewFileName ) then - true - else - ExtStr = string.string(Ext), - NewExtStr = string.string(NewExt), - string.format("FILENAME MISMATCH 2 for %s/%s: %s vs %s\n", - [s(ExtStr), s(NewExtStr), s(FileName), s(NewFileName)], Msg), - unexpected($pred, Msg) - ) - ). + module_name_to_file_name_ext_new(Globals, From, do_search, + do_not_create_dirs, NewExt, ModuleName, FileName, !IO). -module_name_to_lib_file_name(Globals, From, MkDir, Prefix, Ext, NewExt, +module_name_to_lib_file_name(Globals, From, MkDir, Prefix, NewExt, ModuleName, FileName, !IO) :- BaseFileName = sym_name_to_string(ModuleName), BaseNameNoExt = Prefix ++ BaseFileName, - % Library files do not need the preprocessing that - % module_name_to_file_name_ext does before calling choose_file_name. - choose_file_name(Globals, From, do_not_search, Ext, - [], BaseNameNoExt, DirComponents, FileName), - maybe_create_dirs_on_path(MkDir, DirComponents, !IO), - trace [run_time(not(env("NO_EXT_CHECKS"))), io(!TIO)] - ( - FakeModuleName = unqualified(BaseNameNoExt), - module_name_to_file_name_ext_new(Globals, From, do_not_search, MkDir, - NewExt, FakeModuleName, NewFileName, !TIO), - ( if ( newext_uses_option(NewExt) ; FileName = NewFileName ) then - true - else - ExtStr = string.string(Ext), - NewExtStr = string.string(NewExt), - string.format("FILENAME MISMATCH 3 for %s/%s: %s vs %s\n", - [s(ExtStr), s(NewExtStr), s(FileName), s(NewFileName)], Msg), - unexpected($pred, Msg) - ) - ). + FakeModuleName = unqualified(BaseNameNoExt), + module_name_to_file_name_ext_new(Globals, From, do_not_search, MkDir, + NewExt, FakeModuleName, FileName, !IO). -fact_table_file_name(Globals, From, MkDir, Ext, NewExt, +fact_table_file_name(Globals, From, MkDir, NewExt, FactTableFileName, FileName, !IO) :- - % Fact table files do not need the preprocessing that - % module_name_to_file_name_ext does before calling choose_file_name. - choose_file_name(Globals, From, do_not_search, Ext, - [], FactTableFileName, DirComponents, FileName), - maybe_create_dirs_on_path(MkDir, DirComponents, !IO), - trace [run_time(not(env("NO_EXT_CHECKS"))), io(!TIO)] - ( - FakeModuleName = unqualified(FactTableFileName), - module_name_to_file_name_ext_new(Globals, From, do_not_search, MkDir, - NewExt, FakeModuleName, NewFileName, !TIO), - ( if ( newext_uses_option(NewExt) ; FileName = NewFileName ) then - true - else - ExtStr = string.string(Ext), - NewExtStr = string.string(NewExt), - string.format("FILENAME MISMATCH 4 for %s/%s: %s vs %s\n", - [s(ExtStr), s(NewExtStr), s(FileName), s(NewFileName)], Msg), - unexpected($pred, Msg) - ) - ). + FakeModuleName = unqualified(FactTableFileName), + module_name_to_file_name_ext_new(Globals, From, do_not_search, MkDir, + NewExt, FakeModuleName, FileName, !IO). %---------------------------------------------------------------------------% @@ -961,385 +704,6 @@ fact_table_file_name(Globals, From, MkDir, Ext, NewExt, % they should add the .tmp suffix to the filename they get back from those % predicates instead. -:- pred module_name_to_file_name_ext(globals::in, string::in, - maybe_search::in, maybe_create_dirs::in, ext::in, - module_name::in, file_name::out, io::di, io::uo) is det. - -module_name_to_file_name_ext(Globals, From, Search, MkDir, Ext, - ModuleName, FileName, !IO) :- - ( - Ext = ext_src, - module_name_to_source_file_name(ModuleName, FileName, !IO) - ; - Ext = ext_other(OtherExt), - decide_base_name_parent_dirs_other(OtherExt, ModuleName, - BaseParentDirs, BaseNameNoExt), - choose_file_name(Globals, From, Search, OtherExt, - BaseParentDirs, BaseNameNoExt, DirComponents, FileName), - maybe_create_dirs_on_path(MkDir, DirComponents, !IO) - ), - trace [compile_time(flag("file_name_translations")), - runtime(env("FILE_NAME_TRANSLATIONS")), io(!TIO)] - ( - record_translation(Search, MkDir, Ext, ModuleName, FileName, !TIO) - ). - -%---------------------% - -:- pred decide_base_name_parent_dirs_other(other_ext::in, module_name::in, - list(string)::out, file_name::out) is det. - -decide_base_name_parent_dirs_other(OtherExt, ModuleName, - BaseParentDirs, BaseNameNoExt) :- - OtherExt = other_ext(ExtStr), - expect(valid_other_ext(OtherExt), $pred, - ExtStr ++ " is a not valid argument of ext/1"), - ( if - % Java files need to be placed into a package subdirectory - % and may need mangling. - ( string.suffix(ExtStr, ".java") - ; string.suffix(ExtStr, ".class") - ) - then - BaseParentDirs = ["jmercury"], - mangle_sym_name_for_java(ModuleName, module_qual, "__", BaseNameNoExt) - else - BaseParentDirs = [], - BaseNameNoExt = sym_name_to_string_sep(ModuleName, ".") - ). - -%---------------------% - - % choose_file_name(Globals, Search, OtherExt, BaseParentDirs, BaseName, - % FileName, !IO) - % - % BaseParentDirs is usually empty. For Java files, BaseParentDirs are the - % package directories that the file needs to be placed in. - % -:- pred choose_file_name(globals::in, string::in, maybe_search::in, - other_ext::in, list(string)::in, string::in, - list(string)::out, file_name::out) is det. - -choose_file_name(Globals, _From, Search, OtherExt, - BaseParentDirs, BaseNameNoExt, DirComponents, FileName) :- - globals.lookup_bool_option(Globals, use_subdirs, UseSubdirs), - OtherExt = other_ext(ExtStr), - ( if - % If we are searching for (rather than writing) a `.mih' file, - % use the plain file name. This is so that searches for files - % in installed libraries will work. `--c-include-directory' is set - % so that searches for files in the current directory will work. - Search = do_search, - ExtStr = ".mih" - then - DirComponents = [], - FileName = BaseNameNoExt ++ ExtStr - else - ( - UseSubdirs = no, - % Even if not putting files in a `Mercury' directory, - % Java files will have non-empty BaseParentDirs (the package) - % which may need to be created. - % XXX We can never target Java while UseSubdirs = no. However, - % while making dependencies, generate_d_file in write_deps_file.m - % does call module_name_to_file_name with a .java suffix - % without --use-subdirs being enabled, so insisting on - % BaseParentDirs = [] here would cause an abort when making - % dependencies. - % XXX This indicates a deeper problem, which is that while - % different backends use different settings of --use-subdirs - % and --use-grade-subdirs, we are generating dependencies - % for *all* backends with the *same* settings of these options. - FileName = glue_dir_names_file_name(BaseParentDirs, - BaseNameNoExt, ExtStr), - DirComponents = BaseParentDirs - ; - UseSubdirs = yes, - globals.lookup_bool_option(Globals, use_grade_subdirs, - UseGradeSubdirs), - ( if - % The source files, the final executables, library files - % (including .init files) output files intended for use - % by the user, and phony Mmake targets names go in the - % current directory. - not ( - UseGradeSubdirs = yes, - file_is_arch_or_grade_dependent(Globals, OtherExt) - ), - is_current_dir_extension(ExtStr) - then - DirComponents = [], - FileName = BaseNameNoExt ++ ExtStr - else - choose_subdir_name(Globals, ExtStr, SubDirName), - make_file_name(Globals, [SubDirName | BaseParentDirs], Search, - BaseNameNoExt, OtherExt, DirComponents, FileName) - ) - ) - ). - -:- pred is_current_dir_extension(string::in) is semidet. - -is_current_dir_extension(ExtStr) :- - % Executable files. - % XXX The Ext = "" here is wrong. While an empty extension - % *can* mean we are building the name of an executable, - % it can also mean we are building the name of a phony Mmakefile - % target for a library, such as libmer_std in the library - % directory. - ( ExtStr = "" - ; ExtStr = ".bat" - ; ExtStr = ".exe" - - % Library files. - ; ExtStr = ".a" - ; ExtStr = ".$A" - ; ExtStr = ".lib" - ; ExtStr = ".so" - ; ExtStr = ".dll" - ; ExtStr = ".$(EXT_FOR_SHARED_LIB)" - ; ExtStr = ".jar" - ; ExtStr = ".init" - - % XXX Describe me. - ; ExtStr = ".mh" - - % Output files intended for use by the user. - % The MLDS dump files with extensions .c_dump* and .mih_dump* - % also fit into this category, but their filenames are constructed - % by getting the filenames for the .c and .mih extensions - % and adding a suffix to that. - ; ExtStr = ".err" - ; ExtStr = ".ugly" - ; ExtStr = ".hlds_dump" - ; ExtStr = ".mlds_dump" - ; ExtStr = ".dependency_graph" - ; ExtStr = ".order" - - % Mmake targets. - ; ExtStr = ".clean" - ; ExtStr = ".realclean" - ; ExtStr = ".depend" - ; ExtStr = ".install_ints" - ; ExtStr = ".install_opts" - ; ExtStr = ".install_hdrs" - ; ExtStr = ".install_grade_hdrs" - ; ExtStr = ".check" - ; ExtStr = ".ints" - ; ExtStr = ".int3s" - ; ExtStr = ".javas" - ; ExtStr = ".classes" - ; ExtStr = ".opts" - ; ExtStr = ".trans_opts" - ; ExtStr = ".all_ints" - ; ExtStr = ".all_int3s" - ; ExtStr = ".all_opts" - ; ExtStr = ".all_trans_opts" - ). - - % Decide which ext_other extensions go in which directories. - % -:- pred choose_subdir_name(globals::in, string::in, string::out) is det. - -choose_subdir_name(Globals, ExtStr, SubDirName) :- - ( if - ( - ( ExtStr = ".dir/*.o" - ; ExtStr = ".dir/*.$O" - ), - SubDirNamePrime = "dirs" - ; - % .$O, .pic_o and .lpic_o files need to go in the same directory, - % so that using .$(EXT_FOR_PIC_OBJECTS) will work. - ( ExtStr = ".o" - ; ExtStr = ".$O" - ; ExtStr = ".lpic_o" - ; ExtStr = ".pic_o" - ; ExtStr = "$(EXT_FOR_PIC_OBJECTS)" - ; ExtStr = "_init.o" - ; ExtStr = "_init.$O" - ; ExtStr = "_init.lpic_o" - ; ExtStr = "_init.pic_o" - ; ExtStr = "_init.$(EXT_FOR_PIC_OBJECTS)" - ), - SubDirNamePrime = "os" - ; - % `.dv' files go in the `deps' subdirectory, - % along with the `.dep' files. - ExtStr = ".dv", - SubDirNamePrime = "deps" - ; - % Launcher scripts go in the `bin' subdirectory. - ExtStr = "", - SubDirNamePrime = "bin" - ) - then - SubDirName = SubDirNamePrime - else if - globals.lookup_string_option(Globals, library_extension, LibExt), - globals.lookup_string_option(Globals, shared_library_extension, - SharedLibExt), - % Static and shared libraries go in the `lib' subdirectory. - ( ExtStr = LibExt - ; ExtStr = SharedLibExt - ) - then - SubDirName = "lib" - else if - some [ObjExtStr] ( - ( - globals.lookup_string_option(Globals, - object_file_extension, ObjExtStr) - ; - globals.lookup_string_option(Globals, - pic_object_file_extension, ObjExtStr) - ), - ( - ExtStr = ObjExtStr - ; - ExtStr = "_init" ++ ObjExtStr - ) - ) - then - SubDirName = "os" - else if - % _init.c, _init.cs, etc. files go in the cs, css, etc - % subdirectories. - string.remove_prefix("_init.", ExtStr, ExtName) - then - SubDirName = ExtName ++ "s" - else if - % The usual case: `*.foo' files go in the `foos' subdirectory. - string.remove_prefix(".", ExtStr, ExtName) - then - SubDirName = ExtName ++ "s" - else - unexpected($pred, "unknown extension `" ++ ExtStr ++ "'") - ). - -:- pred make_file_name(globals::in, list(dir_name)::in, maybe_search::in, - file_name::in, other_ext::in, list(string)::out, file_name::out) is det. - -make_file_name(Globals, SubDirNames, Search, BaseNameNoExt, OtherExt, - DirComponents, FileName) :- - globals.lookup_bool_option(Globals, use_grade_subdirs, UseGradeSubdirs), - globals.lookup_bool_option(Globals, use_subdirs, UseSubdirs), - OtherExt = other_ext(ExtStr), - ( if - UseGradeSubdirs = yes, - file_is_arch_or_grade_dependent(Globals, OtherExt), - - % If we are searching for (rather than writing) the file, just search - % in Mercury/s. This is so that searches for files in installed - % libraries work. `--intermod-directories' is set so this will work. - - not ( - Search = do_search, - ( ExtStr= ".opt" - ; ExtStr= ".trans_opt" - ; ExtStr= ".analysis" - ; ExtStr= ".imdg" - ; ExtStr= ".request" - ) - ) - then - grade_directory_component(Globals, Grade), - globals.lookup_string_option(Globals, target_arch, TargetArch), - - % The extra "Mercury" is needed so we can use `--intermod-directory - % Mercury//' and `--c-include - % Mercury//' to find the local `.opt' and `.mih' - % files without messing up the search for the files for installed - % libraries. - DirComponents = ["Mercury", Grade, TargetArch, "Mercury" | SubDirNames] - else if - UseSubdirs = yes - then - DirComponents = ["Mercury" | SubDirNames] - else - DirComponents = SubDirNames - ), - FileName = glue_dir_names_file_name(DirComponents, BaseNameNoExt, ExtStr). - -:- func glue_dir_names_file_name(list(string), string, string) = string. - -glue_dir_names_file_name(DirComponents, BaseNameNoExt, ExtStr) = FileName :- - ( - DirComponents = [], - FileName = BaseNameNoExt ++ ExtStr - ; - DirComponents = [_ | _], - Components = DirComponents ++ [BaseNameNoExt ++ ExtStr], - FileName = dir.relative_path_name_from_components(Components) - ). - -%---------------------% - -:- pred file_is_arch_or_grade_dependent(globals::in, other_ext::in) is semidet. - -file_is_arch_or_grade_dependent(Globals, OtherExt) :- - OtherExt = other_ext(ExtStr), - ( - file_is_arch_or_grade_dependent_2(ExtStr) - ; - globals.lookup_string_option(Globals, executable_file_extension, - ExtStr) - ; - globals.lookup_string_option(Globals, library_extension, ExtStr) - ; - globals.lookup_string_option(Globals, shared_library_extension, ExtStr) - ; - some [ObjExtStr] ( - ( - globals.lookup_string_option(Globals, - object_file_extension, ObjExtStr) - ; - globals.lookup_string_option(Globals, - pic_object_file_extension, ObjExtStr) - ), - ( - ExtStr = ObjExtStr - ; - ExtStr = "_init" ++ ObjExtStr - ) - ) - ). - -:- pred file_is_arch_or_grade_dependent_2(string::in) is semidet. - - % The `.used' file isn't grade dependent itself, but it contains - % information collected while compiling a grade-dependent `.c', `.cs', - % etc file. -file_is_arch_or_grade_dependent_2(""). -file_is_arch_or_grade_dependent_2(".$A"). -file_is_arch_or_grade_dependent_2(".a"). -file_is_arch_or_grade_dependent_2(".analysis"). -file_is_arch_or_grade_dependent_2(".analysis_date"). -file_is_arch_or_grade_dependent_2(".analysis_status"). -file_is_arch_or_grade_dependent_2(".bat"). -file_is_arch_or_grade_dependent_2(".c"). -file_is_arch_or_grade_dependent_2(".c_date"). -file_is_arch_or_grade_dependent_2(".class"). -file_is_arch_or_grade_dependent_2(".cs"). -file_is_arch_or_grade_dependent_2(".cs_date"). -file_is_arch_or_grade_dependent_2(".dir"). -file_is_arch_or_grade_dependent_2(".dll"). -file_is_arch_or_grade_dependent_2(".imdg"). -file_is_arch_or_grade_dependent_2(".init"). -file_is_arch_or_grade_dependent_2(".jar"). -file_is_arch_or_grade_dependent_2(".java"). -file_is_arch_or_grade_dependent_2(".java_date"). -file_is_arch_or_grade_dependent_2(".mih"). -file_is_arch_or_grade_dependent_2(".opt"). -file_is_arch_or_grade_dependent_2(".optdate"). -file_is_arch_or_grade_dependent_2(".request"). -file_is_arch_or_grade_dependent_2(".track_flags"). -file_is_arch_or_grade_dependent_2(".trans_opt"). -file_is_arch_or_grade_dependent_2(".trans_opt_date"). -file_is_arch_or_grade_dependent_2(".used"). -file_is_arch_or_grade_dependent_2("_init.$O"). -file_is_arch_or_grade_dependent_2("_init.c"). - %---------------------------------------------------------------------------% mercury_std_library_module_name(ModuleName) :- @@ -1471,6 +835,10 @@ make_include_file_path(ModuleSourceFileName, OrigFileName, Path) :- %---------------------------------------------------------------------------% %---------------------------------------------------------------------------% +/* +XXX Condense the lessons below and move them to comments either on the +newext type or to the top-of-module comment. + :- func make_new_extension(string) = newext. make_new_extension(ExtStr) = NewExt :- @@ -1676,17 +1044,9 @@ make_new_extension(ExtStr) = NewExt :- else unexpected($pred, "unrecognized ExtStr " ++ ExtStr) ). +*/ %---------------------------------------------------------------------------% -% -% This code is near-duplicate of the call-tree of module_name_to_file_name_ext -% above, with the name of each predicate extended with the "_new" suffix. -% -% The intension is that we can modify this copy, and then compare its operation -% with the operation of the original. -% - -% XXX START OF CODE DUPLICATION :- pred module_name_to_file_name_ext_new(globals::in, string::in, maybe_search::in, maybe_create_dirs::in, newext::in, @@ -2067,138 +1427,28 @@ module_name_to_file_name_ext_new(Globals, From, Search, MkDir, Ext, ), maybe_create_dirs_on_path(MkDir, DirComponents, !IO) ) - ; - Ext = newext_other(OtherExt), - decide_base_name_parent_dirs_other_new(OtherExt, ModuleName, - BaseParentDirs, BaseNameNoExt), - choose_file_name_new(Globals, From, Search, OtherExt, - BaseParentDirs, BaseNameNoExt, DirComponents, FileName), - maybe_create_dirs_on_path(MkDir, DirComponents, !IO), - unexpected($pred, "newext_other") + ), + trace [compile_time(flag("file_name_translations")), + runtime(env("FILE_NAME_TRANSLATIONS")), io(!TIO)] + ( + record_translation(From, Search, MkDir, Ext, ModuleName, FileName, + !TIO) + ). + +:- func glue_dir_names_file_name(list(string), string, string) = string. + +glue_dir_names_file_name(DirComponents, BaseNameNoExt, ExtStr) = FileName :- + ( + DirComponents = [], + FileName = BaseNameNoExt ++ ExtStr + ; + DirComponents = [_ | _], + Components = DirComponents ++ [BaseNameNoExt ++ ExtStr], + FileName = dir.relative_path_name_from_components(Components) ). -% XXX NOT YET UPDATED FOR NEWEXT -% trace [compile_time(flag("file_name_translations")), -% runtime(env("FILE_NAME_TRANSLATIONS")), io(!TIO)] -% ( -% record_translation(Search, MkDir, Ext, ModuleName, FileName, !TIO) -% ). %---------------------------------------------------------------------------% -:- pred decide_base_name_parent_dirs_other_new(other_newext::in, - module_name::in, list(string)::out, file_name::out) is det. - -decide_base_name_parent_dirs_other_new(OtherExt, ModuleName, - BaseParentDirs, BaseNameNoExt) :- - OtherExt = other_newext(ExtStr), - expect(valid_other_newext(OtherExt), $pred, - ExtStr ++ " is a not valid argument of ext/1"), - BaseParentDirs = [], - BaseNameNoExt = sym_name_to_string_sep(ModuleName, "."). - -%---------------------% - - % choose_file_name_new(Globals, Search, OtherExt, BaseParentDirs, BaseName, - % FileName, !IO) - % - % BaseParentDirs is usually empty. For Java files, BaseParentDirs are the - % package directories that the file needs to be placed in. - % -:- pred choose_file_name_new(globals::in, string::in, maybe_search::in, - other_newext::in, list(string)::in, string::in, - list(string)::out, file_name::out) is det. - -choose_file_name_new(Globals, _From, Search, OtherExt, - BaseParentDirs, BaseNameNoExt, DirComponents, FileName) :- - globals.lookup_bool_option(Globals, use_subdirs, UseSubdirs), - OtherExt = other_newext(ExtStr), - ( - UseSubdirs = no, - % Even if not putting files in a `Mercury' directory, - % Java files will have non-empty BaseParentDirs (the package) - % which may need to be created. - % XXX We can never target Java while UseSubdirs = no. However, - % while making dependencies, generate_d_file in write_deps_file.m - % does call module_name_to_file_name with a .java suffix - % without --use-subdirs being enabled, so insisting on - % BaseParentDirs = [] here would cause an abort when making - % dependencies. - % XXX This indicates a deeper problem, which is that while - % different backends use different settings of --use-subdirs - % and --use-grade-subdirs, we are generating dependencies - % for *all* backends with the *same* settings of these options. - FileName = glue_dir_names_file_name(BaseParentDirs, - BaseNameNoExt, ExtStr), - DirComponents = BaseParentDirs - ; - UseSubdirs = yes, - choose_subdir_name_new(Globals, ExtStr, SubDirName), - make_file_name_new(Globals, [SubDirName | BaseParentDirs], - Search, BaseNameNoExt, OtherExt, DirComponents, FileName) - ). - - % Decide which ext_other extensions go in which directories. - % -:- pred choose_subdir_name_new(globals::in, string::in, string::out) is det. - -choose_subdir_name_new(Globals, ExtStr, SubDirName) :- - ( if - ( ExtStr = ".dir/*.o" - ; ExtStr = ".dir/*.$O" - ) - then - SubDirName = "dirs" - else if - % _init.c, _init.cs, _init.o etc. files go in the cs, css, os etc - % subdirectories. - string.remove_prefix("_init.", ExtStr, ExtName) - then - SubDirName = ExtName ++ "s" - else if - globals.lookup_string_option(Globals, library_extension, LibExt), - globals.lookup_string_option(Globals, shared_library_extension, - SharedLibExt), - % Static and shared libraries go in the `lib' subdirectory. - ( ExtStr = LibExt - ; ExtStr = SharedLibExt - ) - then - SubDirName = "lib" - else if - % The usual case: `*.foo' files go in the `foos' subdirectory. - string.remove_prefix(".", ExtStr, ExtName) - then - SubDirName = ExtName ++ "s" - else - unexpected($pred, "unknown extension `" ++ ExtStr ++ "'") - ). - -:- pred make_file_name_new(globals::in, list(dir_name)::in, maybe_search::in, - file_name::in, other_newext::in, list(string)::out, file_name::out) is det. - -make_file_name_new(Globals, SubDirNames, _Search, BaseNameNoExt, OtherExt, - DirComponents, FileName) :- - globals.lookup_bool_option(Globals, use_grade_subdirs, UseGradeSubdirs), - globals.lookup_bool_option(Globals, use_subdirs, UseSubdirs), - OtherExt = other_newext(ExtStr), - ( if - UseGradeSubdirs = yes, - file_is_arch_or_grade_dependent_new(Globals, OtherExt) - then - make_grade_subdir_file_name_new(Globals, SubDirNames, - BaseNameNoExt, ExtStr, DirComponents, FileName) - else if - UseSubdirs = yes - then - DirComponents = ["Mercury" | SubDirNames], - FileName = - glue_dir_names_file_name(DirComponents, BaseNameNoExt, ExtStr) - else - DirComponents = SubDirNames, - FileName = - glue_dir_names_file_name(DirComponents, BaseNameNoExt, ExtStr) - ). - :- pred make_grade_subdir_file_name_new(globals::in, list(dir_name)::in, file_name::in, string::in, list(string)::out, file_name::out) is det. @@ -2214,53 +1464,6 @@ make_grade_subdir_file_name_new(Globals, SubDirNames, BaseNameNoExt, ExtStr, DirComponents = ["Mercury", Grade, TargetArch, "Mercury" | SubDirNames], FileName = glue_dir_names_file_name(DirComponents, BaseNameNoExt, ExtStr). -%---------------------% - -:- pred file_is_arch_or_grade_dependent_new(globals::in, other_newext::in) - is semidet. - -file_is_arch_or_grade_dependent_new(Globals, OtherExt) :- - OtherExt = other_newext(ExtStr), - ( - file_is_arch_or_grade_dependent_2_new(ExtStr) - ; - globals.lookup_string_option(Globals, executable_file_extension, - ExtStr) - ; - globals.lookup_string_option(Globals, library_extension, ExtStr) - ; - globals.lookup_string_option(Globals, shared_library_extension, ExtStr) - ; - some [ObjExtStr] ( - ( - globals.lookup_string_option(Globals, - object_file_extension, ObjExtStr) - ; - globals.lookup_string_option(Globals, - pic_object_file_extension, ObjExtStr) - ), - ( - ExtStr = ObjExtStr - ; - ExtStr = "_init" ++ ObjExtStr - ) - ) - ). - -:- pred file_is_arch_or_grade_dependent_2_new(string::in) is semidet. - - % The `.used' file isn't grade dependent itself, but it contains - % information collected while compiling a grade-dependent `.c', `.cs', - % etc file. -file_is_arch_or_grade_dependent_2_new(".dir"). - -:- pred valid_other_newext(other_newext::in) is semidet. - -valid_other_newext(_) :- - semidet_fail. - -% XXX END OF CODE DUPLICATION - %---------------------------------------------------------------------------% :- pred ext_int_extension_dir(ext_int::in, string::out, string::out) is det. @@ -2489,226 +1692,6 @@ ext_misc_gs_extension_dir(ext_misc_gs_used, ext_misc_gs_extension_dir(ext_misc_gs_track_flags, ".track_flags", "track_flagss"). -%---------------------------------------------------------------------------% - -test_file_name_extensions(Globals0, Stream, !IO) :- - TestModuleName = qualified(qualified(unqualified("abc"), "def"), "xyz"), - Extensions = all_extensions(Globals0), - make_cur_dir_globals(Globals0, GlobalsCur), - globals.set_option(use_subdirs, bool(yes), GlobalsCur, GlobalsSub), - globals.set_option(use_grade_subdirs, bool(yes), - GlobalsSub, GlobalsGradeSub), - - test_extensions_loop(GlobalsCur, GlobalsSub, GlobalsGradeSub, Stream, - TestModuleName, Extensions, no, SomeErrors, !IO), - ( - SomeErrors = no - ; - SomeErrors = yes, - io.set_exit_status(1, !IO) - ). - -:- pred make_cur_dir_globals(globals::in, globals::out) is det. - -make_cur_dir_globals(!Globals) :- - globals.set_option(executable_file_extension, - string("exec_file_opt"), !Globals), - globals.set_option(library_extension, - string("lib_opt"), !Globals), - globals.set_option(shared_library_extension, - string("shlib_opt"), !Globals), - globals.set_option(object_file_extension, - string("obj_opt"), !Globals), - globals.set_option(pic_object_file_extension, - string("pic_obj_opt"), !Globals), - globals.set_option(use_subdirs, bool(no), !Globals), - globals.set_option(use_grade_subdirs, bool(no), !Globals). - -:- pred test_extensions_loop(globals::in, globals::in, globals::in, - io.text_output_stream::in, module_name::in, list(string)::in, - bool::in, bool::out, io::di, io::uo) is det. - -test_extensions_loop(_, _, _, _, _, [], !SomeError, !IO). -test_extensions_loop(GlobalsCur, GlobalsSub, GlobalsGradeSub, Stream, - ModuleName, [Ext | Exts], !SomeError, !IO) :- - test_one_extension(GlobalsCur, Stream, "cur", do_not_search, - ModuleName, Ext, !SomeError, !IO), - test_one_extension(GlobalsCur, Stream, "cur", do_search, - ModuleName, Ext, !SomeError, !IO), - test_one_extension(GlobalsSub, Stream, "sub", do_not_search, - ModuleName, Ext, !SomeError, !IO), - test_one_extension(GlobalsSub, Stream, "sub", do_search, - ModuleName, Ext, !SomeError, !IO), - test_one_extension(GlobalsGradeSub, Stream, "gsub", do_not_search, - ModuleName, Ext, !SomeError, !IO), - test_one_extension(GlobalsGradeSub, Stream, "gsub", do_search, - ModuleName, Ext, !SomeError, !IO), - test_extensions_loop(GlobalsCur, GlobalsSub, GlobalsGradeSub, Stream, - ModuleName, Exts, !SomeError, !IO). - -:- pred test_one_extension(globals::in, io.text_output_stream::in, - string::in, maybe_search::in, module_name::in, string::in, - bool::in, bool::out, io::di, io::uo) is det. - -test_one_extension(Globals, Stream, GlobalsStr, MaybeSearch, ModuleName, Ext, - !SomeError, !IO) :- - From = "TEST", - % The value of MkDir does not influence the filename generated - % by module_name_to_file_name_ext. - MkDir = do_not_create_dirs, - module_name_to_file_name_ext(Globals, From, MaybeSearch, MkDir, - ext_other(other_ext(Ext)), ModuleName, OldFileName, !IO), - NewExt = make_new_extension(Ext), - module_name_to_file_name_ext_new(Globals, From, MaybeSearch, MkDir, - NewExt, ModuleName, NewFileName, !IO), - ( if OldFileName = NewFileName then - true - else - ( MaybeSearch = do_search, MaybeSearchStr = "schy" - ; MaybeSearch = do_not_search, MaybeSearchStr = "schn" - ), - io.format(Stream, "BAD FILENAME %s/%s/%-8s %s vs %s\n", - [s(GlobalsStr), s(MaybeSearchStr), s("<" ++ Ext ++ ">:"), - s(OldFileName), s(NewFileName)], !IO), - !:SomeError = yes - ). - -%---------------------% - -:- func all_extensions(globals) = list(string). - -all_extensions(Globals) = AllExtensionStrs :- - StrExtensions = string_extensions, - OptionExtensions = option_extensions, - StrOptionExtensions = string_option_extensions, - list.map(globals.lookup_string_option(Globals), - OptionExtensions, OptionExtensionStrs), - MakeStrOptStr = - ( pred(Str - Opt::in, StrOptStr::out) is det :- - globals.lookup_string_option(Globals, Opt, OptStr), - StrOptStr = Str ++ OptStr - ), - list.map(MakeStrOptStr, - StrOptionExtensions, StrOptionExtensionStrs), - AllExtensionStrs0 = StrExtensions ++ OptionExtensionStrs ++ - StrOptionExtensionStrs, - % Depending on option values, some of OptionExtensionStrs and - % StrOptionExtensionStrs may duplicate strings in StrExtensions. - list.sort_and_remove_dups(AllExtensionStrs0, AllExtensionStrs). - -:- func string_extensions = list(string). - -% We don't test the .m extension, since that is handled separately -% by module_name_to_source_file_name. -% -% We don't test ".$(EXT_FOR_PIC_OBJECTS)", because with --use-subdirs -% and with --use-grade-subdirs, the OLD code produces nonsense results, -% while the new code does fine. -string_extensions = - ["", - % ".$(EXT_FOR_PIC_OBJECTS)", - ".$(EXT_FOR_SHARED_LIB)", - ".$A", -% ".$O", - ".a", - ".all_int3s", - ".all_ints", - ".all_opts", - ".all_trans_opts", - ".analysis", - ".analysis_date", - ".analysis_status", - ".bat", - ".bytedebug", - ".c", - ".c_date", - ".check", - ".class", - ".classes", - ".clean", - ".cs", - ".cs_date", - ".d", - ".date", - ".date0", - ".date3", - ".defn_extents", - ".defn_line_counts", - ".defns", - ".dep", - ".depend", - ".dependency_graph", - ".dir/*.$O", - ".dll", - ".dv", - ".err", - ".err_date", - ".exe", - ".hlds_dump", - ".imdg", - ".imports_graph", - ".init", - ".install_grade_hdrs", - ".install_hdrs", - ".install_ints", - ".install_opts", - ".int", - ".int0", - ".int2", - ".int3", - ".int3s", - ".ints", - ".jar", - ".java", - ".java_date", - ".javas", - ".local_call_tree", - ".local_call_tree_order", - ".mbc", - ".mh", - ".mih", - ".mlds_dump", - ".mode_constraints", - ".module_dep", -% ".o", - ".opt", - ".optdate", - ".opts", - ".order", - ".order_trans_opt", -% ".pic_o", - ".prof", - ".realclean", - ".request", - ".so", - ".track_flags", - ".trans_opt", - ".trans_opt_date", - ".trans_opts", - ".type_repns", - ".ugly", - ".used", - ".xml", - "_init.$O", - "_init.c"]. -% "_init.o", -% "_init.pic_o"]. - -:- func option_extensions = list(option). - -option_extensions = - [executable_file_extension, - library_extension, - object_file_extension, - pic_object_file_extension, - shared_library_extension]. - -:- func string_option_extensions = assoc_list(string, option). - -string_option_extensions = - ["_init" - object_file_extension, - "_init" - pic_object_file_extension]. - %---------------------------------------------------------------------------% %---------------------------------------------------------------------------% % @@ -2726,7 +1709,7 @@ string_option_extensions = % subject to different kinds of postprocessing. :- type record_key - ---> record_key(module_name, ext, maybe_search, maybe_create_dirs). + ---> record_key(module_name, newext, maybe_search, maybe_create_dirs). :- type record_value ---> record_value(string, int). @@ -2734,10 +1717,12 @@ string_option_extensions = :- mutable(translations, map(record_key, record_value), map.init, ground, [untrailed, attach_to_io_state]). -:- pred record_translation(maybe_search::in, maybe_create_dirs::in, ext::in, - module_name::in, string::in, io::di, io::uo) is det. +:- pred record_translation(string::in, maybe_search::in, maybe_create_dirs::in, + newext::in, module_name::in, string::in, io::di, io::uo) is det. -record_translation(Search, MkDir, Ext, ModuleName, FileName, !IO) :- +record_translation(_From, Search, MkDir, Ext, ModuleName, FileName, !IO) :- + % XXX We could record _From in the table. It could show us where + % most translation requests come from. get_translations(Translations0, !IO), Key = record_key(ModuleName, Ext, Search, MkDir), ( if map.search(Translations0, Key, Value0) then @@ -2783,7 +1768,7 @@ record_mkdir(DirName, !IO) :- %---------------------% -write_translations_record_if_any(!IO) :- +write_translations_record_if_any(Globals, !IO) :- get_translations(Translations, !IO), get_no_mkdirs(NoMkDirs, !IO), get_mkdirs(MkDirs, !IO), @@ -2794,7 +1779,7 @@ write_translations_record_if_any(!IO) :- then true else - map.foldl4(gather_translation_stats, Translations, + map.foldl4(gather_translation_stats(Globals), Translations, 0, NumKeys, 0, NumLookups, map.init, ExtMap, map.init, ExtSchDirMap), io.open_append("/tmp/TRANSLATIONS_RECORD", Result, !IO), @@ -2817,27 +1802,22 @@ write_translations_record_if_any(!IO) :- :- type count_sum ---> count_sum(int, int). -:- pred gather_translation_stats(record_key::in, record_value::in, +:- pred gather_translation_stats(globals::in, record_key::in, record_value::in, int::in, int::out, int::in, int::out, map(string, count_sum)::in, map(string, count_sum)::out, map(string, count_sum)::in, map(string, count_sum)::out) is det. -gather_translation_stats(Key, Value, !NumKeys, !NumLookups, +gather_translation_stats(Globals, Key, Value, !NumKeys, !NumLookups, !ExtMap, !ExtSchDirMap) :- !:NumKeys = !.NumKeys + 1, Value = record_value(_FileName, Count), !:NumLookups = !.NumLookups + Count, - Key = record_key(_ModuleName, Ext0, Search, MkDir), - ( - Ext0 = ext_src, - ExtStr = ".m" - ; - Ext0 = ext_other(other_ext(ExtStr0)), - ( if ExtStr0 = "" then - ExtStr = "no_suffix" - else - ExtStr = ExtStr0 - ) + Key = record_key(_ModuleName, Ext, Search, MkDir), + ExtStr0 = extension_to_string(Globals, Ext), + ( if ExtStr0 = "" then + ExtStr = "no_suffix" + else + ExtStr = ExtStr0 ), ( Search = do_search, diff --git a/compiler/generate_dep_d_files.m b/compiler/generate_dep_d_files.m index 06b8f5e62..65852d699 100644 --- a/compiler/generate_dep_d_files.m +++ b/compiler/generate_dep_d_files.m @@ -220,8 +220,7 @@ generate_dependencies(Globals, Mode, Search, ModuleName, DepsMap0, ImpDepsOrdering = digraph.return_sccs_in_from_to_order(ImpDepsGraph), output_module_order(Globals, ModuleName, - other_ext(".order"), newext_user(ext_user_order), - ImpDepsOrdering, !IO) + newext_user(ext_user_order), ImpDepsOrdering, !IO) ; OutputOrder = no ), @@ -310,7 +309,6 @@ generate_dependencies(Globals, Mode, Search, ModuleName, DepsMap0, ( OutputOrder = yes, output_module_order(Globals, ModuleName, - other_ext(".order_trans_opt"), newext_user_ngs(ext_user_ngs_order_to), TransOptDepsOrdering0, !IO) ; @@ -321,8 +319,7 @@ generate_dependencies(Globals, Mode, Search, ModuleName, DepsMap0, list.condense(TransOptDepsOrdering1, TransOptDepsOrdering), globals.lookup_accumulating_option(Globals, intermod_directories, IntermodDirs), - get_opt_deps(Globals, yes, IntermodDirs, - other_ext(".trans_opt"), newext_opt(ext_opt_trans), + get_opt_deps(Globals, yes, IntermodDirs, newext_opt(ext_opt_trans), TransOptDepsOrdering, TransOptOrder, !IO), ( Mode = output_d_file_only, @@ -395,7 +392,6 @@ maybe_output_imports_graph(Globals, ModuleName, IntDepsGraph, ImpDepsGraph, ( ImportsGraph = yes, module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".imports_graph")), newext_user_ngs(ext_user_ngs_imports_graph), ModuleName, FileName, !IO), ( diff --git a/compiler/grab_modules.m b/compiler/grab_modules.m index 85ff7373e..bc983d795 100644 --- a/compiler/grab_modules.m +++ b/compiler/grab_modules.m @@ -1123,7 +1123,11 @@ maybe_log_augment_decision(Why, IntFileKind, ReadWhy, ModuleName, Read, !IO) :- runtime(env("LOG_AUGMENT_DECISION")), io(!TIO)] ( ModuleNameStr = sym_name_to_string(ModuleName), - int_file_kind_to_extension(IntFileKind, ExtStr, _Ext, _NewExt), + ( IntFileKind = ifk_int0, ExtStr = ".int0" + ; IntFileKind = ifk_int1, ExtStr = ".int1" % for alignment + ; IntFileKind = ifk_int2, ExtStr = ".int2" + ; IntFileKind = ifk_int3, ExtStr = ".int3" + ), WhyStr = string.string(ReadWhy), ( Read = decided_not_to_read, diff --git a/compiler/llds_out_file.m b/compiler/llds_out_file.m index c2c92c817..42afc68e5 100644 --- a/compiler/llds_out_file.m +++ b/compiler/llds_out_file.m @@ -119,8 +119,7 @@ output_llds(Globals, CFile, Succeeded, !IO) :- ModuleName = CFile ^ cfile_modulename, module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".c")), newext_target_c_cs(ext_target_c), - ModuleName, FileName, !IO), + newext_target_c_cs(ext_target_c), ModuleName, FileName, !IO), output_to_file_stream(Globals, ModuleName, FileName, output_llds_2(Globals, CFile), Succeeded, !IO). diff --git a/compiler/make.build.m b/compiler/make.build.m index 5c180a2e8..74dd3377e 100644 --- a/compiler/make.build.m +++ b/compiler/make.build.m @@ -262,8 +262,7 @@ unredirect_output(Globals, ModuleName, ErrorOutputStream, !Info, !IO) :- ( TmpErrorLinesRes = ok(TmpErrorLines), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".err")), newext_user(ext_user_err), - ModuleName, ErrorFileName, !IO), + newext_user(ext_user_err), ModuleName, ErrorFileName, !IO), ErrorFileModules0 = make_info_get_error_file_modules(!.Info), ( if set.contains(ErrorFileModules0, ModuleName) then io.open_append(ErrorFileName, ErrorFileRes, !IO) diff --git a/compiler/make.module_dep_file.m b/compiler/make.module_dep_file.m index 2042480a7..bb011af60 100644 --- a/compiler/make.module_dep_file.m +++ b/compiler/make.module_dep_file.m @@ -199,7 +199,6 @@ do_get_module_dependencies(Globals, RebuildModuleDeps, ModuleName, MaybeSourceFileTimestamp, !Info, !IO), module_name_to_file_name(Globals, $pred, do_not_create_dirs, - ext_other(make_module_dep_file_extension), newext_misc_ngs(ext_misc_ngs_module_dep), ModuleName, DepFileName, !IO), globals.lookup_accumulating_option(Globals, search_directories, @@ -353,7 +352,6 @@ do_write_module_dep_file(Globals, BurdenedModule, !IO) :- BurdenedModule = burdened_module(Baggage, ParseTreeModuleSrc), ModuleName = ParseTreeModuleSrc ^ ptms_module_name, module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(make_module_dep_file_extension), newext_misc_ngs(ext_misc_ngs_module_dep), ModuleName, ProgDepFile, !IO), io.open_output(ProgDepFile, ProgDepResult, !IO), @@ -513,7 +511,6 @@ read_module_dependencies_no_search(Globals, RebuildModuleDeps, ModuleName, read_module_dependencies_2(Globals, RebuildModuleDeps, SearchDirs, ModuleName, !Info, !IO) :- module_name_to_search_file_name(Globals, $pred, - ext_other(make_module_dep_file_extension), newext_misc_ngs(ext_misc_ngs_module_dep), ModuleName, ModuleDepFile, !IO), search_for_file_returning_dir_and_stream(SearchDirs, ModuleDepFile, @@ -918,8 +915,7 @@ make_module_dependencies_fatal_error(Globals, OldOutputStream, ErrorStream, Globals, UnredirectGlobals), unredirect_output(UnredirectGlobals, ModuleName, ErrorStream, !Info, !IO), module_name_to_file_name(Globals, $pred, do_not_create_dirs, - ext_other(other_ext(".err")), newext_user(ext_user_err), - ModuleName, ErrFileName, !IO), + newext_user(ext_user_err), ModuleName, ErrFileName, !IO), io.file.remove_file(ErrFileName, _, !IO), ModuleDepMap0 = make_info_get_module_dependencies(!.Info), @@ -1057,7 +1053,6 @@ cleanup_module_dep_files(Globals, ModuleNames, !Info, !IO) :- cleanup_module_dep_file(Globals, ModuleName, !Info, !IO) :- remove_make_module_file(Globals, verbose_make, ModuleName, - ext_other(make_module_dep_file_extension), newext_misc_ngs(ext_misc_ngs_module_dep), !Info, !IO). :- pred maybe_write_importing_module(module_name::in, diff --git a/compiler/make.module_target.m b/compiler/make.module_target.m index 1900478c9..6286c0da0 100644 --- a/compiler/make.module_target.m +++ b/compiler/make.module_target.m @@ -613,8 +613,7 @@ build_target_2(ModuleName, Task, ArgFileName, ModuleDepInfo, Globals, % The `.err_date' file is needed because the `.err' file is touched % by all phases of compilation, including writing interfaces. touch_interface_datestamp(Globals, ProgressStream, ErrorStream, - ModuleName, other_ext(".err_date"), - newext_misc_ngs(ext_misc_ngs_err_date), + ModuleName, newext_misc_ngs(ext_misc_ngs_err_date), TouchSucceeded, !IO), Succeeded = CompileSucceeded `and` TouchSucceeded else @@ -643,9 +642,9 @@ build_target_2(ModuleName, Task, ArgFileName, ModuleDepInfo, Globals, Succeeded, !IO) ; Task = fact_table_code_to_object_code(PIC, FactTableFileName), - get_object_extension(Globals, PIC, ObjExt, ObjNewExt), + get_object_extension(Globals, PIC, ObjNewExt), get_fact_table_foreign_code_file(Globals, do_create_dirs, - ObjExt, newext_target_obj(ObjNewExt), + newext_target_obj(ObjNewExt), FactTableFileName, FactTableForeignCode, !IO), % Run the compilation in a child process so it can be killed @@ -669,7 +668,6 @@ build_object_code(Globals, ModuleName, Target, PIC, ; Target = target_java, module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".java")), newext_target_java(ext_target_java_java), ModuleName, JavaFile, !IO), compile_java_files(Globals, ProgressStream, ErrorStream, @@ -677,8 +675,7 @@ build_object_code(Globals, ModuleName, Target, PIC, ; Target = target_csharp, module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".cs")), newext_target_c_cs(ext_target_cs), - ModuleName, CsharpFile, !IO), + newext_target_c_cs(ext_target_cs), ModuleName, CsharpFile, !IO), compile_target_code.link(Globals, ProgressStream, ErrorStream, csharp_library, ModuleName, [CsharpFile], Succeeded, !IO) ). @@ -722,23 +719,21 @@ do_task_in_separate_process(task_make_xml_doc) = yes. get_foreign_code_file(Globals, ModuleName, PIC, Lang, ForeignCodeFile, !IO) :- foreign_language_module_name(ModuleName, Lang, ForeignModName), - foreign_language_file_extension(Lang, SrcExt, SrcNewExt), - get_object_extension(Globals, PIC, ObjOtherExt, ObjNewExt), + foreign_language_file_extension(Lang, SrcNewExt), + get_object_extension(Globals, PIC, ObjNewExt), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(SrcExt), SrcNewExt, ForeignModName, SrcFileName, !IO), + SrcNewExt, ForeignModName, SrcFileName, !IO), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(ObjOtherExt), newext_target_obj(ObjNewExt), - ForeignModName, ObjFileName, !IO), + newext_target_obj(ObjNewExt), ForeignModName, ObjFileName, !IO), ForeignCodeFile = foreign_code_file(Lang, SrcFileName, ObjFileName). -:- pred get_object_extension(globals::in, pic::in, - other_ext::out, ext_obj::out) is det. +:- pred get_object_extension(globals::in, pic::in, ext_obj::out) is det. -get_object_extension(Globals, PIC, OtherExt, NewExtObj) :- +get_object_extension(Globals, PIC, NewExtObj) :- globals.get_target(Globals, CompilationTarget), ( CompilationTarget = target_c, - maybe_pic_object_file_extension(Globals, PIC, OtherExt, NewExtObj, _) + maybe_pic_object_file_extension(PIC, NewExtObj, _) ; CompilationTarget = target_csharp, sorry($pred, "object extension for csharp") @@ -1038,9 +1033,9 @@ find_files_maybe_touched_by_task(Globals, TargetFile, Task, ; Task = fact_table_code_to_object_code(PIC, FactTableName), TouchedTargetFiles = [TargetFile], - get_object_extension(Globals, PIC, ObjOtherExt, ObjNewExt), + get_object_extension(Globals, PIC, ObjNewExt), fact_table_file_name(Globals, $pred, do_create_dirs, - ObjOtherExt, newext_target_obj(ObjNewExt), + newext_target_obj(ObjNewExt), FactTableName, FactTableObjectFile, !IO), TouchedFileNames = [FactTableObjectFile] ). @@ -1164,12 +1159,9 @@ find_files_maybe_touched_by_process_module(Globals, TargetFile, Task, gather_target_file_timestamp_file_names(Globals, TouchedTargetFile, !TimestampFileNames, !IO) :- TouchedTargetFile = target_file(TargetModuleName, TargetType), - ( if - timestamp_extension(TargetType, TimestampOtherExt, TimestampNewExt) - then + ( if timestamp_extension(TargetType, TimestampNewExt) then module_name_to_file_name(Globals, $pred, do_not_create_dirs, - ext_other(TimestampOtherExt), TimestampNewExt, - TargetModuleName, TimestampFile, !IO), + TimestampNewExt, TargetModuleName, TimestampFile, !IO), list.cons(TimestampFile, !TimestampFileNames) else true @@ -1184,7 +1176,7 @@ external_foreign_code_files(Globals, PIC, ModuleDepInfo, ForeignFiles, !IO) :- % Any changes here may require corresponding changes in % get_foreign_object_targets. - maybe_pic_object_file_extension(Globals, PIC, ObjExt, ObjNewExt, _), + maybe_pic_object_file_extension(PIC, ObjNewExt, _), globals.get_target(Globals, CompilationTarget), % None of the current backends require externally compiled foreign code, @@ -1194,7 +1186,7 @@ external_foreign_code_files(Globals, PIC, ModuleDepInfo, ForeignFiles, !IO) :- module_dep_info_get_fact_tables(ModuleDepInfo, FactTableFiles), list.map_foldl( get_fact_table_foreign_code_file(Globals, do_not_create_dirs, - ObjExt, newext_target_obj(ObjNewExt)), + newext_target_obj(ObjNewExt)), set.to_sorted_list(FactTableFiles), FactTableForeignFiles, !IO), ForeignFiles = FactTableForeignFiles ; @@ -1205,17 +1197,16 @@ external_foreign_code_files(Globals, PIC, ModuleDepInfo, ForeignFiles, !IO) :- ). :- pred get_fact_table_foreign_code_file(globals::in, maybe_create_dirs::in, - other_ext::in, newext::in, file_name::in, foreign_code_file::out, - io::di, io::uo) is det. + newext::in, file_name::in, foreign_code_file::out, io::di, io::uo) is det. -get_fact_table_foreign_code_file(Globals, Mkdir, ObjOtherExt, ObjNewExt, +get_fact_table_foreign_code_file(Globals, Mkdir, ObjNewExt, FactTableFileName, ForeignCodeFile, !IO) :- % XXX EXT Neither of these calls should be needed. fact_table_file_name(Globals, $pred, Mkdir, - other_ext(".c"), newext_target_c_cs(ext_target_c), + newext_target_c_cs(ext_target_c), FactTableFileName, FactTableCFileName, !IO), fact_table_file_name(Globals, $pred, Mkdir, - ObjOtherExt, ObjNewExt, FactTableFileName, FactTableObjFileName, !IO), + ObjNewExt, FactTableFileName, FactTableObjFileName, !IO), ForeignCodeFile = foreign_code_file(lang_c, FactTableCFileName, FactTableObjFileName). diff --git a/compiler/make.program_target.m b/compiler/make.program_target.m index 53966a228..c1224f287 100644 --- a/compiler/make.program_target.m +++ b/compiler/make.program_target.m @@ -619,22 +619,19 @@ build_linked_target_2(Globals, MainModuleName, FileType, OutputFileName, ( CompilationTarget = target_c, - maybe_pic_object_file_extension(NoLinkObjsGlobals, PIC, - ObjOtherExtToUse, ObjNewExt, _), + maybe_pic_object_file_extension(PIC, ObjNewExt, _), NewExt = newext_target_obj(ObjNewExt) ; CompilationTarget = target_csharp, % There is no separate object code step. - ObjOtherExtToUse = other_ext(".cs"), NewExt = newext_target_c_cs(ext_target_cs) ; CompilationTarget = target_java, - ObjOtherExtToUse = other_ext(".class"), NewExt = newext_target_java(ext_target_java_class) ), list.map_foldl( module_name_to_file_name(NoLinkObjsGlobals, $pred, - do_not_create_dirs, ext_other(ObjOtherExtToUse), NewExt), + do_not_create_dirs, NewExt), ObjModules, ObjList, !IO), % LinkObjects may contain `.a' files which must come @@ -786,7 +783,6 @@ build_java_files(Globals, MainModuleName, ModuleNames, Succeeded, maybe_write_msg(MakingMsg, !IO), list.map_foldl( module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".java")), newext_target_java(ext_target_java_java)), ModuleNames, JavaFiles, !IO), % We redirect errors to a file named after the main module. @@ -1566,22 +1562,20 @@ install_ints_and_headers(Globals, SubdirLinkSucceeded, ModuleName, Succeeded, ( if set.is_empty(Children) then Exts0 = [] else - Exts0 = [{other_ext(".int0"), newext_int(ext_int_int0), "int0s"}] + Exts0 = [{newext_int(ext_int_int0), "int0s"}] ), globals.get_any_intermod(Globals, AnyIntermod), ( AnyIntermod = yes, - Exts1 = [{other_ext(".opt"), newext_opt(ext_opt_plain), "opts"} - | Exts0] + Exts1 = [{newext_opt(ext_opt_plain), "opts"} | Exts0] ; AnyIntermod = no, Exts1 = Exts0 ), - Exts = [{other_ext(".int"), newext_int(ext_int_int1), "ints"}, - {other_ext(".int2"), newext_int(ext_int_int2), "int2s"}, - {other_ext(".int3"), newext_int(ext_int_int3), "int3s"}, - {other_ext(".module_dep"), - newext_misc_ngs(ext_misc_ngs_module_dep), "module_deps"} + Exts = [{newext_int(ext_int_int1), "ints"}, + {newext_int(ext_int_int2), "int2s"}, + {newext_int(ext_int_int3), "int3s"}, + {newext_misc_ngs(ext_misc_ngs_module_dep), "module_deps"} | Exts1], globals.lookup_string_option(Globals, install_prefix, Prefix), LibDir = Prefix/"lib"/"mercury", @@ -1603,14 +1597,13 @@ install_ints_and_headers(Globals, SubdirLinkSucceeded, ModuleName, Succeeded, % ModuleDepInfo ^ contains_foreign_export % = contains_foreign_export? module_name_to_file_name(Globals, $pred, do_not_create_dirs, - ext_other(other_ext(".mh")), newext_mh(ext_mh_mh), - ModuleName, FileName, !IO), + newext_mh(ext_mh_mh), ModuleName, FileName, !IO), install_file(Globals, FileName, LibDir/"inc", HeaderSucceeded1, !IO), % This is needed so that the file will be found in Mmake's VPATH. install_subdir_file(Globals, SubdirLinkSucceeded, LibDir/"ints", - ModuleName, {other_ext(".mh"), newext_mh(ext_mh_mh), "mhs"}, + ModuleName, {newext_mh(ext_mh_mh), "mhs"}, HeaderSucceeded2, !IO), HeaderSucceeded = HeaderSucceeded1 `and` HeaderSucceeded2 @@ -1821,8 +1814,7 @@ install_grade_init(Globals, GradeDir, ModuleName, Succeeded, !IO) :- globals.lookup_string_option(Globals, install_prefix, Prefix), GradeModulesDir = Prefix / "lib" / "mercury" / "modules" / GradeDir, module_name_to_file_name(Globals, $pred, do_not_create_dirs, - ext_other(other_ext(".init")), newext_lib_gs(ext_lib_gs_init), - ModuleName, InitFileName, !IO), + newext_lib_gs(ext_lib_gs_init), ModuleName, InitFileName, !IO), install_file(Globals, InitFileName, GradeModulesDir, Succeeded, !IO). % Install the `.opt', `.analysis' and `.mih' files for the current grade. @@ -1848,15 +1840,13 @@ install_grade_ints_and_headers(Globals, LinkSucceeded, GradeDir, ModuleName, then GradeIncDir = LibDir/"lib"/GradeDir/"inc", install_subdir_file(Globals, LinkSucceeded, GradeIncDir, - ModuleName, - {other_ext(".mih"), newext_mih(ext_mih_mih), "mihs"}, + ModuleName, {newext_mih(ext_mih_mih), "mihs"}, HeaderSucceeded1, !IO), % This is needed so that the file will be found in Mmake's VPATH. IntDir = LibDir/"ints", install_subdir_file(Globals, LinkSucceeded, IntDir, ModuleName, - {other_ext(".mih"), newext_mih(ext_mih_mih), "mihs"}, - HeaderSucceeded2, !IO), + {newext_mih(ext_mih_mih), "mihs"}, HeaderSucceeded2, !IO), HeaderSucceeded = HeaderSucceeded1 `and` HeaderSucceeded2 else HeaderSucceeded = succeeded @@ -1867,8 +1857,7 @@ install_grade_ints_and_headers(Globals, LinkSucceeded, GradeDir, ModuleName, ( AnyIntermod = yes, install_subdir_file(Globals, LinkSucceeded, GradeIntDir, - ModuleName, - {other_ext(".opt"), newext_opt(ext_opt_plain), "opts"}, + ModuleName, {newext_opt(ext_opt_plain), "opts"}, OptSucceeded, !IO) ; AnyIntermod = no, @@ -1879,9 +1868,7 @@ install_grade_ints_and_headers(Globals, LinkSucceeded, GradeDir, ModuleName, ( IntermodAnalysis = yes, install_subdir_file(Globals, LinkSucceeded, GradeIntDir, - ModuleName, - {other_ext(".analysis"), newext_analysis(ext_an_analysis), - "analysiss"}, + ModuleName, {newext_analysis(ext_an_analysis), "analysiss"}, IntermodAnalysisSucceeded, !IO) ; IntermodAnalysis = no, @@ -1899,13 +1886,13 @@ install_grade_ints_and_headers(Globals, LinkSucceeded, GradeDir, ModuleName, % (e.g. on Windows). % :- pred install_subdir_file(globals::in, maybe_succeeded::in, dir_name::in, - module_name::in, {other_ext, newext, string}::in, + module_name::in, {newext, string}::in, maybe_succeeded::out, io::di, io::uo) is det. install_subdir_file(Globals, SubdirLinkSucceeded, InstallDir, ModuleName, - {Ext, NewExt, Exts}, Succeeded, !IO) :- + {NewExt, Exts}, Succeeded, !IO) :- module_name_to_file_name(Globals, $pred, do_not_create_dirs, - ext_other(Ext), NewExt, ModuleName, FileName, !IO), + NewExt, ModuleName, FileName, !IO), install_file(Globals, FileName, InstallDir, Succeeded1, !IO), ( SubdirLinkSucceeded = did_not_succeed, @@ -2149,33 +2136,24 @@ make_main_module_realclean(Globals, ModuleName, !Info, !IO) :- LinkedTargetTypes, ThisDirFileNames, !IO), % XXX This symlink should not be necessary anymore for `mmc --make'. module_name_to_file_name(NoSubdirGlobals, $pred, do_not_create_dirs, - ext_other(other_ext(".init")), newext_lib_gs(ext_lib_gs_init), - ModuleName, ThisDirInitFileName, !IO), + newext_lib_gs(ext_lib_gs_init), ModuleName, ThisDirInitFileName, !IO), list.foldl2(make_remove_file(Globals, very_verbose), FileNames ++ ThisDirFileNames ++ [ThisDirInitFileName], !Info, !IO), remove_make_module_file(Globals, very_verbose, ModuleName, - ext_other(other_ext(".init")), newext_lib_gs(ext_lib_gs_init), - !Info, !IO), + newext_lib_gs(ext_lib_gs_init), !Info, !IO), remove_init_files(Globals, very_verbose, ModuleName, !Info, !IO). :- pred remove_init_files(globals::in, option::in, module_name::in, make_info::in, make_info::out, io::di, io::uo) is det. remove_init_files(Globals, Verbose, ModuleName, !Info, !IO) :- - globals.lookup_string_option(Globals, object_file_extension, ObjExt), - globals.lookup_string_option(Globals, pic_object_file_extension, - PicObjExt), - % XXX EXT remove_make_module_file(Globals, Verbose, ModuleName, - ext_other(other_ext("_init.c")), newext_target_init_c(ext_init_c), !Info, !IO), remove_make_module_file(Globals, Verbose, ModuleName, - ext_other(other_ext("_init" ++ ObjExt)), newext_target_init_obj(ext_init_obj_obj_opt), !Info, !IO), remove_make_module_file(Globals, Verbose, ModuleName, - ext_other(other_ext("_init" ++ PicObjExt)), newext_target_init_obj(ext_init_obj_pic_obj_opt), !Info, !IO). %---------------------------------------------------------------------------% @@ -2202,11 +2180,9 @@ make_module_clean(Globals, ModuleName, !Info, !IO) :- module_target_java_class_code], !Info, !IO), remove_make_module_file(Globals, very_verbose, ModuleName, - ext_other(other_ext(".used")), newext_misc_gs(ext_misc_gs_used), - !Info, !IO), + newext_misc_gs(ext_misc_gs_used), !Info, !IO), remove_make_module_file(Globals, very_verbose, ModuleName, - ext_other(other_ext(".prof")), newext_misc_ngs(ext_misc_ngs_prof), - !Info, !IO), + newext_misc_ngs(ext_misc_ngs_prof), !Info, !IO), get_module_dependencies(Globals, ModuleName, MaybeModuleDepInfo, !Info, !IO), @@ -2235,8 +2211,7 @@ make_module_clean(Globals, ModuleName, !Info, !IO) :- remove_fact_table_c_file(Globals, FactTableFile, !Info, !IO) :- fact_table_file_name(Globals, $pred, do_not_create_dirs, - other_ext(".c"), newext_target_c_cs(ext_target_c), - FactTableFile, FactTableCFile, !IO), + newext_target_c_cs(ext_target_c), FactTableFile, FactTableCFile, !IO), make_remove_file(Globals, very_verbose, FactTableCFile, !Info, !IO). :- pred remove_object_and_assembler_files(globals::in, module_name::in, @@ -2286,14 +2261,11 @@ make_module_realclean(Globals, ModuleName, !Info, !IO) :- ModuleName), Targets, !Info, !IO), remove_make_module_file(Globals, very_verbose, ModuleName, - ext_other(make_module_dep_file_extension), newext_misc_ngs(ext_misc_ngs_module_dep), !Info, !IO), remove_make_module_file(Globals, very_verbose, ModuleName, - ext_other(other_ext(".imdg")), newext_analysis(ext_an_imdg), - !Info, !IO), + newext_analysis(ext_an_imdg), !Info, !IO), remove_make_module_file(Globals, very_verbose, ModuleName, - ext_other(other_ext(".request")), newext_analysis(ext_an_request), - !Info, !IO). + newext_analysis(ext_an_request), !Info, !IO). %---------------------------------------------------------------------------% :- end_module make.program_target. diff --git a/compiler/make.track_flags.m b/compiler/make.track_flags.m index a8ac22224..aced0e70d 100644 --- a/compiler/make.track_flags.m +++ b/compiler/make.track_flags.m @@ -133,7 +133,6 @@ make_track_flags_files_for_module(Globals, ModuleName, Succeeded, ), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".track_flags")), newext_misc_gs(ext_misc_gs_track_flags), ModuleName, HashFileName, !IO), compare_hash_file(Globals, HashFileName, Hash, Same, !IO), diff --git a/compiler/make.util.m b/compiler/make.util.m index 76ab7e7b9..4923c7a78 100644 --- a/compiler/make.util.m +++ b/compiler/make.util.m @@ -75,8 +75,7 @@ % Find the extension for the timestamp file for the given target type, % if one exists. % -:- pred timestamp_extension(module_target_type::in, - other_ext::out, newext::out) is semidet. +:- pred timestamp_extension(module_target_type::in, newext::out) is semidet. %---------------------------------------------------------------------------% % @@ -147,7 +146,7 @@ % !Info, !IO). % :- pred remove_make_module_file(globals::in, option::in, module_name::in, - ext::in, newext::in, make_info::in, make_info::out, io::di, io::uo) is det. + newext::in, make_info::in, make_info::out, io::di, io::uo) is det. :- pred make_remove_file(globals::in, option::in, file_name::in, make_info::in, make_info::out, io::di, io::uo) is det. @@ -348,14 +347,14 @@ get_file_name(Globals, From, Search, TargetFile, FileName, !Info, !IO) :- else target_type_to_target_extension(Globals, TargetType, TargetExt), ( - TargetExt = extension(Ext, NewExt), + TargetExt = extension(NewExt), ( Search = do_not_search, module_name_to_file_name(Globals, From, do_not_create_dirs, - Ext, NewExt, ModuleName, FileName, !IO) + NewExt, ModuleName, FileName, !IO) ; Search = do_search, - module_name_to_search_file_name(Globals, From, Ext, NewExt, + module_name_to_search_file_name(Globals, From, NewExt, ModuleName, FileName, !IO) ) ; @@ -390,39 +389,32 @@ dependency_file_to_file_name(Globals, DepFile, FileName, !IO) :- linked_target_file_name(Globals, ModuleName, TargetType, FileName, !IO) :- ( TargetType = executable, - globals.lookup_string_option(Globals, executable_file_extension, Ext), module_name_to_file_name(Globals, $pred, do_not_create_dirs, - ext_other(other_ext(Ext)), newext_exec_gs(ext_exec_exec_opt), - ModuleName, FileName, !IO) + newext_exec_gs(ext_exec_exec_opt), ModuleName, FileName, !IO) ; TargetType = static_library, - globals.lookup_string_option(Globals, library_extension, Ext), module_name_to_lib_file_name(Globals, $pred, do_not_create_dirs, - "lib", other_ext(Ext), newext_lib_gs(ext_lib_gs_lib_opt), + "lib", newext_lib_gs(ext_lib_gs_lib_opt), ModuleName, FileName, !IO) ; TargetType = shared_library, - globals.lookup_string_option(Globals, shared_library_extension, Ext), module_name_to_lib_file_name(Globals, $pred, do_not_create_dirs, - "lib", other_ext(Ext), newext_lib_gs(ext_lib_gs_sh_lib_opt), + "lib", newext_lib_gs(ext_lib_gs_sh_lib_opt), ModuleName, FileName, !IO) ; TargetType = csharp_executable, module_name_to_file_name(Globals, $pred, do_not_create_dirs, - ext_other(other_ext(".exe")), newext_exec(ext_exec_exe), - ModuleName, FileName, !IO) + newext_exec(ext_exec_exe), ModuleName, FileName, !IO) ; TargetType = csharp_library, module_name_to_file_name(Globals, $pred, do_not_create_dirs, - ext_other(other_ext(".dll")), newext_lib_gs(ext_lib_gs_dll), - ModuleName, FileName, !IO) + newext_lib_gs(ext_lib_gs_dll), ModuleName, FileName, !IO) ; ( TargetType = java_archive ; TargetType = java_executable ), module_name_to_file_name(Globals, $pred, do_not_create_dirs, - ext_other(other_ext(".jar")), newext_lib_gs(ext_lib_gs_jar), - ModuleName, FileName, !IO) + newext_lib_gs(ext_lib_gs_jar), ModuleName, FileName, !IO) ). :- pred module_target_to_file_name(globals::in, string::in, @@ -433,8 +425,8 @@ module_target_to_file_name(Globals, From, MkDir, TargetType, ModuleName, FileName, !IO) :- target_type_to_target_extension(Globals, TargetType, TargetExt), ( - TargetExt = extension(Ext, NewExt), - module_name_to_file_name(Globals, From, MkDir, Ext, NewExt, + TargetExt = extension(NewExt), + module_name_to_file_name(Globals, From, MkDir, NewExt, ModuleName, FileName, !IO) ; TargetExt = foreign_obj(PIC, Lang), @@ -443,9 +435,9 @@ module_target_to_file_name(Globals, From, MkDir, TargetType, module_target_object_code(PIC), ForeignModuleName, FileName, !IO) ; TargetExt = fact_table_obj(PIC, FactFile), - maybe_pic_object_file_extension(Globals, PIC, OtherExt, ObjNewExt, _), + maybe_pic_object_file_extension(PIC, ObjNewExt, _), fact_table_file_name(Globals, $pred, MkDir, - OtherExt, newext_target_obj(ObjNewExt), FactFile, FileName, !IO) + newext_target_obj(ObjNewExt), FactFile, FileName, !IO) ). :- pred module_target_to_search_file_name(globals::in, string::in, @@ -456,8 +448,8 @@ module_target_to_search_file_name(Globals, From, TargetType, ModuleName, FileName, !IO) :- target_type_to_target_extension(Globals, TargetType, TargetExt), ( - TargetExt = extension(Ext, NewExt), - module_name_to_search_file_name(Globals, From, Ext, NewExt, + TargetExt = extension(NewExt), + module_name_to_search_file_name(Globals, From, NewExt, ModuleName, FileName, !IO) ; TargetExt = foreign_obj(PIC, Lang), @@ -466,16 +458,16 @@ module_target_to_search_file_name(Globals, From, TargetType, ModuleName, module_target_object_code(PIC), ForeignModuleName, FileName, !IO) ; TargetExt = fact_table_obj(PIC, FactFile), - maybe_pic_object_file_extension(Globals, PIC, OtherExt, ObjNewExt, _), + maybe_pic_object_file_extension(PIC, ObjNewExt, _), % XXX This call ignores the implicit do_search setting. fact_table_file_name(Globals, $pred, do_not_create_dirs, - OtherExt, newext_target_obj(ObjNewExt), FactFile, FileName, !IO) + newext_target_obj(ObjNewExt), FactFile, FileName, !IO) ). %---------------------------------------------------------------------------% :- type target_extension - ---> extension(ext, newext) + ---> extension(newext) ; foreign_obj(pic, foreign_language) ; fact_table_obj(pic, string). @@ -489,73 +481,57 @@ target_type_to_target_extension(Globals, Target, TargetExt) :- require_complete_switch [Target] ( Target = module_target_source, - TargetExt = extension(ext_src, newext_src) + TargetExt = extension(newext_src) ; Target = module_target_errors, - TargetExt = extension(ext_other(other_ext(".err")), - newext_user(ext_user_err)) + TargetExt = extension(newext_user(ext_user_err)) ; Target = module_target_int0, - TargetExt = extension(ext_other(other_ext(".int0")), - newext_int(ext_int_int0)) + TargetExt = extension(newext_int(ext_int_int0)) ; Target = module_target_int1, - TargetExt = extension(ext_other(other_ext(".int")), - newext_int(ext_int_int1)) + TargetExt = extension(newext_int(ext_int_int1)) ; Target = module_target_int2, - TargetExt = extension(ext_other(other_ext(".int2")), - newext_int(ext_int_int2)) + TargetExt = extension(newext_int(ext_int_int2)) ; Target = module_target_int3, - TargetExt = extension(ext_other(other_ext(".int3")), - newext_int(ext_int_int3)) + TargetExt = extension(newext_int(ext_int_int3)) ; Target = module_target_opt, - TargetExt = extension(ext_other(other_ext(".opt")), - newext_opt(ext_opt_plain)) + TargetExt = extension(newext_opt(ext_opt_plain)) ; Target = module_target_analysis_registry, - TargetExt = extension(ext_other(other_ext(".analysis")), - newext_analysis(ext_an_analysis)) + TargetExt = extension(newext_analysis(ext_an_analysis)) ; Target = module_target_track_flags, - TargetExt = extension(ext_other(other_ext(".track_flags")), - newext_misc_gs(ext_misc_gs_track_flags)) + TargetExt = extension(newext_misc_gs(ext_misc_gs_track_flags)) ; Target = module_target_c_header(header_mih), - TargetExt = extension(ext_other(other_ext(".mih")), - newext_mih(ext_mih_mih)) + TargetExt = extension(newext_mih(ext_mih_mih)) ; Target = module_target_c_header(header_mh), - TargetExt = extension(ext_other(other_ext(".mh")), - newext_mh(ext_mh_mh)) + TargetExt = extension(newext_mh(ext_mh_mh)) ; Target = module_target_c_code, - TargetExt = extension(ext_other(other_ext(".c")), - newext_target_c_cs(ext_target_c)) + TargetExt = extension(newext_target_c_cs(ext_target_c)) ; Target = module_target_csharp_code, % XXX ".exe" if the module contains main. - TargetExt = extension(ext_other(other_ext(".cs")), - newext_target_c_cs(ext_target_cs)) + TargetExt = extension(newext_target_c_cs(ext_target_cs)) ; Target = module_target_java_code, - TargetExt = extension(ext_other(other_ext(".java")), - newext_target_java(ext_target_java_java)) + TargetExt = extension(newext_target_java(ext_target_java_java)) ; Target = module_target_java_class_code, - TargetExt = extension(ext_other(other_ext(".class")), - newext_target_java(ext_target_java_class)) + TargetExt = extension(newext_target_java(ext_target_java_class)) ; Target = module_target_object_code(PIC), - maybe_pic_object_file_extension(Globals, PIC, OtherExt, ObjNewExt, _), - TargetExt = extension(ext_other(OtherExt), - newext_target_obj(ObjNewExt)) + maybe_pic_object_file_extension(PIC, ObjNewExt, _), + TargetExt = extension( newext_target_obj(ObjNewExt)) ; Target = module_target_xml_doc, - TargetExt = extension(ext_other(other_ext(".xml")), - newext_user_ngs(ext_user_ngs_xml)) + TargetExt = extension(newext_user_ngs(ext_user_ngs_xml)) ; Target = module_target_foreign_object(PIC, Lang), TargetExt = foreign_obj(PIC, Lang) @@ -632,7 +608,7 @@ target_extension_synonym(".csharp", module_target_csharp_code). % Currently the ".cs" extension is still treated as the build-all target % for C files, so we accept ".csharp" for C# files. -timestamp_extension(ModuleTargetType, other_ext(ExtStr), NewExt) :- +timestamp_extension(ModuleTargetType, NewExt) :- % XXX EXT The absence of code handling .trans_opt_date files % would seem to me (zs) to be a bug. ( @@ -640,27 +616,21 @@ timestamp_extension(ModuleTargetType, other_ext(ExtStr), NewExt) :- % We need a timestamp file for `.err' files because errors are written % to the `.err' file even when writing interfaces. The timestamp % is only updated when compiling to target code. - ExtStr = ".err_date", NewExt = newext_misc_ngs(ext_misc_ngs_err_date) ; ModuleTargetType = module_target_int0, - ExtStr = ".date0", NewExt = newext_int(ext_int_date_int0) ; ModuleTargetType = module_target_int1, - ExtStr = ".date", NewExt = newext_int(ext_int_date_int12) ; ModuleTargetType = module_target_int2, - ExtStr = ".date", NewExt = newext_int(ext_int_date_int12) ; ModuleTargetType = module_target_int3, - ExtStr = ".date3", NewExt = newext_int(ext_int_date_int3) ; ModuleTargetType = module_target_opt, - ExtStr = ".optdate", NewExt = newext_opt(ext_opt_date_plain) ; ModuleTargetType = module_target_analysis_registry, @@ -668,7 +638,6 @@ timestamp_extension(ModuleTargetType, other_ext(ExtStr), NewExt) :- % can be modified in the process of analysing _another_ module. % The timestamp is only updated after actually analysing the module % that the `.analysis' file corresponds to. - ExtStr = ".analysis_date", NewExt = newext_analysis(ext_an_date) ; % Header files share a timestamp file with their corresponding @@ -676,15 +645,12 @@ timestamp_extension(ModuleTargetType, other_ext(ExtStr), NewExt) :- ( ModuleTargetType = module_target_c_code ; ModuleTargetType = module_target_c_header(_) ), - ExtStr = ".c_date", NewExt = newext_target_date(ext_target_date_c) ; ModuleTargetType = module_target_csharp_code, - ExtStr = ".cs_date", NewExt = newext_target_date(ext_target_date_cs) ; ModuleTargetType = module_target_java_code, - ExtStr = ".java_date", NewExt = newext_target_date(ext_target_date_java) ). @@ -697,12 +663,9 @@ init_target_file_timestamps = get_timestamp_file_timestamp(Globals, target_file(ModuleName, TargetType), MaybeTimestamp, !Info, !IO) :- - ( if - timestamp_extension(TargetType, TimestampOtherExt, TimestampNewExt) - then + ( if timestamp_extension(TargetType, TimestampNewExt) then module_name_to_file_name(Globals, $pred, do_not_create_dirs, - ext_other(TimestampOtherExt), TimestampNewExt, - ModuleName, FileName, !IO) + TimestampNewExt, ModuleName, FileName, !IO) else module_target_to_file_name(Globals, $pred, do_not_create_dirs, TargetType, ModuleName, FileName, !IO) @@ -977,20 +940,18 @@ remove_make_target_file_by_name(Globals, From, VerboseOption, module_target_to_file_name(Globals, From, do_not_create_dirs, TargetType, ModuleName, FileName, !IO), make_remove_file(Globals, VerboseOption, FileName, !Info, !IO), - ( if - timestamp_extension(TargetType, TimestampOtherExt, TimestampNewExt) - then + ( if timestamp_extension(TargetType, TimestampNewExt) then remove_make_module_file(Globals, VerboseOption, ModuleName, - ext_other(TimestampOtherExt), TimestampNewExt, !Info, !IO) + TimestampNewExt, !Info, !IO) else true ). %---------------------% -remove_make_module_file(Globals, VerboseOption, ModuleName, Ext, NewExt, +remove_make_module_file(Globals, VerboseOption, ModuleName, NewExt, !Info, !IO) :- - module_name_to_file_name(Globals, $pred, do_not_create_dirs, Ext, NewExt, + module_name_to_file_name(Globals, $pred, do_not_create_dirs, NewExt, ModuleName, FileName, !IO), make_remove_file(Globals, VerboseOption, FileName, !Info, !IO). diff --git a/compiler/mercury_compile_front_end.m b/compiler/mercury_compile_front_end.m index 1d106f999..12887fce5 100644 --- a/compiler/mercury_compile_front_end.m +++ b/compiler/mercury_compile_front_end.m @@ -512,8 +512,7 @@ create_and_write_opt_file(ProgressStream, ErrorStream, IntermodAnalysis, Globals, !HLDS, !DumpInfo, !Specs, !IO) :- module_info_get_name(!.HLDS, ModuleName), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".opt")), newext_opt(ext_opt_plain), - ModuleName, OptFileName, !IO), + newext_opt(ext_opt_plain), ModuleName, OptFileName, !IO), TmpOptFileName = OptFileName ++ ".tmp", io.open_output(TmpOptFileName, OpenResult, !IO), @@ -566,8 +565,7 @@ create_and_write_opt_file(ProgressStream, ErrorStream, IntermodAnalysis, update_interface_report_any_error(Globals, ModuleName, OptFileName, _UpdateSucceeded, !IO), touch_interface_datestamp(Globals, ProgressStream, ErrorStream, - ModuleName, other_ext(".optdate"), newext_opt(ext_opt_date_plain), - _TouchSucceeded, !IO), + ModuleName, newext_opt(ext_opt_date_plain), _TouchSucceeded, !IO), globals.lookup_bool_option(Globals, experiment5, Experiment5), ( @@ -611,8 +609,7 @@ mark_entities_in_opt_file_as_opt_exported(IntermodAnalysis, UseOptFiles = yes, module_info_get_name(!.HLDS, ModuleName), module_name_to_search_file_name(Globals, $pred, - ext_other(other_ext(".opt")), newext_opt(ext_opt_plain), - ModuleName, OptFileName, !IO), + newext_opt(ext_opt_plain), ModuleName, OptFileName, !IO), globals.lookup_accumulating_option(Globals, intermod_directories, IntermodDirs), search_for_file_returning_dir(IntermodDirs, OptFileName, @@ -1200,11 +1197,9 @@ maybe_write_call_tree(ProgressStream, ErrorStream, Verbose, Stats, "% Writing call_tree...", !IO), module_info_get_name(HLDS, ModuleName), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".local_call_tree")), newext_user_ngs(ext_user_ngs_lct), ModuleName, TreeFileName, !IO), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".local_call_tree_order")), newext_user_ngs(ext_user_ngs_lct_order), ModuleName, OrderFileName, !IO), io.open_output(TreeFileName, TreeResult, !IO), diff --git a/compiler/mercury_compile_llds_back_end.m b/compiler/mercury_compile_llds_back_end.m index 7a79575a9..c06cb22e2 100644 --- a/compiler/mercury_compile_llds_back_end.m +++ b/compiler/mercury_compile_llds_back_end.m @@ -886,8 +886,7 @@ make_foreign_import_header_code(Globals, FIMSpec, Include, !IO) :- ( Lang = lang_c, module_name_to_search_file_name(Globals, $pred, - ext_other(other_ext(".mh")), newext_mh(ext_mh_mh), - ModuleName, HeaderFileName, !IO), + newext_mh(ext_mh_mh), ModuleName, HeaderFileName, !IO), IncludeString = "#include """ ++ HeaderFileName ++ """\n", Include = foreign_decl_code(lang_c, foreign_decl_is_exported, floi_literal(IncludeString), dummy_context) @@ -932,13 +931,11 @@ llds_c_to_obj(Globals, ProgressStream, ErrorStream, ModuleName, Succeeded, !IO) :- get_linked_target_type(Globals, LinkedTargetType), get_object_code_type(Globals, LinkedTargetType, PIC), - maybe_pic_object_file_extension(Globals, PIC, ObjOtherExt, ObjNewExt, _), + maybe_pic_object_file_extension(PIC, ObjNewExt, _), module_name_to_file_name(Globals, $pred, do_not_create_dirs, - ext_other(other_ext(".c")), newext_target_c_cs(ext_target_c), - ModuleName, C_File, !IO), + newext_target_c_cs(ext_target_c), ModuleName, C_File, !IO), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(ObjOtherExt), newext_target_obj(ObjNewExt), - ModuleName, O_File, !IO), + newext_target_obj(ObjNewExt), ModuleName, O_File, !IO), compile_target_code.do_compile_c_file(Globals, ProgressStream, ErrorStream, PIC, C_File, O_File, Succeeded, !IO). @@ -950,11 +947,11 @@ compile_fact_table_file(Globals, ProgressStream, ErrorStream, BaseName, O_FileName, Succeeded, !IO) :- get_linked_target_type(Globals, LinkedTargetType), get_object_code_type(Globals, LinkedTargetType, PIC), - maybe_pic_object_file_extension(Globals, PIC, ObjOtherExt, NewExtObj, _), + maybe_pic_object_file_extension(PIC, NewExtObj, _), % XXX EXT C_FileName = BaseName ++ ".c", O_FileName = BaseName ++ extension_to_string(Globals, - ext_other(ObjOtherExt), newext_target_obj(NewExtObj)), + newext_target_obj(NewExtObj)), compile_target_code.do_compile_c_file(Globals, ProgressStream, ErrorStream, PIC, C_FileName, O_FileName, Succeeded, !IO). diff --git a/compiler/mercury_compile_main.m b/compiler/mercury_compile_main.m index 1504c0697..7d7e36ba4 100644 --- a/compiler/mercury_compile_main.m +++ b/compiler/mercury_compile_main.m @@ -152,9 +152,6 @@ real_main(!IO) :- io.set_exit_status(1, !IO) ), record_instmap_delta_restrict_stats(!IO), - trace [compile_time(flag("file_name_translations")), io(!TIO)] ( - write_translations_record_if_any(!TIO) - ), close_any_specific_compiler_streams(!IO). % Expand @File arguments. @@ -288,7 +285,10 @@ real_main_after_expansion(ProgressStream, ErrorStream, CmdLineArgs, !IO) :- ; Specs = [], main_after_setup(ProgressStream, ErrorStream, ActualGlobals, - DetectedGradeFlags, Variables, OptionArgs, NonOptionArgs, !IO) + DetectedGradeFlags, Variables, OptionArgs, NonOptionArgs, !IO), + trace [compile_time(flag("file_name_translations")), io(!TIO)] ( + write_translations_record_if_any(ActualGlobals, !TIO) + ) ) ; MaybeMCFlags = no, @@ -548,14 +548,6 @@ main_after_setup(ProgressStream, ErrorStream, Globals, DetectedGradeFlags, io.stdout_stream(StdOutStream, !IO), display_compiler_version(StdOutStream, !IO) else - globals.lookup_bool_option(Globals, experiment4, Experiment4), - ( - Experiment4 = no - ; - Experiment4 = yes, - test_file_name_extensions(Globals, ErrorStream, !IO) - ), - globals.get_op_mode(Globals, OpMode), HaveReadModuleMaps0 = init_have_read_module_maps, Specs0 = [], @@ -1143,7 +1135,7 @@ do_process_compiler_arg(ProgressStream, ErrorStream, Globals0, else ModuleName = ParseTreeSrc ^ pts_module_name, module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".ugly")), newext_user(ext_user_ugly), + newext_user(ext_user_ugly), ModuleName, OutputFileName, !IO), output_parse_tree_src(ProgressStream, ErrorStream, Globals, OutputFileName, ParseTreeSrc, _Succeeded, !IO) @@ -1312,28 +1304,25 @@ find_smart_recompilation_target_files(Globals, FindTargetFiles) :- globals.get_target(Globals, CompilationTarget), ( CompilationTarget = target_c, - TargetOtherExt = other_ext(".c"), TargetNewExt = newext_target_c_cs(ext_target_c) ; CompilationTarget = target_csharp, - TargetOtherExt = other_ext(".cs"), TargetNewExt = newext_target_c_cs(ext_target_cs) ; CompilationTarget = target_java, - TargetOtherExt = other_ext(".java"), TargetNewExt = newext_target_java(ext_target_java_java) ), FindTargetFiles = - usual_find_target_files(Globals, TargetOtherExt, TargetNewExt). + usual_find_target_files(Globals, TargetNewExt). -:- pred usual_find_target_files(globals::in, other_ext::in, newext::in, +:- pred usual_find_target_files(globals::in, newext::in, module_name::in, list(file_name)::out, io::di, io::uo) is det. -usual_find_target_files(Globals, TargetOtherExt, TargetNewExt, +usual_find_target_files(Globals, TargetNewExt, ModuleName, TargetFiles, !IO) :- % XXX Should we check the generated header files? module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(TargetOtherExt), TargetNewExt, ModuleName, FileName, !IO), + TargetNewExt, ModuleName, FileName, !IO), TargetFiles = [FileName]. :- pred find_timestamp_files(globals::in, @@ -1343,28 +1332,24 @@ find_timestamp_files(Globals, FindTimestampFiles) :- globals.get_target(Globals, CompilationTarget), ( CompilationTarget = target_c, - TimestampOtherExt = other_ext(".c_date"), TimestampNewExt = newext_target_date(ext_target_date_c) ; CompilationTarget = target_csharp, - TimestampOtherExt = other_ext(".cs_date"), TimestampNewExt = newext_target_date(ext_target_date_cs) ; CompilationTarget = target_java, - TimestampOtherExt = other_ext(".java_date"), TimestampNewExt = newext_target_date(ext_target_date_java) ), FindTimestampFiles = - find_timestamp_files_2(Globals, TimestampOtherExt, TimestampNewExt). + find_timestamp_files_2(Globals, TimestampNewExt). -:- pred find_timestamp_files_2(globals::in, other_ext::in, newext::in, +:- pred find_timestamp_files_2(globals::in, newext::in, module_name::in, list(file_name)::out, io::di, io::uo) is det. -find_timestamp_files_2(Globals, TimestampOtherExt, TimestampNewExt, +find_timestamp_files_2(Globals, TimestampNewExt, ModuleName, TimestampFiles, !IO) :- module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(TimestampOtherExt), TimestampNewExt, - ModuleName, FileName, !IO), + TimestampNewExt, ModuleName, FileName, !IO), TimestampFiles = [FileName]. %---------------------------------------------------------------------------% @@ -1882,7 +1867,6 @@ maybe_write_dependency_graph(ProgressStream, ErrorStream, Verbose, Stats, "% Writing dependency graph...", !IO), module_info_get_name(!.HLDS, ModuleName), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".dependency_graph")), newext_user(ext_user_depgraph), ModuleName, FileName, !IO), io.open_output(FileName, Res, !IO), ( @@ -1972,8 +1956,7 @@ after_front_end_passes(ProgressStream, ErrorStream, Globals, OpModeCodeGen, module_info_get_name(!.HLDS, ModuleName), module_name_to_file_name(Globals, $pred, do_not_create_dirs, - ext_other(other_ext(".used")), newext_misc_gs(ext_misc_gs_used), - ModuleName, UsageFileName, !IO), + newext_misc_gs(ext_misc_gs_used), ModuleName, UsageFileName, !IO), io.file.remove_file(UsageFileName, _, !IO), FrontEndErrors = @@ -2011,7 +1994,7 @@ after_front_end_passes(ProgressStream, ErrorStream, Globals, OpModeCodeGen, ; TargetCodeSucceeded = succeeded, module_name_to_file_name(Globals, $pred, - do_not_create_dirs, ext_other(other_ext(".java")), + do_not_create_dirs, newext_target_java(ext_target_java_java), ModuleName, JavaFile, !IO), compile_java_files(Globals, ProgressStream, ErrorStream, @@ -2047,16 +2030,14 @@ after_front_end_passes(ProgressStream, ErrorStream, Globals, OpModeCodeGen, ; TargetCodeSucceeded = succeeded, module_name_to_file_name(Globals, $pred, - do_not_create_dirs, ext_other(other_ext(".c")), + do_not_create_dirs, newext_target_c_cs(ext_target_c), ModuleName, C_File, !IO), get_linked_target_type(Globals, TargetType), get_object_code_type(Globals, TargetType, PIC), - maybe_pic_object_file_extension(Globals, PIC, - ObjOtherExt, ObjNewExt, _), + maybe_pic_object_file_extension(PIC, ObjNewExt, _), module_name_to_file_name(Globals, $pred, - do_create_dirs, ext_other(ObjOtherExt), - newext_target_obj(ObjNewExt), + do_create_dirs, newext_target_obj(ObjNewExt), ModuleName, O_File, !IO), do_compile_c_file(Globals, ProgressStream, ErrorStream, PIC, C_File, O_File, Succeeded, !IO), @@ -2132,8 +2113,7 @@ maybe_output_prof_call_graph(ProgressStream, ErrorStream, Verbose, Stats, maybe_flush_output(ProgressStream, Verbose, !IO), module_info_get_name(!.HLDS, ModuleName), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".prof")), newext_misc_ngs(ext_misc_ngs_prof), - ModuleName, ProfFileName, !IO), + newext_misc_ngs(ext_misc_ngs_prof), ModuleName, ProfFileName, !IO), io.open_output(ProfFileName, Res, !IO), ( Res = ok(FileStream), diff --git a/compiler/mercury_compile_make_hlds.m b/compiler/mercury_compile_make_hlds.m index 0072614d0..0452e76ed 100644 --- a/compiler/mercury_compile_make_hlds.m +++ b/compiler/mercury_compile_make_hlds.m @@ -359,7 +359,7 @@ maybe_read_d_file_for_trans_opt_deps(ProgressStream, ErrorStream, Globals, TransOpt = yes, globals.lookup_bool_option(Globals, verbose, Verbose), module_name_to_file_name(Globals, $pred, do_not_create_dirs, - ext_other(other_ext(".d")), newext_mmake_fragment(ext_mf_d), + newext_mmake_fragment(ext_mf_d), ModuleName, DependencyFileName, !IO), ( Verbose = yes, @@ -374,7 +374,6 @@ maybe_read_d_file_for_trans_opt_deps(ProgressStream, ErrorStream, Globals, ( DepFileOpenResult = ok(DepFileInStream), module_name_to_file_name(Globals, $pred, do_not_create_dirs, - ext_other(other_ext(".trans_opt_date")), newext_opt(ext_opt_date_trans), ModuleName, TransOptDateFileName, !IO), SearchPattern = TransOptDateFileName ++ " :", @@ -595,8 +594,7 @@ make_hlds(ProgressStream, ErrorStream, Globals, AugCompUnit, EventSet, MQInfo, ParseTreeModuleSrc = AugCompUnit ^ acu_module_src, ModuleName = ParseTreeModuleSrc ^ ptms_module_name, module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".hlds_dump")), newext_user(ext_user_hlds_dump), - ModuleName, DumpBaseFileName, !IO), + newext_user(ext_user_hlds_dump), ModuleName, DumpBaseFileName, !IO), parse_tree_to_hlds(AugCompUnit, Globals, DumpBaseFileName, MQInfo, TypeEqvMap, UsedModules, QualInfo, FoundInvalidType, FoundInvalidInstOrMode, !:HLDS, MakeSpecs), @@ -635,7 +633,6 @@ maybe_write_definitions(ProgressStream, ErrorStream, Verbose, Stats, "% Writing definitions...", !IO), module_info_get_name(HLDS, ModuleName), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".defns")), newext_user_ngs(ext_user_ngs_defns), ModuleName, FileName, !IO), io.open_output(FileName, Res, !IO), ( @@ -669,7 +666,6 @@ maybe_write_definition_line_counts(ProgressStream, ErrorStream, Verbose, Stats, "% Writing definition line counts...", !IO), module_info_get_name(HLDS, ModuleName), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".defn_line_counts")), newext_user_ngs(ext_user_ngs_defn_lc), ModuleName, FileName, !IO), io.open_output(FileName, Res, !IO), ( @@ -702,7 +698,6 @@ maybe_write_definition_extents(ProgressStream, ErrorStream, Verbose, Stats, "% Writing definition extents...", !IO), module_info_get_name(HLDS, ModuleName), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".defn_extents")), newext_user_ngs(ext_user_ngs_defn_ext), ModuleName, FileName, !IO), io.open_output(FileName, Res, !IO), ( diff --git a/compiler/mercury_compile_middle_passes.m b/compiler/mercury_compile_middle_passes.m index 3752ebb88..63fb197e9 100644 --- a/compiler/mercury_compile_middle_passes.m +++ b/compiler/mercury_compile_middle_passes.m @@ -454,8 +454,7 @@ output_trans_opt_file(ProgressStream, ErrorStream, !.HLDS, !Specs, module_info_get_name(!.HLDS, ModuleName), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".trans_opt")), newext_opt(ext_opt_trans), - ModuleName, OptFileName, !IO), + newext_opt(ext_opt_trans), ModuleName, OptFileName, !IO), TmpOptFileName = OptFileName ++ ".tmp", io.open_output(TmpOptFileName, TmpOptResult, !IO), ( @@ -473,8 +472,7 @@ output_trans_opt_file(ProgressStream, ErrorStream, !.HLDS, !Specs, update_interface_report_any_error(Globals, ModuleName, OptFileName, _UpdateSucceeded, !IO), touch_interface_datestamp(Globals, ProgressStream, ErrorStream, - ModuleName, other_ext(".trans_opt_date"), - newext_opt(ext_opt_date_trans), _TouchSucceeded, !IO), + ModuleName, newext_opt(ext_opt_date_trans), _TouchSucceeded, !IO), globals.lookup_bool_option(Globals, experiment5, Experiment5), ( @@ -846,9 +844,7 @@ maybe_bytecodes(ProgressStream, HLDS0, Verbose, Stats, !DumpInfo, !IO) :- maybe_report_stats(ProgressStream, Stats, !IO), module_info_get_name(HLDS1, ModuleName), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".bytedebug")), - newext_bytecode(ext_bc_bytedebug), - ModuleName, BytedebugFile, !IO), + newext_bytecode(ext_bc_bytedebug), ModuleName, BytedebugFile, !IO), maybe_write_string(ProgressStream, Verbose, "% Writing bytecodes to `", !IO), maybe_write_string(ProgressStream, Verbose, BytedebugFile, !IO), @@ -857,8 +853,7 @@ maybe_bytecodes(ProgressStream, HLDS0, Verbose, Stats, !DumpInfo, !IO) :- debug_bytecode_file(BytedebugFile, Bytecode, !IO), maybe_write_string(ProgressStream, Verbose, " done.\n", !IO), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".mbc")), newext_bytecode(ext_bc_mbc), - ModuleName, BytecodeFile, !IO), + newext_bytecode(ext_bc_mbc), ModuleName, BytecodeFile, !IO), maybe_write_string(ProgressStream, Verbose, "% Writing bytecodes to `", !IO), maybe_write_string(ProgressStream, Verbose, BytecodeFile, !IO), diff --git a/compiler/mercury_compile_mlds_back_end.m b/compiler/mercury_compile_mlds_back_end.m index 4a63db10f..a1ccebac7 100644 --- a/compiler/mercury_compile_mlds_back_end.m +++ b/compiler/mercury_compile_mlds_back_end.m @@ -450,7 +450,6 @@ maybe_dump_mlds(ProgressStream, Globals, MLDS, StageNum, StageName, !IO) :- "% Dumping out raw MLDS...\n", !IO), ModuleName = mlds_get_module_name(MLDS), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".mlds_dump")), newext_user(ext_user_mlds_dump), ModuleName, DumpBaseFileName, !IO), string.format("%s.%s-%s", diff --git a/compiler/mlds_to_c_file.m b/compiler/mlds_to_c_file.m index bfd138669..1c4c2d89f 100644 --- a/compiler/mlds_to_c_file.m +++ b/compiler/mlds_to_c_file.m @@ -129,8 +129,7 @@ output_c_file_opts(MLDS, Opts, Suffix, Succeeded, !IO) :- ModuleName = mlds_get_module_name(MLDS), Globals = Opts ^ m2co_all_globals, module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".c")), newext_target_c_cs(ext_target_c), - ModuleName, SourceFileName0, !IO), + newext_target_c_cs(ext_target_c), ModuleName, SourceFileName0, !IO), SourceFileName = SourceFileName0 ++ Suffix, Indent = 0, output_to_file_stream(Globals, ModuleName, SourceFileName, @@ -147,8 +146,7 @@ output_c_header_file_opts(MLDS, Opts, Suffix, !:Succeeded, !IO) :- ModuleName = mlds_get_module_name(MLDS), Globals = Opts ^ m2co_all_globals, module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".mih")), newext_mih(ext_mih_mih), - ModuleName, MihFileName, !IO), + newext_mih(ext_mih_mih), ModuleName, MihFileName, !IO), HeaderFileName = MihFileName ++ Suffix, TmpHeaderFileName = HeaderFileName ++ ".tmp", globals.lookup_bool_option(Globals, line_numbers_for_c_headers, @@ -174,8 +172,7 @@ output_c_dump_preds(MLDS, Globals, TargetOrDump, Suffix, DumpPredNames, !IO) :- module_name_to_source_file_name(ModuleName, SourceFileName, !IO), Opts = init_mlds_to_c_opts(Globals, SourceFileName, TargetOrDump), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".mlds_dump")), newext_user(ext_user_mlds_dump), - ModuleName, DumpBaseName, !IO), + newext_user(ext_user_mlds_dump), ModuleName, DumpBaseName, !IO), DumpFileName = DumpBaseName ++ Suffix, MLDS_ModuleName = mercury_module_name_to_mlds(ModuleName), ProcDefns = MLDS ^ mlds_proc_defns, @@ -316,11 +313,9 @@ mlds_output_src_import(Opts, Stream, _Indent, Import, !IO) :- Import = mlds_import(ImportType, ModuleName0), ( ImportType = user_visible_interface, - HeaderOtherExt = other_ext(".mh"), HeaderNewExt = newext_mh(ext_mh_mh) ; ImportType = compiler_visible_interface, - HeaderOtherExt = other_ext(".mih"), HeaderNewExt = newext_mih(ext_mih_mih) ), @@ -336,7 +331,7 @@ mlds_output_src_import(Opts, Stream, _Indent, Import, !IO) :- Globals = Opts ^ m2co_all_globals, module_name_to_search_file_name(Globals, $pred, - ext_other(HeaderOtherExt), HeaderNewExt, ModuleName, HeaderFile, !IO), + HeaderNewExt, ModuleName, HeaderFile, !IO), io.format(Stream, "#include \"%s\"\n", [s(HeaderFile)], !IO). % Generate the `.c' file. diff --git a/compiler/mlds_to_cs_file.m b/compiler/mlds_to_cs_file.m index 23fa47398..0ad31a098 100644 --- a/compiler/mlds_to_cs_file.m +++ b/compiler/mlds_to_cs_file.m @@ -78,8 +78,7 @@ output_csharp_mlds(ModuleInfo, MLDS, Succeeded, !IO) :- module_info_get_globals(ModuleInfo, Globals), ModuleName = mlds_get_module_name(MLDS), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".cs")), newext_target_c_cs(ext_target_cs), - ModuleName, SourceFileName, !IO), + newext_target_c_cs(ext_target_cs), ModuleName, SourceFileName, !IO), output_to_file_stream(Globals, ModuleName, SourceFileName, output_csharp_src_file(ModuleInfo, MLDS), Succeeded, !IO). diff --git a/compiler/mlds_to_java_file.m b/compiler/mlds_to_java_file.m index f18d0c5d9..84b3ff29d 100644 --- a/compiler/mlds_to_java_file.m +++ b/compiler/mlds_to_java_file.m @@ -130,7 +130,6 @@ output_java_mlds(ModuleInfo, MLDS, Succeeded, !IO) :- module_info_get_globals(ModuleInfo, Globals), ModuleName = mlds_get_module_name(MLDS), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".java")), newext_target_java(ext_target_java_java), ModuleName, JavaSourceFileName, !IO), output_to_file_stream(Globals, ModuleName, JavaSourceFileName, diff --git a/compiler/mmc_analysis.m b/compiler/mmc_analysis.m index 2b551b99f..b888f26ef 100644 --- a/compiler/mmc_analysis.m +++ b/compiler/mmc_analysis.m @@ -106,36 +106,35 @@ unit1 : unit(structure_reuse_answer)) ), - module_name_to_read_file_name(mmc, Globals, OtherExt, NewExt, + module_name_to_read_file_name(mmc, Globals, NewExt, ModuleName, MaybeFileName, !IO) :- - mmc_module_name_to_read_file_name(Globals, OtherExt, NewExt, + mmc_module_name_to_read_file_name(Globals, NewExt, ModuleName, MaybeFileName, !IO), - module_name_to_write_file_name(mmc, Globals, OtherExt, NewExt, + module_name_to_write_file_name(mmc, Globals, NewExt, ModuleName, FileName, !IO) :- - mmc_module_name_to_write_file_name(Globals, OtherExt, NewExt, + mmc_module_name_to_write_file_name(Globals, NewExt, ModuleName, FileName, !IO) ]. :- pred mmc_module_name_to_read_file_name(globals::in, - other_ext::in, newext::in, module_name::in, maybe_error(string)::out, + newext::in, module_name::in, maybe_error(string)::out, io::di, io::uo) is det. -mmc_module_name_to_read_file_name(Globals, OtherExt, NewExt, +mmc_module_name_to_read_file_name(Globals, NewExt, ModuleName, MaybeFileName, !IO) :- - module_name_to_search_file_name(Globals, $pred, - ext_other(OtherExt), NewExt, ModuleName, FileName0, !IO), + module_name_to_search_file_name(Globals, $pred, NewExt, + ModuleName, FileName0, !IO), globals.lookup_accumulating_option(Globals, intermod_directories, Dirs), search_for_file(Dirs, FileName0, MaybeFileName, !IO). :- pred mmc_module_name_to_write_file_name(globals::in, - other_ext::in, newext::in, module_name::in, string::out, - io::di, io::uo) is det. + newext::in, module_name::in, string::out, io::di, io::uo) is det. -mmc_module_name_to_write_file_name(Globals, OtherExt, NewExt, +mmc_module_name_to_write_file_name(Globals, NewExt, ModuleName, FileName, !IO) :- - module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(OtherExt), NewExt, ModuleName, FileName, !IO). + module_name_to_file_name(Globals, $pred, do_create_dirs, NewExt, + ModuleName, FileName, !IO). module_name_func_id(ModuleInfo, proc(PredId, ProcId), PredModule, FuncId) :- module_info_pred_info(ModuleInfo, PredId, PredInfo), diff --git a/compiler/mode_constraints.m b/compiler/mode_constraints.m index 4a72a487b..a7f0b00fc 100644 --- a/compiler/mode_constraints.m +++ b/compiler/mode_constraints.m @@ -198,9 +198,7 @@ dump_abstract_constraints(ModuleInfo, ConstraintVarSet, ModeConstraints, module_info_get_globals(ModuleInfo, Globals), module_info_get_name(ModuleInfo, ModuleName), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".mode_constraints")), - newext_user_ngs(ext_user_ngs_mode_constr), - ModuleName, FileName, !IO), + newext_user_ngs(ext_user_ngs_mode_constr), ModuleName, FileName, !IO), OutputFile = FileName, io.open_output(OutputFile, IOResult, !IO), diff --git a/compiler/module_cmds.m b/compiler/module_cmds.m index 729cd95a9..b611229c3 100644 --- a/compiler/module_cmds.m +++ b/compiler/module_cmds.m @@ -105,8 +105,7 @@ % :- pred touch_interface_datestamp(globals::in, io.text_output_stream::in, io.text_output_stream::in, - module_name::in, other_ext::in, newext::in, maybe_succeeded::out, - io::di, io::uo) is det. + module_name::in, newext::in, maybe_succeeded::out, io::di, io::uo) is det. % touch_datestamp(Globals, ProgressStream, ErrorStream, FileName, % Succeeded, !IO): @@ -585,9 +584,9 @@ make_symlink_or_copy_dir(Globals, ProgressStream, ErrorStream, %-----------------------------------------------------------------------------% touch_interface_datestamp(Globals, ProgressStream, ErrorStream, - ModuleName, OtherExt, NewExt, Succeeded, !IO) :- + ModuleName, NewExt, Succeeded, !IO) :- module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(OtherExt), NewExt, ModuleName, OutputFileName, !IO), + NewExt, ModuleName, OutputFileName, !IO), touch_datestamp(Globals, ProgressStream, ErrorStream, OutputFileName, Succeeded, !IO). @@ -862,8 +861,7 @@ use_win32 :- create_java_shell_script(Globals, MainModuleName, Succeeded, !IO) :- module_name_to_file_name(Globals, $pred, do_not_create_dirs, - ext_other(other_ext(".jar")), newext_lib_gs(ext_lib_gs_jar), - MainModuleName, JarFileName, !IO), + newext_lib_gs(ext_lib_gs_jar), MainModuleName, JarFileName, !IO), get_target_env_type(Globals, TargetEnvType), ( ( TargetEnvType = env_type_posix @@ -1207,8 +1205,7 @@ get_env_classpath(Classpath, !IO) :- create_launcher_shell_script(Globals, MainModuleName, Pred, Succeeded, !IO) :- module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext("")), newext_exec_gs(ext_exec_gs_noext), - MainModuleName, FileName, !IO), + newext_exec_gs(ext_exec_gs_noext), MainModuleName, FileName, !IO), get_progress_output_stream(Globals, MainModuleName, ProgressStream, !IO), globals.lookup_bool_option(Globals, verbose, Verbose), @@ -1247,8 +1244,7 @@ create_launcher_shell_script(Globals, MainModuleName, Pred, Succeeded, !IO) :- create_launcher_batch_file(Globals, MainModuleName, Pred, Succeeded, !IO) :- module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".bat")), newext_exec_gs(ext_exec_gs_bat), - MainModuleName, FileName, !IO), + newext_exec_gs(ext_exec_gs_bat), MainModuleName, FileName, !IO), get_progress_output_stream(Globals, MainModuleName, ProgressStream, !IO), globals.lookup_bool_option(Globals, verbose, Verbose), diff --git a/compiler/prog_foreign.m b/compiler/prog_foreign.m index 022cce3da..700b752cf 100644 --- a/compiler/prog_foreign.m +++ b/compiler/prog_foreign.m @@ -138,9 +138,9 @@ % XXX Actually, all the foreign languages we handle *now* *do* % generate external files. (The exception used to be Erlang.) % -:- pred foreign_language_file_extension(foreign_language, other_ext, newext). +:- pred foreign_language_file_extension(foreign_language, newext). % :- mode foreign_language_file_extension(in(lang_gen_ext_file), out) is det. -:- mode foreign_language_file_extension(in, out, out) is det. +:- mode foreign_language_file_extension(in, out) is det. % It is possible that more than one foreign language could be used to % implement a particular piece of code. Therefore, foreign languages @@ -288,7 +288,7 @@ handle_std_library(CurrentModule, ModuleName0) = ModuleName :- foreign_language_module_name(ModuleName, Lang, FullyQualifiedModuleName) :- % Only succeed if this language generates external files. - foreign_language_file_extension(Lang, _, _), + foreign_language_file_extension(Lang, _), Ending = "__" ++ simple_foreign_language_string(Lang) ++ "_code", ( @@ -301,14 +301,14 @@ foreign_language_module_name(ModuleName, Lang, FullyQualifiedModuleName) :- %-----------------------------------------------------------------------------% -:- pragma no_determinism_warning(pred(foreign_language_file_extension/3)). +:- pragma no_determinism_warning(pred(foreign_language_file_extension/2)). foreign_language_file_extension(lang_c, - other_ext(".c"), newext_target_c_cs(ext_target_c)). + newext_target_c_cs(ext_target_c)). foreign_language_file_extension(lang_csharp, - other_ext(".cs"), newext_target_c_cs(ext_target_cs)). + newext_target_c_cs(ext_target_cs)). foreign_language_file_extension(lang_java, - other_ext(".java"), newext_target_java(ext_target_java_java)). + newext_target_java(ext_target_java_java)). %-----------------------------------------------------------------------------% diff --git a/compiler/read_modules.m b/compiler/read_modules.m index 9076505b4..a51adf281 100644 --- a/compiler/read_modules.m +++ b/compiler/read_modules.m @@ -789,14 +789,14 @@ read_module_begin_from_file(Globals, ReadReasonMsg, Search, read_module_begin(Globals, ReadReasonMsg, Search, ModuleName, FileKind, FileName, ReadDoneMsg, SearchDirs, !IO) :- - file_kind_to_extension(FileKind, _ExtStr, Ext, NewExt), + file_kind_to_extension(FileKind, _ExtStr, NewExt), % The rest of this predicate should be kept in sync % with read_module_begin_from_file. ( Search = do_search, % XXX CLEANUP We should either pass SearchDirs to % module_name_to_search_file_name, or get it to give SearchDirs to us. - module_name_to_search_file_name(Globals, $pred, Ext, NewExt, + module_name_to_search_file_name(Globals, $pred, NewExt, ModuleName, FileName, !IO), ( ( FileKind = fk_src @@ -812,7 +812,7 @@ read_module_begin(Globals, ReadReasonMsg, Search, ModuleName, FileKind, ; Search = do_not_search, module_name_to_file_name(Globals, $pred, do_not_create_dirs, - Ext, NewExt, ModuleName, FileName, !IO), + NewExt, ModuleName, FileName, !IO), SearchDirs = [dir.this_directory] ), output_read_reason_msg(Globals, ReadReasonMsg, FileName, ReadDoneMsg, !IO). diff --git a/compiler/recompilation.used_file.m b/compiler/recompilation.used_file.m index e04f323d6..833dd428e 100644 --- a/compiler/recompilation.used_file.m +++ b/compiler/recompilation.used_file.m @@ -249,8 +249,7 @@ write_usage_file(ModuleInfo, UsedFileContents, !IO) :- module_info_get_name(ModuleInfo, ModuleName), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".used")), newext_misc_gs(ext_misc_gs_used), - ModuleName, FileName, !IO), + newext_misc_gs(ext_misc_gs_used), ModuleName, FileName, !IO), io.open_output(FileName, FileResult, !IO), ( FileResult = ok(FileStream), @@ -566,7 +565,7 @@ module_name_and_used_items_to_string(UsedFileContents, _ResolvedUsedItems, _UsedClasses, _ImportedItems, ModuleInstances), map.lookup(TimestampMap, ModuleName, module_timestamp(FileKind, ModuleTimestamp, RecompNeedQual)), - file_kind_to_extension(FileKind, ExtStr, _Ext, _NewExt), + file_kind_to_extension(FileKind, ExtStr, _NewExt), ( RecompNeedQual = recomp_avail_src, ImportStr = "src" @@ -637,8 +636,7 @@ module_name_and_used_items_to_string(UsedFileContents, read_used_file_for_module(Globals, ModuleName, ReadUsedFileResult, !IO) :- module_name_to_file_name(Globals, $pred, do_not_create_dirs, - ext_other(other_ext(".used")), newext_misc_gs(ext_misc_gs_used), - ModuleName, UsedFileName, !IO), + newext_misc_gs(ext_misc_gs_used), ModuleName, UsedFileName, !IO), io.read_named_file_as_string(UsedFileName, MaybeUsedFileString, !IO), ( MaybeUsedFileString = ok(UsedFileString), diff --git a/compiler/write_deps_file.m b/compiler/write_deps_file.m index d6960ae4b..0e7cb5fdb 100644 --- a/compiler/write_deps_file.m +++ b/compiler/write_deps_file.m @@ -121,8 +121,7 @@ module_name::in, deps_map::in, io::di, io::uo) is det. :- pred output_module_order(globals::in, module_name::in, - other_ext::in, newext::in, list(set(module_name))::in, - io::di, io::uo) is det. + newext::in, list(set(module_name))::in, io::di, io::uo) is det. %---------------------------------------------------------------------------% @@ -139,8 +138,8 @@ % and not just the modules' names. % :- pred get_opt_deps(globals::in, bool::in, list(string)::in, - other_ext::in, newext::in, - list(module_name)::in, list(module_name)::out, io::di, io::uo) is det. + newext::in, list(module_name)::in, list(module_name)::out, + io::di, io::uo) is det. %---------------------------------------------------------------------------% %---------------------------------------------------------------------------% @@ -176,7 +175,7 @@ :- type module_file_name_cache == map(module_name_and_ext, file_name). :- type module_name_and_ext - ---> module_name_and_ext(module_name, other_ext). + ---> module_name_and_ext(module_name, newext). %---------------------------------------------------------------------------% @@ -201,8 +200,7 @@ write_dependency_file_fn_cache(Globals, BurdenedAugCompUnit, IntermodDeps, ParseTreeModuleSrc = AugCompUnit ^ acu_module_src, ModuleName = ParseTreeModuleSrc ^ ptms_module_name, module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".d")), newext_mmake_fragment(ext_mf_d), - ModuleName, DependencyFileName, !IO), + newext_mmake_fragment(ext_mf_d), ModuleName, DependencyFileName, !IO), io.file.make_temp_file(dir.dirname(DependencyFileName), "tmp_d", "", TmpDependencyFileNameRes, !IO), get_error_output_stream(Globals, ModuleName, ErrorStream, !IO), @@ -364,9 +362,7 @@ generate_d_file(Globals, BurdenedAugCompUnit, IntermodDeps, set.difference(ShortDeps0, LongDeps, ShortDeps1), set.delete(ModuleName, ShortDeps1, ShortDeps), - make_module_file_name(Globals, $pred, - ext_other(other_ext(".trans_opt_date")), - newext_opt(ext_opt_date_trans), + make_module_file_name(Globals, $pred, newext_opt(ext_opt_date_trans), ModuleName, TransOptDateFileName, !Cache, !IO), construct_trans_opt_deps_rule(Globals, MaybeInclTransOptRule, IntermodDeps, TransOptDateFileName, MmakeRulesTransOpt, !Cache, !IO), @@ -382,25 +378,22 @@ generate_d_file(Globals, BurdenedAugCompUnit, IntermodDeps, ), make_module_file_name(Globals, $pred, - ext_other(other_ext(".optdate")), newext_opt(ext_opt_date_plain), + newext_opt(ext_opt_date_plain), ModuleName, OptDateFileName, !Cache, !IO), make_module_file_name(Globals, $pred, - ext_other(other_ext(".c_date")), newext_target_date(ext_target_date_c), + newext_target_date(ext_target_date_c), ModuleName, CDateFileName, !Cache, !IO), make_module_file_name(Globals, $pred, - ext_other(other_ext(".$O")), newext_target_obj(ext_obj_dollar_o), + newext_target_obj(ext_obj_dollar_o), ModuleName, ObjFileName, !Cache, !IO), make_module_file_name(Globals, $pred, - ext_other(other_ext(".java_date")), newext_target_date(ext_target_date_java), ModuleName, JavaDateFileName, !Cache, !IO), % XXX Why is the extension hardcoded to .pic_o here? That looks wrong. % It should probably be .$(EXT_FOR_PIC_OBJECT) - juliensf. - make_module_file_name(Globals, $pred, - ext_other(other_ext(".pic_o")), newext_target_obj(ext_obj_pic_o), + make_module_file_name(Globals, $pred, newext_target_obj(ext_obj_pic_o), ModuleName, PicObjFileName, !Cache, !IO), - make_module_file_name(Globals, $pred, - ext_other(other_ext(".int0")), newext_int(ext_int_int0), + make_module_file_name(Globals, $pred, newext_int(ext_int_int0), ModuleName, Int0FileName, !Cache, !IO), construct_date_file_deps_rule(Globals, ModuleName, SourceFileName, @@ -416,8 +409,7 @@ generate_d_file(Globals, BurdenedAugCompUnit, IntermodDeps, ErrFileName, TransOptDateFileName, CDateFileName, JavaDateFileName, ObjFileName, MmakeRulesIntermod, !Cache, !IO), - make_module_file_name(Globals, $pred, - ext_other(other_ext(".c")), newext_target_c_cs(ext_target_c), + make_module_file_name(Globals, $pred, newext_target_c_cs(ext_target_c), ModuleName, CFileName, !Cache, !IO), construct_c_header_rules(Globals, ModuleName, AllDeps, CFileName, ObjFileName, PicObjFileName, MmakeRulesCHeaders, @@ -426,11 +418,9 @@ generate_d_file(Globals, BurdenedAugCompUnit, IntermodDeps, construct_module_dep_fragment(Globals, ModuleName, CFileName, MmakeFragmentModuleDep, !Cache, !IO), - make_module_file_name(Globals, $pred, - ext_other(other_ext(".date")), newext_int(ext_int_date_int12), + make_module_file_name(Globals, $pred, newext_int(ext_int_date_int12), ModuleName, DateFileName, !Cache, !IO), - make_module_file_name(Globals, $pred, - ext_other(other_ext(".date0")), newext_int(ext_int_date_int0), + make_module_file_name(Globals, $pred, newext_int(ext_int_date_int0), ModuleName, Date0FileName, !Cache, !IO), construct_self_and_parent_date_date0_rules(Globals, SourceFileName, Date0FileName, DateFileName, Ancestors, LongDeps, ShortDeps, @@ -440,10 +430,8 @@ generate_d_file(Globals, BurdenedAugCompUnit, IntermodDeps, SourceFileModuleName, ObjFileName, PicObjFileName, MmakeRulesForeignImports, !Cache, !IO), - make_module_file_name(Globals, $pred, - ext_other(other_ext(".date3")), newext_int(ext_int_date_int3), - ModuleName, Date3FileName, - !Cache, !IO), + make_module_file_name(Globals, $pred, newext_int(ext_int_date_int3), + ModuleName, Date3FileName, !Cache, !IO), construct_install_shadow_rules(Globals, ModuleName, Int0FileName, Date0FileName, DateFileName, Date3FileName, OptDateFileName, TransOptDateFileName, @@ -530,8 +518,7 @@ construct_trans_opt_deps_rule(Globals, MaybeInclTransOptRule, IntermodDeps, ), % Note that maybe_read_dependency_file searches for % this exact pattern. - make_module_file_names_with_suffix(Globals, - ext_other(other_ext(".trans_opt")), newext_opt(ext_opt_trans), + make_module_file_names_with_suffix(Globals, newext_opt(ext_opt_trans), set.to_sorted_list(TransOptDeps), TransOptDepsFileNames, !Cache, !IO), MmakeRuleTransOpt = mmake_simple_rule("trans_opt_deps", @@ -635,25 +622,20 @@ construct_date_file_deps_rule(Globals, ModuleName, SourceFileName, Int0FileNameGroups = [make_singleton_file_name_group(Int0FileName)] ), make_module_file_name_group_with_suffix(Globals, - "ancestors", - ext_other(other_ext(".int0")), newext_int(ext_int_int0), + "ancestors", newext_int(ext_int_int0), Ancestors, AncestorSourceGroups, !Cache, !IO), make_module_file_name_group_with_suffix(Globals, - "long deps", - ext_other(other_ext(".int")), newext_int(ext_int_int1), + "long deps", newext_int(ext_int_int1), LongDeps, LongDepsSourceGroups, !Cache, !IO), make_module_file_name_group_with_suffix(Globals, - "short deps", - ext_other(other_ext(".int2")), newext_int(ext_int_int2), + "short deps", newext_int(ext_int_int2), ShortDeps, ShortDepsSourceGroups, !Cache, !IO), make_module_file_name_group_with_suffix(Globals, - "type_repn self dep", - ext_other(other_ext(".int")), newext_int(ext_int_int1), + "type_repn self dep", newext_int(ext_int_int1), set.make_singleton_set(ModuleName), TypeRepnSelfDepGroups, !Cache, !IO), make_module_file_name_group_with_suffix(Globals, - "type_repn ancestor dep", - ext_other(other_ext(".int")), newext_int(ext_int_int1), + "type_repn ancestor dep", newext_int(ext_int_int1), get_ancestors_set(ModuleName), TypeRepnAncestorsDepGroups, !Cache, !IO), ForeignIncludeFiles = set.to_sorted_list(ForeignIncludeFilesSet), @@ -695,15 +677,12 @@ construct_build_nested_children_first_rule(Globals, ModuleName, MaybeTopModule, ; NestedModuleNames = [_ | _], % XXX EXT - NestedOtherExts = [ - {other_ext(".optdate"), newext_opt(ext_opt_date_plain)}, - {other_ext(".trans_opt_date"), newext_opt(ext_opt_date_trans)}, - {other_ext(".c_date"), newext_target_date(ext_target_date_c)}, - {other_ext(".dir/*.$O"), - newext_mmake_fragment(ext_mf_dir_sl_all_os)}, - {other_ext(".java_date"), - newext_target_date(ext_target_date_java)} - ], + NestedOtherExts = + [newext_opt(ext_opt_date_plain), + newext_opt(ext_opt_date_trans), + newext_target_date(ext_target_date_c), + newext_mmake_fragment(ext_mf_dir_sl_all_os), + newext_target_date(ext_target_date_java)], list.map_foldl2( gather_nested_deps(Globals, ModuleName, NestedModuleNames), NestedOtherExts, MmakeRulesNestedDeps, !Cache, !IO) @@ -734,8 +713,7 @@ construct_intermod_rules(Globals, ModuleName, LongDeps, AllDeps, % directly or indirectly. ( Intermod = yes, - make_module_file_names_with_suffix(Globals, - ext_other(other_ext(".mh")), newext_mh(ext_mh_mh), + make_module_file_names_with_suffix(Globals, newext_mh(ext_mh_mh), set.to_sorted_list(AllDeps), AllDepsFileNames, !Cache, !IO), MmakeRuleMhDeps = mmake_simple_rule("machine_dependent_header_deps", mmake_rule_is_not_phony, @@ -781,17 +759,14 @@ construct_intermod_rules(Globals, ModuleName, LongDeps, AllDeps, MaybeTransOptDeps1 = yes(TransOptDeps1) else get_opt_deps(Globals, BuildOptFiles, IntermodDirs, - other_ext(".opt"), newext_opt(ext_opt_plain), - BaseDeps, OptDeps, !IO), + newext_opt(ext_opt_plain), BaseDeps, OptDeps, !IO), MaybeTransOptDeps1 = no ), OptInt0Deps = set.union_list(list.map(get_ancestors_set, OptDeps)), - make_module_file_names_with_suffix(Globals, - ext_other(other_ext(".opt")), newext_opt(ext_opt_plain), + make_module_file_names_with_suffix(Globals, newext_opt(ext_opt_plain), OptDeps, OptDepsFileNames, !Cache, !IO), - make_module_file_names_with_suffix(Globals, - ext_other(other_ext(".int0")), newext_int(ext_int_int0), + make_module_file_names_with_suffix(Globals, newext_int(ext_int_int0), set.to_sorted_list(OptInt0Deps), OptInt0DepsFileNames, !Cache, !IO), MmakeRuleDateOptInt0Deps = mmake_flat_rule("dates_on_opts_and_int0s", mmake_rule_is_not_phony, @@ -804,7 +779,7 @@ construct_intermod_rules(Globals, ModuleName, LongDeps, AllDeps, ErrDateTargets = one_or_more(ErrFileName, [CDateFileName, JavaDateFileName]), make_module_file_names_with_suffix(Globals, - ext_other(other_ext(".trans_opt")), newext_opt(ext_opt_trans), + newext_opt(ext_opt_trans), TransOptDeps2, TransOptDepsOptFileNames, !Cache, !IO), MmakeRuleTransOptOpts = mmake_flat_rule("dates_on_trans_opts", mmake_rule_is_not_phony, @@ -843,7 +818,7 @@ construct_c_header_rules(Globals, ModuleName, AllDeps, % the C files, since the generated C files #include those header files. Targets = one_or_more(PicObjFileName, [ObjFileName]), make_module_file_names_with_suffix(Globals, - ext_other(other_ext(".mih")), newext_mih(ext_mih_mih), + newext_mih(ext_mih_mih), set.to_sorted_list(AllDeps), AllDepsFileNames, !Cache, !IO), MmakeRuleObjOnMihs = mmake_flat_rule("objs_on_mihs", mmake_rule_is_not_phony, @@ -862,11 +837,9 @@ construct_c_header_rules(Globals, ModuleName, AllDeps, % `:- pragma foreign_import_module' declarations. In some grades the header % file won't actually be built (e.g. LLDS grades for modules not containing % `:- pragma export' declarations), but this rule won't do any harm. - make_module_file_name(Globals, $pred, - ext_other(other_ext(".mh")), newext_mh(ext_mh_mh), + make_module_file_name(Globals, $pred, newext_mh(ext_mh_mh), ModuleName, MhHeaderFileName, !Cache, !IO), - make_module_file_name(Globals, $pred, - ext_other(other_ext(".mih")), newext_mih(ext_mih_mih), + make_module_file_name(Globals, $pred, newext_mih(ext_mih_mih), ModuleName, MihHeaderFileName, !Cache, !IO), MmakeRuleMhMihOnC = mmake_flat_rule("mh_and_mih_on_c", mmake_rule_is_not_phony, @@ -890,11 +863,9 @@ construct_c_header_rules(Globals, ModuleName, AllDeps, construct_module_dep_fragment(Globals, ModuleName, CFileName, MmakeFragmentModuleDep, !Cache, !IO) :- make_module_file_name(Globals, $pred, - ext_other(other_ext(".java")), newext_target_java(ext_target_java_java), ModuleName, JavaFileName, !Cache, !IO), make_module_file_name(Globals, $pred, - ext_other(make_module_dep_file_extension), newext_misc_ngs(ext_misc_ngs_module_dep), ModuleName, ModuleDepFileName, !Cache, !IO), MmakeFragmentModuleDep = mmf_conditional_entry( @@ -935,17 +906,13 @@ construct_module_dep_fragment(Globals, ModuleName, CFileName, construct_self_and_parent_date_date0_rules(Globals, SourceFileName, Date0FileName, DateFileName, Ancestors, LongDeps, ShortDeps, MmakeRulesParentDates, !Cache, !IO) :- - make_module_file_names_with_suffix(Globals, - ext_other(other_ext(".date")), newext_int(ext_int_date_int12), + make_module_file_names_with_suffix(Globals, newext_int(ext_int_date_int12), set.to_sorted_list(Ancestors), AncestorDateFileNames, !Cache, !IO), - make_module_file_names_with_suffix(Globals, - ext_other(other_ext(".int0")), newext_int(ext_int_int0), + make_module_file_names_with_suffix(Globals, newext_int(ext_int_int0), set.to_sorted_list(Ancestors), AncestorInt0FileNames, !Cache, !IO), - make_module_file_names_with_suffix(Globals, - ext_other(other_ext(".int3")), newext_int(ext_int_int3), + make_module_file_names_with_suffix(Globals, newext_int(ext_int_int3), set.to_sorted_list(LongDeps), LongDepInt3FileNames, !Cache, !IO), - make_module_file_names_with_suffix(Globals, - ext_other(other_ext(".int3")), newext_int(ext_int_int3), + make_module_file_names_with_suffix(Globals, newext_int(ext_int_int3), set.to_sorted_list(ShortDeps), ShortDepInt3FileNames, !Cache, !IO), MmakeRuleParentDates = mmake_general_rule("self_and_parent_date_deps", @@ -960,8 +927,7 @@ construct_self_and_parent_date_date0_rules(Globals, SourceFileName, make_file_name_group("long dep int3s", LongDepInt3FileNames) ++ make_file_name_group("short dep int3s", ShortDepInt3FileNames), []), - make_module_file_names_with_suffix(Globals, - ext_other(other_ext(".date0")), newext_int(ext_int_date_int0), + make_module_file_names_with_suffix(Globals, newext_int(ext_int_date_int0), set.to_sorted_list(Ancestors), AncestorDate0FileNames, !Cache, !IO), MmakeRuleParentDate0s = mmake_general_rule("self_and_parent_date0_deps", mmake_rule_is_not_phony, @@ -1049,24 +1015,19 @@ construct_foreign_import_rules(Globals, AugCompUnit, IntermodDeps, % .pic_o file. We need to include dependencies for the latter % otherwise invoking mmake with a .pic_o target will break. ForeignImportTargets = one_or_more(ObjFileName, [PicObjFileName]), - ForeignImportOtherExt = other_ext(".mh"), ForeignImportNewExt = newext_mh(ext_mh_mh), - gather_foreign_import_deps(Globals, - ForeignImportOtherExt, ForeignImportNewExt, + gather_foreign_import_deps(Globals, ForeignImportNewExt, ForeignImportTargets, ForeignImportedModuleNames, MmakeRuleForeignImports, !Cache, !IO), MmakeRulesForeignImports = [MmakeRuleForeignImports] ; Target = target_java, make_module_file_name(Globals, $pred, - ext_other(other_ext(".class")), newext_target_java(ext_target_java_class), ModuleName, ClassFileName, !Cache, !IO), ForeignImportTargets = one_or_more(ClassFileName, []), - ForeignImportOtherExt = other_ext(".java"), ForeignImportNewExt = newext_target_java(ext_target_java_java), - gather_foreign_import_deps(Globals, - ForeignImportOtherExt, ForeignImportNewExt, + gather_foreign_import_deps(Globals, ForeignImportNewExt, ForeignImportTargets, ForeignImportedModuleNames, MmakeRuleForeignImports, !Cache, !IO), MmakeRulesForeignImports = [MmakeRuleForeignImports] @@ -1098,20 +1059,15 @@ construct_install_shadow_rules(Globals, ModuleName, Int0FileName, Date0FileName, DateFileName, Date3FileName, OptDateFileName, TransOptDateFileName, MmakeRulesInstallShadows, !Cache, !IO) :- - make_module_file_name(Globals, $pred, - ext_other(other_ext(".int")), newext_int(ext_int_int1), + make_module_file_name(Globals, $pred, newext_int(ext_int_int1), ModuleName, IntFileName, !Cache, !IO), - make_module_file_name(Globals, $pred, - ext_other(other_ext(".int2")), newext_int(ext_int_int2), + make_module_file_name(Globals, $pred, newext_int(ext_int_int2), ModuleName, Int2FileName, !Cache, !IO), - make_module_file_name(Globals, $pred, - ext_other(other_ext(".int3")), newext_int(ext_int_int3), + make_module_file_name(Globals, $pred, newext_int(ext_int_int3), ModuleName, Int3FileName, !Cache, !IO), - make_module_file_name(Globals, $pred, - ext_other(other_ext(".opt")), newext_opt(ext_opt_plain), + make_module_file_name(Globals, $pred, newext_opt(ext_opt_plain), ModuleName, OptFileName, !Cache, !IO), - make_module_file_name(Globals, $pred, - ext_other(other_ext(".trans_opt")), newext_opt(ext_opt_trans), + make_module_file_name(Globals, $pred, newext_opt(ext_opt_trans), ModuleName, TransOptFileName, !Cache, !IO), MmakeRulesInstallShadows = [ @@ -1148,12 +1104,12 @@ construct_subdir_short_rules(Globals, ModuleName, ( UseSubdirs = yes, SubDirShorthandOtherExts = - [{other_ext(".c"), newext_target_c_cs(ext_target_c)}, - {other_ext(".$O"), newext_target_obj(ext_obj_dollar_o)}, - {other_ext(".pic_o"), newext_target_obj(ext_obj_pic_o)}, - {other_ext(".java"), newext_target_java(ext_target_java_java)}, - {other_ext(".class"), newext_target_java(ext_target_java_class)}, - {other_ext(".dll"), newext_lib_gs(ext_lib_gs_dll)}], + [newext_target_c_cs(ext_target_c), + newext_target_obj(ext_obj_dollar_o), + newext_target_obj(ext_obj_pic_o), + newext_target_java(ext_target_java_java), + newext_target_java(ext_target_java_class), + newext_lib_gs(ext_lib_gs_dll)], list.map_foldl2( construct_subdirs_shorthand_rule(Globals, ModuleName), SubDirShorthandOtherExts, MmakeRulesSubDirShorthand, !Cache, !IO) @@ -1307,36 +1263,34 @@ gather_fim_specs_in_parse_tree_plain_opt(ParseTreePlainOpt, !FIMSpecs) :- %---------------------------------------------------------------------------% :- pred gather_nested_deps(globals::in, module_name::in, list(module_name)::in, - {other_ext, newext}::in, mmake_entry::out, + newext::in, mmake_entry::out, module_file_name_cache::in, module_file_name_cache::out, io::di, io::uo) is det. -gather_nested_deps(Globals, ModuleName, NestedDeps, {OtherExt, NewExt}, - MmakeRule, !Cache, !IO) :- - make_module_file_name(Globals, $pred, ext_other(OtherExt), NewExt, +gather_nested_deps(Globals, ModuleName, NestedDeps, NewExt, MmakeRule, + !Cache, !IO) :- + make_module_file_name(Globals, $pred, NewExt, ModuleName, ModuleExtName, !Cache, !IO), - make_module_file_names_with_suffix(Globals, ext_other(OtherExt), NewExt, + make_module_file_names_with_suffix(Globals, NewExt, NestedDeps, NestedDepsFileNames, !Cache, !IO), - ExtStr = extension_to_string(Globals, ext_other(OtherExt), NewExt), + ExtStr = extension_to_string(Globals, NewExt), MmakeRule = mmake_simple_rule("nested_deps_for_" ++ ExtStr, mmake_rule_is_not_phony, ModuleExtName, NestedDepsFileNames, []). -:- pred gather_foreign_import_deps(globals::in, other_ext::in, newext::in, +:- pred gather_foreign_import_deps(globals::in, newext::in, one_or_more(string)::in, list(module_name)::in, mmake_entry::out, module_file_name_cache::in, module_file_name_cache::out, io::di, io::uo) is det. -gather_foreign_import_deps(Globals, ForeignImportOtherExt, ForeignImportNewExt, - ForeignImportTargets, ForeignImportedModuleNames, MmakeRule, - !Cache, !IO) :- - make_module_file_names_with_suffix(Globals, - ext_other(ForeignImportOtherExt), ForeignImportNewExt, +gather_foreign_import_deps(Globals, ForeignImportNewExt, ForeignImportTargets, + ForeignImportedModuleNames, MmakeRule, !Cache, !IO) :- + make_module_file_names_with_suffix(Globals, ForeignImportNewExt, ForeignImportedModuleNames, ForeignImportedFileNames, !Cache, !IO), ForeignImportExtStr = extension_to_string(Globals, - ext_other(ForeignImportOtherExt), ForeignImportNewExt), + ForeignImportNewExt), RuleName = "foreign_deps_for_" ++ string.remove_prefix_if_present(".", ForeignImportExtStr), MmakeRule = mmake_flat_rule(RuleName, @@ -1347,50 +1301,53 @@ gather_foreign_import_deps(Globals, ForeignImportOtherExt, ForeignImportNewExt, %---------------------------------------------------------------------------% -:- pred make_module_file_name(globals::in, string::in, ext::in, newext::in, +:- pred make_module_file_name(globals::in, string::in, newext::in, module_name::in, file_name::out, module_file_name_cache::in, module_file_name_cache::out, io::di, io::uo) is det. -make_module_file_name(Globals, From, Ext, NewExt, ModuleName, FileName, +make_module_file_name(Globals, From, NewExt, ModuleName, FileName, !Cache, !IO) :- - ( - Ext = ext_src, + ( if % No point caching these. + % XXX This should be a complete switch on NewExt, with an + % explcit decision for each category of extension about whether + % it is worth caching files with those extensions. + NewExt = newext_src + then module_name_to_file_name(Globals, From, do_not_create_dirs, - Ext, NewExt, ModuleName, FileName, !IO) - ; - Ext = ext_other(OtherExt), - ModuleNameExt = module_name_and_ext(ModuleName, OtherExt), + NewExt, ModuleName, FileName, !IO) + else + ModuleNameExt = module_name_and_ext(ModuleName, NewExt), ( if map.search(!.Cache, ModuleNameExt, FileName0) then FileName = FileName0 else % The result of module_name_to_file_name is cached to save on % temporary string constructions. module_name_to_file_name(Globals, From, do_not_create_dirs, - Ext, NewExt, ModuleName, FileName, !IO), + NewExt, ModuleName, FileName, !IO), map.det_insert(ModuleNameExt, FileName, !Cache) ) ). -:- pred make_module_file_names_with_suffix(globals::in, ext::in, newext::in, +:- pred make_module_file_names_with_suffix(globals::in, newext::in, list(module_name)::in, list(mmake_file_name)::out, module_file_name_cache::in, module_file_name_cache::out, io::di, io::uo) is det. -make_module_file_names_with_suffix(Globals, Ext, NewExt, Modules, FileNames, +make_module_file_names_with_suffix(Globals, NewExt, Modules, FileNames, !Cache, !IO) :- - list.map_foldl2(make_module_file_name(Globals, $pred, Ext, NewExt), + list.map_foldl2(make_module_file_name(Globals, $pred, NewExt), Modules, FileNames, !Cache, !IO). :- pred make_module_file_name_group_with_suffix(globals::in, string::in, - ext::in, newext::in, set(module_name)::in, list(mmake_file_name_group)::out, + newext::in, set(module_name)::in, list(mmake_file_name_group)::out, module_file_name_cache::in, module_file_name_cache::out, io::di, io::uo) is det. -make_module_file_name_group_with_suffix(Globals, GroupName, Ext, NewExt, +make_module_file_name_group_with_suffix(Globals, GroupName, NewExt, Modules, Groups, !Cache, !IO) :- - list.map_foldl2(make_module_file_name(Globals, $pred, Ext, NewExt), + list.map_foldl2(make_module_file_name(Globals, $pred, NewExt), set.to_sorted_list(Modules), FileNames, !Cache, !IO), Groups = make_file_name_group(GroupName, FileNames). @@ -1403,31 +1360,31 @@ foreign_include_file_path_name(SourceFileName, IncludeFile) = IncludePath :- IncludeFile = foreign_include_file_info(_Lang, IncludeFileName), make_include_file_path(SourceFileName, IncludeFileName, IncludePath). -:- pred get_fact_table_dependencies(globals::in, other_ext::in, newext::in, +:- pred get_fact_table_dependencies(globals::in, newext::in, list(file_name)::in, list(string)::out, io::di, io::uo) is det. -get_fact_table_dependencies(_, _, _, [], [], !IO). -get_fact_table_dependencies(Globals, OtherExt, NewExt, +get_fact_table_dependencies(_, _, [], [], !IO). +get_fact_table_dependencies(Globals, NewExt, [ExtraLink | ExtraLinks], [FileName | FileNames], !IO) :- - fact_table_file_name(Globals, $pred, do_not_create_dirs, OtherExt, NewExt, + fact_table_file_name(Globals, $pred, do_not_create_dirs, NewExt, ExtraLink, FileName, !IO), - get_fact_table_dependencies(Globals, OtherExt, NewExt, + get_fact_table_dependencies(Globals, NewExt, ExtraLinks, FileNames, !IO). % With `--use-subdirs', allow users to type `mmake module.c' % rather than `mmake Mercury/cs/module.c'. % :- pred construct_subdirs_shorthand_rule(globals::in, module_name::in, - {other_ext, newext}::in, mmake_entry::out, + newext::in, mmake_entry::out, module_file_name_cache::in, module_file_name_cache::out, io::di, io::uo) is det. -construct_subdirs_shorthand_rule(Globals, ModuleName, {OtherExt, NewExt}, +construct_subdirs_shorthand_rule(Globals, ModuleName, NewExt, MmakeRule, !Cache, !IO) :- module_name_to_file_name_stem(ModuleName, ModuleStr), - make_module_file_name(Globals, $pred, ext_other(OtherExt), NewExt, + make_module_file_name(Globals, $pred, NewExt, ModuleName, Target, !Cache, !IO), - ExtStr = extension_to_string(Globals, ext_other(OtherExt), NewExt), + ExtStr = extension_to_string(Globals, NewExt), ShorthandTarget = ModuleStr ++ ExtStr, MmakeRule = mmake_simple_rule("subdir_shorthand_for_" ++ ExtStr, mmake_rule_is_phony, ShorthandTarget, [Target], []). @@ -1560,8 +1517,7 @@ generate_dependencies_write_dv_file(Globals, SourceFileName, ModuleName, DepsMap, !IO) :- globals.lookup_bool_option(Globals, verbose, Verbose), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".dv")), newext_mmake_fragment(ext_mf_dv), - ModuleName, DvFileName, !IO), + newext_mmake_fragment(ext_mf_dv), ModuleName, DvFileName, !IO), get_progress_output_stream(Globals, ModuleName, ProgressStream, !IO), string.format("%% Creating auto-dependency file `%s'...\n", [s(DvFileName)], CreatingMsg), @@ -1619,7 +1575,7 @@ generate_dv_file(Globals, SourceFileName, ModuleName, DepsMap, list.map(add_suffix(".dep_err"), SourceFiles)), make_module_file_names_with_suffix(Globals, - ext_other(other_ext("")), newext_exec_gs(ext_exec_gs_noext), + newext_exec_gs(ext_exec_gs_noext), Modules, ModulesSourceFileNames, !Cache, !IO), MmakeVarModuleMods = mmake_var_defn_list(ModuleMakeVarName ++ ".mods", ModulesSourceFileNames), @@ -1634,7 +1590,7 @@ generate_dv_file(Globals, SourceFileName, ModuleName, DepsMap, ), Modules), make_module_file_names_with_suffix(Globals, - ext_other(other_ext("")), newext_exec_gs(ext_exec_gs_noext), + newext_exec_gs(ext_exec_gs_noext), ModulesWithSubModules, ModulesWithSubModulesSourceFileNames, !Cache, !IO), MmakeVarModuleParentMods = mmake_var_defn_list( @@ -1649,18 +1605,18 @@ generate_dv_file(Globals, SourceFileName, ModuleName, DepsMap, ), ForeignModulesAndExts = [] ), - ForeignModules = list.map((func({A, _B, _C}) = A), ForeignModulesAndExts), + ForeignModules = list.map((func({A, _C}) = A), ForeignModulesAndExts), make_module_file_names_with_suffix(Globals, - ext_other(other_ext("")), newext_exec_gs(ext_exec_gs_noext), + newext_exec_gs(ext_exec_gs_noext), ForeignModules, ForeignModulesFileNames, !Cache, !IO), MmakeVarForeignModules = mmake_var_defn_list(ModuleMakeVarName ++ ".foreign", ForeignModulesFileNames), MakeFileName = - ( pred({M, E, NE}::in, F::out, IO0::di, IO::uo) is det :- - module_name_to_file_name(Globals, $pred, do_create_dirs, E, NE, + ( pred({M, NE}::in, F::out, IO0::di, IO::uo) is det :- + module_name_to_file_name(Globals, $pred, do_create_dirs, NE, M, F0, IO0, IO), F = "$(os_subdir)" ++ F0 ), @@ -1692,14 +1648,11 @@ generate_dv_file(Globals, SourceFileName, ModuleName, DepsMap, % XXX EXT % We should just be able to append ".c", ".$O" and the pic extension % to each string in FactTableFileNames. - get_fact_table_dependencies(Globals, - other_ext(".c"), newext_target_c_cs(ext_target_c), + get_fact_table_dependencies(Globals, newext_target_c_cs(ext_target_c), FactTableFileNames, FactTableFileNamesC, !IO), - get_fact_table_dependencies(Globals, - other_ext(".$O"), newext_target_obj(ext_obj_dollar_o), + get_fact_table_dependencies(Globals, newext_target_obj(ext_obj_dollar_o), FactTableFileNames, FactTableFileNamesOs, !IO), get_fact_table_dependencies(Globals, - other_ext(".$(EXT_FOR_PIC_OBJECTS)"), newext_target_obj(ext_obj_dollar_efpo), FactTableFileNames, FactTableFileNamesPicOs, !IO), @@ -1791,10 +1744,8 @@ generate_dv_file(Globals, SourceFileName, ModuleName, DepsMap, string.format("$(%s.mods:%%=$(ds_subdir)%%.d)", [s(ModuleMakeVarName)])), - % XXX Why is make_module_dep_file_extension a function? - ModuleDepFileExt = make_module_dep_file_extension, ModuleDepFileExtStr = extension_to_string(Globals, - ext_other(ModuleDepFileExt), newext_misc_ngs(ext_misc_ngs_module_dep)), + newext_misc_ngs(ext_misc_ngs_module_dep)), MmakeVarModuleDeps = mmake_var_defn(ModuleMakeVarName ++ ".module_deps", string.format("$(%s.mods:%%=$(module_deps_subdir)%%%s)", [s(ModuleMakeVarName), s(ModuleDepFileExtStr)])), @@ -1970,8 +1921,7 @@ generate_dependencies_write_dep_file(Globals, SourceFileName, ModuleName, DepsMap, !IO) :- globals.lookup_bool_option(Globals, verbose, Verbose), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".dep")), newext_mmake_fragment(ext_mf_dep), - ModuleName, DepFileName, !IO), + newext_mmake_fragment(ext_mf_dep), ModuleName, DepFileName, !IO), get_progress_output_stream(Globals, ModuleName, ProgressStream, !IO), string.format("%% Creating auto-dependency file `%s'...\n", [s(DepFileName)], CreatingMsg), @@ -2013,17 +1963,13 @@ generate_dep_file(Globals, SourceFileName, ModuleName, DepsMap, module_name_to_make_var_name(ModuleName, ModuleMakeVarName), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".init")), newext_lib_gs(ext_lib_gs_init), - ModuleName, InitFileName, !IO), + newext_lib_gs(ext_lib_gs_init), ModuleName, InitFileName, !IO), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext("_init.c")), newext_target_init_c(ext_init_c), - ModuleName, InitCFileName, !IO), + newext_target_init_c(ext_init_c), ModuleName, InitCFileName, !IO), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext("_init.$O")), newext_target_init_obj(ext_init_obj_dollar_o), ModuleName, InitObjFileName, !IO), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext("_init.pic_o")), newext_target_init_obj(ext_init_obj_pic_o), ModuleName, InitPicObjFileName, !IO), @@ -2097,8 +2043,7 @@ generate_dep_file_exec_library_targets(Globals, ModuleName, ExeFileName, JarFileName, LibFileName, SharedLibFileName, !MmakeFile, !IO) :- module_name_to_file_name(Globals, $pred, do_not_create_dirs, - ext_other(other_ext("")), newext_exec_gs(ext_exec_gs_noext), - ModuleName, ExeFileName, !IO), + newext_exec_gs(ext_exec_gs_noext), ModuleName, ExeFileName, !IO), MmakeRuleExtForExe = mmake_simple_rule("ext_for_exe", mmake_rule_is_phony, ExeFileName, @@ -2154,21 +2099,17 @@ generate_dep_file_exec_library_targets(Globals, ModuleName, MmakeRuleExecutableJava, MmakeRuleExecutableNonJava), module_name_to_lib_file_name(Globals, $pred, do_not_create_dirs, "lib", - other_ext(""), newext_exec_gs(ext_exec_gs_noext), - ModuleName, LibTargetName, !IO), + newext_exec_gs(ext_exec_gs_noext), ModuleName, LibTargetName, !IO), module_name_to_lib_file_name(Globals, $pred, do_create_dirs, "lib", - other_ext(".$A"), newext_lib_gs(ext_lib_gs_dollar_a), - ModuleName, LibFileName, !IO), + newext_lib_gs(ext_lib_gs_dollar_a), ModuleName, LibFileName, !IO), module_name_to_lib_file_name(Globals, $pred, do_create_dirs, "lib", - other_ext(".$(EXT_FOR_SHARED_LIB)"), newext_lib(ext_lib_dollar_efsl), - ModuleName, SharedLibFileName, !IO), + newext_lib(ext_lib_dollar_efsl), ModuleName, SharedLibFileName, !IO), % XXX EXT What is the point of this call, given the call just above? module_name_to_lib_file_name(Globals, $pred, do_not_create_dirs, "lib", - other_ext(".$(EXT_FOR_SHARED_LIB)"), newext_lib(ext_lib_dollar_efsl), - ModuleName, MaybeSharedLibFileName, !IO), + newext_lib(ext_lib_dollar_efsl), ModuleName, + MaybeSharedLibFileName, !IO), module_name_to_file_name(Globals, $pred, do_not_create_dirs, - ext_other(other_ext(".jar")), newext_lib_gs(ext_lib_gs_jar), - ModuleName, JarFileName, !IO), + newext_lib_gs(ext_lib_gs_jar), ModuleName, JarFileName, !IO), % Set up the installed name for shared libraries. @@ -2253,11 +2194,9 @@ generate_dep_file_init_targets(Globals, ModuleName, ModuleMakeVarName, InitCFileName, InitFileName, DepFileName, DvFileName, !MmakeFile, !IO) :- module_name_to_file_name(Globals, $pred, do_not_create_dirs, - ext_other(other_ext(".dep")), newext_mmake_fragment(ext_mf_dep), - ModuleName, DepFileName, !IO), + newext_mmake_fragment(ext_mf_dep), ModuleName, DepFileName, !IO), module_name_to_file_name(Globals, $pred, do_not_create_dirs, - ext_other(other_ext(".dv")), newext_mmake_fragment(ext_mf_dv), - ModuleName, DvFileName, !IO), + newext_mmake_fragment(ext_mf_dv), ModuleName, DvFileName, !IO), ModuleMakeVarNameCs = "$(" ++ ModuleMakeVarName ++ ".cs)", InitAction1 = "echo > " ++ InitFileName, @@ -2320,16 +2259,15 @@ generate_dep_file_install_targets(Globals, ModuleName, DepsMap, MaybeModuleDepsVarPair = MaybeModuleDepsVar - MaybeModuleDepsVarSpace, module_name_to_lib_file_name(Globals, $pred, do_not_create_dirs, "lib", - other_ext(".install_ints"), newext_mmake_target(ext_mt_install_ints), + newext_mmake_target(ext_mt_install_ints), ModuleName, LibInstallIntsTargetName, !IO), module_name_to_lib_file_name(Globals, $pred, do_not_create_dirs, "lib", - other_ext(".install_opts"), newext_mmake_target(ext_mt_install_opts), + newext_mmake_target(ext_mt_install_opts), ModuleName, LibInstallOptsTargetName, !IO), module_name_to_lib_file_name(Globals, $pred, do_not_create_dirs, "lib", - other_ext(".install_hdrs"), newext_mmake_target(ext_mt_install_hdrs), + newext_mmake_target(ext_mt_install_hdrs), ModuleName, LibInstallHdrsTargetName, !IO), module_name_to_lib_file_name(Globals, $pred, do_not_create_dirs, "lib", - other_ext(".install_grade_hdrs"), newext_mmake_target(ext_mt_install_grade_hdrs), ModuleName, LibInstallGradeHdrsTargetName, !IO), @@ -2541,41 +2479,30 @@ generate_dep_file_collective_targets(Globals, ModuleName, list.map_foldl( generate_dep_file_collective_target(Globals, ModuleName, ModuleMakeVarName), - [{ext_other(other_ext(".check")), - newext_mmake_target(ext_mt_check), ".errs"}, - {ext_other(other_ext(".ints")), - newext_mmake_target(ext_mt_ints), ".dates"}, - {ext_other(other_ext(".int3s")), - newext_mmake_target(ext_mt_int3s), ".date3s"}, - {ext_other(other_ext(".opts")), - newext_mmake_target(ext_mt_opts), ".optdates"}, - {ext_other(other_ext(".trans_opts")), - newext_mmake_target(ext_mt_trans_opts), ".trans_opt_dates"}, - {ext_other(other_ext(".javas")), - newext_mmake_target(ext_mt_javas), ".javas"}, - {ext_other(other_ext(".classes")), - newext_mmake_target(ext_mt_classes), ".classes"}, - {ext_other(other_ext(".all_ints")), - newext_mmake_target(ext_mt_all_ints), ".dates"}, - {ext_other(other_ext(".all_int3s")), - newext_mmake_target(ext_mt_all_int3s), ".date3s"}, - {ext_other(other_ext(".all_opts")), - newext_mmake_target(ext_mt_all_opts), ".optdates"}, - {ext_other(other_ext(".all_trans_opts")), - newext_mmake_target(ext_mt_all_trans_opts), ".trans_opt_dates"}], + [{newext_mmake_target(ext_mt_check), ".errs"}, + {newext_mmake_target(ext_mt_ints), ".dates"}, + {newext_mmake_target(ext_mt_int3s), ".date3s"}, + {newext_mmake_target(ext_mt_opts), ".optdates"}, + {newext_mmake_target(ext_mt_trans_opts), ".trans_opt_dates"}, + {newext_mmake_target(ext_mt_javas), ".javas"}, + {newext_mmake_target(ext_mt_classes), ".classes"}, + {newext_mmake_target(ext_mt_all_ints), ".dates"}, + {newext_mmake_target(ext_mt_all_int3s), ".date3s"}, + {newext_mmake_target(ext_mt_all_opts), ".optdates"}, + {newext_mmake_target(ext_mt_all_trans_opts), ".trans_opt_dates"}], MmakeRules, !IO), add_mmake_entries(MmakeRules, !MmakeFile). :- pred generate_dep_file_collective_target(globals::in, - module_name::in, string::in, {ext, newext, string}::in, + module_name::in, string::in, {newext, string}::in, mmake_entry::out, io::di, io::uo) is det. generate_dep_file_collective_target(Globals, ModuleName, ModuleMakeVarName, - {Ext, NewExt, VarExtension}, MmakeRule, !IO) :- - module_name_to_file_name(Globals, $pred, do_not_create_dirs, Ext, NewExt, + {NewExt, VarExtension}, MmakeRule, !IO) :- + module_name_to_file_name(Globals, $pred, do_not_create_dirs, NewExt, ModuleName, TargetName, !IO), Source = string.format("$(%s%s)", [s(ModuleMakeVarName), s(VarExtension)]), - ExtStr = extension_to_string(Globals, Ext, NewExt), + ExtStr = extension_to_string(Globals, NewExt), MmakeRule = mmake_simple_rule( "collective_target_" ++ ExtStr ++ VarExtension, mmake_rule_is_phony, TargetName, [Source], []). @@ -2594,11 +2521,9 @@ generate_dep_file_clean_targets(Globals, ModuleName, ModuleMakeVarName, % documentation in doc/user_guide.texi. module_name_to_file_name(Globals, $pred, do_not_create_dirs, - ext_other(other_ext(".clean")), newext_mmake_target(ext_mt_clean), ModuleName, CleanTargetName, !IO), module_name_to_file_name(Globals, $pred, do_not_create_dirs, - ext_other(other_ext(".realclean")), newext_mmake_target(ext_mt_realclean), ModuleName, RealCleanTargetName, !IO), @@ -2680,9 +2605,9 @@ get_source_file(DepsMap, ModuleName, FileName) :- %---------------------------------------------------------------------------% -output_module_order(Globals, ModuleName, Ext, NewExt, DepsOrdering, !IO) :- +output_module_order(Globals, ModuleName, NewExt, DepsOrdering, !IO) :- module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(Ext), NewExt, ModuleName, OrdFileName, !IO), + NewExt, ModuleName, OrdFileName, !IO), get_progress_output_stream(Globals, ModuleName, ProgressStream, !IO), globals.lookup_bool_option(Globals, verbose, Verbose), string.format("%% Creating module order file `%s'...", @@ -2757,8 +2682,7 @@ get_both_opt_deps(Globals, BuildOptFiles, IntermodDirs, [Dep | Deps], ), ( Found = no, - make_module_file_name(Globals, $pred, - ext_other(other_ext(".opt")), newext_opt(ext_opt_plain), + make_module_file_name(Globals, $pred, newext_opt(ext_opt_plain), Dep, OptName, !Cache, !IO), search_for_file_returning_dir(IntermodDirs, OptName, MaybeOptDir, !IO), ( @@ -2767,8 +2691,7 @@ get_both_opt_deps(Globals, BuildOptFiles, IntermodDirs, [Dep | Deps], ; MaybeOptDir = error(_) ), - make_module_file_name(Globals, $pred, - ext_other(other_ext(".trans_opt")), newext_opt(ext_opt_trans), + make_module_file_name(Globals, $pred, newext_opt(ext_opt_trans), Dep, TransOptName, !Cache, !IO), search_for_file_returning_dir(IntermodDirs, TransOptName, MaybeTransOptDir, !IO), @@ -2782,10 +2705,10 @@ get_both_opt_deps(Globals, BuildOptFiles, IntermodDirs, [Dep | Deps], Found = yes ). -get_opt_deps(_, _, _, _, _, [], [], !IO). -get_opt_deps(Globals, BuildOptFiles, IntermodDirs, OtherExt, NewExt, +get_opt_deps(_, _, _, _, [], [], !IO). +get_opt_deps(Globals, BuildOptFiles, IntermodDirs, NewExt, [Dep | Deps], !:OptDeps, !IO) :- - get_opt_deps(Globals, BuildOptFiles, IntermodDirs, OtherExt, NewExt, + get_opt_deps(Globals, BuildOptFiles, IntermodDirs, NewExt, Deps, !:OptDeps, !IO), ( BuildOptFiles = yes, @@ -2805,7 +2728,7 @@ get_opt_deps(Globals, BuildOptFiles, IntermodDirs, OtherExt, NewExt, ( Found = no, module_name_to_search_file_name(Globals, $pred, - ext_other(OtherExt), NewExt, Dep, OptName, !IO), + NewExt, Dep, OptName, !IO), search_for_file(IntermodDirs, OptName, MaybeOptDir, !IO), ( MaybeOptDir = ok(_), diff --git a/compiler/write_module_interface_files.m b/compiler/write_module_interface_files.m index 0ba81ae8c..a095fdc55 100644 --- a/compiler/write_module_interface_files.m +++ b/compiler/write_module_interface_files.m @@ -154,14 +154,13 @@ write_short_interface_file_int3(ProgressStream, ErrorStream, Globals, actually_write_interface_file3(ProgressStream, ErrorStream, Globals, ParseTreeInt3, "", no, OutputSucceeded, !IO), touch_interface_datestamp(Globals, ProgressStream, ErrorStream, - ModuleName, other_ext(".date3"), newext_int(ext_int_date_int3), + ModuleName, newext_int(ext_int_date_int3), TouchSucceeded, !IO), Succeeded = OutputSucceeded `and` TouchSucceeded ; EffectivelyErrors = yes, report_file_not_written(ErrorStream, Globals, Specs, [], ModuleName, - other_ext(".int3"), newext_int(ext_int_int3), no, - other_ext(".date3"), newext_int(ext_int_date_int3), !IO), + newext_int(ext_int_int3), no, newext_int(ext_int_date_int3), !IO), Succeeded = did_not_succeed ). @@ -210,15 +209,15 @@ write_private_interface_file_int0(ProgressStream, ErrorStream, Globals, Globals, ParseTreeInt0, "", MaybeTimestamp, OutputSucceeded, !IO), touch_interface_datestamp(Globals, ProgressStream, ErrorStream, - ModuleName, other_ext(".date0"), newext_int(ext_int_date_int0), + ModuleName, newext_int(ext_int_date_int0), TouchSucceeded, !IO), Succeeded = OutputSucceeded `and` TouchSucceeded ; EffectiveGetQualSpecs = [_ | _], report_file_not_written(ErrorStream, Globals, EffectiveGetQualSpecs, [], ModuleName, - other_ext(".int0"), newext_int(ext_int_int0), no, - other_ext(".date0"), newext_int(ext_int_date_int0), !IO), + newext_int(ext_int_int0), no, + newext_int(ext_int_date_int0), !IO), Succeeded = did_not_succeed ) else @@ -227,9 +226,8 @@ write_private_interface_file_int0(ProgressStream, ErrorStream, Globals, PrefixPieces = [words("Error reading interface files."), nl_indent_delta(-1)], report_file_not_written(ErrorStream, Globals, GetSpecs, - PrefixPieces, ModuleName, - other_ext(".int0"), newext_int(ext_int_int0), no, - other_ext(".date0"), newext_int(ext_int_date_int0), !IO), + PrefixPieces, ModuleName, newext_int(ext_int_int0), no, + newext_int(ext_int_date_int0), !IO), Succeeded = did_not_succeed ). @@ -292,7 +290,7 @@ write_interface_file_int1_int2(ProgressStream, ErrorStream, Globals, Globals, ParseTreeInt2, "", MaybeTimestamp, OutputSucceeded2, !IO), touch_interface_datestamp(Globals, ProgressStream, ErrorStream, - ModuleName, other_ext(".date"), newext_int(ext_int_date_int12), + ModuleName, newext_int(ext_int_date_int12), TouchSucceeded, !IO), Succeeded = and_list([OutputSucceeded1, OutputSucceeded2, TouchSucceeded]) @@ -300,9 +298,8 @@ write_interface_file_int1_int2(ProgressStream, ErrorStream, Globals, EffectiveGetQualSpecs = [_ | _], report_file_not_written(ErrorStream, Globals, EffectiveGetQualSpecs, [], ModuleName, - other_ext(".int"), newext_int(ext_int_int1), - yes({other_ext(".int2"), newext_int(ext_int_int2)}), - other_ext(".date"), newext_int(ext_int_date_int12), !IO), + newext_int(ext_int_int1), yes(newext_int(ext_int_int2)), + newext_int(ext_int_date_int12), !IO), Succeeded = did_not_succeed ) else @@ -311,9 +308,9 @@ write_interface_file_int1_int2(ProgressStream, ErrorStream, Globals, PrefixPieces = [words("Error reading .int3 files."), nl_indent_delta(-1)], report_file_not_written(ErrorStream, Globals, GetSpecs, PrefixPieces, - ModuleName, other_ext(".int"), newext_int(ext_int_int1), - yes({other_ext(".int2"), newext_int(ext_int_int2)}), - other_ext(".date"), newext_int(ext_int_date_int12), !IO), + ModuleName, newext_int(ext_int_int1), + yes(newext_int(ext_int_int2)), + newext_int(ext_int_date_int12), !IO), Succeeded = did_not_succeed ). @@ -411,9 +408,9 @@ actually_write_interface_file3(ProgressStream, ErrorStream, Globals, construct_int_file_name(Globals, ModuleName, IntFileKind, ExtraSuffix, OutputFileName, TmpOutputFileName, !IO) :- - int_file_kind_to_extension(IntFileKind, _ExtStr, OtherExt, NewExt), + int_file_kind_to_extension(IntFileKind, _ExtStr, NewExt), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(OtherExt), NewExt, ModuleName, OutputFileName0, !IO), + NewExt, ModuleName, OutputFileName0, !IO), OutputFileName = OutputFileName0 ++ ExtraSuffix, TmpOutputFileName = OutputFileName ++ ".tmp". @@ -584,27 +581,25 @@ insist_on_timestamp(MaybeTimestamp, Timestamp) :- :- pred report_file_not_written(io.text_output_stream::in, globals::in, list(error_spec)::in, list(format_piece)::in, module_name::in, - other_ext::in, newext::in, maybe({other_ext, newext})::in, - other_ext::in, newext::in, io::di, io::uo) is det. + newext::in, maybe(newext)::in, newext::in, io::di, io::uo) is det. report_file_not_written(ErrorStream, Globals, Specs, PrefixPieces, - ModuleName, OtherExtA, NewExtA, MaybeOtherNewExtB, - OtherExtDate, NewExtDate, !IO) :- + ModuleName, NewExtA, MaybeNewExtB, NewExtDate, !IO) :- % We use write_error_spec to print the message the interface file or % files not being written in order to wrap the message if it is % longer than the line length. module_name_to_file_name(Globals, $pred, do_not_create_dirs, - ext_other(OtherExtA), NewExtA, ModuleName, IntAFileName, !IO), + NewExtA, ModuleName, IntAFileName, !IO), module_name_to_file_name(Globals, $pred, do_not_create_dirs, - ext_other(OtherExtDate), NewExtDate, ModuleName, DateFileName, !IO), + NewExtDate, ModuleName, DateFileName, !IO), ( - MaybeOtherNewExtB = no, + MaybeNewExtB = no, NotWrittenPieces = [quote(IntAFileName), words("not written."), nl], ToRemoveFileNames = [IntAFileName, DateFileName] ; - MaybeOtherNewExtB = yes({OtherExtB, NewExtB}), + MaybeNewExtB = yes(NewExtB), module_name_to_file_name(Globals, $pred, do_not_create_dirs, - ext_other(OtherExtB), NewExtB, ModuleName, IntBFileName, !IO), + NewExtB, ModuleName, IntBFileName, !IO), NotWrittenPieces = [quote(IntAFileName), words("and"), quote(IntBFileName), words("not written."), nl], ToRemoveFileNames = [IntAFileName, IntBFileName, DateFileName] diff --git a/compiler/xml_documentation.m b/compiler/xml_documentation.m index 2de8bd766..f5b11d938 100644 --- a/compiler/xml_documentation.m +++ b/compiler/xml_documentation.m @@ -94,8 +94,7 @@ xml_documentation(ModuleInfo, !IO) :- module_info_get_globals(ModuleInfo, Globals), module_info_get_name(ModuleInfo, ModuleName), module_name_to_file_name(Globals, $pred, do_create_dirs, - ext_other(other_ext(".xml")), newext_user_ngs(ext_user_ngs_xml), - ModuleName, FileName, !IO), + newext_user_ngs(ext_user_ngs_xml), ModuleName, FileName, !IO), lookup_module_source_file(ModuleName, MaybeSrcFileName, !IO), (