[m-rev.] diff: cleanups for mmc --make

Julien Fischer juliensf at csse.unimelb.edu.au
Thu Nov 23 11:54:00 AEDT 2006


Estimated hours taken: 1
Branches: main

Change the representation of some types used by mmc --make.
Minor formatting and style cleanups for mmc --make.  There are no changes
to any algorithms.

compiler/make.m:
 	Delete the compilation_task type; it is unused.

 	Convert the target_file and linked_target_file types into
 	du's with named fields.  This is nicer to deal with in mdb
         than pairs.

compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/options_file.m:
 	Conform to the above changes.

 	Make a bunch of minor formatting and style changes.

compiler/make.util.m:
 	Add a predicate make_target_file_list required by the above.

compiler/inst_graph.m:
 	Replace DCGs with state variables.

compiler/common.m:
 	Fix some typos.

Julien.

Index: compiler/common.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/common.m,v
retrieving revision 1.100
diff -u -r1.100 common.m
--- compiler/common.m	13 Oct 2006 04:52:16 -0000	1.100
+++ compiler/common.m	23 Nov 2006 00:28:11 -0000
@@ -18,7 +18,7 @@
  % deconstructions of known cells, replacing them with assignments to the
  % arguments where this is guaranteed to not increase the number of stack slots
  % required by the goal.  Repeated calls to predicates with the same input
-% arguments are replaced by assigments and warnings are returned.
+% arguments are replaced by assignments and warnings are returned.
  %
  % IMPORTANT: This module does a small subset of the job of compile-time
  % garbage collection, but it does so without paying attention to uniqueness
@@ -177,11 +177,11 @@
      % type to information about cells involving that cons_id.
      %
      % The reason why we need the principal type constructors is that two
-    % syntactially identical structures have compatible representations if and
+    % syntactically identical structures have compatible representations if and
      % only if their principal type constructors are the same.  For example, if
      % we have:
      %
-    %   :- type maybe_err(T) --> ok(T) ; err(string).
+    %   :- type maybe_err(T) ---> ok(T) ; err(string).
      %
      %   :- pred p(maybe_err(foo)::in, maybe_err(bar)::out) is semidet.
      %   p(err(X), err(X)).
@@ -347,7 +347,7 @@
      (
          % Don't optimise partially instantiated deconstruction unifications,
          % because it would be tricky to work out how to mode the replacement
-        % asssignment unifications. In the vast majority of cases, the variable
+        % assignment unifications. In the vast majority of cases, the variable
          % is ground.
          Mode = LVarMode - _,
          mode_get_insts(ModuleInfo, LVarMode, Inst0, _),
Index: compiler/inst_graph.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/inst_graph.m,v
retrieving revision 1.12
diff -u -r1.12 inst_graph.m
--- compiler/inst_graph.m	1 Nov 2006 06:32:54 -0000	1.12
+++ compiler/inst_graph.m	23 Nov 2006 00:29:23 -0000
@@ -275,8 +275,8 @@
          ), Args, MAcc0, MAcc)
      ), Functors, !Acc).

-foldl_reachable_from_list(P, InstGraph, Vars) -->
-    list.foldl(foldl_reachable(P, InstGraph), Vars).
+foldl_reachable_from_list(P, InstGraph, Vars, !Acc) :-
+    list.foldl(foldl_reachable(P, InstGraph), Vars, !Acc).

  foldl_reachable2(P, InstGraph, Var, !Acc1, !Acc2) :-
      % A possible alternate implementation:
Index: compiler/make.dependencies.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make.dependencies.m,v
retrieving revision 1.32
diff -u -r1.32 make.dependencies.m
--- compiler/make.dependencies.m	15 Oct 2006 23:26:44 -0000	1.32
+++ compiler/make.dependencies.m	23 Nov 2006 00:13:34 -0000
@@ -129,11 +129,11 @@
          !Info, !IO) :-
      FindDeps(ModuleName, Success, Deps, !Info, !IO).

-    % Note that we go to some effort in this module to stop
-    % dependency calculation as soon as possible if there are errors.
-    % This is important because the calls to get_module_dependencies
-    % from the dependency calculation predicates can result in
-    % every module in the program being read.
+    % Note that we go to some effort in this module to stop dependency
+    % calculation as soon as possible if there are errors.
+    % This is important because the calls to get_module_dependencies from
+    % the dependency calculation predicates can result in every module in
+    % the program being read.
      %
  :- func combine_deps(find_module_deps(T)::in(find_module_deps),
      find_module_deps(T)::in(find_module_deps)) =
@@ -735,11 +735,11 @@
      Modules = set.filter((pred(M::in) is semidet :- Filter(ModuleName, M)),
          Modules0).

-    % If the current module we are compiling is not in the standard
-    % library and the module we are importing is then remove it,
-    % otherwise keep it.  When compiling with `--target il', if the
-    % current module is not in the standard library, we link with
-    % mercury.dll rather than the DLL file for the imported module.
+    % If the current module we are compiling is not in the standard library
+    % and the module we are importing is then remove it, otherwise keep it.
+    % When compiling with `--target il', if the current module is not in the
+    % standard library, we link with mercury.dll rather than the DLL file
+    % for the imported module.
      %
  :- pred maybe_keep_std_lib_module(module_name::in, module_name::in) is semidet.

