[m-rev.] diff: use promise_equivalent_solutions in compiler

Julien Fischer juliensf at cs.mu.OZ.AU
Mon Sep 26 14:32:38 AEST 2005


Estimated hours taken: 0.5
Branches: main

compiler/assertion.m:
compiler/magic.m:
compiler/mercury_compile.m:
compiler/ml_code_gen.m:
compiler/modes.m:
compiler/modules.m:
compiler/options_file.m:
compiler/recompilation.check.m:
compiler/recompiltaion.usage.m:
	Use promise_equivalent_solutions scopes in place of
	promise_only_solution and promise_only_solution_io in the compiler.


Julien.

Index: compiler/assertion.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/assertion.m,v
retrieving revision 1.38
diff -u -r1.38 assertion.m
--- compiler/assertion.m	14 Sep 2005 05:26:36 -0000	1.38
+++ compiler/assertion.m	22 Sep 2005 13:50:20 -0000
@@ -217,10 +217,10 @@
         P = conj(PCalls) - _PGoalInfo,
         Q = conj(QCalls) - _QGoalInfo
     ),
-
-    AssociativeVars - OutputVar =
-        promise_only_solution(associative(PCalls, QCalls,
-            UniversiallyQuantifiedVars, CallVars)).
+    promise_equivalent_solutions [AssociativeVars, OutputVar] (
+         associative(PCalls, QCalls, UniversiallyQuantifiedVars, CallVars,
+            AssociativeVars - OutputVar)
+    ).

     % associative(Ps, Qs, Us, R):
     %
Index: compiler/magic.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/magic.m,v
retrieving revision 1.55
diff -u -r1.55 magic.m
--- compiler/magic.m	30 Aug 2005 04:11:53 -0000	1.55
+++ compiler/magic.m	26 Sep 2005 03:29:14 -0000
@@ -458,12 +458,9 @@
 			UsedPreds = UsedPreds0
 		)
 	    ),
