[m-rev.] for review: document coverage testing

Zoltan Somogyi zs at csse.unimelb.edu.au
Mon Oct 2 15:19:35 AEST 2006


On 29-Sep-2006, Zoltan Somogyi <zs at csse.unimelb.edu.au> wrote:
> > I therefore think it'd be better to keep the definition of the term
> > "label" and use that to describe what the trace counts are counting.
> 
> I disagree.

Ian doesn't object to "event" very strongly, so I kept that terminology.
The committed diff follows.

Zoltan.

Document my recent change implementing coverage testing. At the same time,
eliminate the old hack that allowed a file containing a list of file names to
be considered a trace count file. We haven't needed it since the addition of
mtc_union, and it can lead to incomprensible error messages. (The presence
of the old hack made documenting coverage testing harder.)

In the process, fix the tools code for rerunning failed test cases only.

doc/user_guide.texi:
	Document my recent change implementing coverage testing, and the
	elimination of the old hack.

mdbcomp/trace_counts.m:
	Modify the predicates for reading in trace count files along the lines
	above.

mdbcomp/slice_and_dice.m:
	Modify the predicates for reading in slices and dices along the lines
	above.

	Rename some function symbols to avoid ambiguities.

compiler/tupling.m:
slice/mcov.m:
slice/mtc_diff.m:
slice/mtc_union.m:
trace/mercury_trace_declarative.c:
	Conform to the changes above.

slice/mcov.m:
	Fix the usage message, which referred to this program by its old name
	mct.

	Allow the output to be restricted to a set of named modules only.
	This is to make testing easier.

slice/mtc_diff.m:
	Rename the long form of the -o option from --out to --output-file,
	to make it consistent with the other programs.

tests/run_one_test:
tools/bootcheck:
	Modify the algorithm we use to gather trace counts for the Mercury
	compiler from both passed and failed test cases to run mtc_union
	periodically instead of gathering all the trace counts file and keeping
	them to the end (which takes far too much disk space).

	Fix an old bug: gather trace counts from executions of the Mercury
	compiler only.

tests/debugger/Mmakefile:
tests/debugger/dice.passes:
	Modify the dice test case to compute the union of the trace counts for
	the passed versions of this test case to use mtc_union to create
	dice.passes, instead of having dice.passes statically contain the list
	of the names of the passed trace count files (since that capability
	is deleted by this diff).

tools/bootcheck:
tests/Mmake.common:
	Fix the code for rerunning failed tests only.

mdbcomp/prim_data.m:
	Eliminate some ambiguities in predicate names.

