diff: bug fix for recompute_instmap_delta on switches

Fergus Henderson fjh at murlibobo.cs.mu.OZ.AU
Mon Jun 16 17:19:24 AEST 1997


compiler/instmap.m:
	Add a few comments to instmap_delta_binda_vars and
	use more meaningful variable names.

compiler/mode_util.m:
	Avoid some unnecessary code duplication.

Index: instmap.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/instmap.m,v
retrieving revision 1.9
diff -u -r1.9 instmap.m
--- instmap.m	1997/06/16 07:16:26	1.9
+++ instmap.m	1997/06/13 10:54:00
@@ -387,17 +387,31 @@
 		ModuleInfo = ModuleInfo0
 	;
 		InstmapDelta0 = reachable(InstmappingDelta0),
+
+		%
+		% Get the initial inst from the InstMap
+		%
 		instmap__lookup_var(InstMap, Var, OldInst),
-		( map__search(InstmappingDelta0, Var, Inst0) ->
-			Inst1 = Inst0
+
+		%
+		% Compute the new inst by taking the old inst,
+		% applying the instmap delta to it,
+		% and then unifying with bound(ConsId, ...)
+		%
+		( map__search(InstmappingDelta0, Var, NewInst0) ->
+			NewInst1 = NewInst0
 		;
-			Inst1 = OldInst
+			NewInst1 = OldInst
 		),
-		bind_inst_to_functor(Inst1, ConsId, Inst,
+		bind_inst_to_functor(NewInst1, ConsId, NewInst,
 			ModuleInfo0, ModuleInfo),
-		( Inst \= OldInst ->
-			instmap_delta_set(InstmapDelta0, Var,
-				Inst, InstmapDelta)
+
+		%
+		% add `Var :: OldInst -> NewInst' to the instmap delta
+		%
+		( NewInst \= OldInst ->
+			instmap_delta_set(InstmapDelta0, Var, NewInst,
+				InstmapDelta)
 		;
 			InstmapDelta = InstmapDelta0
 		)
Index: mode_util.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/mode_util.m,v
retrieving revision 1.91
diff -u -r1.91 mode_util.m
--- mode_util.m	1997/06/16 07:16:30	1.91
+++ mode_util.m	1997/06/16 06:28:29
@@ -1728,22 +1728,11 @@
 
 recompute_instmap_delta_cases(_, _, [], [], _, _, InstMapDelta) -->
 	{ instmap_delta_init_unreachable(InstMapDelta) }.
-recompute_instmap_delta_cases(Atomic, Var, [Case0], [Case],
-		InstMap0, _NonLocals, InstMapDelta) -->
-	{ Case0 = case(Functor, Goal0) },
-	instmap__bind_var_to_functor(Var, Functor, InstMap0, InstMap),
-	recompute_instmap_delta(Atomic, Goal0, Goal,
-		InstMap, InstMapDelta0),
-	instmap_delta_bind_var_to_functor(Var, Functor,
-		InstMap0, InstMapDelta0, InstMapDelta),
-	{ Case = case(Functor, Goal) }.
 recompute_instmap_delta_cases(Atomic, Var, [Case0 | Cases0], [Case | Cases],
 		InstMap0, NonLocals, InstMapDelta) -->
-	{ Cases0 = [_|_] },
 	{ Case0 = case(Functor, Goal0) },
 	instmap__bind_var_to_functor(Var, Functor, InstMap0, InstMap),
-	recompute_instmap_delta(Atomic, Goal0, Goal,
-		InstMap, InstMapDelta0),
+	recompute_instmap_delta(Atomic, Goal0, Goal, InstMap, InstMapDelta0),
 	instmap_delta_bind_var_to_functor(Var, Functor,
 		InstMap0, InstMapDelta0, InstMapDelta1),
 	{ Case = case(Functor, Goal) },



More information about the developers mailing list