-
-	Preds = promise_only_solution(
-		(pred(Preds1::out) is cc_multi :-
-			unsorted_aggregate(Generator, Accumulator,
-				Preds0, Preds1)
-		)).
+	promise_equivalent_solutions [Preds] (
+		unsorted_aggregate(Generator, Accumulator, Preds0, Preds)
+	).

 	% Convert imported Aditi procedures for the magic sets interface.
 :- pred magic__process_imported_procs(list(pred_id)::in, set(pred_id)::in,
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.348
diff -u -r1.348 mercury_compile.m
--- compiler/mercury_compile.m	22 Sep 2005 06:13:27 -0000	1.348
+++ compiler/mercury_compile.m	26 Sep 2005 04:07:24 -0000
@@ -2789,8 +2789,9 @@
         BenchmarkModes = yes,
         globals__io_lookup_int_option(benchmark_modes_repeat, Repeats, !IO),
         io__format("%s %d ", [s(Stage), i(Repeats)], !IO),
-        promise_only_solution_io(do_io_benchmark(Pred, Repeats, A0), A - Time,
-            !IO),
+        promise_equivalent_solutions [A, Time, !:IO] (
+            do_io_benchmark(Pred, Repeats, A0, A - Time, !IO)
+        ),
         io__format("%d ms\n", [i(Time)], !IO)
     ;
         BenchmarkModes = no,
Index: compiler/ml_code_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_code_gen.m,v
retrieving revision 1.156
diff -u -r1.156 ml_code_gen.m
--- compiler/ml_code_gen.m	13 Sep 2005 01:19:55 -0000	1.156
+++ compiler/ml_code_gen.m	26 Sep 2005 03:46:56 -0000
@@ -1502,12 +1502,12 @@

 :- func union_of_direct_subgoal_locals(hlds_goal) = set(prog_var).

-union_of_direct_subgoal_locals(Goal - _GoalInfo) =
-    promise_only_solution((pred(UnionOfSubGoalLocals::out) is cc_multi :-
+union_of_direct_subgoal_locals(Goal - _GoalInfo) = UnionOfSubGoalLocals :-
+    promise_equivalent_solutions [UnionOfSubGoalLocals] (
         set__init(EmptySet),
         unsorted_aggregate(direct_subgoal(Goal),
             union_subgoal_locals, EmptySet, UnionOfSubGoalLocals)
-    )).
+    ).

 :- pred union_subgoal_locals(hlds_goal::in, set(prog_var)::in,
     set(prog_var)::out) is det.
Index: compiler/modes.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modes.m,v
retrieving revision 1.311
diff -u -r1.311 modes.m
--- compiler/modes.m	14 Sep 2005 05:26:38 -0000	1.311
+++ compiler/modes.m	22 Sep 2005 13:48:29 -0000
@@ -2207,8 +2207,10 @@
                 % Find the set of vars whose instantiation should lead to
                 % a deterministic schedule.
                 %
-            CandidateInitVars = promise_only_solution(
-                candidate_init_vars(!.ModeInfo, Goals0, NonFreeVars0)),
+            promise_equivalent_solutions [CandidateInitVars] (
+                candidate_init_vars(!.ModeInfo, Goals0, NonFreeVars0,
+                    CandidateInitVars)
+            ),

                 % And verify that all of these vars are
                 % solver type vars (and can therefore be
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.343
diff -u -r1.343 modules.m
--- compiler/modules.m	15 Sep 2005 07:38:44 -0000	1.343
+++ compiler/modules.m	26 Sep 2005 03:36:19 -0000
@@ -1461,7 +1461,9 @@
     % strip_unnecessary_impl_defns_2 is cc_multi because of the call
     % to std_util.unsorted_aggregate. The order in which items are deleted
     % from a multi_map does not matter.
-    Items = promise_only_solution(strip_unnecessary_impl_defns_2(Items0)).
+    promise_equivalent_solutions [Items] (
+        strip_unnecessary_impl_defns_2(Items0, Items)
+    ).

 :- pred strip_unnecessary_impl_defns_2(item_list::in, item_list::out)
     is cc_multi.
Index: compiler/options_file.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options_file.m,v
retrieving revision 1.28
diff -u -r1.28 options_file.m
--- compiler/options_file.m	16 Sep 2005 17:27:07 -0000	1.28
+++ compiler/options_file.m	26 Sep 2005 04:09:13 -0000
@@ -142,67 +142,59 @@
     ).


-read_options_file(OptionsFile, Variables0, MaybeVariables) -->
-    promise_only_solution_io(
-        (pred(R::out, di, uo) is cc_multi -->
-        try_io(
-                (pred((Variables1)::out, di, uo) is det -->
-            read_options_file(error, no_search, no, OptionsFile,
-                Variables0, Variables1)
-            ), R)
-        ), OptionsFileResult),
+read_options_file(OptionsFile, Variables0, MaybeVariables, !IO) :-
+    promise_equivalent_solutions [OptionsFileResult, !:IO] (
+        try_io((pred((Variables1)::out, !.IO::di, !:IO::uo) is det :-
+                    read_options_file(error, no_search, no, OptionsFile,
+                    Variables0, Variables1, !IO)
+            ),
+            OptionsFileResult, !IO)
+    ),
     (
-        { OptionsFileResult = succeeded(Variables) },
-        { MaybeVariables = yes(Variables) }
+        OptionsFileResult = succeeded(Variables),
+        MaybeVariables = yes(Variables)
     ;
-        { OptionsFileResult = exception(Exception) },
-        { Exception = univ(found_options_file_error) ->
+        OptionsFileResult = exception(Exception),
+        ( Exception = univ(found_options_file_error) ->
             MaybeVariables = no
         ;
             rethrow(OptionsFileResult)
-        }
-    ;
-        { OptionsFileResult = failed },
-        { error("read_options_files") }
+        )
     ).

-read_options_files(Variables0, MaybeVariables) -->
-    promise_only_solution_io(
-        (pred(R::out, di, uo) is cc_multi -->
+read_options_files(Variables0, MaybeVariables, !IO) :-
+    promise_equivalent_solutions [OptionsFileResult, !:IO] (
         try_io(
-                (pred((Variables1)::out, di, uo) is det -->
-            globals__io_lookup_accumulating_option(options_files,
-                OptionsFiles),
-            { ReadFile =
+                (pred((Variables1)::out, !.IO::di, !:IO::uo) is det :-
+            globals.io_lookup_accumulating_option(options_files,
+                OptionsFiles, !IO),
+            ReadFile =
                 (pred(OptionsFile::in, Vars0::in, Vars::out,
-                    di, uo) is det -->
-                { OptionsFile = "Mercury.options" ->
+                   !.IO::di, !:IO::uo) is det :-
+                ( OptionsFile = "Mercury.options" ->
                     ErrorIfNotExist = no_error,
                     Search = no_search
                 ;
                     ErrorIfNotExist = error,
                     Search = search
-                },
+                ),
                 read_options_file(ErrorIfNotExist, Search, no,
-                    OptionsFile, Vars0, Vars)
-                ) },
-            list__foldl2(ReadFile, OptionsFiles,
-                Variables0, Variables1)
-            ), R)
-        ), OptionsFileResult),
+                    OptionsFile, Vars0, Vars, !IO)
+                ),
+                list.foldl2(ReadFile, OptionsFiles, Variables0, Variables1,
+                    !IO)
+            ), OptionsFileResult, !IO)
+    ),
     (
-        { OptionsFileResult = succeeded(Variables) },
-        { MaybeVariables = yes(Variables) }
+        OptionsFileResult = succeeded(Variables),
+        MaybeVariables = yes(Variables)
     ;
-        { OptionsFileResult = exception(Exception) },
-        { Exception = univ(found_options_file_error) ->
+        OptionsFileResult = exception(Exception),
+        ( Exception = univ(found_options_file_error) ->
             MaybeVariables = no
         ;
             rethrow(OptionsFileResult)
-        }
-    ;
-        { OptionsFileResult = failed },
-        { error("read_options_files") }
+        )
     ).

 :- type error_if_not_exist