compiler/*.m:
	Conform to the change to prim_data.m.

compiler/error_util.m:
	Add reading files as a phase in error messages.

compiler/mercury_compile.m:
	Use the new facilities in error_util for printing an error message.

cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/libatomic_ops-1.2
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/doc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/hpc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/ibmc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/icc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/msftc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/src/atomic_ops/sysdeps/sunc
cvs diff: Diffing boehm_gc/libatomic_ops-1.2/tests
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing boehm_gc/windows-untested
cvs diff: Diffing boehm_gc/windows-untested/vc60
cvs diff: Diffing boehm_gc/windows-untested/vc70
cvs diff: Diffing boehm_gc/windows-untested/vc71
cvs diff: Diffing browser
Index: browser/declarative_debugger.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/browser/declarative_debugger.m,v
retrieving revision 1.71
diff -u -b -r1.71 declarative_debugger.m
--- browser/declarative_debugger.m	31 Aug 2006 11:09:47 -0000	1.71
+++ browser/declarative_debugger.m	30 Sep 2006 09:53:41 -0000
@@ -741,7 +741,7 @@
     "MR_DD_decl_add_trusted_module").
 
 add_trusted_module(ModuleName, Diagnoser0, Diagnoser) :-
-    string_to_sym_name(ModuleName, ".", SymModuleName),
+    SymModuleName = string_to_sym_name(ModuleName),
     add_trusted_module(SymModuleName, Diagnoser0 ^ oracle_state, Oracle),
     Diagnoser = Diagnoser0 ^ oracle_state := Oracle.
 
Index: browser/declarative_oracle.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/browser/declarative_oracle.m,v
retrieving revision 1.53
diff -u -b -r1.53 declarative_oracle.m
--- browser/declarative_oracle.m	22 Aug 2006 05:03:30 -0000	1.53
+++ browser/declarative_oracle.m	30 Sep 2006 09:54:19 -0000
@@ -398,15 +398,15 @@
 
 format_trust_command(module(ModuleName),
         S, S ++ "trust " ++ ModuleNameStr ++ "\n") :-
-    sym_name_to_string(ModuleName, ".", ModuleNameStr).
+    ModuleNameStr = sym_name_to_string(ModuleName).
 format_trust_command(predicate(ModuleName, Name, Arity), S, S ++ Command) :-
     ArityStr = int_to_string(Arity),
-    sym_name_to_string(ModuleName, ".", ModuleNameStr),
+    ModuleNameStr = sym_name_to_string(ModuleName),
     Command = "trust pred*" ++ ModuleNameStr ++ "." ++ Name ++ "/"
         ++ ArityStr ++ "\n".
 format_trust_command(function(ModuleName, Name, Arity), S, S ++ Command) :-
     ArityStr = int_to_string(Arity - 1),
-    sym_name_to_string(ModuleName, ".", ModuleNameStr),
+    ModuleNameStr = sym_name_to_string(ModuleName),
     Command = "trust func*" ++ ModuleNameStr ++ "." ++ Name ++ "/"
         ++ ArityStr ++ "\n".
 format_trust_command(standard_library, S, S ++ "trust std lib\n").
@@ -415,16 +415,16 @@
     string::out) is det.
 
 format_trust_display(Id, module(ModuleName), S, S ++ Display) :-
-    sym_name_to_string(ModuleName, ".", ModuleNameStr),
+    ModuleNameStr = sym_name_to_string(ModuleName),
     Display = int_to_string(Id) ++ ": module " ++ ModuleNameStr ++ "\n".
 format_trust_display(Id, predicate(ModuleName, Name, Arity),
         S, S ++ Display) :-
-    sym_name_to_string(ModuleName, ".", ModuleNameStr),
+    ModuleNameStr = sym_name_to_string(ModuleName),
     Display = int_to_string(Id) ++ ": predicate " ++ ModuleNameStr ++ "." 
         ++ Name ++ "/" ++ int_to_string(Arity) ++ "\n".
 format_trust_display(Id, function(ModuleName, Name, Arity),
         S, S ++ Display) :-
-    sym_name_to_string(ModuleName, ".", ModuleNameStr),
+    ModuleNameStr = sym_name_to_string(ModuleName),
     Display = int_to_string(Id) ++ ": function " ++ ModuleNameStr ++ "." ++
         Name ++ "/" ++ int_to_string(Arity - 1) ++ "\n".
 format_trust_display(Id, standard_library, S, S ++ Display) :-
Index: browser/declarative_tree.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/browser/declarative_tree.m,v
retrieving revision 1.46
diff -u -b -r1.46 declarative_tree.m
--- browser/declarative_tree.m	5 Sep 2006 06:21:19 -0000	1.46
+++ browser/declarative_tree.m	30 Sep 2006 09:55:49 -0000
@@ -1512,8 +1512,7 @@
     ProcLabel = get_proc_label_from_layout(Atom ^ proc_layout),
     get_pred_attributes(ProcLabel, EventModule, EventName, _, _),
     EventArity = length(Atom ^ atom_args),
-    sym_name_to_string(EventModule, ".", EventModuleStr),
-    EventModuleStr = GoalModule,
+    GoalModule = sym_name_to_string(EventModule),
     EventName = GoalName,
     EventArity = GoalArity.
 
Index: browser/declarative_user.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/browser/declarative_user.m,v
retrieving revision 1.65
diff -u -b -r1.65 declarative_user.m
--- browser/declarative_user.m	20 Sep 2006 09:42:01 -0000	1.65
+++ browser/declarative_user.m	30 Sep 2006 09:56:10 -0000
@@ -689,7 +689,7 @@
     get_user_arg_values(Args, ArgValues),
     get_pred_attributes(ProcLabel, Module, Name, _, PredOrFunc),
     IsFunction = pred_to_bool(unify(PredOrFunc, function)),
-    sym_name_to_string(Module, ".", ModuleStr),
+    ModuleStr = sym_name_to_string(Module),
     BrowserTerm = synthetic_term_to_browser_term(ModuleStr ++ "." ++ Name,
         ArgValues, IsFunction),
     browse_browser_term(BrowserTerm, !.User ^ instr, !.User ^ outstr,
@@ -708,7 +708,7 @@
     get_user_arg_values(Args, ArgValues),
     get_pred_attributes(ProcLabel, Module, Name, _, PredOrFunc),
     IsFunction = pred_to_bool(unify(PredOrFunc, function)),
-    sym_name_to_string(Module, ".", ModuleStr),
+    ModuleStr = sym_name_to_string(Module),
     BrowserTerm = synthetic_term_to_browser_term(ModuleStr ++ "." ++ Name,
         ArgValues, IsFunction),
     save_and_browse_browser_term_xml(BrowserTerm, User ^ outstr,
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/add_clause.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_clause.m,v
retrieving revision 1.35
diff -u -b -r1.35 add_clause.m
--- compiler/add_clause.m	22 Sep 2006 05:35:32 -0000	1.35
+++ compiler/add_clause.m	30 Sep 2006 10:17:51 -0000
@@ -117,7 +117,7 @@
         ->
             PredId = PredId0,
             ( GoalType = goal_type_promise(_) ->
-                sym_name_to_string(PredName, NameString),
+                NameString = sym_name_to_string(PredName),
                 string.format("%s %s %s (%s).\n",
                     [s("Attempted to introduce a predicate"),
                     s("for a promise with an identical"),
Index: compiler/add_heap_ops.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_heap_ops.m,v
retrieving revision 1.30
diff -u -b -r1.30 add_heap_ops.m
--- compiler/add_heap_ops.m	31 Jul 2006 08:31:26 -0000	1.30
+++ compiler/add_heap_ops.m	30 Sep 2006 10:24:54 -0000
@@ -346,7 +346,7 @@
 
 generate_call(PredName, Detism, Purity, Args, InstMap, ModuleInfo, Context,
         CallGoal) :-
-    mercury_private_builtin_module(BuiltinModule),
+    BuiltinModule = mercury_private_builtin_module,
     goal_util.generate_simple_call(BuiltinModule, PredName, predicate,
         only_mode, Detism, Purity, Args, [], InstMap, ModuleInfo,
         Context, CallGoal).
Index: compiler/add_pragma.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_pragma.m,v
retrieving revision 1.51
diff -u -b -r1.51 add_pragma.m
--- compiler/add_pragma.m	1 Oct 2006 06:05:02 -0000	1.51
+++ compiler/add_pragma.m	1 Oct 2006 08:50:13 -0000
@@ -2023,7 +2023,7 @@
 
 create_tabling_statistics_pred(ProcId, Context, SimpleCallId, SingleProc,
         !ProcTable, !Status, !ModuleInfo, !QualInfo, !Specs) :-
-    mercury_table_builtin_module(TableBuiltinModule),
+    TableBuiltinModule = mercury_table_builtin_module,
     StatsTypeName = qualified(TableBuiltinModule, "proc_table_statistics"),
     StatsType = defined_type(StatsTypeName, [], kind_star),
     ArgDecl1 = type_and_mode(StatsType, out_mode),
Index: compiler/add_trail_ops.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_trail_ops.m,v
retrieving revision 1.42
diff -u -b -r1.42 add_trail_ops.m
--- compiler/add_trail_ops.m	6 Sep 2006 04:02:54 -0000	1.42
+++ compiler/add_trail_ops.m	30 Sep 2006 10:25:18 -0000
@@ -183,7 +183,7 @@
         % make sure that it can't fail. So we use a call to
         % `private_builtin.unused' (which will call error/1) rather than
         % `fail' for the "then" part.
-        mercury_private_builtin_module(PrivateBuiltin),
+        PrivateBuiltin = mercury_private_builtin_module,
         generate_simple_call(PrivateBuiltin, "unused", predicate, only_mode,
             detism_det, purity_pure, [], [], [], ModuleInfo, Context, ThenGoal)
     ;
@@ -613,7 +613,7 @@
 
 trail_generate_call(PredName, Detism, Purity, Args, InstMap, ModuleInfo,
         Context, CallGoal) :-
-    mercury_private_builtin_module(BuiltinModule),
+    BuiltinModule = mercury_private_builtin_module,
     goal_util.generate_simple_call(BuiltinModule, PredName, predicate,
         only_mode, Detism, Purity, Args, [], InstMap, ModuleInfo, Context,
         CallGoal).
@@ -626,7 +626,7 @@
 
 trail_generate_foreign_proc(PredName, Purity, InstMap,
         ModuleInfo, Context, Args, ForeignCode, ForeignProcGoal) :-
-    mercury_private_builtin_module(PrivateBuiltinModule),
+    PrivateBuiltinModule = mercury_private_builtin_module,
     Detism = detism_det,
     some [!ForeignProcAttrs] (
         % XXX handle other target languages here.
Index: compiler/add_type.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_type.m,v
retrieving revision 1.20
diff -u -b -r1.20 add_type.m
--- compiler/add_type.m	10 Sep 2006 23:38:58 -0000	1.20
+++ compiler/add_type.m	30 Sep 2006 10:18:12 -0000
@@ -799,7 +799,7 @@
         % XXX We should record each error.
         % using module_info_incr_errors
         FieldDefn = hlds_ctor_field_defn(Context, _, _, _, _),
-        sym_name_to_string(FieldName, FieldString),
+        FieldString = sym_name_to_string(FieldName),
         Pieces = [words("Error: field"), quote(FieldString),
             words("multiply defined.")],
         Msg1 = simple_msg(Context, [always(Pieces)]),
Index: compiler/bytecode.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/bytecode.m,v
retrieving revision 1.70
diff -u -b -r1.70 bytecode.m
--- compiler/bytecode.m	27 Sep 2006 06:16:47 -0000	1.70
+++ compiler/bytecode.m	30 Sep 2006 10:13:39 -0000
@@ -697,8 +697,7 @@
 :- pred output_module_id(byte_module_id::in, io::di, io::uo) is det.
 
 output_module_id(ModuleId, !IO) :-
-    sym_name_to_string(ModuleId, ModuleIdString),
-    output_string(ModuleIdString, !IO).
+    output_string(sym_name_to_string(ModuleId), !IO).
 
 :- pred debug_module_id(byte_module_id::in, io::di, io::uo) is det.
 
Index: compiler/check_typeclass.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/check_typeclass.m,v
retrieving revision 1.101
diff -u -b -r1.101 check_typeclass.m
--- compiler/check_typeclass.m	27 Sep 2006 06:16:48 -0000	1.101
+++ compiler/check_typeclass.m	30 Sep 2006 10:14:52 -0000
@@ -542,7 +542,7 @@
         OrderedInstanceMethods = OrderedInstanceMethods0,
         InstanceDefn = InstanceDefn0,
         ClassId = class_id(ClassName, _ClassArity),
-        sym_name_to_string(ClassName, ClassNameString),
+        ClassNameString = sym_name_to_string(ClassName),
         InstanceTypesString = mercury_type_list_to_string(InstanceVarSet,
             InstanceTypes),
         ErrorHeaderPieces =
@@ -574,7 +574,7 @@
         OrderedInstanceMethods = OrderedInstanceMethods0,
         InstanceDefn = InstanceDefn0,
         ClassId = class_id(ClassName, _ClassArity),
-        sym_name_to_string(ClassName, ClassNameString),
+        ClassNameString = sym_name_to_string(ClassName),
         InstanceTypesString = mercury_type_list_to_string(InstanceVarSet,
             InstanceTypes),
 
@@ -770,8 +770,8 @@
 make_introduced_pred_name(ClassId, MethodName, Arity, InstanceTypes,
         PredName) :-
     ClassId = class_id(ClassName, _ClassArity),
-    sym_name_to_string(ClassName, "__", ClassNameString),
-    sym_name_to_string(MethodName, "__", MethodNameString),
+    ClassNameString = sym_name_to_string_sep(ClassName, "__"),
+    MethodNameString = sym_name_to_string_sep(MethodName, "__"),
     % Perhaps we should include the arity in this mangled string?
     string.int_to_string(Arity, ArityString),
     make_instance_string(InstanceTypes, InstanceString),
@@ -855,7 +855,7 @@
     ;
         UnprovenConstraints = [_ | _],
         ClassId = class_id(ClassName, _ClassArity),
-        sym_name_to_string(ClassName, ClassNameString),
+        ClassNameString = sym_name_to_string(ClassName),
         InstanceTypesString = mercury_type_list_to_string(InstanceVarSet2,
             InstanceTypes),
         constraint_list_to_string(ClassVarSet, UnprovenConstraints,
@@ -1000,7 +1000,7 @@
         MissingConcreteError = yes,
         !:FoundError = yes,
         ClassId = class_id(ClassName, _),
-        sym_name_to_string(ClassName, ClassNameString),
+        ClassNameString = sym_name_to_string(ClassName),
         AbstractTypesString = mercury_type_list_to_string(
             AbstractInstance ^ instance_tvarset, AbstractTypes),
         AbstractInstanceName = ClassNameString ++
Index: compiler/compile_target_code.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/compile_target_code.m,v
retrieving revision 1.93
diff -u -b -r1.93 compile_target_code.m
--- compiler/compile_target_code.m	27 Sep 2006 06:16:49 -0000	1.93
+++ compiler/compile_target_code.m	30 Sep 2006 10:10:42 -0000
@@ -1308,7 +1308,7 @@
             %       directory which is the one where the library is going to
             %       be installed, *not* where it is going to be built. 
             %        
-            sym_name_to_string(ModuleName, BaseFileName),
+            BaseFileName = sym_name_to_string(ModuleName),
             globals.io_lookup_string_option(shared_library_extension,
                 SharedLibExt, !IO),
             ShLibFileName = "lib" ++ BaseFileName ++ SharedLibExt,
Index: compiler/complexity.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/complexity.m,v
retrieving revision 1.24
diff -u -b -r1.24 complexity.m
--- compiler/complexity.m	20 Sep 2006 09:42:03 -0000	1.24
+++ compiler/complexity.m	30 Sep 2006 10:43:28 -0000
@@ -353,7 +353,7 @@
             - ImpureOrigGoalInfo
     ),
 
-    mercury_term_size_prof_builtin_module(TSPB),
+    TSPB = mercury_term_size_prof_builtin_module,
     SwitchArms = [
         case(cons(qualified(TSPB, "is_inactive"), 0), TransformedGoal),
         case(cons(qualified(TSPB, "is_active"), 0), OrigGoal)
@@ -486,7 +486,7 @@
 
 complexity_generate_foreign_proc(PredName, Detism, Args, ExtraArgs,
         Code, BoundVars, ModuleInfo, Context, Goal) :-
-    mercury_term_size_prof_builtin_module(BuiltinModule),
+    BuiltinModule = mercury_term_size_prof_builtin_module,
     Attrs0 = default_attributes(lang_c),
     set_may_call_mercury(proc_will_not_call_mercury, Attrs0, Attrs),
     MaybeTraceRuntimeCond = no,
@@ -556,7 +556,7 @@
 :- func is_active_type = mer_type.
 
 is_active_type = Type :-
-    mercury_term_size_prof_builtin_module(M),
+    M = mercury_term_size_prof_builtin_module,
     construct_type(type_ctor(qualified(M, "complexity_is_active"), 0), [],
         Type).
 
Index: compiler/deep_profiling.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/deep_profiling.m,v
retrieving revision 1.55
diff -u -b -r1.55 deep_profiling.m
--- compiler/deep_profiling.m	5 Sep 2006 06:21:24 -0000	1.55
+++ compiler/deep_profiling.m	30 Sep 2006 10:19:36 -0000
@@ -453,7 +453,7 @@
         % We don't want to transform the procedures for
         % managing the deep profiling call graph, or we'd get
         % infinite recursion.
-        mercury_profiling_builtin_module(PredModuleName)
+        PredModuleName = mercury_profiling_builtin_module
     ->
         true
     ;
@@ -1573,7 +1573,7 @@
     VarSet0 = !.DeepInfo ^ vars,
     VarTypes0 = !.DeepInfo ^ var_types,
     varset.new_named_var(VarSet0, "CSNCell", CellVar, VarSet),
-    mercury_profiling_builtin_module(ProfilingBuiltin),
+    ProfilingBuiltin = mercury_profiling_builtin_module,
     CellTypeName = string.format("call_site_nums_%d", [i(Length)]),
     CellTypeId = type_ctor(qualified(ProfilingBuiltin, CellTypeName), Length),
     construct_type(CellTypeId, [], CellType),
@@ -1665,7 +1665,7 @@
     pred_id::out, proc_id::out) is det.
 
 get_deep_profile_builtin_ppid(ModuleInfo, Name, Arity, PredId, ProcId) :-
-    mercury_profiling_builtin_module(ModuleName),
+    ModuleName = mercury_profiling_builtin_module,
     module_info_get_predicate_table(ModuleInfo, PredTable),
     (
         predicate_table_search_pred_m_n_a(PredTable,
@@ -1696,8 +1696,7 @@
                 "get_deep_profile_builtin_ppid: pred_id not unique")
         )
     ;
-        format("couldn't find pred_id for `%s'/%d",
-            [s(Name), i(Arity)], Msg),
+        format("couldn't find pred_id for `%s'/%d", [s(Name), i(Arity)], Msg),
         unexpected(this_file, Msg)
     ).
 
Index: compiler/deforest.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/deforest.m,v
retrieving revision 1.73
diff -u -b -r1.73 deforest.m
--- compiler/deforest.m	1 Oct 2006 04:57:29 -0000	1.73
+++ compiler/deforest.m	1 Oct 2006 04:59:59 -0000
@@ -462,7 +462,7 @@
         ), Goals0, Constraints, Goals1),
         Constraints = [_ | _]
     ->
-        sym_name_to_string(SymName, SymNameString),
+        SymNameString = sym_name_to_string(SymName),
         pd_debug_message("propagating constraints into call to %s\n",
             [s(SymNameString)], !IO),
 
Index: compiler/error_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/error_util.m,v
retrieving revision 1.54
diff -u -b -r1.54 error_util.m
--- compiler/error_util.m	15 Sep 2006 11:14:32 -0000	1.54
+++ compiler/error_util.m	30 Sep 2006 11:00:02 -0000
@@ -100,7 +100,8 @@
     ;       actual_severity_informational.
 
 :- type error_phase
-    --->    phase_term_to_parse_tree
+    --->    phase_read_files
+    ;       phase_term_to_parse_tree
     ;       phase_parse_tree_to_hlds
     ;       phase_type_check
     ;       phase_mode_check
@@ -1210,13 +1211,12 @@
 
 %-----------------------------------------------------------------------------%
 
-describe_sym_name_and_arity(SymName / Arity) = String :-
-    sym_name_to_string(SymName, SymNameString),
-    String = string.append_list(["`", SymNameString, "/",
+describe_sym_name_and_arity(SymName / Arity) =
+    string.append_list(["`", sym_name_to_string(SymName), "/",
         string.int_to_string(Arity), "'"]).
 
-describe_sym_name(SymName) = string.append_list(["`", SymNameString, "'"]) :-
-    sym_name_to_string(SymName, SymNameString).
+describe_sym_name(SymName) =
+    string.append_list(["`", sym_name_to_string(SymName), "'"]).
 
 pred_or_func_to_string(predicate) = "predicate".
 pred_or_func_to_string(function) = "function".
Index: compiler/foreign.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/foreign.m,v
retrieving revision 1.66
diff -u -b -r1.66 foreign.m
--- compiler/foreign.m	27 Sep 2006 06:16:52 -0000	1.66
+++ compiler/foreign.m	30 Sep 2006 10:55:28 -0000
@@ -610,15 +610,14 @@
     ;
         unexpected(this_file, "to_type_string: qualified C type")
     ).
-to_type_string(lang_csharp, foreign(ForeignType, _)) = Result :-
-    sym_name_to_string(ForeignType, ".", Result).
+to_type_string(lang_csharp, foreign(ForeignType, _)) =
+        sym_name_to_string(ForeignType).
 to_type_string(lang_managed_cplusplus, foreign(ForeignType, _)) =
-        Result ++ " *" :-
-    sym_name_to_string(ForeignType, "::", Result).
-to_type_string(lang_il, foreign(ForeignType, _)) = Result :-
-    sym_name_to_string(ForeignType, ".", Result).
-to_type_string(lang_java, foreign(ForeignType, _)) = Result :-
-    sym_name_to_string(ForeignType, ".", Result).
+        sym_name_to_string_sep(ForeignType, "::") ++ " *".
+to_type_string(lang_il, foreign(ForeignType, _)) =
+        sym_name_to_string(ForeignType).
+to_type_string(lang_java, foreign(ForeignType, _)) =
+        sym_name_to_string(ForeignType).
 
     % XXX does this do the right thing for high level data?
 to_type_string(lang_c, mercury(Type)) = Result :-
Index: compiler/higher_order.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/higher_order.m,v
retrieving revision 1.161
diff -u -b -r1.161 higher_order.m
--- compiler/higher_order.m	20 Sep 2006 09:42:04 -0000	1.161
+++ compiler/higher_order.m	30 Sep 2006 10:43:56 -0000
@@ -2668,7 +2668,7 @@
 maybe_write_request(no, _, _, _, _, _, _, _, _, !IO).
 maybe_write_request(yes, ModuleInfo, Msg, SymName, Arity, ActualArity,
         MaybeNewName, HOArgs, Context, !IO) :-
-    prim_data.sym_name_to_string(SymName, OldName),
+    OldName = sym_name_to_string(SymName),
     string.int_to_string(Arity, ArStr),
     io.write_string("% ", !IO),
     prog_out.write_context(Context, !IO),
Index: compiler/hlds_code_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_code_util.m,v
retrieving revision 1.30
diff -u -b -r1.30 hlds_code_util.m
--- compiler/hlds_code_util.m	22 Aug 2006 05:03:46 -0000	1.30
+++ compiler/hlds_code_util.m	30 Sep 2006 10:16:54 -0000
@@ -149,7 +149,7 @@
 type_to_string(Type, String) :-
     ( type_to_ctor_and_args(Type, TypeCtor, _) ->
         TypeCtor = type_ctor(TypeName, TypeArity),
-        sym_name_to_string(TypeName, "__", TypeNameString),
+        TypeNameString = sym_name_to_string_sep(TypeName, "__"),
         string.int_to_string(TypeArity, TypeArityString),
         String = TypeNameString ++ "__arity" ++ TypeArityString ++ "__"
     ;
Index: compiler/hlds_error_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_error_util.m,v
retrieving revision 1.23
diff -u -b -r1.23 hlds_error_util.m
--- compiler/hlds_error_util.m	7 Sep 2006 05:50:53 -0000	1.23
+++ compiler/hlds_error_util.m	30 Sep 2006 10:17:26 -0000
@@ -215,8 +215,7 @@
 module_qualification(ModuleName, ShouldModuleQualify) = ModuleQualification :-
     (
         ShouldModuleQualify = should_module_qualify,
-        sym_name_to_string(ModuleName, ModuleNameString),
-        ModuleQualification = ModuleNameString ++ "."
+        ModuleQualification = sym_name_to_string(ModuleName) ++ "."
     ;
         ShouldModuleQualify = should_not_module_qualify,
         ModuleQualification = ""
Index: compiler/hlds_out.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_out.m,v
retrieving revision 1.404
diff -u -b -r1.404 hlds_out.m
--- compiler/hlds_out.m	1 Oct 2006 04:57:29 -0000	1.404
+++ compiler/hlds_out.m	1 Oct 2006 04:59:59 -0000
@@ -305,7 +305,7 @@
     io.write_string(cons_id_to_string(ConsId), !IO).
 
 cons_id_to_string(cons(SymName, Arity)) = String :-
-    sym_name_to_string(SymName, SymNameString0),
+    SymNameString0 = sym_name_to_string(SymName),
     ( string.contains_char(SymNameString0, '*') ->
         % We need to protect against the * appearing next to a /
         Stuff = (pred(Char::in, Str0::in, Str::out) is det :-
Index: compiler/intermod.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/intermod.m,v
retrieving revision 1.209
diff -u -b -r1.209 intermod.m
--- compiler/intermod.m	28 Sep 2006 12:29:25 -0000	1.209
+++ compiler/intermod.m	30 Sep 2006 10:44:09 -0000
@@ -2270,7 +2270,7 @@
     maybe_write_string(VeryVerbose,
         "% Reading optimization interface for module", !IO),
     maybe_write_string(VeryVerbose, " `", !IO),
-    mdbcomp.prim_data.sym_name_to_string(ModuleToRead, ModuleToReadString),
+    ModuleToReadString = sym_name_to_string(ModuleToRead),
     maybe_write_string(VeryVerbose, ModuleToReadString, !IO),
     maybe_write_string(VeryVerbose, "'...\n", !IO),
     maybe_flush_output(VeryVerbose, !IO),
Index: compiler/layout_out.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/layout_out.m,v
retrieving revision 1.73
diff -u -b -r1.73 layout_out.m
--- compiler/layout_out.m	29 Sep 2006 06:34:49 -0000	1.73
+++ compiler/layout_out.m	1 Oct 2006 05:00:00 -0000
@@ -1135,8 +1135,7 @@
     io.write_string(" = {\n{\n", !IO),
     output_proc_id(ClosureProcLabel, PredOrigin, !IO),
     io.write_string("},\n", !IO),
-    sym_name_to_string(ModuleName, ModuleNameStr),
-    quote_and_write_string(ModuleNameStr, !IO),
+    quote_and_write_string(sym_name_to_string(ModuleName), !IO),
     io.write_string(",\n", !IO),
     quote_and_write_string(FileName, !IO),
     io.write_string(",\n", !IO),
@@ -1153,13 +1152,11 @@
         ProcLabel = ordinary_proc_label(DefiningModule, PredOrFunc,
             DeclaringModule, PredName0, Arity, Mode),
         PredName = origin_name(Origin, PredName0),
-        sym_name_to_string(DefiningModule, DefiningModuleStr),
-        sym_name_to_string(DeclaringModule, DeclaringModuleStr),
         output_pred_or_func(PredOrFunc, !IO),
         io.write_string(",\n", !IO),
-        quote_and_write_string(DeclaringModuleStr, !IO),
+        quote_and_write_string(sym_name_to_string(DeclaringModule), !IO),
         io.write_string(",\n", !IO),
-        quote_and_write_string(DefiningModuleStr, !IO),
+        quote_and_write_string(sym_name_to_string(DefiningModule), !IO),
         io.write_string(",\n", !IO),
         quote_and_write_string(PredName, !IO),
         io.write_string(",\n", !IO),
@@ -1173,13 +1170,11 @@
         TypeCtor = type_ctor(qualified(TypeModule, TypeName), TypeArity),
         PredName0 = special_pred_name(SpecialPredId, TypeCtor),
         PredName = origin_name(Origin, PredName0),
-        sym_name_to_string(DefiningModule, DefiningModuleStr),
-        sym_name_to_string(TypeModule, TypeModuleStr),
         quote_and_write_string(TypeName, !IO),
         io.write_string(",\n", !IO),
-        quote_and_write_string(TypeModuleStr, !IO),
+        quote_and_write_string(sym_name_to_string(TypeModule), !IO),
         io.write_string(",\n", !IO),
-        quote_and_write_string(DefiningModuleStr, !IO),
+        quote_and_write_string(sym_name_to_string(DefiningModule), !IO),
         io.write_string(",\n", !IO),
         quote_and_write_string(PredName, !IO),
         io.write_string(",\n", !IO),
@@ -1313,8 +1308,7 @@
     io.write_string("\n", !IO),
     output_layout_name_storage_type_name(ModuleLayoutName, yes, !IO),
     io.write_string(" = {\n", !IO),
-    sym_name_to_string(ModuleName, ModuleNameStr),
-    quote_and_write_string(ModuleNameStr, !IO),
+    quote_and_write_string(sym_name_to_string(ModuleName), !IO),
     io.write_string(",\n", !IO),
     io.write_int(StringTableSize, !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.45
diff -u -b -r1.45 make.module_target.m
--- compiler/make.module_target.m	22 Aug 2006 05:03:52 -0000	1.45
+++ compiler/make.module_target.m	30 Sep 2006 10:24:21 -0000
@@ -350,7 +350,7 @@
 
 build_target_2(ModuleName, process_module(ModuleTask), ArgFileName,
         _Imports, AllOptionArgs, ErrorStream, Succeeded, !Info, !IO) :-
-    sym_name_to_string(ModuleName, ".", ModuleArg),
+    ModuleArg = sym_name_to_string(ModuleName),
 
     globals.io_lookup_bool_option(verbose_commands, Verbose, !IO),
     (
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.406
diff -u -b -r1.406 mercury_compile.m
--- compiler/mercury_compile.m	2 Oct 2006 01:41:13 -0000	1.406
+++ compiler/mercury_compile.m	2 Oct 2006 01:43:20 -0000
@@ -902,7 +902,7 @@
         MaybeTimestamp, Items, Error, !ReadModules, !IO) :-
     globals.io_lookup_bool_option(verbose, Verbose, !IO),
     maybe_write_string(Verbose, "% Parsing module `", !IO),
-    sym_name_to_string(ModuleName, ModuleNameString),
+    ModuleNameString = sym_name_to_string(ModuleName),
     maybe_write_string(Verbose, ModuleNameString, !IO),
     maybe_write_string(Verbose, "' and imported interfaces...\n", !IO),
     (
@@ -1177,7 +1177,7 @@
         (
             non_traced_mercury_builtin_module(ModuleName),
             not (
-                    mercury_profiling_builtin_module(ModuleName),
+                    ModuleName = mercury_profiling_builtin_module,
                     TraceProf = yes
             )
         ->
@@ -1821,12 +1821,13 @@
                 WarnNoTransOptDeps),
             (
                 WarnNoTransOptDeps = yes,
-                sym_name_to_string(ModuleName, ModuleString),
-                Msg1 = "Warning: cannot read trans-opt dependencies " ++
-                    "for module `" ++ ModuleString ++ "'.",
-                Msg2 = "You need to remake the dependencies.",
-                write_error_pieces_plain([words(Msg1), nl, words(Msg2)], !IO),
-                record_warning(!IO)
+                Pieces = [words("Warning: cannot read trans-opt dependencies"),
+                    words("for module"), sym_name(ModuleName), suffix("."), nl,
+                    words("You need to remake the dependencies."), nl],
+                Msg = error_msg(no, no, 0, [always(Pieces)]),
+                Spec = error_spec(severity_warning, phase_read_files, [Msg]),
+                % XXX _NumErrors
+                write_error_spec(Spec, 0, _NumWarnings, 0, _NumErrors, !IO)
             ;
                 WarnNoTransOptDeps = no
             )
Index: compiler/mercury_to_mercury.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mercury_to_mercury.m,v
retrieving revision 1.304
diff -u -b -r1.304 mercury_to_mercury.m
--- compiler/mercury_to_mercury.m	1 Oct 2006 04:57:30 -0000	1.304
+++ compiler/mercury_to_mercury.m	1 Oct 2006 05:00:00 -0000
@@ -1600,13 +1600,13 @@
     add_lambda_eval_method(EvalMethod, !U),
     add_string(")>", !U).
 mercury_format_cons_id(type_ctor_info_const(Module, Type, Arity), _, !U) :-
-    sym_name_to_string(Module, ModuleString),
+    ModuleString = sym_name_to_string(Module),
     string.int_to_string(Arity, ArityString),
     add_strings(["<type_ctor_info for ",
         ModuleString, ".", Type, "/", ArityString, ">"], !U).
 mercury_format_cons_id(base_typeclass_info_const(Module, Class, InstanceNum,
         InstanceString), _, !U) :-
-    sym_name_to_string(Module, ModuleString),
+    ModuleString = sym_name_to_string(Module),
     add_string("<base_typeclass_info for ", !U),
     add_class_id(Class, !U),
     ( ModuleString \= "some bogus module name" ->
@@ -1784,7 +1784,7 @@
             RefOrVal = value,
             RefOrValStr = "valuetype "
         ),
-        sym_name_to_string(ForeignTypeName, ".", NameStr),
+        NameStr = sym_name_to_string(ForeignTypeName),
         ForeignTypeStr = RefOrValStr ++ "[" ++ ForeignLocStr ++ "]" ++ NameStr
     ;
         ForeignType = c(c_type(ForeignTypeStr))
Index: compiler/ml_code_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_code_gen.m,v
retrieving revision 1.187
diff -u -b -r1.187 ml_code_gen.m
--- compiler/ml_code_gen.m	1 Oct 2006 04:57:31 -0000	1.187
+++ compiler/ml_code_gen.m	1 Oct 2006 05:00:00 -0000
@@ -1257,7 +1257,7 @@
 :- func init_step(string) = mlds_initializer.
 
 init_step(Str) = init_obj(Rval) :-
-    mercury_private_builtin_module(PrivateBuiltin),
+    PrivateBuiltin = mercury_private_builtin_module,
     MLDS_ModuleName = mercury_module_name_to_mlds(PrivateBuiltin),
     Var = qual(MLDS_ModuleName, module_qual, mlds_var_name(Str, no)),
     % XXX These are actually enumeration constants.
Index: compiler/ml_code_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_code_util.m,v
retrieving revision 1.117
diff -u -b -r1.117 ml_code_util.m
--- compiler/ml_code_util.m	20 Sep 2006 09:42:08 -0000	1.117
+++ compiler/ml_code_util.m	30 Sep 2006 11:02:27 -0000
@@ -1336,7 +1336,7 @@
             (
                 TypeCtorSymName = unqualified(TypeName),
                 type_ctor_is_tuple(TypeCtor),
-                mercury_public_builtin_module(TypeModule)
+                TypeModule = mercury_public_builtin_module
             ;
                 TypeCtorSymName = qualified(TypeModule, TypeName)
             )
@@ -1429,7 +1429,7 @@
         % The variable won't have been declared, so we need to generate
         % a dummy lval for this variable.
 
-        mercury_private_builtin_module(PrivateBuiltin),
+        PrivateBuiltin = mercury_private_builtin_module,
         MLDS_Module = mercury_module_name_to_mlds(PrivateBuiltin),
         ml_gen_type(Info, Type, MLDS_Type),
         Lval = var(qual(MLDS_Module, module_qual,
@@ -2014,7 +2014,7 @@
 trace_type_info_type(Type, RealType) :-
     Type = defined_type(TypeName, _, _),
     TypeName = qualified(PrivateBuiltin, Name),
-    mercury_private_builtin_module(PrivateBuiltin),
+    PrivateBuiltin = mercury_private_builtin_module,
     ( Name = "type_info", RealType = sample_type_info_type
     ; Name = "type_ctor_info", RealType = c_pointer_type
     ; Name = "typeclass_info", RealType = sample_typeclass_info_type
@@ -2111,7 +2111,7 @@
     PredLabel = mlds_user_pred_label((predicate), no, PredName, PredOrigArity,
         model_det, no),
     ProcId = hlds_pred.initial_proc_id,
-    mercury_private_builtin_module(PredModule),
+    PredModule = mercury_private_builtin_module,
     MLDS_Module = mercury_module_name_to_mlds(PredModule),
     ProcLabel = mlds_proc_label(PredLabel, ProcId),
     QualProcLabel = qual(MLDS_Module, module_qual, ProcLabel),
@@ -2654,7 +2654,7 @@
 
 fixup_builtin_module(ModuleName0) = ModuleName :-
     ( ModuleName0 = unqualified("") ->
-        mercury_public_builtin_module(ModuleName)
+        ModuleName = mercury_public_builtin_module
     ;
         ModuleName = ModuleName0
     ).
Index: compiler/ml_elim_nested.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_elim_nested.m,v
retrieving revision 1.85
diff -u -b -r1.85 ml_elim_nested.m
--- compiler/ml_elim_nested.m	22 Aug 2006 05:03:54 -0000	1.85
+++ compiler/ml_elim_nested.m	30 Sep 2006 10:59:17 -0000
@@ -507,7 +507,7 @@
         \+ (
             Name = entity_function(PredLabel, _, _, _),
             PredLabel = mlds_user_pred_label(_, _, "gc_trace", 1, _, _),
-            mercury_private_builtin_module(PrivateBuiltin),
+            PrivateBuiltin = mercury_private_builtin_module,
             ModuleName = mercury_module_name_to_mlds(PrivateBuiltin)
         )
     ->
@@ -1229,7 +1229,7 @@
 :- func ml_stack_chain_var = mlds_lval.
 
 ml_stack_chain_var = StackChain :-
-    mercury_private_builtin_module(PrivateBuiltin),
+    PrivateBuiltin = mercury_private_builtin_module,
     MLDS_Module = mercury_module_name_to_mlds(PrivateBuiltin),
     StackChain = var(qual(MLDS_Module, module_qual,
         mlds_var_name("stack_chain", no)), ml_stack_chain_type).
@@ -1313,9 +1313,7 @@
 
 :- func ml_module_name_string(mercury_module_name) = string.
 
-ml_module_name_string(ModuleName) = ModuleNameString :-
-    Separator = "__",
-    sym_name_to_string(ModuleName, Separator, ModuleNameString).
+ml_module_name_string(ModuleName) = sym_name_to_string_sep(ModuleName, "__").
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/ml_optimize.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_optimize.m,v
retrieving revision 1.44
diff -u -b -r1.44 ml_optimize.m
--- compiler/ml_optimize.m	22 Aug 2006 05:03:55 -0000	1.44
+++ compiler/ml_optimize.m	30 Sep 2006 10:25:51 -0000
@@ -272,7 +272,7 @@
             CallArgs = [Rval],
             AtomicStmt = restore_hp(Rval)
         ),
-        mercury_private_builtin_module(PrivateBuiltin),
+        PrivateBuiltin = mercury_private_builtin_module,
         ModName = mercury_module_name_to_mlds(PrivateBuiltin)
     ->
         Stmt = atomic(AtomicStmt)
Index: compiler/ml_type_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_type_gen.m,v
retrieving revision 1.59
diff -u -b -r1.59 ml_type_gen.m
--- compiler/ml_type_gen.m	7 Sep 2006 05:50:58 -0000	1.59
+++ compiler/ml_type_gen.m	30 Sep 2006 10:26:01 -0000
@@ -931,7 +931,7 @@
     ;
         % Builtin types like `int' may be still unqualified at this point.
         Name = unqualified(TypeName),
-        mercury_public_builtin_module(ModuleName)
+        ModuleName = mercury_public_builtin_module
     ),
     MLDS_Module = mercury_module_name_to_mlds(ModuleName),
     QualifiedTypeName = qual(MLDS_Module, module_qual, TypeName).
Index: compiler/ml_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_util.m,v
retrieving revision 1.51
diff -u -b -r1.51 ml_util.m
--- compiler/ml_util.m	22 Aug 2006 05:03:56 -0000	1.51
+++ compiler/ml_util.m	30 Sep 2006 10:26:28 -0000
@@ -649,8 +649,8 @@
 
     % XXX Do we need to do the same for the Java back-end?
 type_ctor_needs_lowlevel_rep(target_il, type_ctor(TypeName, _Arity)) :-
-    mercury_public_builtin_module(Builtin),
-    mercury_private_builtin_module(PrivateBuiltin),
+    Builtin = mercury_public_builtin_module,
+    PrivateBuiltin = mercury_private_builtin_module,
     RttiImplementation = unqualified("rtti_implementation"),
     Univ = unqualified("univ"),
     MutVar = unqualified("mutvar"),
@@ -685,7 +685,7 @@
 %-----------------------------------------------------------------------------%
 
 gen_init_builtin_const(Name) = init_obj(Rval) :-
-    mercury_private_builtin_module(PrivateBuiltin),
+    PrivateBuiltin = mercury_private_builtin_module,
     MLDS_Module = mercury_module_name_to_mlds(PrivateBuiltin),
     % XXX These are actually enumeration constants.
     % Perhaps we should be using an enumeration type here,
Index: compiler/mlds_to_c.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mlds_to_c.m,v
retrieving revision 1.199
diff -u -b -r1.199 mlds_to_c.m
--- compiler/mlds_to_c.m	1 Oct 2006 04:57:31 -0000	1.199
+++ compiler/mlds_to_c.m	1 Oct 2006 05:00:01 -0000
@@ -649,8 +649,8 @@
 output_init_fn_name(ModuleName, Suffix, !IO) :-
     % Here we ensure that we only get one "mercury__" at the start
     % of the function name.
-    sym_name_to_string(mlds_module_name_to_sym_name(ModuleName), "__",
-        ModuleNameString0),
+    ModuleNameString0 = sym_name_to_string_sep(
+        mlds_module_name_to_sym_name(ModuleName), "__"),
     ( string.prefix(ModuleNameString0, "mercury__") ->
         ModuleNameString = ModuleNameString0
     ;
@@ -672,8 +672,8 @@
 output_required_fn_name(ModuleName, Suffix, !IO) :-
     % Here we ensure that we only get one "mercury__" at the start
     % of the function name.
-    sym_name_to_string(mlds_module_name_to_sym_name(ModuleName), "__",
-        ModuleNameString0),
+    ModuleNameString0 = sym_name_to_string_sep(
+        mlds_module_name_to_sym_name(ModuleName), "__"),
     ( string.prefix(ModuleNameString0, "mercury__") ->
         ModuleNameString = ModuleNameString0
     ;
Index: compiler/mlds_to_gcc.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mlds_to_gcc.m,v
retrieving revision 1.122
diff -u -b -r1.122 mlds_to_gcc.m
--- compiler/mlds_to_gcc.m	22 Aug 2006 05:03:57 -0000	1.122
+++ compiler/mlds_to_gcc.m	30 Sep 2006 10:30:09 -0000
@@ -417,9 +417,8 @@
 init_fn_name(ModuleName, Suffix) = InitFnName :-
 		% Here we ensure that we only get one "mercury__" at the
 		% start of the function name.
-	mdbcomp__prim_data__sym_name_to_string(
-			mlds_module_name_to_sym_name(ModuleName), "__",
-			ModuleNameString0),
+	ModuleNameString0 = sym_name_to_string_sep(
+		mlds_module_name_to_sym_name(ModuleName), "__"),
 	(
 		string__prefix(ModuleNameString0, "mercury__")
 	->
@@ -3331,7 +3330,7 @@
 	;
 		% check if it's in the private_builtin module
 		% and is an RTTI enumeration constant
-		{ mercury_private_builtin_module(PrivateBuiltin) },
+		{ PrivateBuiltin = mercury_private_builtin_module },
 		{ mercury_module_name_to_mlds(PrivateBuiltin) = ModuleName },
 		{ VarName = mlds_var_name(VarNameBase, _MaybeNum) },
 		{ rtti_enum_const(VarNameBase, IntVal) }
@@ -3339,7 +3338,7 @@
 		gcc__build_int(IntVal, Expr)
 	;
 		% check if it's private_builtin:dummy_var
-		{ mercury_private_builtin_module(PrivateBuiltin) },
+		{ PrivateBuiltin = mercury_private_builtin_module },
 		{ mercury_module_name_to_mlds(PrivateBuiltin) = ModuleName },
 		{ VarName = mlds_var_name("dummy_var", _) }
 	->
Index: compiler/mlds_to_il.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mlds_to_il.m,v
retrieving revision 1.170
diff -u -b -r1.170 mlds_to_il.m
--- compiler/mlds_to_il.m	20 Sep 2006 09:42:08 -0000	1.170
+++ compiler/mlds_to_il.m	30 Sep 2006 10:27:33 -0000
@@ -292,8 +292,8 @@
         transform_mlds(MLDS),
 
     ModuleName = mercury_module_name_to_mlds(MercuryModuleName),
-    prim_data.sym_name_to_string(mlds_module_name_to_sym_name(ModuleName),
-        ".", AssemblyName),
+    AssemblyName =
+        sym_name_to_string(mlds_module_name_to_sym_name(ModuleName)),
     get_il_data_rep(ILDataRep, !IO),
     globals.io_lookup_bool_option(debug_il_asm, DebugIlAsm, !IO),
     globals.io_lookup_bool_option(verifiable_code,
@@ -4132,7 +4132,7 @@
             Import = foreign_import(ForeignImportName),
             ForeignImportName = il_assembly_name(ImportName),
             PackageName = mlds_module_name_to_package_name( ImportName),
-            prim_data.sym_name_to_string(PackageName, ForeignPackageStr),
+            ForeignPackageStr = sym_name_to_string(PackageName),
             ( string.prefix(ForeignPackageStr, "System") ->
                 AsmDecls = dotnet_system_assembly_decls(Version)
             ;
Index: compiler/mlds_to_java.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mlds_to_java.m,v
retrieving revision 1.84
diff -u -b -r1.84 mlds_to_java.m
--- compiler/mlds_to_java.m	7 Sep 2006 05:50:59 -0000	1.84
+++ compiler/mlds_to_java.m	30 Sep 2006 10:28:03 -0000
@@ -402,7 +402,7 @@
     ),
     SymName = mlds_module_name_to_sym_name(ImportName),
     JavaSafeSymName = valid_module_name(SymName),
-    sym_name_to_string(JavaSafeSymName, ".", File),
+    File = sym_name_to_string(JavaSafeSymName),
     % XXX Name mangling code should be put here when we start enforcing
     % Java's naming conventions.
     ClassFile = File,
@@ -1073,8 +1073,7 @@
 output_package_info(unqualified(_), !IO).
 output_package_info(qualified(Module, _), !IO) :-
     io.write_string("package ", !IO),
-    sym_name_to_string(Module, ".", Package),
-    io.write_string(Package, !IO),
+    io.write_string(sym_name_to_string(Module), !IO),
     io.write_string(";\n", !IO).
 
     % Check if this module contains a `main' predicate and if it does insert
Index: compiler/mlds_to_managed.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mlds_to_managed.m,v
retrieving revision 1.35
diff -u -b -r1.35 mlds_to_managed.m
--- compiler/mlds_to_managed.m	22 Aug 2006 05:03:58 -0000	1.35
+++ compiler/mlds_to_managed.m	30 Sep 2006 10:28:43 -0000
@@ -93,10 +93,9 @@
 
 output_src_start(ModuleName, !IO) :-
     library.version(Version),
-    sym_name_to_string(ModuleName, ModuleNameStr),
     io.write_strings(
         ["//\n// Automatically generated from `",
-        ModuleNameStr,
+        sym_name_to_string(ModuleName),
         ".m' by the\n",
         "// Mercury compiler, version ",
         Version,
@@ -225,7 +224,7 @@
                     )
                 ;
                     SymName = mlds_module_name_to_sym_name(Name),
-                    sym_name_to_string(SymName, ".", Str)
+                    Str = sym_name_to_string(SymName)
                 ),
                 Result = [Str]
             ;
@@ -240,9 +239,8 @@
             io.write_string(".dll""\n", !IO)
         ), ActualImports, !IO),
 
-    sym_name_to_string(ModuleName, ModuleNameStr),
     io.write_strings([
-        "#using """, ModuleNameStr, ".dll""\n",
+        "#using """, sym_name_to_string(ModuleName), ".dll""\n",
         "#include ""mercury_mcpp.h""\n",
 
         % XXX We have to use the mercury namespace, as
Index: compiler/mmc_analysis.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mmc_analysis.m,v
retrieving revision 1.19
diff -u -b -r1.19 mmc_analysis.m
--- compiler/mmc_analysis.m	31 Jul 2006 08:31:54 -0000	1.19
+++ compiler/mmc_analysis.m	30 Sep 2006 10:44:37 -0000
@@ -128,11 +128,9 @@
         !IO),
     IsLocal = (if ModuleId `list.member` LocalModuleIds then yes else no).
 
-module_name_to_module_id(ModuleName) = ModuleId :-
-    sym_name_to_string(ModuleName, ModuleId).
+module_name_to_module_id(ModuleName) = sym_name_to_string(ModuleName).
 
-module_id_to_module_name(ModuleId) = ModuleName :-
-    string_to_sym_name(ModuleId, ".", ModuleName).
+module_id_to_module_name(ModuleId) = string_to_sym_name(ModuleId).
 
 pred_or_func_name_arity_to_func_id(PredOrFunc, Name, Arity, ProcId) = FuncId :-
     SimpleCallId = simple_call_id(PredOrFunc, unqualified(Name), Arity),
Index: compiler/modes.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/modes.m,v
retrieving revision 1.346
diff -u -b -r1.346 modes.m
--- compiler/modes.m	27 Sep 2006 06:16:58 -0000	1.346
+++ compiler/modes.m	30 Sep 2006 10:15:04 -0000
@@ -1473,7 +1473,7 @@
 
 modecheck_goal_expr(plain_call(PredId, ProcId0, Args0, _, Context, PredName),
         GoalInfo0, Goal, !ModeInfo, !IO) :-
-    sym_name_to_string(PredName, PredNameString),
+    PredNameString = sym_name_to_string(PredName),
     string.append("call ", PredNameString, CallString),
     mode_checkpoint(enter, CallString, !ModeInfo, !IO),
 
Index: compiler/module_qual.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/module_qual.m,v
retrieving revision 1.148
diff -u -b -r1.148 module_qual.m
--- compiler/module_qual.m	12 Sep 2006 04:41:40 -0000	1.148
+++ compiler/module_qual.m	30 Sep 2006 11:00:15 -0000
@@ -1916,7 +1916,7 @@
     %
     ( ImplicitPart = qualified(Parent, Child) ->
         NextImplicitPart = Parent,
-        insert_module_qualifier(Child, ExplicitPart, NextExplicitPart),
+        NextExplicitPart = insert_module_qualifier(Child, ExplicitPart),
         get_partial_qualifiers_2(NextImplicitPart, NextExplicitPart,
             ModuleIdSet, !Qualifiers)
     ;
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.404
diff -u -b -r1.404 modules.m
--- compiler/modules.m	1 Oct 2006 04:24:07 -0000	1.404
+++ compiler/modules.m	1 Oct 2006 05:00:01 -0000
@@ -838,14 +838,13 @@
         % Look up the module in the module->file mapping.
         source_file_map.lookup_module_source_file(ModuleName, FileName, !IO)
     ;
-        sym_name_to_string(ModuleName, ".", BaseFileName),
-        string.append(BaseFileName, Ext, BaseName),
+        string.append(sym_name_to_string(ModuleName), Ext, BaseName),
         choose_file_name(ModuleName, BaseName, Ext, Search, MkDir, FileName,
             !IO)
     ).
 
 module_name_to_lib_file_name(Prefix, ModuleName, Ext, MkDir, FileName, !IO) :-
-    sym_name_to_string(ModuleName, ".", BaseFileName),
+    BaseFileName = sym_name_to_string(ModuleName),
     string.append_list([Prefix, BaseFileName, Ext], BaseName),
     choose_file_name(ModuleName, BaseName, Ext, no, MkDir, FileName, !IO).
 
@@ -1045,13 +1044,13 @@
     ).
 
 file_name_to_module_name(FileName, ModuleName) :-
-    string_to_sym_name(FileName, ".", ModuleName).
+    ModuleName = string_to_sym_name(FileName).
 
 module_name_to_file_name(ModuleName, FileName) :-
-    sym_name_to_string(ModuleName, ".", FileName).
+    FileName = sym_name_to_string(ModuleName).
 
 module_name_to_make_var_name(ModuleName, MakeVarName) :-
-    sym_name_to_string(ModuleName, ".", MakeVarName).
+    MakeVarName = sym_name_to_string(ModuleName).
 
 maybe_make_symlink(LinkTarget, LinkName, Result, !IO) :-
     globals.io_lookup_bool_option(use_symlinks, UseSymLinks, !IO),
@@ -2706,12 +2705,12 @@
     list(module_name)::in, list(module_name)::out) is det.
 
 add_implicit_imports(Items, Globals, !ImportDeps, !UseDeps) :-
-    mercury_public_builtin_module(MercuryPublicBuiltin),
-    mercury_private_builtin_module(MercuryPrivateBuiltin),
-    mercury_table_builtin_module(MercuryTableBuiltin),
-    mercury_profiling_builtin_module(MercuryProfilingBuiltin),
-    mercury_term_size_prof_builtin_module(MercuryTermSizeProfBuiltin),
-    mercury_par_builtin_module(MercuryParBuiltin),
+    MercuryPublicBuiltin = mercury_public_builtin_module,
+    MercuryPrivateBuiltin = mercury_private_builtin_module,
+    MercuryTableBuiltin = mercury_table_builtin_module,
+    MercuryProfilingBuiltin = mercury_profiling_builtin_module,
+    MercuryTermSizeProfBuiltin = mercury_term_size_prof_builtin_module,
+    MercuryParBuiltin = mercury_par_builtin_module,
     !:ImportDeps = [MercuryPublicBuiltin | !.ImportDeps],
     !:UseDeps = [MercuryPrivateBuiltin | !.UseDeps],
     (
@@ -2720,12 +2719,16 @@
         % a tabling pragma, or if one of --use-minimal-model and
         % --trace-table-io is specified.
         %
-        ( contains_tabling_pragma(Items)
-        ; globals.lookup_bool_option(Globals,
+        (
+            contains_tabling_pragma(Items)
+        ;
+            globals.lookup_bool_option(Globals,
             use_minimal_model_stack_copy, yes)
-        ; globals.lookup_bool_option(Globals,
+        ;
+            globals.lookup_bool_option(Globals,
             use_minimal_model_own_stacks, yes)
-        ; globals.lookup_bool_option(Globals, trace_table_io, yes)
+        ;
+            globals.lookup_bool_option(Globals, trace_table_io, yes)
         )
     ->
         !:UseDeps = [MercuryTableBuiltin | !.UseDeps]
@@ -3917,7 +3920,7 @@
     ModuleDep = deps(_, ModuleImports),
     module_imports_get_error(ModuleImports, Error),
     ( Error = fatal_module_errors ->
-        sym_name_to_string(ModuleName, ModuleString),
+        ModuleString = sym_name_to_string(ModuleName),
         string.append_list(["can't read source file for module `",
             ModuleString, "'."], Message),
         report_error(Message, !IO)
@@ -4487,8 +4490,8 @@
     comparison_result::out) is det.
 
 compare_module_names(Sym1, Sym2, Result) :-
-    sym_name_to_string(Sym1, Str1),
-    sym_name_to_string(Sym2, Str2),
+    Str1 = sym_name_to_string(Sym1),
+    Str2 = sym_name_to_string(Sym2),
     compare(Result, Str1, Str2).
 
 :- pred generate_dv_file(file_name::in, module_name::in, deps_map::in,
@@ -4497,7 +4500,7 @@
 generate_dv_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :-
     io.write_string(DepStream,
         "# Automatically generated dependency variables for module `", !IO),
-    sym_name_to_string(ModuleName, ModuleNameString),
+    ModuleNameString = sym_name_to_string(ModuleName),
     io.write_string(DepStream, ModuleNameString, !IO),
     io.write_string(DepStream, "'\n", !IO),
     io.write_string(DepStream, "# generated from source file `", !IO),
@@ -4988,7 +4991,7 @@
 generate_dep_file(SourceFileName, ModuleName, DepsMap, DepStream, !IO) :-
     io.write_string(DepStream,
         "# Automatically generated dependencies for module `", !IO),
-    sym_name_to_string(ModuleName, ModuleNameString),
+    ModuleNameString = sym_name_to_string(ModuleName),
     io.write_string(DepStream, ModuleNameString, !IO),
     io.write_string(DepStream, "'\n", !IO),
     io.write_string(DepStream,
@@ -5251,7 +5254,7 @@
     % The `force-module_init' dependency forces the commands for
     % the `module_init.c' rule to be run every time the rule
     % is considered.
-    sym_name_to_string(ModuleName, ".", ModuleFileName),
+    ModuleFileName = sym_name_to_string(ModuleName),
     ForceC2InitTarget = "force-" ++ ModuleFileName ++ "_init",
     TmpInitCFileName = InitCFileName ++ ".tmp",
     io.write_strings(DepStream, [
@@ -5685,7 +5688,7 @@
         ModuleImports ^ has_foreign_code = contains_foreign_code(Langs),
         set.member(lang_c, Langs)
     ->
-        sym_name_to_string(Module, ".", FileName),
+        FileName = sym_name_to_string(Module),
         NewLinkObjs = [(FileName ++ "__c_code") - Module | FactTableObjs]
     ;
         NewLinkObjs = FactTableObjs
Index: compiler/options_file.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/options_file.m,v
retrieving revision 1.36
diff -u -b -r1.36 options_file.m
--- compiler/options_file.m	29 Mar 2006 08:07:12 -0000	1.36
+++ compiler/options_file.m	30 Sep 2006 10:24:44 -0000
@@ -1034,7 +1034,7 @@
         OptionsVariableClass = module_specific(ModuleName),
         options_variable_type_is_target_specific(FlagsVar) = yes
     ->
-        sym_name_to_string(ModuleName, ".", ModuleFileNameBase),
+        ModuleFileNameBase = sym_name_to_string(ModuleName),
         ModuleVarName = VarName ++ "-" ++ ModuleFileNameBase,
         lookup_variable_words_report_error(Vars, ModuleVarName,
             ModuleFlagsResult, !IO)
Index: compiler/polymorphism.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/polymorphism.m,v
retrieving revision 1.308
diff -u -b -r1.308 polymorphism.m
--- compiler/polymorphism.m	27 Sep 2006 06:17:00 -0000	1.308
+++ compiler/polymorphism.m	30 Sep 2006 10:15:28 -0000
@@ -1597,8 +1597,8 @@
 
 foreign_proc_add_typeclass_info(CanOptAwayUnnamed, Mode, Impl, TypeVarSet,
         Constraint, MaybeArgName - native_if_possible) :-
-    Constraint = constraint(Name0, Types),
-    sym_name_to_string(Name0, "__", Name),
+    Constraint = constraint(SymName, Types),
+    Name = sym_name_to_string_sep(SymName, "__"),
     type_vars_list(Types, TypeVars),
     TypeVarNames = list.map(underscore_and_tvar_name(TypeVarSet), TypeVars),
     string.append_list(["TypeClassInfo_for_", Name | TypeVarNames],
Index: compiler/pred_table.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/pred_table.m,v
retrieving revision 1.4
diff -u -b -r1.4 pred_table.m
--- compiler/pred_table.m	7 Sep 2006 05:51:02 -0000	1.4
+++ compiler/pred_table.m	30 Sep 2006 11:03:54 -0000
@@ -1071,11 +1071,11 @@
         % that this never happens
         list.length(ArgTypes, Arity),
         PredOrFuncStr = prog_out.pred_or_func_to_str(PredOrFunc),
-        mdbcomp.prim_data.sym_name_to_string(SymName, Name2),
+        NameStr = sym_name_to_string(SymName),
         string.int_to_string(Arity, ArityString),
         string.append_list(["get_pred_id_and_proc_id: ",
             "undefined/invalid ", PredOrFuncStr,
-            "\n`", Name2, "/", ArityString, "'"], Msg),
+            "\n`", NameStr, "/", ArityString, "'"], Msg),
         unexpected(this_file, Msg)
     ),
     get_proc_id(ModuleInfo, PredId, ProcId).
Index: compiler/proc_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/proc_gen.m,v
retrieving revision 1.7
diff -u -b -r1.7 proc_gen.m
--- compiler/proc_gen.m	4 Sep 2006 01:47:34 -0000	1.7
+++ compiler/proc_gen.m	30 Sep 2006 10:22:05 -0000
@@ -1205,7 +1205,7 @@
     module_info_pred_info(ModuleInfo, PredId, PredInfo),
     ModuleSymName = pred_info_module(PredInfo),
 
-    sym_name_to_string(ModuleSymName, "__", ModuleName),
+    ModuleName = sym_name_to_string_sep(ModuleSymName, "__"),
 
     code_util.make_local_entry_label(ModuleInfo, PredId, ProcId, no, Entry),
 
@@ -1286,7 +1286,7 @@
 
 find_arg_type_ctor_name(TypeCtor, TypeName) :-
     TypeCtor = type_ctor(TypeCtorSymName, TypeCtorArity),
-    mdbcomp.prim_data.sym_name_to_string(TypeCtorSymName, TypeCtorName),
+    TypeCtorName = sym_name_to_string(TypeCtorSymName),
     string.int_to_string(TypeCtorArity, ArityStr),
     string.append_list([TypeCtorName, "_", ArityStr], TypeName).
 
Index: compiler/proc_label.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/proc_label.m,v
retrieving revision 1.22
diff -u -b -r1.22 proc_label.m
--- compiler/proc_label.m	27 Sep 2006 06:17:02 -0000	1.22
+++ compiler/proc_label.m	30 Sep 2006 10:12:22 -0000
@@ -82,7 +82,7 @@
             (
                 TypeCtorSymName = unqualified(TypeName),
                 type_ctor_is_tuple(TypeCtor),
-                mercury_public_builtin_module(TypeModule)
+                TypeModule = mercury_public_builtin_module
             ;
                 TypeCtorSymName = qualified(TypeModule, TypeName)
             )
Index: compiler/prog_io.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_io.m,v
retrieving revision 1.275
diff -u -b -r1.275 prog_io.m
--- compiler/prog_io.m	20 Sep 2006 09:42:12 -0000	1.275
+++ compiler/prog_io.m	30 Sep 2006 10:33:59 -0000
@@ -454,7 +454,7 @@
             search_for_module_source(Dirs, ModuleName, PartialModuleName1,
                 Result, !IO)
         ;
-            sym_name_to_string(ModuleName, ModuleNameStr),
+            ModuleNameStr = sym_name_to_string(ModuleName),
             Result = error("can't find source for module `" ++
                 ModuleNameStr ++ "'")
         )
@@ -695,7 +695,7 @@
             ModuleName = StartModuleName,
             Messages = []
         ;
-            sym_name_to_string(StartModuleName, StartModuleNameString),
+            StartModuleNameString = sym_name_to_string(StartModuleName),
             WrongModuleWarning = "source file `" ++ SourceFileName ++
                 "' contains module named `" ++ StartModuleNameString ++ "'",
             maybe_add_warning(WarnWrong, MaybeFirstTerm, FirstContext,
@@ -4093,7 +4093,7 @@
         )
     ;
         ( Term = term.functor(term.atom(Name), [], _Context3) ->
-            string_to_sym_name(Name, "__", SymName),
+            SymName = string_to_sym_name_sep(Name, "__"),
             Result = ok1(SymName)
         ;
             term.coerce(Term, ErrorTerm),
@@ -4183,7 +4183,7 @@
         )
     ;
         ( Term = term.functor(term.atom(Name), Args, _) ->
-            string_to_sym_name(Name, "__", SymName),
+            SymName = string_to_sym_name_sep(Name, "__"),
             Result = ok2(SymName, Args)
         ;
             string.append("atom expected in ", Msg, ErrorMsg),
Index: compiler/prog_io_pragma.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_io_pragma.m,v
retrieving revision 1.114
diff -u -b -r1.114 prog_io_pragma.m
--- compiler/prog_io_pragma.m	1 Oct 2006 04:16:59 -0000	1.114
+++ compiler/prog_io_pragma.m	1 Oct 2006 05:00:01 -0000
@@ -379,7 +379,7 @@
     ->
         string.left(String1, Index, AssemblyName),
         string.split(String1, Index + 1, _, TypeNameStr),
-        string_to_sym_name(TypeNameStr, ".", TypeSymName),
+        TypeSymName = string_to_sym_name(TypeNameStr),
         ForeignType = ok1(il(il_type(reference, AssemblyName, TypeSymName)))
     ;
         string.append("valuetype [", String1, String0),
@@ -387,7 +387,7 @@
     ->
         string.left(String1, Index, AssemblyName),
         string.split(String1, Index + 1, _, TypeNameStr),
-        string_to_sym_name(TypeNameStr, ".", TypeSymName),
+        TypeSymName = string_to_sym_name(TypeNameStr),
         ForeignType = ok1(il(il_type(value, AssemblyName, TypeSymName)))
     ;
         ForeignType = error1(["invalid foreign language type description" -
Index: compiler/prog_io_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_io_util.m,v
retrieving revision 1.53
diff -u -b -r1.53 prog_io_util.m
--- compiler/prog_io_util.m	10 Sep 2006 23:39:07 -0000	1.53
+++ compiler/prog_io_util.m	30 Sep 2006 10:35:58 -0000
@@ -588,7 +588,7 @@
         % Anything else must be a user-defined inst.
         parse_qualified_term(Term, Term, "inst", ok2(QualifiedName, Args1)),
         (
-            mercury_public_builtin_module(BuiltinModule),
+            BuiltinModule = mercury_public_builtin_module,
             sym_name_get_module_name(QualifiedName, unqualified(""),
                 BuiltinModule),
             % If the term is qualified with the `builtin' module
Index: compiler/prog_mode.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_mode.m,v
retrieving revision 1.16
diff -u -b -r1.16 prog_mode.m
--- compiler/prog_mode.m	20 Aug 2006 08:21:26 -0000	1.16
+++ compiler/prog_mode.m	30 Sep 2006 10:36:20 -0000
@@ -164,7 +164,7 @@
 make_std_mode(Name, Args, make_std_mode(Name, Args)).
 
 make_std_mode(Name, Args) = Mode :-
-    mercury_public_builtin_module(MercuryBuiltin),
+    MercuryBuiltin = mercury_public_builtin_module,
     QualifiedName = qualified(MercuryBuiltin, Name),
     Mode = user_defined_mode(QualifiedName, Args).
 
@@ -561,7 +561,7 @@
 strip_builtin_qualifier_from_sym_name(SymName0, SymName) :-
     (
         SymName0 = qualified(Module, Name),
-        mercury_public_builtin_module(Module)
+        Module = mercury_public_builtin_module
     ->
         SymName = unqualified(Name)
     ;
Index: compiler/prog_out.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_out.m,v
retrieving revision 1.77
diff -u -b -r1.77 prog_out.m
--- compiler/prog_out.m	10 Sep 2006 23:39:07 -0000	1.77
+++ compiler/prog_out.m	30 Sep 2006 10:36:34 -0000
@@ -259,7 +259,7 @@
     io.write_string("'", !IO).
 
 sym_name_and_arity_to_string(SymName/Arity) = String :-
-    sym_name_to_string(SymName, SymNameString),
+    SymNameString = sym_name_to_string(SymName),
     string.int_to_string(Arity, ArityString),
     string.append_list([SymNameString, "/", ArityString], String).
 
Index: compiler/prog_rep.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_rep.m,v
retrieving revision 1.48
diff -u -b -r1.48 prog_rep.m
--- compiler/prog_rep.m	5 Sep 2006 06:21:30 -0000	1.48
+++ compiler/prog_rep.m	30 Sep 2006 10:22:53 -0000
@@ -266,7 +266,7 @@
         AtomicBytes, _),
     module_info_pred_info(Info ^ module_info, PredId, PredInfo),
     ModuleSymName = pred_info_module(PredInfo),
-    mdbcomp.prim_data.sym_name_to_string(ModuleSymName, ModuleName),
+    ModuleName = sym_name_to_string(ModuleSymName),
     PredName = pred_info_name(PredInfo),
     string_to_byte_list(ModuleName, !StackInfo, ModuleNameBytes),
     string_to_byte_list(PredName, !StackInfo, PredNameBytes),
Index: compiler/prog_type.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_type.m,v
retrieving revision 1.27
diff -u -b -r1.27 prog_type.m
--- compiler/prog_type.m	20 Sep 2006 09:42:13 -0000	1.27
+++ compiler/prog_type.m	30 Sep 2006 11:46:10 -0000
@@ -515,10 +515,10 @@
             SymName = SymName0
         ;
             Purity = purity_semipure,
-            insert_module_qualifier("semipure", SymName0, SymName)
+            SymName = insert_module_qualifier("semipure", SymName0)
         ;
             Purity = purity_impure,
-            insert_module_qualifier("impure", SymName0, SymName)
+            SymName = insert_module_qualifier("impure", SymName0)
         ),
         TypeCtor = type_ctor(SymName, Arity)
     ;
@@ -684,7 +684,7 @@
         defined_type(Name, Args, Kind)) :-
     (
         Name0 = qualified(Module, Name1),
-        mercury_public_builtin_module(Module)
+        Module = mercury_public_builtin_module
     ->
         Name = unqualified(Name1)
     ;
@@ -758,7 +758,7 @@
 
 type_is_io_state(Type) :-
     type_to_ctor_and_args(Type, TypeCtor, []),
-    mercury_std_lib_module_name("io", ModuleName),
+    ModuleName = mercury_std_lib_module_name("io"),
     TypeCtor = type_ctor(qualified(ModuleName, "state"), 0).
 
 type_ctor_is_array(type_ctor(qualified(unqualified("array"), "array"), 1)).
@@ -769,7 +769,7 @@
 
 is_introduced_type_info_type_ctor(TypeCtor) :-
     TypeCtor = type_ctor(qualified(PrivateBuiltin, Name), 0),
-    mercury_private_builtin_module(PrivateBuiltin),
+    PrivateBuiltin = mercury_private_builtin_module,
     ( Name = "type_info"
     ; Name = "type_ctor_info"
     ; Name = "typeclass_info"
@@ -836,35 +836,35 @@
 void_type = defined_type(unqualified("void"), [], kind_star).
 
 c_pointer_type = defined_type(Name, [], kind_star) :-
-    mercury_public_builtin_module(BuiltinModule),
+    BuiltinModule = mercury_public_builtin_module,
     Name = qualified(BuiltinModule, "c_pointer").
 
 heap_pointer_type = defined_type(Name, [], kind_star) :-
-    mercury_private_builtin_module(BuiltinModule),
+    BuiltinModule = mercury_private_builtin_module,
     Name = qualified(BuiltinModule, "heap_pointer").
 
 sample_type_info_type = defined_type(Name, [], kind_star) :-
-    mercury_private_builtin_module(BuiltinModule),
+    BuiltinModule = mercury_private_builtin_module,
     Name = qualified(BuiltinModule, "sample_type_info").
 
 sample_typeclass_info_type = defined_type(Name, [], kind_star) :-
-    mercury_private_builtin_module(BuiltinModule),
+    BuiltinModule = mercury_private_builtin_module,
     Name = qualified(BuiltinModule, "sample_typeclass_info").
 
 comparison_result_type = defined_type(Name, [], kind_star) :-
-    mercury_public_builtin_module(BuiltinModule),
+    BuiltinModule = mercury_public_builtin_module,
     Name = qualified(BuiltinModule, "comparison_result").
 
 type_info_type = defined_type(Name, [], kind_star) :-
-    mercury_private_builtin_module(BuiltinModule),
+    BuiltinModule = mercury_private_builtin_module,
     Name = qualified(BuiltinModule, "type_info").
 
 type_ctor_info_type = defined_type(Name, [], kind_star) :-
-    mercury_private_builtin_module(BuiltinModule),
+    BuiltinModule = mercury_private_builtin_module,
     Name = qualified(BuiltinModule, "type_ctor_info").
 
 io_state_type = defined_type(Name, [], kind_star) :-
-    mercury_std_lib_module_name("io", Module),
+    Module = mercury_std_lib_module_name("io"),
     Name = qualified(Module, "state").
 
 %-----------------------------------------------------------------------------%
@@ -961,7 +961,7 @@
 
 unqualify_private_builtin(unqualified(Name), Name).
 unqualify_private_builtin(qualified(ModuleName, Name), Name) :-
-    mercury_private_builtin_module(ModuleName).
+    ModuleName = mercury_private_builtin_module.
 
 :- pred name_is_type_info(string::in) is semidet.
 
Index: compiler/rtti.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rtti.m,v
retrieving revision 1.75
diff -u -b -r1.75 rtti.m
--- compiler/rtti.m	27 Sep 2006 06:17:03 -0000	1.75
+++ compiler/rtti.m	30 Sep 2006 10:13:11 -0000
@@ -1017,13 +1017,13 @@
     unexpected(this_file, "rtti_data_to_name: type_var").
 
 var_arity_id_to_rtti_type_ctor(pred_type_info) = Ctor :-
-    mercury_public_builtin_module(Builtin),
+    Builtin = mercury_public_builtin_module,
     Ctor = rtti_type_ctor(Builtin, "pred", 0).
 var_arity_id_to_rtti_type_ctor(func_type_info) = Ctor :-
-    mercury_public_builtin_module(Builtin),
+    Builtin = mercury_public_builtin_module,
     Ctor = rtti_type_ctor(Builtin, "func", 0).
 var_arity_id_to_rtti_type_ctor(tuple_type_info) = Ctor :-
-    mercury_public_builtin_module(Builtin),
+    Builtin = mercury_public_builtin_module,
     Ctor = rtti_type_ctor(Builtin, "tuple", 0).
 
 rtti_id_maybe_element_has_array_type(item_type(RttiId)) =
@@ -1393,7 +1393,7 @@
         % XXX We may wish to check that all arguments are variables.
     ),
     RttiTypeCtor = rtti_type_ctor(ModuleName, TypeName, _CtorArity),
-    sym_name_to_string(qualified(ModuleName, TypeName), "__", TypeStr),
+    TypeStr = sym_name_to_string_sep(qualified(ModuleName, TypeName), "__"),
     % XXX This naming scheme is the same as for base_typeclass_infos.
     % We should think about
     % - whether encoding guarantees different names for different instance
@@ -1411,7 +1411,7 @@
     % that are after everything has been module qualified. The only
     % things with an empty module name should be the builtins.
     ( ModuleNameSym0 = unqualified("") ->
-        mercury_public_builtin_module(ModuleNameSym)
+        ModuleNameSym = mercury_public_builtin_module
     ;
         ModuleNameSym = ModuleNameSym0
     ),
Index: compiler/rtti_out.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rtti_out.m,v
retrieving revision 1.68
diff -u -b -r1.68 rtti_out.m
--- compiler/rtti_out.m	22 Aug 2006 05:04:06 -0000	1.68
+++ compiler/rtti_out.m	30 Sep 2006 10:23:42 -0000
@@ -213,8 +213,7 @@
     list.length(MethodIds, NumMethodIds),
     output_generic_rtti_data_defn_start(TCIdRttiId, !DeclSet, !IO),
     io.write_string(" = {\n\t""", !IO),
-    sym_name_to_string(ModuleSymName, ModuleName),
-    c_util.output_quoted_string(ModuleName, !IO),
+    c_util.output_quoted_string(sym_name_to_string(ModuleSymName), !IO),
     io.write_string(""",\n\t""", !IO),
     c_util.output_quoted_string(ClassName, !IO),
     io.write_string(""",\n\t", !IO),
@@ -596,8 +595,7 @@
     io.write_string(",\n\t", !IO),
     output_static_code_addr(CompareCodeAddr, !IO),
     io.write_string(",\n\t""", !IO),
-    sym_name_to_string(Module, ModuleName),
-    c_util.output_quoted_string(ModuleName, !IO),
+    c_util.output_quoted_string(sym_name_to_string(Module), !IO),
     io.write_string(""",\n\t""", !IO),
     c_util.output_quoted_string(TypeName, !IO),
     io.write_string(""",\n\t", !IO),
Index: compiler/rtti_to_mlds.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rtti_to_mlds.m,v
retrieving revision 1.75
diff -u -b -r1.75 rtti_to_mlds.m
--- compiler/rtti_to_mlds.m	1 Oct 2006 04:57:32 -0000	1.75
+++ compiler/rtti_to_mlds.m	1 Oct 2006 05:00:02 -0000
@@ -228,7 +228,7 @@
     TypeCtorData = type_ctor_data(Version, TypeModule, TypeName,
         TypeArity, UnifyUniv, CompareUniv, Flags, TypeCtorDetails),
     RttiTypeCtor = rtti_type_ctor(TypeModule, TypeName, TypeArity),
-    sym_name_to_string(TypeModule, TypeModuleName),
+    TypeModuleName = sym_name_to_string(TypeModule),
     NumPtags = type_ctor_details_num_ptags(TypeCtorDetails),
     NumFunctors = type_ctor_details_num_functors(TypeCtorDetails),
     FunctorsRttiId = ctor_rtti_id(RttiTypeCtor, type_ctor_type_functors),
@@ -311,7 +311,7 @@
         MethodIdsInit = gen_init_rtti_id(ModuleName, MethodIdsRttiId)
     ),
     TCIdRttiId = tc_rtti_id(TCName, type_class_id),
-    sym_name_to_string(ModuleSymName, ModuleSymNameStr),
+    ModuleSymNameStr = sym_name_to_string(ModuleSymName),
     list.length(TVarNames, NumTVars),
     list.length(MethodIds, NumMethods),
     TCIdInit = init_struct(mlds_rtti_type(item_type(TCIdRttiId)), [
@@ -1226,7 +1226,7 @@
         % don't have any qualifiers at this point, so we need to add
         % the `builtin' qualifier now.
         ( RttiModuleName = unqualified("") ->
-            mercury_public_builtin_module(ModuleName),
+            ModuleName = mercury_public_builtin_module,
             RttiTypeCtor = rtti_type_ctor(RttiModuleName,
                 RttiTypeName, RttiTypeArity)
         ;
Index: compiler/simplify.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/simplify.m,v
retrieving revision 1.190
diff -u -b -r1.190 simplify.m
--- compiler/simplify.m	27 Sep 2006 06:17:03 -0000	1.190
+++ compiler/simplify.m	30 Sep 2006 10:16:02 -0000
@@ -1560,7 +1560,6 @@
     simplify_info_set_var_types(VarTypes, !Info),
 
     % Construct the call to compare/3.
-    mercury_public_builtin_module(BuiltinModule),
     hlds_goal.goal_info_get_context(GoalInfo, Context),
     Args     = [TI, R, X, Y],
 
@@ -1577,6 +1576,7 @@
 
     Unique   = ground(unique, none),
     ArgInsts = [R - Unique],
+    BuiltinModule = mercury_public_builtin_module,
     goal_util.generate_simple_call(BuiltinModule, "compare", predicate,
         mode_no(ModeNo), detism_det, purity_pure, Args, [], ArgInsts,
         ModuleInfo, Context, CmpGoal0),
Index: compiler/source_file_map.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/source_file_map.m,v
retrieving revision 1.18
diff -u -b -r1.18 source_file_map.m
--- compiler/source_file_map.m	31 Jul 2006 08:32:00 -0000	1.18
+++ compiler/source_file_map.m	30 Sep 2006 10:38:53 -0000
@@ -69,8 +69,7 @@
         FileName = default_source_file(ModuleName)
     ).
 
-default_source_file(ModuleName) = BaseFileName ++ ".m" :-
-    sym_name_to_string(ModuleName, ".", BaseFileName).
+default_source_file(ModuleName) = sym_name_to_string(ModuleName) ++ ".m".
 
 have_source_file_map(HaveMap, !IO) :-
     get_source_file_map(_, !IO),
@@ -124,7 +123,7 @@
     (
         ModuleCharsResult = ok(RevModuleChars),
         string.from_rev_char_list(RevModuleChars, ModuleStr),
-        string_to_sym_name(ModuleStr, ".", ModuleName),
+        ModuleName = string_to_sym_name(ModuleStr),
         read_until_char('\n', [], FileNameCharsResult, !IO),
         (
             FileNameCharsResult = ok(FileNameChars),
Index: compiler/table_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/table_gen.m,v
retrieving revision 1.121
diff -u -b -r1.121 table_gen.m
--- compiler/table_gen.m	20 Sep 2006 09:42:14 -0000	1.121
+++ compiler/table_gen.m	30 Sep 2006 11:00:45 -0000
@@ -722,7 +722,7 @@
         purity_impure, Context, InactiveGoalInfo),
     InactiveGoal = InactiveGoalExpr - InactiveGoalInfo,
 
-    mercury_table_builtin_module(TB),
+    TB = mercury_table_builtin_module,
     SwitchArms = [
         case(cons(qualified(TB, "loop_active"), 0), ActiveGoal),
         case(cons(qualified(TB, "loop_inactive"), 0), InactiveGoal)
@@ -923,7 +923,7 @@
             Detism, purity_impure, Context, InactiveGoalInfo),
         InactiveGoal = InactiveGoalExpr - InactiveGoalInfo,
 
-        mercury_table_builtin_module(TB),
+        TB = mercury_table_builtin_module,
         SwitchArms = [
             case(cons(qualified(TB, "memo_det_active"), 0), ActiveGoal),
             case(cons(qualified(TB, "memo_det_inactive"), 0), InactiveGoal),
@@ -961,7 +961,7 @@
         InactiveGoal = InactiveGoalExpr - InactiveGoalInfo,
         FailedGoal = fail_goal,
 
-        mercury_table_builtin_module(TB),
+        TB = mercury_table_builtin_module,
         SwitchArms = [
             case(cons(qualified(TB, "memo_semi_active"), 0), ActiveGoal),
             case(cons(qualified(TB, "memo_semi_inactive"), 0), InactiveGoal),
@@ -1079,7 +1079,7 @@
     OutputVars = list.map(project_var, NumberedOutputVars),
     InactiveInstmapDelta = bind_vars(OutputVars),
 
-    mercury_table_builtin_module(TB),
+    TB = mercury_table_builtin_module,
     SwitchArms = [
         case(cons(qualified(TB, "memo_non_active"), 0), InfiniteRecursionGoal),
         case(cons(qualified(TB, "memo_non_inactive"), 0), InactiveGoal),
@@ -1226,16 +1226,16 @@
         CounterVar),
     generate_new_table_var("StartVar", int_type, !VarSet, !VarTypes,
         StartVar),
-    generate_call("table_io_in_range", detism_semi,
+    table_generate_call("table_io_in_range", detism_semi,
         [TableVar, CounterVar, StartVar], purity_impure,
         ground_vars([TableVar, CounterVar, StartVar]),
         ModuleInfo, Context, InRangeGoal),
     generate_new_table_var("TipVar", trie_node_type, !VarSet, !VarTypes,
         TipVar),
-    generate_call("table_lookup_insert_start_int", detism_det,
+    table_generate_call("table_lookup_insert_start_int", detism_det,
         [TableVar, StartVar, CounterVar, TipVar], purity_impure,
         ground_vars([TipVar]), ModuleInfo, Context, LookupGoal),
-    generate_call("table_io_has_occurred", detism_semi, [TipVar],
+    table_generate_call("table_io_has_occurred", detism_semi, [TipVar],
         purity_impure, [], ModuleInfo, Context, OccurredGoal),
     (
         TableDecl = table_io_decl,
@@ -1288,7 +1288,7 @@
             unexpected(this_file,
                 "create_new_io_goal: one in / one out violation")
         ),
-        generate_call("table_io_copy_io_state", detism_det,
+        table_generate_call("table_io_copy_io_state", detism_det,
             [IoStateAssignFromVar, IoStateAssignToVar], purity_pure,
             [IoStateAssignFromVar - ground(clobbered, none),
             IoStateAssignToVar - ground(unique, none)],
@@ -1319,11 +1319,11 @@
         Unitize = table_io_unitize,
         generate_new_table_var("SavedTraceEnabled", int_type,
             !VarSet, !VarTypes, SavedTraceEnabledVar),
-        generate_call("table_io_left_bracket_unitized_goal", detism_det,
+        table_generate_call("table_io_left_bracket_unitized_goal", detism_det,
             [SavedTraceEnabledVar], purity_impure,
             ground_vars([SavedTraceEnabledVar]),
             ModuleInfo, Context, LeftBracketGoal),
-        generate_call("table_io_right_bracket_unitized_goal", detism_det,
+        table_generate_call("table_io_right_bracket_unitized_goal", detism_det,
             [SavedTraceEnabledVar], purity_impure, [],
             ModuleInfo, Context, RightBracketGoal),
         CallSaveAnswerGoalList = [LeftBracketGoal, NewGoal,
@@ -1467,13 +1467,13 @@
         Context, MainGoalInfo),
     MainGoal = MainExpr - MainGoalInfo,
 
-    generate_call("table_mm_completion", detism_det, [SubgoalVar],
+    table_generate_call("table_mm_completion", detism_det, [SubgoalVar],
         purity_impure, [], ModuleInfo, Context, ResumeGoal0),
     append_fail(ResumeGoal0, ResumeGoal),
     InactiveExpr = disj([MainGoal, ResumeGoal]),
     InactiveGoal = InactiveExpr - MainGoalInfo,
 
-    mercury_table_builtin_module(TB),
+    TB = mercury_table_builtin_module,
     SwitchArms = [
         case(cons(qualified(TB, "mm_inactive"), 0), InactiveGoal),
         case(cons(qualified(TB, "mm_complete"), 0), RestoreAllAnswerGoal),
@@ -1649,7 +1649,7 @@
         unexpected(this_file, "do_own_stack_transform: invalid determinism")
     ),
     % XXX consider inlining the predicate being called
-    generate_call(ConsumePredName, Detism, [ConsumerVar, AnswerBlockVar],
+    table_generate_call(ConsumePredName, Detism, [ConsumerVar, AnswerBlockVar],
         purity_impure, ground_vars([AnswerBlockVar]), ModuleInfo, Context,
         GetNextAnswerGoal),
     DebugArgStr = get_debug_arg_string(!.TableInfo),
@@ -2722,7 +2722,7 @@
     generate_new_table_var("AnswerBlock", answer_block_type,
         !VarSet, !VarTypes, AnswerBlockVar),
     ModuleInfo = TableInfo ^ table_module_info,
-    generate_call(ReturnAllAns, Detism, [RecordVar, AnswerBlockVar],
+    table_generate_call(ReturnAllAns, Detism, [RecordVar, AnswerBlockVar],
         purity_semipure, ground_vars([AnswerBlockVar]), ModuleInfo,
         Context, ReturnAnswerBlocksGoal),
     DebugArgStr = get_debug_arg_string(TableInfo),
@@ -2794,7 +2794,7 @@
     generate_new_table_var("AnswerBlock", answer_block_type,
         !VarSet, !VarTypes, AnswerBlockVar),
     ModuleInfo = TableInfo ^ table_module_info,
-    generate_call(PredName, Detism, [SubgoalVar, AnswerBlockVar],
+    table_generate_call(PredName, Detism, [SubgoalVar, AnswerBlockVar],
         Purity, ground_vars([AnswerBlockVar]), ModuleInfo,
         Context, ReturnAnswerBlocksGoal),
     DebugArgStr = get_debug_arg_string(TableInfo),
@@ -2892,15 +2892,15 @@
     Arity = pred_info_orig_arity(PredInfo),
     PredOrFunc = pred_info_is_pred_or_func(PredInfo),
     PredOrFuncStr = pred_or_func_to_str(PredOrFunc),
-    sym_name_to_string(qualified(Module, Name), NameStr),
+    NameStr = sym_name_to_string(qualified(Module, Name)),
     string.int_to_string(Arity, ArityStr),
     Message = Msg ++ " in " ++ PredOrFuncStr ++ " " ++ NameStr
         ++ "/" ++ ArityStr,
 
     gen_string_construction("Message", Message, !VarSet, !VarTypes,
         MessageVar, MessageStrGoal),
-    generate_call("table_error", detism_erroneous, [MessageVar], purity_pure,
-        [], ModuleInfo, Context, CallGoal),
+    table_generate_call("table_error", detism_erroneous, [MessageVar],
+        purity_pure, [], ModuleInfo, Context, CallGoal),
 
     GoalExpr = conj(plain_conj, [MessageStrGoal, CallGoal]),
     goal_info_init_hide(set.init, bind_vars([]), detism_erroneous,
@@ -2917,13 +2917,13 @@
     varset.new_named_var(!.VarSet, Name, Var, !:VarSet),
     map.set(!.VarTypes, Var, Type, !:VarTypes).
 
-:- pred generate_call(string::in, determinism::in, list(prog_var)::in,
+:- pred table_generate_call(string::in, determinism::in, list(prog_var)::in,
     purity::in, assoc_list(prog_var, mer_inst)::in,
     module_info::in, term.context::in, hlds_goal::out) is det.
 
-generate_call(PredName, Detism, Args, Purity, InstMapSrc, ModuleInfo, Context,
-        Goal) :-
-    mercury_table_builtin_module(BuiltinModule),
+table_generate_call(PredName, Detism, Args, Purity, InstMapSrc, ModuleInfo,
+        Context, Goal) :-
+    BuiltinModule = mercury_table_builtin_module,
     ( Purity = purity_pure ->
         Features0 = []
     ;
@@ -2946,7 +2946,6 @@
 
 table_generate_foreign_proc(PredName, Detism, Attributes, Args, ExtraArgs,
         Code, Purity, InstMapSrc, ModuleInfo, Context, Goal) :-
-    mercury_table_builtin_module(BuiltinModule),
     ( Purity = purity_pure ->
         Features0 = []
     ;
@@ -2957,6 +2956,7 @@
     ;
         Features = Features0
     ),
+    BuiltinModule = mercury_table_builtin_module,
     MaybeTraceRuntimCond = no,
     goal_util.generate_foreign_proc(BuiltinModule, PredName, predicate,
         only_mode, Detism, Purity, Attributes, Args, ExtraArgs,
@@ -3002,44 +3002,44 @@
 :- func mm_status_type = mer_type.
 
 proc_table_info_type = Type :-
-    mercury_table_builtin_module(TB),
+    TB = mercury_table_builtin_module,
     construct_type(type_ctor(qualified(TB, "ml_proc_table_info"), 0),
         [], Type).
 
 trie_node_type = Type :-
-    mercury_table_builtin_module(TB),
+    TB = mercury_table_builtin_module,
     construct_type(type_ctor(qualified(TB, "ml_trie_node"), 0), [], Type).
 
 memo_non_record_type = Type :-
-    mercury_table_builtin_module(TB),
+    TB = mercury_table_builtin_module,
     construct_type(type_ctor(qualified(TB, "memo_non_record"), 0), [], Type).
 
 subgoal_type = Type :-
-    mercury_table_builtin_module(TB),
+    TB = mercury_table_builtin_module,
     construct_type(type_ctor(qualified(TB, "ml_subgoal"), 0), [], Type).
 
 answer_block_type = Type :-
-    mercury_table_builtin_module(TB),
+    TB = mercury_table_builtin_module,
     construct_type(type_ctor(qualified(TB, "ml_answer_block"), 0), [], Type).
 
 loop_status_type = Type :-
-    mercury_table_builtin_module(TB),
+    TB = mercury_table_builtin_module,
     construct_type(type_ctor(qualified(TB, "loop_status"), 0), [], Type).
 
 memo_det_status_type = Type :-
-    mercury_table_builtin_module(TB),
+    TB = mercury_table_builtin_module,
     construct_type(type_ctor(qualified(TB, "memo_det_status"), 0), [], Type).
 
 memo_semi_status_type = Type :-
-    mercury_table_builtin_module(TB),
+    TB = mercury_table_builtin_module,
     construct_type(type_ctor(qualified(TB, "memo_semi_status"), 0), [], Type).
 
 memo_non_status_type = Type :-
-    mercury_table_builtin_module(TB),
+    TB = mercury_table_builtin_module,
     construct_type(type_ctor(qualified(TB, "memo_non_status"), 0), [], Type).
 
 mm_status_type = Type :-
-    mercury_table_builtin_module(TB),
+    TB = mercury_table_builtin_module,
     construct_type(type_ctor(qualified(TB, "mm_status"), 0), [], Type).
 
 %-----------------------------------------------------------------------------%
@@ -3047,13 +3047,13 @@
 :- func consumer_type = mer_type.
 
 consumer_type = Type :-
-    mercury_table_builtin_module(TB),
+    TB = mercury_table_builtin_module,
     construct_type(type_ctor(qualified(TB, "ml_consumer"), 0), [], Type).
 
 :- func generator_type = mer_type.
 
 generator_type = Type :-
-    mercury_table_builtin_module(TB),
+    TB = mercury_table_builtin_module,
     construct_type(type_ctor(qualified(TB, "ml_generator"), 0), [], Type).
 
 :- type maybe_specified_method
Index: compiler/trans_opt.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/trans_opt.m,v
retrieving revision 1.42
diff -u -b -r1.42 trans_opt.m
--- compiler/trans_opt.m	20 Aug 2006 08:21:33 -0000	1.42
+++ compiler/trans_opt.m	30 Sep 2006 10:47:26 -0000
@@ -220,7 +220,7 @@
     maybe_write_string(VeryVerbose,
         "% Reading transitive optimization interface for module", !IO),
     maybe_write_string(VeryVerbose, " `", !IO),
-    sym_name_to_string(Import, ImportString),
+    ImportString = sym_name_to_string(Import),
     maybe_write_string(VeryVerbose, ImportString, !IO),
     maybe_write_string(VeryVerbose, "'... ", !IO),
     maybe_flush_output(VeryVerbose, !IO),
Index: compiler/tupling.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/tupling.m,v
retrieving revision 1.31
diff -u -b -r1.31 tupling.m
--- compiler/tupling.m	29 Sep 2006 06:34:51 -0000	1.31
+++ compiler/tupling.m	1 Oct 2006 05:00:02 -0000
@@ -160,8 +160,7 @@
         report_warning("Warning: --tuple requires " ++
             "--tuple-trace-counts-file to work.\n", !IO)
     ;
-        read_trace_counts_source(no, try_single_first, TraceCountsFile,
-            Result, !IO),
+        read_trace_counts_source(TraceCountsFile, Result, !IO),
         (
             Result = list_ok(_, TraceCounts),
             tuple_arguments_2(!ModuleInfo, TraceCounts, !IO)
Index: compiler/unify_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/unify_gen.m,v
retrieving revision 1.171
diff -u -b -r1.171 unify_gen.m
--- compiler/unify_gen.m	22 Aug 2006 05:04:12 -0000	1.171
+++ compiler/unify_gen.m	30 Sep 2006 10:24:00 -0000
@@ -1115,7 +1115,7 @@
 var_type_msg(Type, Msg) :-
     ( type_to_ctor_and_args(Type, TypeCtor, _) ->
         TypeCtor = type_ctor(TypeSym, TypeArity),
-        sym_name_to_string(TypeSym, TypeSymStr),
+        TypeSymStr = sym_name_to_string(TypeSym),
         string.int_to_string(TypeArity, TypeArityStr),
         string.append_list([TypeSymStr, "/", TypeArityStr], Msg)
     ;
Index: compiler/unify_proc.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/unify_proc.m,v
retrieving revision 1.174
diff -u -b -r1.174 unify_proc.m
--- compiler/unify_proc.m	27 Sep 2006 06:17:08 -0000	1.174
+++ compiler/unify_proc.m	30 Sep 2006 10:16:25 -0000
@@ -1584,7 +1584,7 @@
     build_call("builtin_int_gt", [X_Index, Y_Index], Context,
         Call_Greater_Than, !Info),
 
-    mercury_public_builtin_module(Builtin),
+    Builtin = mercury_public_builtin_module,
     make_const_construction(Res, cons(qualified(Builtin, "<"), 0),
         Return_Less_Than),
     make_const_construction(Res, cons(qualified(Builtin, ">"), 0),
@@ -1714,7 +1714,7 @@
     create_atomic_complicated_unification(Y,
         rhs_functor(FunctorConsId2, no, Vars2), Context, umc_explicit, [],
         UnifyY_Goal),
-    mercury_public_builtin_module(Builtin),
+    Builtin = mercury_public_builtin_module,
     make_const_construction(R, cons(qualified(Builtin, CompareOp), 0),
         ReturnResult),
     GoalList = [UnifyX_Goal, UnifyY_Goal, ReturnResult],
Index: compiler/unique_modes.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/unique_modes.m,v
retrieving revision 1.117
diff -u -b -r1.117 unique_modes.m
--- compiler/unique_modes.m	27 Sep 2006 06:17:09 -0000	1.117
+++ compiler/unique_modes.m	30 Sep 2006 10:16:37 -0000
@@ -449,7 +449,7 @@
 
 check_goal_2(plain_call(PredId, ProcId0, Args, Builtin, CallContext,
         PredName), GoalInfo0, Goal, !ModeInfo, !IO) :-
-    sym_name_to_string(PredName, PredNameString),
+    PredNameString = sym_name_to_string(PredName),
     string.append("call ", PredNameString, CallString),
     mode_checkpoint(enter, CallString, !ModeInfo, !IO),
     mode_info_get_call_id(!.ModeInfo, PredId, CallId),
Index: compiler/unused_args.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/unused_args.m,v
retrieving revision 1.136
diff -u -b -r1.136 unused_args.m
--- compiler/unused_args.m	20 Sep 2006 09:42:17 -0000	1.136
+++ compiler/unused_args.m	30 Sep 2006 10:48:02 -0000
@@ -1150,7 +1150,7 @@
             TypeName = type_ctor_name(ModuleInfo, TypeCtor),
             TypeArity = type_ctor_arity(ModuleInfo, TypeCtor),
             string.int_to_string(TypeArity, TypeArityStr),
-            sym_name_to_string(TypeModule, TypeModuleString0),
+            TypeModuleString0 = sym_name_to_string(TypeModule),
             string.replace_all(TypeModuleString0, ".", "__", TypeModuleString),
             string.append_list([Name0, "_", TypeModuleString, "__", TypeName,
                 "_", TypeArityStr], Name1)
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing debian/patches
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.494
diff -u -b -r1.494 user_guide.texi
--- doc/user_guide.texi	2 Oct 2006 01:41:17 -0000	1.494
+++ doc/user_guide.texi	2 Oct 2006 01:43:23 -0000
@@ -3713,13 +3713,12 @@
 that contains a summary of the program's execution
 This summary is called a slice.
 Copy the generated slice to a new file for each test case,
-to end up with some passing slices,
-say @samp{pass1}, @samp{pass2}, @samp{pass3}, etc.
-and a failing slice, say @samp{fail}.
- at sp 1
-Once one or more passing slices
-and a failing slice have been generated the @samp{dice} command
-can be used to display a table of statistics
+to end up with a failing slice, say @samp{fail},
+and some passing slices, say @samp{pass1}, @samp{pass2}, @samp{pass3}, etc.
+Union the passing slices with a command such as
+ at samp{mtc_union -p passes pass1 pass2 pass3}.
+ at sp 1
+The @samp{dice} command can use these files to display a table of statistics
 comparing the passing test runs to the failing run.
 Here is an example of a dice displayed in an mdb session:
 @sp 1
@@ -3772,8 +3771,8 @@
 @samp{-f} or @samp{--fail-trace-counts} option or with a separate 
 @samp{set fail_trace_count @var{filename}} command.
 @sp 1
-The name of a file containing a list of the files containing the passing
-slices can be given with the @samp{-p} or @samp{--pass-trace-counts} option.
+The name of the file containing the union of the passing slices
+can be given with the @samp{-p} or @samp{--pass-trace-counts} option.
 Alternatively a separate @samp{set pass_trace_counts @var{filename}} command
 can be given.  See @ref{Trace counts} for more information about trace counts.
 @sp 1
@@ -4703,37 +4702,36 @@
 @node Trace counts
 @section Trace counts
 
-A program with debugging enabled may be run in a special mode that causes it
-to write out a summary of its execution to a file.
-This summary is called a @emph{trace count} or @emph{slice}.
-A slice is a record of how many times each @emph{label} in the program was
-executed for a particular run.
-A label is a point in the source code where a debugger event,
-such as CALL or EXIT,
-can be triggered.
-
-Slices are useful for determining what parts of a failing program are being run
-and possibly causing the failure.
-Slices from failing and passing runs can be compared to see which parts of the
-program are being run in the failing runs,
-but not the passing runs.
+A program with debugging enabled may be run in a special mode
+that causes it to write out to a @emph{trace count file}
+a record of how many times each @emph{debugger event} in the program
+was executed during that run.
+
+Trace counts are useful for determining
+what parts of a failing program are being run
+and possibly causing the failure;
+this is called @emph{slicing}.
+Slices from failing and passing runs can be compared
+to see which parts of the program are being executed during failing runs,
+but not during passing runs; this is called @emph{dicing}.
 
 @menu
 * Generating trace counts::
+* Combining trace counts::
 * Slicing::
 * Dicing::
-* Combining trace counts::
+* Coverage testing::
 @end menu
 
 @node Generating trace counts
 @subsection Generating trace counts
 
-To generate a slice for a program run, first compile the program with deep
-tracing enabled
-(either by using the @samp{--trace deep} option or
-compiling the program in a debugging grade). 
-Then invoke the program with the mtc script, passing any required
-arguments after the program name.
+To generate a slice for a program run,
+first compile the program with deep tracing enabled
+(either by using the @samp{--trace deep} option
+or by compiling the program in a debugging grade).
+Then invoke the program with the @samp{mtc} script,
+passing any required arguments after the program name.
 @sp 1
 For example:
 @sp 1
@@ -4741,26 +4739,88 @@
 mtc ./myprog arg1 arg2
 @end example
 @sp 1
-The program will run as usual, except that when it terminates it will write
-a summary of the run to a file.
+The program will run as usual, except that when it terminates
+it will write the number of times each debugger event was executed
+to a trace count file.
 @sp 1
 @samp{mtc} accepts an @samp{-f} or @samp{--output-file} option.
-The argument to this option is the filename to use for the generated
-trace count file.
-If this option is not given then the trace count will be written to a
-file with the prefix @samp{.mercury_trace_counts}
-and a unique suffix.
- at sp 1
-The generated slice can then be analysed by the @samp{mslice}
-and @samp{mdice} tools.
-It can also be used to help direct a declarative debugging search
+The argument to this option is the filename to use
+for the generated trace count file.
+If this option is not given,
+then the trace count will be written to a file
+with the prefix @samp{.mercury_trace_counts} and a unique suffix.
+ at sp 1
+Ordinarily, the generated trace count file will list
+only the debugger events that were actually executed during this run.
+However, it will list all debugger events, even unexecuted ones,
+if @samp{mtc} is given the @samp{-c} or @samp{--coverage-test} option.
+ at sp 1
+ at samp{mtc} also supports two more options intended for coverage testing:
+ at samp{-s} or @samp{--summary-file}, and @samp{--summary-count}.
+These each set an option in the @samp{MERCURY_OPTIONS} environment variable,
+ at samp{--trace-count-summary-file} and @samp{--trace-count-summary-max}
+respectively.
+For the documentation of these @samp{mtc} options,
+see the documentation of @samp{MERCURY_OPTIONS} environment variable.
+
+ at sp 1
+
+Trace count files
+can be manipulated with the @samp{mtc_union} and @samp{mtc_diff} tools,
+and they can be analysed by the @samp{mslice} and @samp{mdice} tools.
+They can also be used to help direct a declarative debugging search
 (see @ref{Search Modes}).
 
+ at sp 1
+
+ at node Combining trace counts
+ at subsection Combining trace counts
+
+The @samp{mtc_union} tool can be used
+to combine several trace count files into one trace count file.
+You need to use this when you have
+many trace count files you wish to analyse with @samp{mslice} or @samp{mdice}.
+
+ at samp{mtc_union} is invoked by issuing a command of the form:
+ at sp 1
+ at example
+mtc_union [-v] -o output_file file1 file2 ...
+ at end example
+ at sp 1
+ at samp{file1}, @samp{file2}, etc.
+are the trace count files that should be combined.
+The new trace count file will be written to @samp{output_file}.
+This file will preserve
+the count of the test cases that contributed to its contents,
+even if some of @samp{file1}, @samp{file2}, etc themselves
+were created by @samp{mtc_union}.
+If the @samp{-v} or @samp{--verbose} option is specified
+then a progress message will be displayed
+as each file is read and its contents merged into the union.
+
+The @samp{mtc_diff} tool can be used
+to subtract one trace count file from another.
+
+ at samp{mtc_diff} is invoked by issuing a command of the form:
+ at sp 1
+ at example
+mtc_diff -o output_file file1 file2
+ at end example
+ at sp 1
+ at samp{file1} and @samp{file2} must both be trace counts files.
+The output, written to @samp{output_file}, will contain
+the difference between the trace counts in @samp{file1} and @samp{file2}
+for every event that occurs in @samp{file1}.
+Unlike @samp{mtc_union}, @samp{mtc_diff} does not preserve
+the count of the test cases that contributed to its contents in any useful way.
+
+ at sp 1
+
 @node Slicing
 @subsection Slicing
 
-Once a slice has been generated it can be viewed in various ways using the
-mslice tool.
+Once a slice has been generated
+it can be viewed in various ways using the mslice tool.
 The output of the mslice tool will look something like the following:
 @sp 1
 @example
@@ -4778,18 +4838,19 @@
 @item @samp{Procedure}:
 This column displays the procedure that the label relates to.
 @item @samp{Path/Port}:
-For labels that generate interface events this column displays          
-the event port and for labels that generate internal events it          
-displays the goal path. (See @ref{Tracing of Mercury programs} for an
-explanation of interface and internal events.)
+For interface events this column displays the event port,
+while for internal events it displays the goal path.
+(See @ref{Tracing of Mercury programs}
+for an explanation of interface and internal events.)
 @item @samp{File:Line}:
-This column displays the context of the label.
+This column displays the context of the event.
 @item @samp{Count}:
-This column displays how many times the label was executed.
-The number in parentheses for each label row says in how many runs the label
-was executed.
+This column displays how many times the event was executed.
+The number in parentheses for each event row
+says in how many runs the event was executed.
 The number in parentheses in the heading row (after the word "Count")
-indicates how many runs were analysed by the mslice tool.
+indicates how many runs were represented
+in the trace counts file analysed by the mslice tool.
 @end itemize
 
 @sp 1
@@ -4799,13 +4860,14 @@
 mslice [-s sortspec] [-l N] [-m module] file
 @end example
 @sp 1
-where @samp{file} may be a generated trace count file, or a file containing
-a list of generated trace count file names.
- at sp 1
-The @samp{-s} or @samp{--sort} option specifies how the output should be
-sorted.
- at samp{sortspec} should be a string made up of any combination of the letters
- at samp{cCtT}.
+where @samp{file} is a trace count file,
+generated either directly by a program run
+or indirectly by the @samp{mtc_union} or @samp{mtc_diff} tools.
+ at sp 1
+The @samp{-s} or @samp{--sort} option
+specifies how the output should be sorted.
+ at samp{sortspec} should be a string made up of
+any combination of the letters @samp{cCtT}.
 Each letter specifies a column and direction to sort on:
 @itemize @bullet
 @item @samp{c}: Count ascending
@@ -4814,14 +4876,15 @@
 @item @samp{T}: Number of runs descending
 @end itemize
 @sp 1
-For example the option @samp{-s cT} will sort the output table by the
-Count column in ascending order.  If the counts for two or more labels are the
-same, then those labels will be sorted by number of runs in descending order.
+For example the option @samp{-s cT} will sort the output table
+by the Count column in ascending order.
+If the counts for two or more events are the same,
+then those events will be sorted by number of runs in descending order.
 @sp 1
 The @samp{-l} or @samp{--limit} option limits the output to @samp{N} lines.
 @sp 1
-The @samp{-m} or @samp{--module} option limits the output to labels only
-from the given module.
+The @samp{-m} or @samp{--module} option limits the output
+to events only from the given module.
 @sp 1
 
 @node Dicing
@@ -4830,11 +4893,13 @@
 A dice is a comparison between passing and failing runs of a program.
 @sp 1
 Dice are created using the @samp{mdice} tool.
-To use the @samp{mdice} tool one must first generate a set of trace count
-files for passing runs and a set of trace count files for failing runs
+To use the @samp{mdice} tool,
+one must first generate a set of trace count files for passing runs
+and a set of trace count files for failing runs
 using the @samp{mtc} tool (@ref{Generating trace counts}).
-Once this has been done, the @samp{mdice}
-can be used to display a table of statistics
+Once this has been done,
+and the union of each set computed using @samp{mtc_union},
+ at samp{mdice} can be used to display a table of statistics
 that compares the passing runs to the failing runs.
 @sp 1
 Here is an example of the output of the @samp{mdice} tool:
@@ -4852,34 +4917,34 @@
 but never during the passing test runs,
 so this would be a good place to start looking for a bug.
 @sp 1
-Each row corresponds to a label in the program. 
+Each row corresponds to an event in the program.
 The meanings of the columns are as follows:
 @itemize @bullet
 @item @samp{Procedure}:
-This column displays the procedure the label relates to.
+This column displays the procedure the event relates to.
 @item @samp{Path/Port}:
-For labels that generate interface events this column displays          
-the event port and for labels that generate internal events it          
-displays the goal path. (See @ref{Tracing of Mercury programs} for an
-explanation of interface and internal events.)
+For interface events this column displays the event port,
+while for internal events it displays the goal path.
+(See @ref{Tracing of Mercury programs}
+for an explanation of interface and internal events.)
 @item @samp{File:Line}:
-This column displays the context of the label.
+This column displays the context of the event.
 @item @samp{Pass (total passing test runs)}:
-This columns displays the total number of times the label was executed in all
-the passing test runs.
-This is followed by a number in parentheses which indicates the number of test
-runs the label was executed in.
-The heading of this column also has a number in
-parentheses which is the total number of passing test cases.
+This columns displays the total number of times
+the event was executed in all the passing test runs.
+This is followed by a number in parentheses
+which indicates the number of test runs the event was executed in.
+The heading of this column also has a number in parentheses
+which is the total number of passing test cases.
 @item @samp{Fail}:
-This column displays the number of times the goal was executed in the failing
-test run(s).
+This column displays the number of times
+the goal was executed in the failing test run(s).
 @item @samp{Suspicion}:
-This columns displays a number between 0 and 1 which gives an indication of how
-likely a particular goal is to contain a bug. 
-The suspicion is calculated as Suspicion = F / (P + F) where F is the number of
-times the goal was executed in failing runs and P is the number of times
-the goal was executed in passing runs.
+This columns displays a number between 0 and 1
+which gives an indication of how likely a particular goal is to contain a bug.
+The suspicion is calculated as Suspicion = F / (P + F)
+where F is the number of times the goal was executed in failing runs
+and P is the number of times the goal was executed in passing runs.
 @end itemize
 @sp 1
 The @samp{mdice} tool is invoked with a command of the form:
@@ -4887,18 +4952,19 @@
 @example
 mdice [-s sortspec] [-l N] [-m module] passfile failfile
 @end example
- at samp{passfile} is either a generated trace count file for a passing run,
-or a file containing a list of generated trace count filenames for passing
-runs.
- at samp{failfile} is either a generated trace count file for a failing run,
-or a file containing a list of generated trace count filenames for failing
-runs.
- at sp 1
-The table can be sorted on the Pass, Fail or Suspicion columns, or a
-combination of these.  This can be done with the @samp{-s} or @samp{--sort}
-option.  The argument of this option is a string made up of any combination of
-the letters @samp{pPfFsS}.  The letters in the string indicate how the table
-should be sorted:
+ at samp{passfile} is a trace count file,
+generated either directly by a passing program run
+or as the union of the trace count files of passing program runs.
+ at samp{failfile} is a trace count file,
+generated either directly by a failing program run
+or as the union of the trace count files of failing program runs.
+ at sp 1
+The table can be sorted on the Pass, Fail or Suspicion columns,
+or a combination of these.
+This can be done with the @samp{-s} or @samp{--sort} option.
+The argument of this option is a string
+made up of any combination of the letters @samp{pPfFsS}.
+The letters in the string indicate how the table should be sorted:
 @sp 1
 @itemize @bullet
 @item @samp{p}: Pass ascending
@@ -4909,39 +4975,59 @@
 @item @samp{S}: Suspicion descending
 @end itemize
 @sp 1
-For example the string "SF" means sort the table by suspicion in descending
-order, and if any two suspicions are the same, then by number of executions in
-the failing run(s), also in descending order.
- at sp 1
-The option @samp{-l} or @samp{--limit} can be used to limit the number of lines
-displayed.
- at sp 1
-The @samp{-m} or @samp{--module} option limits the output to the given module
-and any submodules.
+For example the string "SF" means
+sort the table by suspicion in descending order,
+and if any two suspicions are the same,
+then by number of executions in the failing run(s), also in descending order.
+ at sp 1
+The option @samp{-l} or @samp{--limit}
+can be used to limit the number of lines displayed.
+ at sp 1
+The @samp{-m} or @samp{--module} option
+limits the output to the given module and any submodules.
 
 @sp 1
 
- at node Combining trace counts
- at subsection Combining trace counts
-
-The @samp{mtc_union} tool can be used to combine several trace count files
-into one trace count file.
-This is useful when you have many trace count files you wish to analyse with
- at samp{mslice} or @samp{mdice}.
-It avoids the overhead of reading all the files
-each time @samp{mslice} or @samp{mdice} is invoked.
-
- at samp{mtc_union} is invoked by issuing a command of the form:
+ at node Coverage testing
+ at subsection Coverage testing
+
+Coverage testing is the process of finding out
+which parts of the code of a program
+are not executed during any test case,
+so that new test cases can be designed specifically to exercise those parts.
+ at sp 1
+The first step in coverage testing a Mercury program
+is compiling that program with execution tracing enabled,
+either by using the @samp{--trace deep} option
+or by compiling the program in a debugging grade.
+The second step is to execute that program on all its test cases
+with coverage testing enabled.
+This can be done either by running the program with @samp{mtc --coverage-test},
+or by including one of the corresponding options
+(@samp{--coverage-test} or @samp{--coverage-test-if-exec=@var{programname}})
+in the value of the @samp{MERCURY_OPTIONS} environment variable.
+These runs generate a set of trace counts files
+that can be given to the Mercury test coverage tool, the @samp{mcov} program.
+ at sp 1
+The @samp{mcov} tool is invoked with a command of the form:
 @sp 1
 @example
-mtc_union [-v] -o output_file file1 file2 ...
+mcov [-d] [-v] [-o output_file] tracecountfile1 ...
 @end example
+The arguments consist of one or more trace count files.
+The output will normally be a list of all the procedures in the program
+that were not executed in any of the runs
+that generated these trace count files.
+The output will go to standard output
+unless this is overridden by the @samp{-o} or @samp{--output-file} option.
+ at sp 1
+If the @samp{-d} or @samp{--detailed} option is specified,
+then the the output will list all the @emph{events} in the program
+that were not executed in any of these runs.
+This option can thus show the unexecuted parts of the executed procedures.
 @sp 1
- at samp{file1}, @samp{file2}, etc. are the trace count files that should be
-combined.
-The new trace count file will be written to @samp{output_file}.
-If the @samp{-v} or @samp{--verbose} option is specified then a progress
-message will be displayed as the files are merged.
+If the @samp{-v} or @samp{--verbose} option is specified,
+then a progress message will be displayed as each file is read.
 
 @c ----------------------------------------------------------------------------
 
@@ -8726,6 +8812,97 @@
 for the lowest value of @var{N} (up to 99)
 which doesn't overwrite an existing file.
 
+ at sp 1
+ at item --trace-count
+ at findex --trace-count
+When the program terminates, generate a trace counts file
+listing all the debugger events the program executed,
+if the program actually executed any debugger events.
+If MERCURY_OPTIONS includes
+the --trace-count-output-file=@var{filename} option,
+then the trace counts are put into the file @var{filename}.
+If MERCURY_OPTIONS includes
+the --trace-count-summary-file=@var{basename} option,
+then the trace counts are put
+either in the file @var{basename} (if it does not exist),
+or in @var{basename.N} for the lowest value of the integer @var{N}
+which doesn't overwrite an existing file.
+(There is a limit on the value of @var{N};
+see the option --trace-count-summary-max below.)
+If neither option is specified,
+then the output will be written to a file
+with the prefix @samp{.mercury_trace_counts} and a unique suffix.
+Specifying both options is an error.
+
+ at sp 1
+ at item --coverage-test
+ at findex --coverage-test
+Act as the --trace-count option, except
+include @emph{all} debugger events in the output,
+even the ones that were not executed.
+
+ at sp 1
+ at item --trace-count-if-exec=@var{prog}
+ at findex --trace-count-if-exec=@var{prog}
+Act as the --trace-count option,
+but only if the executable is named @var{prog}.
+This is to allow
+the collection of trace count information from only one Mercury program
+even if several Mercury programs
+are executed with the same setting of MERCURY_OPTIONS.
+
+ at sp 1
+ at item --coverage-test-if-exec=@var{prog}
+ at findex --coverage-test-if-exec=@var{prog}
+Act as the --coverage-test option,
+but only if the executable is named @var{prog}.
+This is to allow
+the collection of coverage test information from only one Mercury program
+even if several Mercury programs
+are executed with the same setting of MERCURY_OPTIONS.
+
+ at sp 1
+ at item --trace-count-output-file=@var{filename}
+ at findex --trace-count-output-file=@var{filename}
+Documented alongside the --trace-count option.
+
+ at sp 1
+ at item --trace-count-summary-file=@var{basename}
+ at findex --trace-count-summary-file=@var{basename}
+Documented alongside the --trace-count option.
+
+ at sp 1
+ at item --trace-count-summary-max=@var{N}
+ at findex --trace-count-summary-max=@var{N}
+If MERCURY_OPTIONS includes both
+the --trace-count option (or one of the other options that imply --trace-count)
+and the --trace-count-summary-file=@var{basename} option,
+then the generated program will put the generated trace counts
+either in @var{basename} (if it does not exist),
+or in @var{basename.N} for the lowest value of the integer @var{N}
+which doesn't overwrite an existing file.
+The --trace-count-summary-max option
+specifies the maximum value of this @var{N}.
+When this maximum is reached,
+the program will invoke the @samp{mtc_union} program
+to summarize @var{basename}, @var{basename.1}, ... @var{basename.N}
+into a single file @var{basename}, and delete the rest.
+By imposing a limit on the total number
+(and hence indirectly on the total size) of these trace count files,
+this mechanism allows the gathering of trace count information
+from a large number of program runs.
+The default maximum value of @var{N} is 20.
+
+ at c @sp 1
+ at c @item --trace-count-summary-cmd=@var{cmd}
+ at c @findex --trace-count-summary-cmd=@var{cmd}
+ at c This option specifies the command to use instead of mtc_union
+ at c for computing trace counts summaries, as shown for the above option.
+ at c This documentation is commented out
+ at c because the option is for implementors only.
+ at c The intended use is to override the installed version of mtc_union
+ at c with the version in a specific workspace, which may be more recent.
+
 @end table
 
 @sp 1
cvs diff: Diffing extras
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/gator
cvs diff: Diffing extras/gator/generations
cvs diff: Diffing extras/gator/generations/1
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_glut
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/solver_types
cvs diff: Diffing extras/solver_types/library
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/windows_installer_generator
cvs diff: Diffing extras/windows_installer_generator/sample
cvs diff: Diffing extras/windows_installer_generator/sample/images
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing mdbcomp
Index: mdbcomp/prim_data.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/mdbcomp/prim_data.m,v
retrieving revision 1.13
diff -u -b -r1.13 prim_data.m
--- mdbcomp/prim_data.m	29 Sep 2006 06:34:53 -0000	1.13
+++ mdbcomp/prim_data.m	1 Oct 2006 05:00:07 -0000
@@ -128,27 +128,32 @@
     %
 :- func get_special_pred_id_arity(special_pred_id) = int.
 
-    % string_to_sym_name(String, Separator, SymName):
+    % string_to_sym_name_sep(String, Separator) = SymName:
     %
     % Convert a string, possibly prefixed with module qualifiers (separated
     % by Separator), into a symbol name.
     %
-:- pred string_to_sym_name(string::in, string::in, sym_name::out) is det.
+:- func string_to_sym_name_sep(string, string) = sym_name.
 
-    % sym_name_to_string(SymName, Separator, String):
+    % string_to_sym_name(String) = SymName:
+    %
+    % Convert a string, possibly prefixed with module qualifiers (separated
+    % by the standard Mercury module qualifier separator), into a symbol name.
+    %
+:- func string_to_sym_name(string) = sym_name.
+
+    % sym_name_to_string_sep(SymName, Separator) = String:
     %
     % Convert a symbol name to a string, with module qualifiers separated
     % by Separator.
     %
-:- pred sym_name_to_string(sym_name::in, string::in, string::out) is det.
-:- func sym_name_to_string(sym_name, string) = string.
+:- func sym_name_to_string_sep(sym_name, string) = string.
 
-    % sym_name_to_string(SymName, String):
+    % sym_name_to_string(SymName) = String:
     %
     % Convert a symbol name to a string, with module qualifiers separated by
     % the standard Mercury module qualifier operator.
     %
-:- pred sym_name_to_string(sym_name::in, string::out) is det.
 :- func sym_name_to_string(sym_name) = string.
 
     % is_submodule(SymName1, SymName2):
@@ -158,20 +163,18 @@
     %
 :- pred is_submodule(module_name::in, module_name::in) is semidet.
 
-    % insert_module_qualifier(ModuleName, SymName0, SymName):
+    % insert_module_qualifier(ModuleName, SymName0) = SymName:
     %
     % Prepend the specified ModuleName onto the module qualifiers in SymName0,
     % giving SymName.
     %
-:- pred insert_module_qualifier(string::in, sym_name::in, sym_name::out)
-    is det.
+:- func insert_module_qualifier(string, sym_name) = sym_name.
 
     % Returns the name of the module containing public builtins;
     % originally this was "mercury_builtin", but it later became
     % just "builtin", and it may eventually be renamed "std.builtin".
     % This module is automatically imported, as if via `import_module'.
     %
-:- pred mercury_public_builtin_module(sym_name::out) is det.
 :- func mercury_public_builtin_module = sym_name.
 
     % Returns the name of the module containing private builtins;
@@ -180,7 +183,6 @@
     % "std.private_builtin". This module is automatically imported,
     % as if via `use_module'.
     %
-:- pred mercury_private_builtin_module(sym_name::out) is det.
 :- func mercury_private_builtin_module = sym_name.
 
     % Returns the name of the module containing builtins for tabling;
@@ -188,33 +190,28 @@
     % a separate module. This module is automatically imported iff any
     % predicate is tabled.
     %
-:- pred mercury_table_builtin_module(sym_name::out) is det.
 :- func mercury_table_builtin_module = sym_name.
 
     % Returns the name of the module containing the builtins for deep
     % profiling. This module is automatically imported iff deep profiling
     % is enabled.
     %
-:- pred mercury_profiling_builtin_module(sym_name::out) is det.
 :- func mercury_profiling_builtin_module = sym_name.
 
     % Returns the name of the module containing the builtins for term size
     % profiling. This module is automatically imported iff term size profiling
     % is enabled.
     %
-:- pred mercury_term_size_prof_builtin_module(sym_name::out) is det.
 :- func mercury_term_size_prof_builtin_module = sym_name.
 
     % Returns the name of the module containing the builtins for parallelism.
     % This module is automatically imported iff building in a .par grade.
     %
-:- pred mercury_par_builtin_module(sym_name::out) is det.
 :- func mercury_par_builtin_module = sym_name.
 
     % Returns the sym_name of the module with the given name in the
     % Mercury standard library.
     %
-:- pred mercury_std_lib_module_name(string::in, sym_name::out) is det.
 :- func mercury_std_lib_module_name(string) = sym_name.
 
     % Succeeds iff the specified module is one of the builtin modules listed
@@ -234,7 +231,7 @@
 :- import_module list.
 :- import_module string.
 
-string_to_sym_name(String, ModuleSeparator, Result) :-
+string_to_sym_name_sep(String, ModuleSeparator) = Result :-
     % This would be simpler if we had a string.rev_sub_string_search/3 pred.
     % With that, we could search for underscores right-to-left, and construct
     % the resulting symbol directly. Instead, we search for them left-to-right,
@@ -248,32 +245,27 @@
         string.length(ModuleSeparator, SeparatorLength),
         RightLength = StringLength - LeftLength - SeparatorLength,
         string.right(String, RightLength, Name),
-        string_to_sym_name(Name, ModuleSeparator, NameSym),
-        insert_module_qualifier(ModuleName, NameSym, Result)
+        NameSym = string_to_sym_name_sep(Name, ModuleSeparator),
+        Result = insert_module_qualifier(ModuleName, NameSym)
     ;
         Result = unqualified(String)
     ).
 
-insert_module_qualifier(ModuleName, unqualified(PlainName),
-        qualified(unqualified(ModuleName), PlainName)).
-insert_module_qualifier(ModuleName, qualified(ModuleQual0, PlainName),
-        qualified(ModuleQual, PlainName)) :-
-    insert_module_qualifier(ModuleName, ModuleQual0, ModuleQual).
-
-sym_name_to_string(SymName, String) :-
-    sym_name_to_string(SymName, ".", String).
-
-sym_name_to_string(SymName) = String :-
-    sym_name_to_string(SymName, String).
-
-sym_name_to_string(SymName, Separator) = String :-
-    sym_name_to_string(SymName, Separator, String).
-
-sym_name_to_string(unqualified(Name), _Separator, Name).
-sym_name_to_string(qualified(ModuleSym, Name), Separator, QualName) :-
-    sym_name_to_string(ModuleSym, Separator, ModuleName),
+string_to_sym_name(String) = string_to_sym_name_sep(String, ".").
+
+sym_name_to_string_sep(unqualified(Name), _Separator) = Name.
+sym_name_to_string_sep(qualified(ModuleSym, Name), Separator) = QualName :-
+    ModuleName = sym_name_to_string_sep(ModuleSym, Separator),
     string.append_list([ModuleName, Separator, Name], QualName).
 
+sym_name_to_string(SymName) = sym_name_to_string_sep(SymName, ".").
+
+insert_module_qualifier(ModuleName, unqualified(PlainName)) =
+        qualified(unqualified(ModuleName), PlainName).
+insert_module_qualifier(ModuleName, qualified(ModuleQual0, PlainName)) =
+        qualified(ModuleQual, PlainName) :-
+    insert_module_qualifier(ModuleName, ModuleQual0) = ModuleQual.
+
 is_submodule(SymName, SymName).
 is_submodule(qualified(SymNameA, _), SymNameB) :-
     is_submodule(SymNameA, SymNameB).
@@ -297,32 +289,25 @@
 % mercury_private_builtin_module(M) =
 %       qualified(unqualified("std"), "private_builtin"))).
 mercury_public_builtin_module = unqualified("builtin").
-mercury_public_builtin_module(mercury_public_builtin_module).
 mercury_private_builtin_module = unqualified("private_builtin").
-mercury_private_builtin_module(mercury_private_builtin_module).
 mercury_table_builtin_module = unqualified("table_builtin").
-mercury_table_builtin_module(mercury_table_builtin_module).
 mercury_profiling_builtin_module = unqualified("profiling_builtin").
-mercury_profiling_builtin_module(mercury_profiling_builtin_module).
 mercury_term_size_prof_builtin_module = unqualified("term_size_prof_builtin").
-mercury_term_size_prof_builtin_module(mercury_term_size_prof_builtin_module).
 mercury_par_builtin_module = unqualified("par_builtin").
-mercury_par_builtin_module(mercury_par_builtin_module).
 mercury_std_lib_module_name(Name) = unqualified(Name).
-mercury_std_lib_module_name(Name, unqualified(Name)).
 
 any_mercury_builtin_module(Module) :-
-    ( mercury_public_builtin_module(Module)
-    ; mercury_private_builtin_module(Module)
-    ; mercury_table_builtin_module(Module)
-    ; mercury_profiling_builtin_module(Module)
-    ; mercury_term_size_prof_builtin_module(Module)
-    ; mercury_par_builtin_module(Module)
+    ( Module = mercury_public_builtin_module
+    ; Module = mercury_private_builtin_module
+    ; Module = mercury_table_builtin_module
+    ; Module = mercury_profiling_builtin_module
+    ; Module = mercury_term_size_prof_builtin_module
+    ; Module = mercury_par_builtin_module
     ).
 
 non_traced_mercury_builtin_module(Module) :-
-    ( mercury_table_builtin_module(Module)
-    ; mercury_profiling_builtin_module(Module)
-    ; mercury_term_size_prof_builtin_module(Module)
-    ; mercury_par_builtin_module(Module)
+    ( Module = mercury_table_builtin_module
+    ; Module = mercury_profiling_builtin_module
+    ; Module = mercury_term_size_prof_builtin_module
+    ; Module = mercury_par_builtin_module
     ).
Index: mdbcomp/program_representation.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/mdbcomp/program_representation.m,v
retrieving revision 1.17
diff -u -b -r1.17 program_representation.m
--- mdbcomp/program_representation.m	20 Sep 2006 09:42:27 -0000	1.17
+++ mdbcomp/program_representation.m	30 Sep 2006 09:48:51 -0000
@@ -379,12 +379,12 @@
 
 call_does_not_generate_events(ModuleName, PredName, Arity) :-
     (
-        string_to_sym_name(ModuleName, ".", SymModuleName),
+        SymModuleName = string_to_sym_name(ModuleName),
         non_traced_mercury_builtin_module(SymModuleName)
     ;
         % The debugger cannot handle calls to polymorphic builtins that 
         % do not take a type_info argument, so such calls are not traced.
-        string_to_sym_name(ModuleName, ".", SymModuleName),
+        SymModuleName = string_to_sym_name(ModuleName),
         no_type_info_builtin(SymModuleName, PredName, Arity)
     ;
         pred_is_external(ModuleName, PredName, Arity)
@@ -549,19 +549,19 @@
     no_type_info_builtin_2(ModuleNameType, PredName, Arity),
     (
         ModuleNameType = builtin,
-        mercury_public_builtin_module(ModuleName)
+        ModuleName = mercury_public_builtin_module
     ;
         ModuleNameType = private_builtin,
-        mercury_private_builtin_module(ModuleName)
+        ModuleName = mercury_private_builtin_module
     ;
         ModuleNameType = table_builtin,
-        mercury_table_builtin_module(ModuleName)
+        ModuleName = mercury_table_builtin_module
     ;
         ModuleNameType = term_size_prof_builtin,
-        mercury_term_size_prof_builtin_module(ModuleName)
+        ModuleName = mercury_term_size_prof_builtin_module
     ;
         ModuleNameType = par_builtin,
-        mercury_par_builtin_module(ModuleName)
+        ModuleName = mercury_par_builtin_module
     ).
 
 :- type builtin_mod
Index: mdbcomp/rtti_access.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/mdbcomp/rtti_access.m,v
retrieving revision 1.6
diff -u -b -r1.6 rtti_access.m
--- mdbcomp/rtti_access.m	8 Jun 2006 08:19:53 -0000	1.6
+++ mdbcomp/rtti_access.m	30 Sep 2006 09:49:02 -0000
@@ -138,15 +138,15 @@
         ;
             error("get_proc_label_from_layout: bad special_pred_id")
         ),
-        string_to_sym_name(DefModule, ".", SymDefModule),
-        string_to_sym_name(TypeModule, ".", SymTypeModule),
+        SymDefModule = string_to_sym_name(DefModule),
+        SymTypeModule = string_to_sym_name(TypeModule),
         ProcLabel = special_proc_label(SymDefModule, SpecialId, 
             SymTypeModule, TypeName, TypeArity, ModeNum)
     ;
         proc_layout_get_non_uci_fields(Layout, PredOrFunc,
             DeclModule, DefModule, PredName, Arity, ModeNum),
-        string_to_sym_name(DefModule, ".", SymDefModule),
-        string_to_sym_name(DeclModule, ".", SymDeclModule),
+        SymDefModule = string_to_sym_name(DefModule),
+        SymDeclModule = string_to_sym_name(DeclModule),
         ProcLabel = ordinary_proc_label(SymDefModule, PredOrFunc,
             SymDeclModule, PredName, Arity, ModeNum)
     ).
Index: mdbcomp/slice_and_dice.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/mdbcomp/slice_and_dice.m,v
retrieving revision 1.9
diff -u -b -r1.9 slice_and_dice.m
--- mdbcomp/slice_and_dice.m	22 Sep 2006 03:50:45 -0000	1.9
+++ mdbcomp/slice_and_dice.m	30 Sep 2006 09:49:14 -0000
@@ -50,25 +50,24 @@
                                     % executed in.
             ).
 
-    % read_slice(Source, File, MaybeSlice, !IO):
+    % read_slice(File, MaybeSlice, !IO):
     %
-    % Read the slice(s) from Source and File.
+    % Read the slices from File.
     %
-:- pred read_slice(slice_source::in, string::in,
-    maybe_error(slice)::out, io::di, io::uo) is det.
+:- pred read_slice(string::in, maybe_error(slice)::out, io::di, io::uo) is det.
 
     % read_slice_to_string(File, SortStr, N, Module, SliceStr, Problem, !IO):
     %
-    % Read the slice(s) from try_single_first and File, and convert it
-    % to a string suitable for displaying on the screen, sorting it first
-    % using SortStr. SortStr can be any combination of the letters "cCtT"
-    % and indicates how the dice is to be sorted. See the documentation
-    % for the `mslice' tool in the user guide for an explanation of
-    % the sort string. Take only the top N lines of the sorted list.
-    %
-    % If Module is not the empty string then only labels from the named
-    % module will be included in the dice string, otherwise all modules
-    % will be included.
+    % Read the slice from File, and convert it to a string suitable for
+    % displaying on the screen, sorting it first using SortStr. SortStr
+    % can be any combination of the letters "cCtT" and indicates how the slice
+    % is to be sorted. See the documentation for the `mslice' tool in the
+    % user guide for an explanation of the sort string. Take only the top N
+    % lines of the sorted list.
+    %
+    % If Module is not the empty string then only labels from the named module
+    % will be included in the dice string, otherwise all modules will be
+    % included.
     %
     % If there was a problem reading the trace counts then Problem will
     % contain a string describing the problem encountered and SliceStr
@@ -112,29 +111,21 @@
                                 % was executed in.
             ).
 
-    % read_dice(PassSource, PassFile, FailSource, FailFile, MaybeDice, !IO):
+    % read_dice(PassFile, FailFile, MaybeDice, !IO):
     %
-    % Read the slice(s) from PassSource and PassFile, interpreting them as
-    % passing slices; read the slice(s) from FailSource and FailFile,
-    % interpreting them as failing slices; then produce the dice you get
-    % from them.
+    % Read the slice from PassFile, interpreting it as (a union of) passing
+    % slices; read the slices from FailFile, interpreting it as (a union of)
+    % failing slices; then produce the dice you get from them.
     %
-:- pred read_dice(slice_source::in, string::in, slice_source::in, string::in,
-    maybe_error(dice)::out, io::di, io::uo) is det.
-
-    % Same as read_dice/7, but with PassSource and FailSource both
-    % try_single_first.
-    %
-:- pred read_dice_try_single_first(string::in, string::in,
-    maybe_error(dice)::out, io::di, io::uo) is det.
+:- pred read_dice(string::in, string::in, maybe_error(dice)::out,
+    io::di, io::uo) is det.
 
     % read_dice_to_string(PassFile, FailFile, SortStr, N, Module, DiceStr,
     %   Problem, !IO):
     %
-    % Read the slice(s) from try_single_first and PassFile, interpreting them
-    % as passing slices; read the slice(s) from try_single_first and FailFile,
-    % interpreting them as failing slices; then produce the dice you get
-    % from them.
+    % Read the slice from PassFile, interpreting it as (a union of) passing
+    % slices; read the slices from FailFile, interpreting it as (a union of)
+    % failing slices; then produce the dice you get from them.
     %
     % Then convert the dice to a string suitable for displaying on the screen,
     % sorting it first using SortStr. SortStr can be any combination of the
@@ -143,9 +134,9 @@
     % for an explanation of the sort string. Take only the top N lines
     % of the sorted list.
     %
-    % If Module is not the empty string then only labels from the named
-    % module will be included in the dice string, otherwise all modules
-    % will be included.
+    % If Module is not the empty string then only labels from the named module
+    % will be included in the dice string, otherwise all modules will be
+    % included.
     %
     % If there was a problem reading the trace counts then Problem will
     % contain a string describing the problem encountered and DiceStr
@@ -200,8 +191,8 @@
 % The mechanism for reading in slices. The structure is similar to the
 % mechanism for reading in dices below.
 
-read_slice(Source, File, Result, !IO) :-
-    read_trace_counts_source(no, Source, File, ReadResult, !IO),
+read_slice(File, Result, !IO) :-
+    read_trace_counts_source(File, ReadResult, !IO),
     (
         ReadResult = list_ok(FileType, TraceCounts),
         slice_merge_trace_counts(TraceCounts, map.init, SliceProcMap),
@@ -268,17 +259,19 @@
 % The mechanism for reading in dices. The structure is similar to the
 % mechanism for reading in slices above.
 
-read_dice(PassSource, PassFile, FailSource, FailFile, Result, !IO) :-
-    read_trace_counts_source(no, PassSource, PassFile, ReadPassResult, !IO),
+:- pragma foreign_export("C", read_dice(in, in, out, di, uo),
+    "MR_MDB_read_dice").
+
+read_dice(PassFile, FailFile, Result, !IO) :-
+    read_trace_counts_source(PassFile, ReadPassResult, !IO),
     (
         ReadPassResult = list_ok(PassFileType, PassTraceCounts),
-        read_trace_counts_source(no, FailSource, FailFile, ReadFailResult,
-            !IO),
+        read_trace_counts_source(FailFile, ReadFailResult, !IO),
         (
             ReadFailResult = list_ok(FailFileType, FailTraceCounts),
-            dice_merge_trace_counts(pass, PassTraceCounts, map.init,
+            dice_merge_trace_counts(pass_slice, PassTraceCounts, map.init,
                 PassDiceProcMap),
-            dice_merge_trace_counts(fail, FailTraceCounts,
+            dice_merge_trace_counts(fail_slice, FailTraceCounts,
                 PassDiceProcMap, DiceProcMap),
             TotalPassTests = num_tests_for_file_type(PassFileType),
             TotalFailTests = num_tests_for_file_type(FailFileType),
@@ -293,13 +286,6 @@
         Result = error(Problem)
     ).
 
-:- pragma foreign_export("C", read_dice_try_single_first(in, in, out, di, uo),
-    "MR_MDB_read_dice_try_single_first").
-
-read_dice_try_single_first(PassFile, FailFile, Result, !IO) :-
-    read_dice(try_single_first, PassFile, try_single_first, FailFile, Result,
-        !IO).
-
 :- pred maybe_dice_error_to_problem_string(maybe_error(dice)::in, string::out)
 	is det.
 
@@ -319,8 +305,8 @@
 	error("det_maybe_dice_error_to_dice: result is error").
 
 :- type trace_counts_kind
-    --->    pass
-    ;       fail.
+    --->    pass_slice
+    ;       fail_slice.
 
     % Merge the passing or failing trace_counts into the given dice.
     %
@@ -360,11 +346,11 @@
     ;
         LineNoAndCount = line_no_and_count(LineNumber, ExecCount, NumTests),
         (
-            Kind = pass,
+            Kind = pass_slice,
             InitCount = dice_exec_count(FileName, LineNumber,
                 ExecCount, NumTests, 0, 0)
         ;
-            Kind = fail,
+            Kind = fail_slice,
             InitCount = dice_exec_count(FileName, LineNumber, 0, 0,
                 ExecCount, NumTests)
         ),
@@ -374,13 +360,13 @@
 :- pred dice_add_trace_count(trace_counts_kind::in, line_no_and_count::in,
     dice_exec_count::in, dice_exec_count::out) is det.
 
-dice_add_trace_count(pass, LineNoAndCount, ExecCounts0, ExecCounts) :-
+dice_add_trace_count(pass_slice, LineNoAndCount, ExecCounts0, ExecCounts) :-
     LineNoAndCount = line_no_and_count(_LineNumber, ExecCount, NumTests),
     ExecCounts0 = dice_exec_count(FileName, LineNumber,
         PassExec, PassTests, FailExec, FailTests),
     ExecCounts = dice_exec_count(FileName, LineNumber,
         PassExec + ExecCount, PassTests + NumTests, FailExec, FailTests).
-dice_add_trace_count(fail, LineNoAndCount, ExecCounts0, ExecCounts) :-
+dice_add_trace_count(fail_slice, LineNoAndCount, ExecCounts0, ExecCounts) :-
     LineNoAndCount = line_no_and_count(_LineNumber, ExecCount, NumTests),
     ExecCounts0 = dice_exec_count(FileName, LineNumber,
         PassExec, PassTests, FailExec, FailTests),
@@ -398,7 +384,7 @@
 
 read_slice_to_string(File, SortStr0, N, Module, SliceStr, Problem, !IO) :-
     ( slice_sort_string_is_valid(SortStr0) ->
-        read_slice(try_single_first, File, ReadSliceResult, !IO),
+        read_slice(File, ReadSliceResult, !IO),
         (
             ReadSliceResult = ok(Slice),
             Slice = slice(TotalTests, SliceProcMap),
@@ -581,8 +567,7 @@
 read_dice_to_string(PassFile, FailFile, SortStr, N, Module, DiceStr, Problem,
         !IO) :-
     ( dice_sort_string_is_valid(SortStr) ->
-        read_dice(try_single_first, PassFile, try_single_first, FailFile,
-            ReadDiceResult, !IO),
+        read_dice(PassFile, FailFile, ReadDiceResult, !IO),
         (
             ReadDiceResult = ok(Dice),
             Dice = dice(TotalPassTests, TotalFailTests, DiceProcMap),
@@ -850,7 +835,7 @@
     ;
         ProcLabel = special_proc_label(_, _, ProcSymModule, _, _, _)
     ),
-    string_to_sym_name(Module, ".", SymModule),
+    SymModule = string_to_sym_name(Module),
     is_submodule(ProcSymModule, SymModule).
 
 :- func format_proc_label(proc_label) = string.
Index: mdbcomp/trace_counts.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/mdbcomp/trace_counts.m,v
retrieving revision 1.14
diff -u -b -r1.14 trace_counts.m
--- mdbcomp/trace_counts.m	29 Sep 2006 06:34:53 -0000	1.14
+++ mdbcomp/trace_counts.m	1 Oct 2006 05:00:07 -0000
@@ -126,37 +126,15 @@
 :- pred read_trace_counts_list(bool::in, string::in,
     read_trace_counts_list_result::out, io::di, io::uo) is det.
 
-:- type slice_source
-    --->    file_list
-    ;       single_file
-    ;       try_single_first.
-
-    % read_trace_counts_source(ShowProgress, Source, FileName, Result, !IO):
-    %
-    % Read in trace counts stored in one or more trace count files.
-    %
-    % If Source is file_list, then FileName should contain a list of filenames,
-    % and read_trace_counts_source will read in the trace counts from each
-    % of those files.
-    %
-    % If Source is single_file, then FileName should itself be a file
-    % containing trace counts data.
-    %
-    % If Source is try_single_first, then read_trace_counts_source will
-    % check to see if FileName contains trace counts data. If yes, it will
-    % get trace counts from there. If not, read_trace_counts_source will
-    % interpret FileName as a file that itself contains filenames, and
-    % will treat it as with Source=file_list.
+    % read_trace_counts_source(FileName, Result, !IO):
     %
-    % If the source is a list of files and ShowProgress is yes then
-    % the name of each file read will be printed to the current output
-    % stream just before it is read.
+    % Read in trace counts stored in a given trace count file.
     %
-:- pred read_trace_counts_source(bool::in, slice_source::in, string::in,
+:- pred read_trace_counts_source(string::in,
     read_trace_counts_list_result::out, io::di, io::uo) is det.
 
-    % read_and_union_trace_counts(ShowProgress, Source, FileNames,
-    %   NumTests, TestKinds, TraceCounts, MaybeError, !IO):
+    % read_and_union_trace_counts(ShowProgress, FileNames, NumTests, TestKinds,
+    %   TraceCounts, MaybeError, !IO):
     %
     % Invoke read_trace_counts_source for each of the supplied filenames, and
     % union the resulting trace counts. If there is a problem with reading in
@@ -165,9 +143,13 @@
     % the union of the trace counts and NumTests will contain the number of
     % tests the trace counts come from.
     %
-:- pred read_and_union_trace_counts(bool::in, slice_source::in,
-    list(string)::in, int::out, set(trace_count_file_type)::out,
-    trace_counts::out, maybe(string)::out, io::di, io::uo) is det.
+    % If the source is a list of files and ShowProgress is yes then
+    % the name of each file read will be printed to the current output
+    % stream just before it is read.
+    %
+:- pred read_and_union_trace_counts(bool::in, list(string)::in, int::out,
+    set(trace_count_file_type)::out, trace_counts::out, maybe(string)::out,
+    io::di, io::uo) is det.
 
     % write_trace_counts_to_file(FileType, TraceCounts, FileName, Result, !IO):
     %
@@ -305,19 +287,7 @@
 
 %-----------------------------------------------------------------------------%
 
-read_trace_counts_source(ShowProgress, Source, FileName, Result, !IO) :-
-    (
-        Source = file_list,
-        read_trace_counts_list(ShowProgress, FileName, Result, !IO)
-    ;
-        Source = single_file,
-        (
-            ShowProgress = yes,
-            io.write_string(FileName, !IO),
-            io.nl(!IO)
-        ;
-            ShowProgress = no
-        ),
+read_trace_counts_source(FileName, Result, !IO) :-
         read_trace_counts(FileName, ReadTCResult, !IO),
         (
             ReadTCResult = ok(FileType, TraceCount),
@@ -340,19 +310,6 @@
             ReadTCResult = error_message(ErrMsg),
             Result = list_error_message("Error reading trace counts " ++
                 "from file `" ++ FileName ++ "': " ++ ErrMsg)
-        )
-    ;
-        Source = try_single_first,
-        read_trace_counts_source(ShowProgress, single_file, FileName,
-            TryResult, !IO),
-        (
-            TryResult = list_ok(_, _),
-            Result = TryResult
-        ;
-            TryResult = list_error_message(_),
-            read_trace_counts_source(ShowProgress, file_list, FileName,
-                Result, !IO)
-        )
     ).
 
 read_trace_counts_list(ShowProgress, FileName, Result, !IO) :-
@@ -551,7 +508,7 @@
                 token_cons(name(NextModuleName), _,
                 token_nil)
         ->
-            string_to_sym_name(NextModuleName, ".", NextModuleNameSym),
+            NextModuleNameSym = string_to_sym_name(NextModuleName),
             io.read_line_as_string(Result, !IO),
             (
                 Result = ok(Line),
@@ -611,7 +568,7 @@
                     token_cons(integer(Arity), _,
                     token_cons(integer(Mode), _,
                     token_nil)))),
-                string_to_sym_name(DeclModuleName, ".", DeclModuleNameSym),
+                DeclModuleNameSym = string_to_sym_name(DeclModuleName),
                 ProcLabel = ordinary_proc_label(CurModuleNameSym, predicate,
                     DeclModuleNameSym, Name, Arity, Mode)
             ;
@@ -622,7 +579,7 @@
                     token_cons(integer(Arity), _,
                     token_cons(integer(Mode), _,
                     token_nil)))),
-                string_to_sym_name(DeclModuleName, ".", DeclModuleNameSym),
+                DeclModuleNameSym = string_to_sym_name(DeclModuleName),
                 ProcLabel = ordinary_proc_label(CurModuleNameSym, function,
                     DeclModuleNameSym, Name, Arity, Mode)
             )
@@ -781,9 +738,9 @@
 
 %-----------------------------------------------------------------------------%
 
-read_and_union_trace_counts(ShowProgress, SliceSource, Files,
-        NumTests, TestKinds, TraceCounts, MaybeError, !IO) :-
-    read_and_union_trace_counts_2(ShowProgress, SliceSource, Files,
+read_and_union_trace_counts(ShowProgress, Files, NumTests, TestKinds,
+        TraceCounts, MaybeError, !IO) :-
+    read_and_union_trace_counts_2(ShowProgress, Files,
         union_file(0, []), FileType, map.init, TraceCounts, MaybeError, !IO),
     (
         FileType = union_file(NumTests, TestKindList),
@@ -796,22 +753,28 @@
         error("read_and_union_trace_counts: diff_file")
     ).
 
-:- pred read_and_union_trace_counts_2(bool::in, slice_source::in,
+:- pred read_and_union_trace_counts_2(bool::in,
     list(string)::in, trace_count_file_type::in, trace_count_file_type::out,
     trace_counts::in, trace_counts::out, maybe(string)::out,
     io::di, io::uo) is det.
 
-read_and_union_trace_counts_2(_, _, [], !FileType, !TraceCounts,
-        no, !IO).
-read_and_union_trace_counts_2(ShowProgress, SliceSource, [File | Files],
+read_and_union_trace_counts_2(_, [], !FileType, !TraceCounts, no, !IO).
+read_and_union_trace_counts_2(ShowProgress, [FileName | FileNames],
         !FileType, !TraceCounts, MaybeError, !IO) :-
-    read_trace_counts_source(ShowProgress, SliceSource, File, TCResult, !IO),
+    (
+        ShowProgress = yes,
+        io.write_string(FileName, !IO),
+        io.nl(!IO)
+    ;
+        ShowProgress = no
+    ),
+    read_trace_counts_source(FileName, TCResult, !IO),
     (
         TCResult = list_ok(FileType, NewTraceCounts),
         summarize_trace_counts_list([!.TraceCounts, NewTraceCounts],
             !:TraceCounts),
         !:FileType = sum_trace_count_file_type(!.FileType, FileType),
-        read_and_union_trace_counts_2(ShowProgress, SliceSource, Files,
+        read_and_union_trace_counts_2(ShowProgress, FileNames,
             !FileType, !TraceCounts, MaybeError, !IO)
     ;
         TCResult = list_error_message(Message),
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing slice
Index: slice/mcov.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/slice/mcov.m,v
retrieving revision 1.2
diff -u -b -r1.2 mcov.m
--- slice/mcov.m	29 Sep 2006 06:34:56 -0000	1.2
+++ slice/mcov.m	1 Oct 2006 05:00:10 -0000
@@ -53,8 +53,8 @@
         (
             Args = [_ | _],
             lookup_bool_option(OptionTable, verbose, Verbose),
-            read_and_union_trace_counts(Verbose, try_single_first, Args,
-                _NumTests, FileTypes, TraceCounts, MaybeReadError, !IO),
+            read_and_union_trace_counts(Verbose, Args, _NumTests, FileTypes,
+                TraceCounts, MaybeReadError, !IO),
             stderr_stream(StdErr, !IO),
             (
                 MaybeReadError = yes(ReadErrorMsg),
@@ -75,14 +75,25 @@
                     io.write_string(StdErr, consistency_warning, !IO)
                 ),
                 lookup_bool_option(OptionTable, detailed, Detailed),
+                lookup_accumulating_option(OptionTable, modules, Modules),
+                (
+                    Modules = [],
+                    RestrictToModules = no
+                ;
+                    Modules = [_ | _],
+                    ModuleSyms = list.map(string_to_sym_name, Modules),
+                    RestrictToModules = yes(set.list_to_set(ModuleSyms))
+                ),
                 lookup_string_option(OptionTable, output_filename, OutputFile),
                 ( OutputFile = "" ->
-                    write_coverage_test(Detailed, TraceCounts, !IO)
+                    write_coverage_test(Detailed, RestrictToModules,
+                        TraceCounts, !IO)
                 ;
                     io.tell(OutputFile, OpenRes, !IO),
                     (
                         OpenRes = ok,
-                        write_coverage_test(Detailed, TraceCounts, !IO)
+                        write_coverage_test(Detailed, RestrictToModules,
+                            TraceCounts, !IO)
                     ;
                         OpenRes = error(OpenErrorMsg),
                         io.write_string(StdErr, "Error opening " ++
@@ -129,10 +140,21 @@
                 label_path_port     :: path_port
             ).
 
-:- pred write_coverage_test(bool::in, trace_counts::in, io::di, io::uo) is det.
+:- type trace_counts_list ==
+    assoc_list(proc_label_in_context, proc_trace_counts).
 
-write_coverage_test(Detailed, TraceCountMap, !IO) :-
-    map.to_assoc_list(TraceCountMap, TraceCounts),
+:- pred write_coverage_test(bool::in, maybe(set(module_name))::in,
+    trace_counts::in, io::di, io::uo) is det.
+
+write_coverage_test(Detailed, RestrictToModules, TraceCountMap, !IO) :-
+    map.to_assoc_list(TraceCountMap, TraceCounts0),
+    (
+        RestrictToModules = no,
+        TraceCounts = TraceCounts0
+    ;
+        RestrictToModules = yes(Modules),
+        list.filter(in_module_set(Modules), TraceCounts0, TraceCounts)
+    ),
     (
         Detailed = no,
         collect_zero_count_local_procs(TraceCounts, ZeroCountProcs),
@@ -147,10 +169,16 @@
         list.foldl(write_label_info, SortedZeroCountLabels, !IO)
     ).
 
+:- pred in_module_set(set(module_name)::in, pair(proc_label_in_context, T)::in)
+    is semidet.
+
+in_module_set(Modules, ProcLabelInContext - _) :-
+    ProcLabelInContext = proc_label_in_context(Module, _, _),
+    set.member(Module, Modules).
+
 %-----------------------------------------------------------------------------%
 
-:- pred collect_zero_count_local_procs(
-    assoc_list(proc_label_in_context, proc_trace_counts)::in,
+:- pred collect_zero_count_local_procs(trace_counts_list::in,
     list(proc_info)::out) is det.
 
 collect_zero_count_local_procs(TraceCounts, ZeroCountProcInfos) :-
@@ -160,8 +188,7 @@
     list.filter_map(is_zero_count_local_proc(ProcInfoMap), CountList,
         ZeroCountProcInfos).
 
-:- pred collect_proc_infos_counts(
-    assoc_list(proc_label_in_context, proc_trace_counts)::in,
+:- pred collect_proc_infos_counts(trace_counts_list::in,
     map(proc_label, proc_info)::in, map(proc_label, proc_info)::out,
     map(proc_label, int)::in, map(proc_label, int)::out) is det.
 
@@ -210,8 +237,7 @@
 
 %-----------------------------------------------------------------------------%
 
-:- pred collect_zero_count_local_labels(
-    assoc_list(proc_label_in_context, proc_trace_counts)::in,
+:- pred collect_zero_count_local_labels(trace_counts_list::in,
     list(label_info)::in, list(label_info)::out) is det.
 
 collect_zero_count_local_labels([], !ZeroLabelInfos).
@@ -325,20 +351,24 @@
 
 usage(!IO) :-
     io.write_strings([
-        "Usage: mct [-d] [-v] [-o output_file] file1 file2 ...\n",
+        "Usage: mcov [-d] [-v] [-m module] [-o output_file] file1 file2 ...\n",
         "The -d or --detailed option causes the printing of a report for\n",
         "each label that has not been executed, even if some other code\n",
         "has been executed in the same procedure.\n",
         "The -v or --verbose option causes each trace count file name\n",
         "to be printed as it is added to the union.\n",
-        "file1, file2, etc can be trace count files or they can be files\n",
-        "that contains lists of the names of other trace count files.\n"],
+        "file1, file2, etc should be trace count files.\n",
+        "If one or more -m or --module options are given, then the output\n",
+        "will be restricted to the modules named by their arguments.\n",
+        "The argument of the -o or --output-file option gives the name\n",
+        "of the output file.\n"],
         !IO).
 
 %-----------------------------------------------------------------------------%
 
 :- type option
     --->    detailed
+    ;       modules
     ;       output_filename
     ;       verbose.
 
@@ -349,15 +379,18 @@
 :- pred option_default(option::out, option_data::out) is multi.
 
 option_default(detailed,        bool(no)).
+option_default(modules,         accumulating([])).
 option_default(output_filename, string("")).
 option_default(verbose,         bool(no)).
 
 short_option('d',               detailed).
+short_option('m',               modules).
 short_option('o',               output_filename).
 short_option('v',               verbose).
 
 long_option("detailed",         detailed).
-long_option("out",              output_filename).
+long_option("module",           modules).
+long_option("output-file",      output_filename).
 long_option("verbose",          verbose).
 
 %-----------------------------------------------------------------------------%
Index: slice/mtc_diff.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/slice/mtc_diff.m,v
retrieving revision 1.1
diff -u -b -r1.1 mtc_diff.m
--- slice/mtc_diff.m	22 Sep 2006 03:50:48 -0000	1.1
+++ slice/mtc_diff.m	24 Sep 2006 05:48:59 -0000
@@ -50,8 +50,7 @@
             OutputFile \= ""
         ->
             stderr_stream(StdErr, !IO),
-            read_trace_counts_source(no, try_single_first, Arg1,
-                MaybeTraceCounts1, !IO),
+            read_trace_counts_source(Arg1, MaybeTraceCounts1, !IO),
             (
                 MaybeTraceCounts1 = list_ok(_, _)
             ;
@@ -59,8 +58,7 @@
                 io.write_string(StdErr, Msg1, !IO),
                 io.nl(StdErr, !IO)
             ),
-            read_trace_counts_source(no, try_single_first, Arg2,
-                MaybeTraceCounts2, !IO),
+            read_trace_counts_source(Arg2, MaybeTraceCounts2, !IO),
             (
                 MaybeTraceCounts2 = list_ok(_, _)
             ;
@@ -100,10 +98,8 @@
 :- pred usage(io::di, io::uo) is det.
 
 usage(!IO) :-
-    io.write_strings([
-        "Usage: mtc_diff -o outputfile file1 file2\n",
-        "file1, file2, etc can be trace count files or they can be files\n",
-        "that contains lists of the names of other trace count files.\n"],
+    io.write_string(
+        "Usage: mtc_diff -o outputfile tracecountfile1 tracecountfile2\n",
         !IO).
 
 %-----------------------------------------------------------------------------%
Index: slice/mtc_union.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/slice/mtc_union.m,v
retrieving revision 1.3
diff -u -b -r1.3 mtc_union.m
--- slice/mtc_union.m	22 Sep 2006 03:50:48 -0000	1.3
+++ slice/mtc_union.m	24 Sep 2006 05:49:19 -0000
@@ -51,8 +51,8 @@
             OutputFile \= ""
         ->
             lookup_bool_option(OptionTable, verbose, Verbose),
-            read_and_union_trace_counts(Verbose, try_single_first, Args,
-                NumTests, Kinds, TraceCounts, MaybeReadError, !IO),
+            read_and_union_trace_counts(Verbose, Args, NumTests, Kinds,
+                TraceCounts, MaybeReadError, !IO),
             stderr_stream(StdErr, !IO),
             (
                 MaybeReadError = yes(ReadErrorMsg),
@@ -89,8 +89,7 @@
         "Usage: mtc_union [-v] -o output_file file1 file2 ...\n",
         "The -v or --verbose option causes each trace count file name\n",
         "to be printed as it is added to the union.\n",
-        "file1, file2, etc can be trace count files or they can be files\n",
-        "that contains lists of the names of other trace count files.\n"],
+        "file1, file2, etc should be trace count files.\n"],
         !IO).
 
 %-----------------------------------------------------------------------------%
cvs diff: Diffing tests
Index: tests/Mmake.common
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/Mmake.common,v
retrieving revision 1.47
diff -u -b -r1.47 Mmake.common
--- tests/Mmake.common	25 Jan 2006 07:03:44 -0000	1.47
+++ tests/Mmake.common	24 Sep 2006 03:57:46 -0000
@@ -275,7 +275,10 @@
 THIS_DIR_TESTS_TO_RUN := $(SPECIFIED_TESTS)
 else
 ifdef FAILED_TESTS_ONLY
-THIS_DIR_TESTS_TO_RUN := $(shell FAILED_TESTS)
+# FAILED_TESTS contains the names of failed tests from subdirectories
+# as well as this directory. We want to run the failed tests from this
+# directory only.
+THIS_DIR_TESTS_TO_RUN := $(shell egrep -v / FAILED_TESTS)
 else
 ifdef TESTS_TO_RUN
 THIS_DIR_TESTS_TO_RUN := $(shell echo $(patsubst $(THIS_DIR)/%,%,\
Index: tests/run_one_test
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/run_one_test,v
retrieving revision 1.2
diff -u -b -r1.2 run_one_test
--- tests/run_one_test	29 Apr 2005 01:03:24 -0000	1.2
+++ tests/run_one_test	24 Sep 2006 00:47:39 -0000
@@ -3,6 +3,8 @@
 
 set -x
 
+max_num_trace_counts=50
+
 exitstatus=0
 echo RUNNING TEST $this_dir/$test_full $params_msg | tee $test_full.log
 echo "MERCURY_OPTIONS=$MERCURY_OPTIONS"
@@ -48,32 +50,36 @@
         echo $this_dir/$test_full $params_msg \
             >> $tests_dir/FAILED_TESTS_SUMMARY
         tcdir=FAILED_TC_DIR
-        tcfile=FAILED_TC_FILES
         exitstatus=1
     else
         rm -f $test_full.log $test.out* $test.*res*
         mmake $test.realclean > /dev/null 2>&1
         echo PASSED TEST $this_dir/$test_full $params_msg
         tcdir=PASSED_TC_DIR
-        tcfile=PASSED_TC_FILES
     fi
     case "$trace_count" in
         true)
-            mkdir -p $tests_dir/$tcdir
-            testname=`echo $this_dir/$test_full | tr '[/]' '[:]'`
+            n=`cat $tests_dir/$tcdir/NEXT_NUMBER`
             for counts_file in .mercury_trace_counts.*
             do
                 if test -s "$counts_file"
                 then
-                    progpidname=`echo "$counts_file" | \
-                        sed -e 's/.mercury_trace_counts.//'`
-                    name="TEST_${testname}_PROG_${progpidname}"
-                    mv $counts_file $tests_dir/$tcdir/$name
-                    /bin/rm -f $tests_dir/$tcdir/$name.gz
-                    gzip $tests_dir/$tcdir/$name
-                    echo $tcdir/$name >> $tests_dir/$tcfile
+                    mv "$counts_file" "$tests_dir/$tcdir/trace_counts.$n"
+                    n=`expr $n + 1`
                 fi
             done
+            if test "$n" -gt "$max_num_trace_counts"
+            then
+                ${SLICE_DIR}mtc_union -o $tests_dir/$tcdir/tmp_summary \
+                    $tests_dir/$tcdir/trace_counts.*
+                /bin/rm -f $tests_dir/$tcdir/trace_counts.*
+                mv $tests_dir/$tcdir/tmp_summary \
+                    $tests_dir/$tcdir/trace_counts.0
+
+                echo 1 > $tests_dir/$tcdir/NEXT_NUMBER
+            else
+                echo $n > $tests_dir/$tcdir/NEXT_NUMBER
+            fi
             ;;
     esac
 fi
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
Index: tests/debugger/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/Mmakefile,v
retrieving revision 1.125
diff -u -b -r1.125 Mmakefile
--- tests/debugger/Mmakefile	22 Aug 2006 02:33:48 -0000	1.125
+++ tests/debugger/Mmakefile	24 Sep 2006 03:35:36 -0000
@@ -317,12 +317,16 @@
 	MERCURY_OPTIONS=--trace-count ./dice 10 11 100 && \
 	mv .mercury_trace_counts.*dice.* dice.pass3
 
+dice.passes: dice.pass1 dice.pass2 dice.pass3
+	MERCURY_OPTIONS= \
+	$(SLICE_DIR)mtc_union -o dice.passes dice.pass1 dice.pass2 dice.pass3
+
 dice.fail: dice
 	/bin/rm -f .mercury_trace_counts.*dice.*
 	MERCURY_OPTIONS=--trace-count ./dice 4 1 2 3 && \
 	mv .mercury_trace_counts.*dice.* dice.fail
 
-dice.out: dice dice.inp dice.pass1 dice.pass2 dice.pass3 dice.fail
+dice.out: dice dice.inp dice.passes dice.fail
 	$(MDB_STD) ./dice 4 1 2 3 < dice.inp > dice.out 2>&1
 
 # We need to pipe the output through sed to avoid hard-coding dependencies on
Index: tests/debugger/dice.passes
===================================================================
RCS file: tests/debugger/dice.passes
diff -N tests/debugger/dice.passes
--- tests/debugger/dice.passes	10 Feb 2005 04:10:32 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,3 +0,0 @@
-dice.pass1
-dice.pass2
-dice.pass3
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/par_conj
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/trailing
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
Index: tools/bootcheck
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/tools/bootcheck,v
retrieving revision 1.185
diff -u -b -r1.185 bootcheck
--- tools/bootcheck	22 Sep 2006 03:50:48 -0000	1.185
+++ tools/bootcheck	24 Sep 2006 03:45:47 -0000
@@ -543,7 +543,7 @@
 
 if $trace_count
 then
-    MERCURY_OPTIONS="$MERCURY_OPTIONS --trace-count"
+    MERCURY_OPTIONS="$MERCURY_OPTIONS --trace-count-if-exec=mercury_compile"
     export MERCURY_OPTIONS
 else
     true
@@ -1566,15 +1566,20 @@
 
         case $failing_tests_only in
             true)
-                test_log_opt="FAILING_TESTS_ONLY"
+                test_log_opt="FAILED_TESTS_ONLY=yes"
                 ;;
         esac
 
         cd $root/${tests_prefix}tests
-        /bin/rm -fr PASSED_TC_DIR PASSED_TC_FILES > /dev/null 2>&1
-        /bin/rm -fr FAILED_TC_DIR FAILED_TC_FILES > /dev/null 2>&1
         > FAILED_TESTS_SUMMARY
 
+        /bin/rm -fr PASSED_TC_DIR FAILED_TC_DIR > /dev/null 2>&1
+        mkdir -p PASSED_TC_DIR FAILED_TC_DIR
+        echo 0 > PASSED_TC_DIR/NEXT_NUMBER
+        echo 0 > FAILED_TC_DIR/NEXT_NUMBER
+        SLICE_DIR="$root/slice/"
+        export SLICE_DIR
+
         if test "$specified_tests_only" != ""
         then
             test_status=0
@@ -1621,6 +1626,16 @@
             mv "$type_stats" "$type_stats".test.$$
         fi
 
+        for tcdir in PASSED_TC_DIR FAILED_TC_DIR
+        do
+            if test "`cat $tcdir/NEXT_NUMBER`" -gt 0
+            then
+                ${SLICE_DIR}slice/mtc_union -o $tcdir/SUMMARY \
+                    $tcdir/trace_counts.*
+                /bin/rm $tcdir/trace_counts.*
+            fi
+        done
+
         cd $root
     fi
 fi
cvs diff: Diffing trace
Index: trace/mercury_trace_declarative.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_declarative.c,v
retrieving revision 1.102
diff -u -b -r1.102 mercury_trace_declarative.c
--- trace/mercury_trace_declarative.c	29 Sep 2006 06:34:57 -0000	1.102
+++ trace/mercury_trace_declarative.c	1 Oct 2006 05:00:16 -0000
@@ -2256,12 +2256,11 @@
     );
 
     MR_TRACE_CALL_MERCURY(
-        MR_MDB_read_dice_try_single_first(
+        MR_MDB_read_dice(
             aligned_pass_trace_counts_file,
             aligned_fail_trace_counts_file,
             &maybe_dice);
-        MR_DD_maybe_dice_error_to_problem_string(maybe_dice, 
-            problem);
+        MR_DD_maybe_dice_error_to_problem_string(maybe_dice, problem);
     );
     if (! MR_streq(*problem, "")) {
         return MR_FALSE;
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
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