[m-dev.] [reuse] diff: lifo v2

Peter Ross petdr at miscrit.be
Fri Oct 13 07:36:41 AEDT 2000


Hi,


===================================================================


Estimated hours taken: 1

sr_choice.m:
    Fix the lifo implementation.

Index: sr_choice.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/sr_choice.m,v
retrieving revision 1.1.2.9
diff -u -r1.1.2.9 sr_choice.m
--- sr_choice.m	2000/10/12 14:27:08	1.1.2.9
+++ sr_choice.m	2000/10/12 20:33:54
@@ -270,7 +270,7 @@
 	--->	lifo(
 			all_locals	:: list(list(prog_var)),
 			local		:: list(prog_var),
-			global		:: list(prog_var)
+			global		:: list(list(prog_var))
 		).
 
 :- func selection_info_init = selection_info.
@@ -413,8 +413,8 @@
 	Global = Local0 `set__union` Global0,
 	Conds = Conds0,
 
-	Lifo0 = lifo(AllLocals0, Locals0, Globals0),
-	Lifo  = lifo(AllLocals0, [], Locals0 ++ Globals0).
+	Lifo0 = lifo(AllLocals, Locals, Globals),
+	Lifo  = lifo(AllLocals, [], [Locals | Globals]).
 
 	%
 	% At the end of processing all branches of a
@@ -429,7 +429,14 @@
 	Conds = Conds0,
 
 	Lifo0 = lifo(AllLocals0, Locals0, Globals0),
-	Lifo  = lifo([], [], list_merge([Locals0 | AllLocals0]) ++ Globals0).
+	( Globals0 = [G | Gs] ->
+		Locals = list_merge([Locals0 | AllLocals0]) ++ G,
+		Globals = Gs
+	;
+		Locals = list_merge([Locals0 | AllLocals0]),
+		Globals = []
+	),
+	Lifo  = lifo([], Locals, Globals).
 
 	% [ [1a,2a], [2b,1b], [2c,3c,1c] ] -> [1a, 2b, 2c, 2a, 1b, 3c, 1c]
 :- func list_merge(list(list(T))) = list(T).
@@ -483,7 +490,8 @@
 				\+ set__member(Var, LocalReused0),
 				\+ set__member(Var, GlobalReused)
 			)},
-		{ list__filter_map(F, Locals ++ Globals, Candidates) }
+		{ list__filter_map(F,
+				Locals ++ list__condense(Globals), Candidates) }
 	;
 		{ Selection = random },
 		{ P = (pred(Choice::out) is nondet :- 

--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list