@@ -965,7 +965,7 @@
          BuildDepsSucceeded, DepFiles, WriteDepFile, DepTimestamps, !IO) :-
      assoc_list.from_corresponding_lists(DepFiles, DepTimestamps,
          DepTimestampAL),
-    solutions.solutions(
+    solutions(
          (pred(DepFile::out) is nondet :-
              list.member(DepFile - error(_), DepTimestampAL)
          ), ErrorDeps),
@@ -1050,7 +1050,7 @@
      io.write_string(": newer dependencies: ", !IO),
      assoc_list.from_corresponding_lists(DepFiles, DepTimestamps,
          DepTimestampAL),
-    solutions.solutions(
+    solutions(
          (pred(DepFile::out) is nondet :-
              list.member(DepFile - MaybeDepTimestamp, DepTimestampAL),
              (
@@ -1086,7 +1086,7 @@
          !:Info = !.Info ^ dependency_status ^ elem(Dep) := Status
      ).
  dependency_status(dep_target(Target) @ Dep, Status, !Info, !IO) :-
-    Target = ModuleName - FileType,
+    Target = target_file(ModuleName, FileType),
      ( FileType = module_target_source ->
          % Source files are always up-to-date.
          ModuleTarget = module_target(module_target_source),
Index: compiler/make.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make.m,v
retrieving revision 1.40
diff -u -r1.40 make.m
--- compiler/make.m	15 Oct 2006 23:26:44 -0000	1.40
+++ compiler/make.m	22 Nov 2006 23:55:50 -0000
@@ -160,8 +160,6 @@
      ;       make_error_dependencies(module_name)
      ;       make_error_other(string).

-:- type compilation_task == pair(compilation_task_type, module_name).
-
  :- type compilation_task_type
      --->    process_module(module_compilation_task_type)

@@ -222,8 +220,17 @@
      ;       deps_status_up_to_date
      ;       deps_status_error.

-:- type target_file == pair(module_name, module_target_type).
-:- type linked_target_file == pair(module_name, linked_target_type).
+:- type target_file
+    --->    target_file(
+                target_file_name :: module_name,
+                target_file_type :: module_target_type
+            ).
+
+:- type linked_target_file 
+    --->    linked_target_file(
+                linked_tf_name :: module_name,
+                linked_tf_type :: linked_target_type
+            ).

  %-----------------------------------------------------------------------------%

@@ -266,10 +273,9 @@
          globals.io_get_globals(Globals, !IO),

          %
-        % Accept and ignore `.depend' targets.
-        % `mmc --make' does not need a separate
-        % make depend step. The dependencies for
-        % each module are regenerated on demand.
+        % Accept and ignore `.depend' targets.  `mmc --make' does not
+        % need a separate make depend step. The dependencies for each
+        % module are regenerated on demand.
          %
          NonDependTargets = list.filter(
              (pred(Target::in) is semidet :-
@@ -314,11 +320,13 @@
      Target = ModuleName - TargetType,
      (
          TargetType = module_target(ModuleTargetType),
-        make_module_target(dep_target(ModuleName - ModuleTargetType), Success,
+        TargetFile = target_file(ModuleName, ModuleTargetType),
+        make_module_target(dep_target(TargetFile), Success,
              !Info, !IO)
      ;
          TargetType = linked_target(ProgramTargetType),
-        make_linked_target(ModuleName - ProgramTargetType, Success, !Info, !IO)
+        LinkedTargetFile = linked_target_file(ModuleName, ProgramTargetType),
+        make_linked_target(LinkedTargetFile, Success, !Info, !IO)
      ;
          TargetType = misc_target(MiscTargetType),
          make_misc_target(ModuleName - MiscTargetType, Success, !Info, !IO)
Index: compiler/make.module_dep_file.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make.module_dep_file.m,v
retrieving revision 1.25
diff -u -r1.25 make.module_dep_file.m
--- compiler/make.module_dep_file.m	15 Oct 2006 23:26:44 -0000	1.25
+++ compiler/make.module_dep_file.m	23 Nov 2006 00:03:47 -0000
@@ -144,11 +144,10 @@
          read_module_dependencies(RebuildDeps, ModuleName, !Info, !IO),

          %
-        % Check for the case where the module name doesn't match
-        % the source file name (e.g. parse.m contains module
-        % mdb.parse). Get the correct source file name from
-        % the module dependency file, then check whether the
-        % module dependency file is up to date.
+        % Check for the case where the module name doesn't match the
+        % source file name (e.g. parse.m contains module mdb.parse). Get
+        % the correct source file name from the module dependency file,
+        % then check whether the module dependency file is up to date.
          %
          map.lookup(!.Info ^ module_dependencies, ModuleName, !:MaybeImports),
          (
@@ -186,11 +185,10 @@
          MaybeDepFileTimestamp = error(_),

          %
-        % Try to make the dependencies. This will succeed
-        % when the module name doesn't match the file name
-        % and the dependencies for this module haven't been
-        % built before. It will fail if the source file is
-        % in another directory.
+        % Try to make the dependencies. This will succeed when the
+        % module name doesn't match the file name and the dependencies
+        % for this module haven't been built before. It will fail if the
+        % source file is in another directory.
          %
          (
              RebuildDeps = yes,
@@ -271,12 +269,12 @@
              mercury_output_foreign_language_string, !IO),
          io.write_string("},\n\t{", !IO),
          io.write_list(Imports  ^ foreign_import_modules, ", ",
-            (pred(ForeignImportModule::in, di, uo) is det -->
-                { ForeignImportModule = foreign_import_module_info(Lang,
-                    ForeignImport, _) },
-                mercury_output_foreign_language_string(Lang),
-                io.write_string(" - "),
-                mercury_output_bracketed_sym_name(ForeignImport)
+            (pred(ForeignImportModule::in, !.IO::di, !:IO::uo) is det :-
+                ForeignImportModule = foreign_import_module_info(Lang,
+                    ForeignImport, _),
+                mercury_output_foreign_language_string(Lang, !IO),
+                io.write_string(" - ", !IO),
+                mercury_output_bracketed_sym_name(ForeignImport, !IO)
              ), !IO),
          io.write_string("},\n\t", !IO),
          io.write(Imports ^ contains_foreign_export, !IO),
@@ -417,12 +415,11 @@
                  := yes(Imports),

              %
-            % Read the dependencies for the nested children.
-            % If something goes wrong (for example one of the
-            % files was removed), the dependencies for all
-            % modules in the source file will be remade
-            % (make_module_dependencies expects to be given
-            % the top-level module in the source file).
+            % Read the dependencies for the nested children.  If something
+            % goes wrong (for example one of the files was removed), the
+            % dependencies for all modules in the source file will be remade
+            % (make_module_dependencies expects to be given the top-level
+            % module in the source file).
              %
              SubRebuildDeps = no,
              list.foldl2(read_module_dependencies(SubRebuildDeps),
@@ -552,9 +549,10 @@
              % while we have the contents of the module. The `int3'
              % file doesn't depend on anything else.
              %
-            ( Error = no_module_errors ->
-                Target = ModuleName -
-                    module_target_unqualified_short_interface,
+            (
+                Error = no_module_errors,
+                Target = target_file(ModuleName,
+                    module_target_unqualified_short_interface),
                  maybe_make_target_message_to_stream(OldOutputStream, Target,
                      !IO),
                  build_with_check_for_interrupt(
@@ -566,6 +564,9 @@
                      cleanup_short_interfaces(SubModuleNames),
                      Succeeded, !Info, !IO)
              ;
+                ( Error = some_module_errors
+                ; Error = fatal_module_errors
+                ),
                  Succeeded = no
              ),

@@ -575,8 +576,9 @@
                          ModuleImportList)
                  ), cleanup_module_dep_files(SubModuleNames), _, !Info, !IO),

-            record_made_target(
-                ModuleName - module_target_unqualified_short_interface,
+            MadeTarget = target_file(ModuleName,
+                module_target_unqualified_short_interface),
+            record_made_target(MadeTarget,
                  process_module(task_make_short_interface), Succeeded,
                  !Info, !IO),
              unredirect_output(ModuleName, ErrorStream, !Info, !IO)
@@ -630,9 +632,9 @@
  maybe_write_importing_module(_, no, !IO).
  maybe_write_importing_module(ModuleName, yes(ImportingModuleName), !IO) :-
      io.write_string("** Module `", !IO),
-    prog_out.write_sym_name(ModuleName, !IO),
+    write_sym_name(ModuleName, !IO),
      io.write_string("' is imported or included by module `", !IO),
-    prog_out.write_sym_name(ImportingModuleName, !IO),
+    write_sym_name(ImportingModuleName, !IO),
      io.write_string("'.\n", !IO).

  %-----------------------------------------------------------------------------%
Index: compiler/make.module_target.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make.module_target.m,v
retrieving revision 1.48
diff -u -r1.48 make.module_target.m
--- compiler/make.module_target.m	25 Oct 2006 03:39:04 -0000	1.48
+++ compiler/make.module_target.m	23 Nov 2006 00:24:22 -0000
@@ -96,7 +96,7 @@
      dependency_status(Dep, Status, !Info, !IO),
      (
          Status = deps_status_not_considered,
-        TargetFile = ModuleName - FileType,
+        TargetFile = target_file(ModuleName, FileType),
          get_module_dependencies(ModuleName, MaybeImports, !Info, !IO),
          (
              MaybeImports = no,
@@ -115,8 +115,10 @@
                  CompilationTask = process_module(_) - _,
                  Imports ^ source_file_module_name \= ModuleName
              ->
+                NestedTargetFile = target_file(
+                    Imports ^ source_file_module_name, FileType),
                  make_module_target_extra_options(ExtraOptions,
-                    dep_target(Imports ^ source_file_module_name - FileType),
+                    dep_target(NestedTargetFile),
                      Succeeded, !Info, !IO)
              ;
                  CompilationTask = CompilationTaskType - _,
@@ -137,7 +139,10 @@
                      union_deps(target_dependencies(Globals, FileType)),
                      ModulesToCheck, DepsSuccess, set.init, DepFiles0,
                      !Info, !IO),
-                ( TargetFile = _ - module_target_private_interface ->
+                (
+                    TargetFile = target_file(_, TargetType),
+                    TargetType = module_target_private_interface
+                ->
                      % Avoid circular dependencies (the `.int0' files
                      % for the nested sub-modules depend on this module's
                      % `.int0' file).
@@ -201,7 +206,10 @@
          Succeeded = yes
      ;
          Status = deps_status_being_built,
-        ( TargetFile = _FileName - module_target_foreign_il_asm(_Lang) ->
+        ( 
+            TargetFile = target_file(_FileName, FileType),
+            FileType = module_target_foreign_il_asm(_Lang)
+        ->
              io.write_string("Error: circular dependency detected " ++
                  "while building\n", !IO),
              io.write_string("  `", !IO),
@@ -249,7 +257,10 @@
          debug_file_msg(TargetFile, "target file does not exist", !IO),
          DepsResult = deps_out_of_date
      ;
-        ( TargetFile = ModuleName - module_target_analysis_registry ->
+        (
+            TargetFile = target_file(ModuleName, FileType),
+            FileType = module_target_analysis_registry
+        ->
              force_reanalysis_of_suboptimal_module(ModuleName, ForceReanalysis,
                  !.Info, !IO)
          ;
@@ -307,33 +318,33 @@
  build_target(CompilationTask, TargetFile, Imports, TouchedTargetFiles,
          TouchedFiles, ExtraOptions, Succeeded, !Info, !IO) :-
      maybe_make_target_message(TargetFile, !IO),
-    TargetFile = ModuleName - _FileType,
+    TargetFile = target_file(ModuleName, _FileType),
      CompilationTask = Task - TaskOptions,
      (
          CompilationTask = process_module(ModuleTask) - _,
          forkable_module_compilation_task_type(ModuleTask) = yes,
          \+ can_fork
      ->
-        % We need a temporary file to pass the arguments to
-        % the mmc process which will do the compilation.
-        % It's created here (not in invoke_mmc) so it can be
-        % cleaned up by build_with_check_for_interrupt.
+        % We need a temporary file to pass the arguments to the mmc process
+        % which will do the compilation.  It's created here
+        % (not in invoke_mmc) so it can be cleaned up by
+        % build_with_check_for_interrupt.
          io.make_temp(ArgFileName, !IO),
          MaybeArgFileName = yes(ArgFileName)
      ;
          MaybeArgFileName = no
      ),
      Cleanup =
-        (pred(MakeInfo0::in, MakeInfo::out, di, uo) is det -->
+        (pred(!.MakeInfo::in, !:MakeInfo::out, !.IO::di, !:IO::uo) is det :-
              % XXX Remove `.int.tmp' files.
              list.foldl2(make_remove_target_file, TouchedTargetFiles,
-                MakeInfo0, MakeInfo1),
-            list.foldl2(make_remove_file, TouchedFiles, MakeInfo1, MakeInfo),
+                !MakeInfo, !IO),
+            list.foldl2(make_remove_file, TouchedFiles, !MakeInfo, !IO),
              (
-                { MaybeArgFileName = yes(ArgFileName2) },
-                io.remove_file(ArgFileName2, _)
+                MaybeArgFileName = yes(ArgFileName2),
+                io.remove_file(ArgFileName2, _, !IO)
              ;
-                { MaybeArgFileName = no }
+                MaybeArgFileName = no
              )
          ),
      build_with_check_for_interrupt(
@@ -366,16 +377,15 @@
          Verbose = no
      ),

-    % Run compilations to target code in a separate process.
-    % This is necessary for `--target asm' because the GCC
-    % backend can only be invoked once per process. It's a good
-    % idea for other the backends because it avoids problems with
-    % the Boehm GC retaining memory by scanning too much of the
-    % Mercury stacks. If the compilation is run in a separate
-    % process, it is also easier to kill if an interrupt arrives.
-    % We do the same for intermodule-optimization interfaces
-    % because if type checking gets overloaded by ambiguities
-    % it can be difficult to kill the compiler otherwise.
+    % Run compilations to target code in a separate process.  This is
+    % necessary for `--target asm' because the GCC backend can only be
+    % invoked once per process. It's a good idea for other the backends
+    % because it avoids problems with the Boehm GC retaining memory by
+    % scanning too much of the Mercury stacks. If the compilation is run in
+    % a separate process, it is also easier to kill if an interrupt arrives.
+    % We do the same for intermodule-optimization interfaces because if type
+    % checking gets overloaded by ambiguities it can be difficult to kill
+    % the compiler otherwise.
      io.set_output_stream(ErrorStream, OldOutputStream, !IO),
      (
          forkable_module_compilation_task_type(ModuleTask) = yes
@@ -576,15 +586,13 @@

      QuotedArgs = list.map(quote_arg, Args),

-    % Some operating systems (e.g. Windows) have shells with
-    % ludicrously short limits on the length of command lines,
-    % so we need to write the arguments to a file which will
-    % be read by the child mmc process.
-    % This code is only called if fork() doesn't work, so there's
-    % no point checking whether the shell actually has this
-    % limitation.
-    % The temporary file is created by the caller so that it will be
-    % removed by build_with_check_for_interrupt if an interrupt occurs.
+    % Some operating systems (e.g. Windows) have shells with ludicrously
+    % short limits on the length of command lines, so we need to write the
+    % arguments to a file which will be read by the child mmc process.
+    % This code is only called if fork() doesn't work, so there's no point
+    % checking whether the shell actually has this limitation.
+    % The temporary file is created by the caller so that it will be removed
+    % by build_with_check_for_interrupt if an interrupt occurs.
      (
          MaybeArgFileName = yes(ArgFileName)
      ;
@@ -722,7 +730,7 @@

  touched_files(TargetFile, process_module(Task), TouchedTargetFiles,
          TouchedFileNames, !Info, !IO) :-
-    TargetFile = ModuleName - FileType,
+    TargetFile = target_file(ModuleName, FileType),
      get_module_dependencies(ModuleName, MaybeImports, !Info, !IO),
      (
          MaybeImports = yes(Imports0),
@@ -787,7 +795,7 @@
                  % a header file.
                  %
                  HeaderModuleNames = SourceFileModuleNames,
-                HeaderTargets0 = make_target_list(HeaderModuleNames,
+                HeaderTargets0 = make_target_file_list(HeaderModuleNames,
                      module_target_c_header(header_mih))
              ;
                  HighLevelCode = no,
@@ -805,13 +813,12 @@
                          contains_foreign_code(_) =
                              MImports ^ has_foreign_code
                      ), ModuleImportsList),
-            HeaderTargets0 = make_target_list(HeaderModuleNames,
+            HeaderTargets0 = make_target_file_list(HeaderModuleNames,
                  module_target_c_header(header_mih))
          ;
-            CompilationTarget = target_il,
-            HeaderTargets0 = []
-        ;
-            CompilationTarget = target_java,
+            ( CompilationTarget = target_il
+            ; CompilationTarget = target_java
+            ),
              HeaderTargets0 = []
          ),

@@ -822,13 +829,14 @@
          ->
              Names = SourceFileModuleNames,
              HeaderTargets =
-                make_target_list(Names, module_target_c_header(header_mh))
+                make_target_file_list(Names, module_target_c_header(header_mh))
                  ++ HeaderTargets0
          ;
              HeaderTargets = HeaderTargets0
          ),

-        TouchedTargetFiles0 = make_target_list(TargetModuleNames, FileType),
+        TouchedTargetFiles0 = make_target_file_list(TargetModuleNames,
+            FileType),
          TouchedTargetFiles = TouchedTargetFiles0 ++ HeaderTargets
      ;
          Task = task_make_interface,
@@ -836,9 +844,11 @@
          % when making the interface.
          ForeignCodeFiles = [],
          TouchedTargetFiles =
-            make_target_list(TargetModuleNames, module_target_long_interface)
+            make_target_file_list(TargetModuleNames,
+                module_target_long_interface)
              ++
-            make_target_list(TargetModuleNames, module_target_short_interface)
+            make_target_file_list(TargetModuleNames,
+                module_target_short_interface)
      ;
          ( Task = task_errorcheck
          ; Task = task_make_short_interface
@@ -847,12 +857,14 @@
          ; Task = task_make_analysis_registry
          ),
          ForeignCodeFiles = [],
-        TouchedTargetFiles = make_target_list(TargetModuleNames, FileType)
+        TouchedTargetFiles = make_target_file_list(TargetModuleNames, FileType)
      ),
      globals.io_get_globals(Globals, !IO),
      list.foldl2(
-        (pred((TargetModuleName - TargetFileType)::in, !.TimestampFiles::in,
-            !:TimestampFiles::out, !.IO::di, !:IO::uo) is det :-
+        (pred(TouchedTargetFile::in,
+            !.TimestampFiles::in, !:TimestampFiles::out, !.IO::di, !:IO::uo)
+            is det :-
+        TouchedTargetFile = target_file(TargetModuleName, TargetFileType),
          ( TimestampExt = timestamp_extension(Globals, TargetFileType) ->
              module_name_to_file_name(TargetModuleName, TimestampExt, no,
                  TimestampFile, !IO),
@@ -868,13 +880,13 @@

  touched_files(TargetFile, foreign_code_to_object_code(PIC, Lang),
          [TargetFile], [ForeignObjectFile], !Info, !IO) :-
-    TargetFile = ModuleName - _,
+    TargetFile = target_file(ModuleName, _),
      foreign_code_file(ModuleName, PIC, Lang, ForeignCodeFile, !IO),
      ForeignObjectFile = ForeignCodeFile ^ object_file.

  touched_files(TargetFile, fact_table_code_to_object_code(PIC, FactTableName),
          [TargetFile], [FactTableObjectFile], !Info, !IO) :-
-    TargetFile = ModuleName - _,
+    TargetFile = target_file(ModuleName, _),
      globals.io_get_globals(Globals, !IO),
      ObjExt = get_object_extension(Globals, PIC),
      fact_table_file_name(ModuleName, FactTableName, ObjExt, yes,
Index: compiler/make.program_target.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make.program_target.m,v
retrieving revision 1.57
diff -u -r1.57 make.program_target.m
--- compiler/make.program_target.m	15 Nov 2006 08:12:55 -0000	1.57
+++ compiler/make.program_target.m	23 Nov 2006 00:06:23 -0000
@@ -50,7 +50,8 @@

  %-----------------------------------------------------------------------------%

-make_linked_target(MainModuleName - FileType, Succeeded, !Info, !IO) :-
+make_linked_target(LinkedTargetFile, Succeeded, !Info, !IO) :-
+    LinkedTargetFile = linked_target_file(MainModuleName, FileType),
      (
          FileType = shared_library,
          ExtraOptions = ["--compile-to-shared-lib"]
@@ -91,7 +92,8 @@
          (
              Succeeded0 = yes,
              build_with_module_options(MainModuleName, ExtraOptions,
-                make_linked_target_2(MainModuleName - FileType),
+                make_linked_target_2(
+                    linked_target_file(MainModuleName, FileType)),
                  Succeeded, !Info, !IO)
          ;
              Succeeded0 = no,
@@ -102,7 +104,8 @@
  :- pred make_linked_target_2(linked_target_file::in, list(string)::in,
      bool::out, make_info::in, make_info::out, io::di, io::uo) is det.

-make_linked_target_2(MainModuleName - FileType, _, Succeeded, !Info, !IO) :-
+make_linked_target_2(LinkedTargetFile, _, Succeeded, !Info, !IO) :-
+    LinkedTargetFile = linked_target_file(MainModuleName, FileType),
      find_reachable_local_modules(MainModuleName, DepsSuccess,
          AllModules, !Info, !IO),
      globals.io_lookup_bool_option(keep_going, KeepGoing, !IO),
@@ -192,8 +195,8 @@
      ->
          % `.err' and `.s' files are only produced for the top-level module
          % in each source file.
-        list.foldl3(get_target_modules_2, AllModules,
-            [], TargetModules, !Info, !IO)
+        list.foldl3(get_target_modules_2, AllModules, [], TargetModules,
+            !Info, !IO)
      ;
          TargetModules = AllModules
      ).
@@ -234,15 +237,16 @@
          Imports ^ has_foreign_code = contains_foreign_code(Langs),
          set.member(lang_c, Langs)
      ->
-        ForeignObjectTargets =
-            [dep_target(ModuleName
-                - module_target_foreign_object(PIC, lang_c))]
+        ForeignObjectFileType = module_target_foreign_object(PIC, lang_c),
+        ForeignObjectTarget   = target_file(ModuleName, ForeignObjectFileType),
+        ForeignObjectTargets  = [dep_target(ForeignObjectTarget)]
      ;
          CompilationTarget = target_il,
          Imports ^ has_foreign_code = contains_foreign_code(Langs)
      ->
          ForeignObjectTargets = list.map(
-            (func(L) = dep_target(ModuleName - module_target_foreign_il_asm(L))
+            (func(L) = dep_target(target_file(ModuleName,
+                module_target_foreign_il_asm(L)))
              ), set.to_sorted_list(Langs))
      ;
          ForeignObjectTargets = []
@@ -256,8 +260,8 @@
          ),
          FactObjectTargets = list.map(
              (func(FactFile) =
-                dep_target(ModuleName -
-                    module_target_fact_table_object(PIC, FactFile))
+                dep_target(target_file(ModuleName,
+                    module_target_fact_table_object(PIC, FactFile)))
              ),
              Imports ^ fact_table_deps),
          ObjectTargets = FactObjectTargets ++ ForeignObjectTargets
@@ -576,14 +580,16 @@
              IntSucceeded, !Info, !IO),
          (
              IntSucceeded = yes,
-            make_linked_target(MainModuleName - static_library,
+            make_linked_target(
+                linked_target_file(MainModuleName, static_library),
                  StaticSucceeded, !Info, !IO),
              shared_libraries_supported(SharedLibsSupported, !IO),
              (
                  StaticSucceeded = yes,
                  (
                      SharedLibsSupported = yes,
-                    make_linked_target(MainModuleName - shared_library,
+                    make_linked_target(
+                        linked_target_file(MainModuleName, shared_library),
                          SharedLibsSucceeded, !Info, !IO)
                  ;
                      SharedLibsSupported = no,
@@ -770,7 +776,7 @@

  reset_analysis_registry_dependency_status(ModuleName, Info,
          Info ^ dependency_status ^ elem(Dep) := deps_status_not_considered) :-
-    Dep = dep_target(ModuleName - module_target_analysis_registry).
+    Dep = dep_target(target_file(ModuleName, module_target_analysis_registry)).

  %-----------------------------------------------------------------------------%

@@ -855,7 +861,7 @@
          globals.io_get_target(Target, !IO),
          (
              % `.mh' files are (were) only generated for modules containing
-            % `:- pragma export' declarations.
+            % `:- pragma foreign_export' declarations.
              % But `.mh' files are expected by Mmake so always generate them,
              % otherwise there is trouble using libraries installed by
              % `mmc --make' with Mmake.
@@ -943,7 +949,7 @@
          StatusMap = map.from_assoc_list(list.filter(
              (pred((File - _)::in) is semidet :-
                  \+ (
-                    File = dep_target(_ - Target),
+                    File = dep_target(target_file(_, Target)),
                      target_is_grade_or_arch_dependent(Target)
                  )
              ),
Index: compiler/make.util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make.util.m,v
retrieving revision 1.38
diff -u -r1.38 make.util.m
--- compiler/make.util.m	25 Oct 2006 03:39:04 -0000	1.38
+++ compiler/make.util.m	23 Nov 2006 00:26:29 -0000
@@ -186,6 +186,9 @@

  :- func make_target_list(list(K), V) = assoc_list(K, V).

+:- func make_target_file_list(list(module_name), module_target_type) = 
+    list(target_file).
+
  :- func make_dependency_list(list(module_name), module_target_type)
      = list(dependency_file).

@@ -249,8 +252,8 @@
      %
  :- pred file_error(file_name::in, io::di, io::uo) is det.

-    % If the given target was specified on the command
-    % line, warn that it was already up to date.
+    % If the given target was specified on the command line, warn that it
+    % was already up to date.
      %
  :- pred maybe_warn_up_to_date_target(pair(module_name, target_type)::in,
      make_info::in, make_info::out, io::di, io::uo) is det.
@@ -528,8 +531,8 @@

  %-----------------------------------------------------------------------------%

-get_timestamp_file_timestamp(ModuleName - FileType, MaybeTimestamp,
-        !Info, !IO) :-
+get_timestamp_file_timestamp(target_file(ModuleName, FileType),
+        MaybeTimestamp, !Info, !IO) :-
      globals.io_get_globals(Globals, !IO),
      ( TimestampExt = timestamp_extension(Globals, FileType) ->
          module_name_to_file_name(ModuleName, TimestampExt, no, FileName, !IO)
@@ -557,7 +560,7 @@
  get_dependency_timestamp(dep_target(Target), MaybeTimestamp, !Info, !IO) :-
      get_target_timestamp(yes, Target, MaybeTimestamp0, !Info, !IO),
      (
-        Target = _ - module_target_c_header(header_mih),
+        Target = target_file(_, module_target_c_header(header_mih)),
          MaybeTimestamp0 = ok(_)
      ->
          % Don't rebuild the `.o' file if an irrelevant part of a
@@ -571,7 +574,7 @@
      ).

  get_target_timestamp(Search, Target, MaybeTimestamp, !Info, !IO) :-
-    ( Target = ModuleName - module_target_analysis_registry ->
+    ( Target = target_file(ModuleName, module_target_analysis_registry) ->
          get_target_timestamp_analysis_registry(Search, ModuleName,
              MaybeTimestamp, !Info, !IO)
      ;
@@ -599,8 +602,8 @@
              ; Status = suboptimal
              ),
              get_timestamp_file_timestamp(
-                ModuleName - module_target_analysis_registry, MaybeTimestamp0,
-                !Info, !IO),
+                target_file(ModuleName, module_target_analysis_registry),
+                MaybeTimestamp0, !Info, !IO),
              (
                  MaybeTimestamp0 = ok(_),
                  MaybeTimestamp = MaybeTimestamp0
@@ -619,17 +622,17 @@
      ;
          MaybeStatus = no,
          get_target_timestamp_2(Search,
-            ModuleName - module_target_analysis_registry, MaybeTimestamp,
-            !Info, !IO)
+            target_file(ModuleName, module_target_analysis_registry),
+            MaybeTimestamp, !Info, !IO)
      ).

  :- pred get_target_timestamp_2(bool::in, target_file::in,
      maybe_error(timestamp)::out, make_info::in, make_info::out,
      io::di, io::uo) is det.

-get_target_timestamp_2(Search, ModuleName - FileType, MaybeTimestamp,
-        !Info, !IO) :-
-    get_file_name(Search, ModuleName - FileType, FileName, !Info, !IO),
+get_target_timestamp_2(Search, TargetFile, MaybeTimestamp, !Info, !IO) :-
+    TargetFile = target_file(ModuleName, FileType),
+    get_file_name(Search, TargetFile, FileName, !Info, !IO),
      (
          Search = yes,
          get_search_directories(FileType, SearchDirs, !IO)
@@ -664,7 +667,8 @@
          MaybeTimestamp = MaybeTimestamp0
      ).

-get_file_name(Search, ModuleName - FileType, FileName, !Info, !IO) :-
+get_file_name(Search, TargetFile, FileName, !Info, !IO) :-
+    TargetFile = target_file(ModuleName, FileType),
      ( FileType = module_target_source ->
          % In some cases the module name won't match the file name
          % (module mdb.parse might be in parse.m or mdb.m), so we need to
@@ -757,7 +761,7 @@

  %-----------------------------------------------------------------------------%

-make_remove_target_file(ModuleName - FileType, !Info, !IO) :-
+make_remove_target_file(target_file(ModuleName, FileType), !Info, !IO) :-
      make_remove_target_file(ModuleName, FileType, !Info, !IO).

  make_remove_target_file(ModuleName, FileType, !Info, !IO) :-
@@ -791,8 +795,13 @@

  make_target_list(Ks, V) = list.map((func(K) = K - V), Ks).

+make_target_file_list(ModuleNames, FileType) = 
+    list.map((func(ModuleName) = target_file(ModuleName, FileType)),
+        ModuleNames).
+
  make_dependency_list(ModuleNames, FileType) =
-    list.map((func(Module) = dep_target(Module - FileType)), ModuleNames).
+    list.map((func(Module) = dep_target(target_file(Module, FileType))),
+        ModuleNames).

  target_extension(_, module_target_source) = yes(".m").
  target_extension(_, module_target_errors) = yes(".err").
@@ -821,17 +830,17 @@
  target_extension(_, module_target_foreign_il_asm(_)) = no.
  target_extension(_, module_target_fact_table_object(_, _)) = no.

-linked_target_file_name(ModuleName, executable, FileName) -->
-    globals.io_lookup_string_option(executable_file_extension, Ext),
-    module_name_to_file_name(ModuleName, Ext, no, FileName).
-linked_target_file_name(ModuleName, static_library, FileName) -->
-    globals.io_lookup_string_option(library_extension, Ext),
-    module_name_to_lib_file_name("lib", ModuleName, Ext, no, FileName).
-linked_target_file_name(ModuleName, shared_library, FileName) -->
-    globals.io_lookup_string_option(shared_library_extension, Ext),
-    module_name_to_lib_file_name("lib", ModuleName, Ext, no, FileName).
-linked_target_file_name(ModuleName, java_archive, FileName) -->
-    module_name_to_file_name(ModuleName, ".jar", no, FileName).
+linked_target_file_name(ModuleName, executable, FileName, !IO) :-
+    globals.io_lookup_string_option(executable_file_extension, Ext, !IO),
+    module_name_to_file_name(ModuleName, Ext, no, FileName, !IO).
+linked_target_file_name(ModuleName, static_library, FileName, !IO) :-
+    globals.io_lookup_string_option(library_extension, Ext, !IO),
+    module_name_to_lib_file_name("lib", ModuleName, Ext, no, FileName, !IO).
+linked_target_file_name(ModuleName, shared_library, FileName, !IO) :-
+    globals.io_lookup_string_option(shared_library_extension, Ext, !IO),
+    module_name_to_lib_file_name("lib", ModuleName, Ext, no, FileName, !IO).
+linked_target_file_name(ModuleName, java_archive, FileName, !IO) :-
+    module_name_to_file_name(ModuleName, ".jar", no, FileName, !IO).

  :- pred module_target_to_file_name(module_name::in, module_target_type::in,
      bool::in, file_name::out, io::di, io::uo) is det.
@@ -1005,11 +1014,11 @@

  debug_file_msg(TargetFile, Msg, !IO) :-
      debug_msg(
-        (pred(di, uo) is det -->
-            write_target_file(TargetFile),
-            io.write_string(": "),
-            io.write_string(Msg),
-            io.nl
+        (pred(!.IO::di, !:IO::uo) is det :-
+            write_target_file(TargetFile, !IO),
+            io.write_string(": ", !IO),
+            io.write_string(Msg, !IO),
+            io.nl(!IO)
          ), !IO).

  write_dependency_file(dep_target(TargetFile), !IO) :-
@@ -1017,16 +1026,17 @@
  write_dependency_file(dep_file(FileName, _), !IO) :-
      io.write_string(FileName, !IO).

-write_target_file(ModuleName - FileType, !IO) :-
+write_target_file(TargetFile, !IO) :-
+    TargetFile = target_file(ModuleName, FileType),
      module_target_to_file_name(ModuleName, FileType, no, FileName, !IO),
      io.write_string(FileName, !IO).

  maybe_make_linked_target_message(TargetFile, !IO) :-
      verbose_msg(
-        (pred(di, uo) is det -->
-            io.write_string("Making "),
-            io.write_string(TargetFile),
-            io.nl
+        (pred(!.IO::di, !:IO::uo) is det :-
+            io.write_string("Making ", !IO),
+            io.write_string(TargetFile, !IO),
+            io.nl(!IO)
          ), !IO).

  maybe_make_target_message(TargetFile, !IO) :-
@@ -1035,12 +1045,12 @@

  maybe_make_target_message_to_stream(OutputStream, TargetFile, !IO) :-
      verbose_msg(
-        (pred(di, uo) is det -->
-            io.set_output_stream(OutputStream, OldOutputStream),
-            io.write_string("Making "),
-            write_target_file(TargetFile),
-            io.nl,
-            io.set_output_stream(OldOutputStream, _)
+        (pred(!.IO::di, !:IO::uo) is det :-
+            io.set_output_stream(OutputStream, OldOutputStream, !IO),
+            io.write_string("Making ", !IO),
+            write_target_file(TargetFile, !IO),
+            io.nl(!IO),
+            io.set_output_stream(OldOutputStream, _, !IO)
          ), !IO).

  maybe_reanalyse_modules_message(!IO) :-
@@ -1093,7 +1103,8 @@
  write_module_or_linked_target(ModuleName - FileType, !IO) :-
      (
          FileType = module_target(ModuleTargetType),
-        write_target_file(ModuleName - ModuleTargetType, !IO)
+        TargetFile = target_file(ModuleName, ModuleTargetType),
+        write_target_file(TargetFile, !IO)
      ;
          FileType = linked_target(LinkedTargetType),
          linked_target_file_name(ModuleName, LinkedTargetType, FileName, !IO),
Index: compiler/options_file.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/options_file.m,v
retrieving revision 1.39
diff -u -r1.39 options_file.m
--- compiler/options_file.m	17 Oct 2006 15:15:28 -0000	1.39
+++ compiler/options_file.m	23 Nov 2006 00:00:10 -0000
@@ -5,13 +5,13 @@
  % This file may only be copied under the terms of the GNU General
  % Public License - see the file COPYING in the Mercury distribution.
  %-----------------------------------------------------------------------------%
-
+%
  % File: options_file.m.
  % Main author: stayl.
-
+%
  % Code to deal with options for `mmc --make', including code to parse
-% an Mmakefile equivalent.
-
+% Mercury.options files.
+%
  %-----------------------------------------------------------------------------%

  :- module make.options_file.
@@ -91,6 +91,7 @@
  :- import_module map.
  :- import_module std_util.
  :- import_module string.
+:- import_module svmap.
  :- import_module term.
  :- import_module univ.

@@ -460,11 +461,11 @@
              ),
              OptVarValue = options_variable_value(NewValue, Words,
                  options_file),
-            map.set(!.Variables, VarName, OptVarValue, !:Variables)
+            svmap.set(VarName, OptVarValue, !Variables)
          )
      ;
          OptVarValue = options_variable_value(NewValue1, Words1, options_file),
-        map.set(!.Variables, VarName, OptVarValue, !:Variables)
+        svmap.set(VarName, OptVarValue, !Variables)
      ).

  :- pred expand_variables(options_variables::in, list(char)::in,

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list