@@ -313,8 +305,9 @@

 read_options_lines(Dir, !Variables, !IO) :-
     io__get_line_number(LineNumber, !IO),
-    promise_only_solution_io(read_options_lines_2(Dir, !.Variables),
-        LineResult, !IO),
+    promise_equivalent_solutions [LineResult, !:IO] (
+        read_options_lines_2(Dir, !.Variables, LineResult, !IO)
+    ),
     (
         LineResult = succeeded(!:Variables - FoundEOF),
         (
@@ -742,21 +735,16 @@
 :- func checked_split_into_words(list(char)) = maybe_error(list(string)).

 checked_split_into_words(Chars) = Result :-
-    TryResult =
-        promise_only_solution(
-        (pred(TResult::out) is cc_multi :-
-            try(
+    promise_equivalent_solutions [TryResult] (
+        try(
             (pred(Words0::out) is det :-
                 Words0 = split_into_words(Chars)
-            ), TResult)
-        )),
+            ), TryResult)
+    ),
     (
         TryResult = succeeded(Words),
         Result = ok(Words)
     ;
-        TryResult = failed,
-        error("split_into_words failed")
-    ;
         TryResult = exception(Exception),
         ( Exception = univ(options_file_error(Msg)) ->
             Result = error(Msg)
@@ -1147,5 +1135,11 @@
     ).

 %-----------------------------------------------------------------------------%
+
+:- func this_file = string.
+
+this_file = "options_file.m.".
+
+%-----------------------------------------------------------------------------%
 :- end_module options_file.
 %-----------------------------------------------------------------------------%
Index: compiler/recompilation.check.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/recompilation.check.m,v
retrieving revision 1.18
diff -u -r1.18 recompilation.check.m
--- compiler/recompilation.check.m	12 Sep 2005 03:05:47 -0000	1.18
+++ compiler/recompilation.check.m	26 Sep 2005 04:10:25 -0000
@@ -108,10 +108,10 @@
 		MaybeVersionStream = ok(VersionStream0),
 		io__set_input_stream(VersionStream0, OldInputStream, !IO),

-		promise_only_solution_io(
+		promise_equivalent_solutions [Result, !:IO] (
 			should_recompile_3_try(IsSubModule,
-				FindTimestampFiles, !.Info),
-			Result, !IO),
+				FindTimestampFiles, !.Info, Result, !IO)
+		),
 		(
 			Result = succeeded(!:Info),
 			Reasons = !.Info ^ recompilation_reasons
Index: compiler/recompilation.usage.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/recompilation.usage.m,v
retrieving revision 1.19
diff -u -r1.19 recompilation.usage.m
--- compiler/recompilation.usage.m	20 Apr 2005 12:57:16 -0000	1.19
+++ compiler/recompilation.usage.m	26 Sep 2005 04:12:11 -0000
@@ -552,13 +552,12 @@
 	% causing ambiguity when the interface of the module changes.
 	%
 	map__init(ImportedItems0),
-	ImportedItems2 = promise_only_solution(
-		(pred(ImportedItems1::out) is cc_multi :-
-			std_util__unsorted_aggregate(
-				visible_modules(ModuleInfo),
-				insert_into_imported_items_map,
-				ImportedItems0, ImportedItems1)
-		)),
+	promise_equivalent_solutions [ImportedItems1] (
+		std_util__unsorted_aggregate(
+			visible_modules(ModuleInfo),
+			insert_into_imported_items_map,
+			ImportedItems0, ImportedItems1)
+	),

 	queue__init(ItemsToProcess0),
 	map__init(ModuleUsedClasses),
@@ -573,7 +572,7 @@
 		Classes, ResolvedCtors, ResolvedPreds, ResolvedFuncs),

 	Info0 = recompilation_usage_info(ModuleInfo, ItemsToProcess0,
-		ImportedItems2, ModuleUsedClasses, Dependencies,
+		ImportedItems1, ModuleUsedClasses, Dependencies,
 		ResolvedUsedItems0, UsedClasses0),

 	recompilation__usage__find_all_used_imported_items_2(UsedItems,

--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list