[m-rev.] [reuse] trivial diff: add maybe-access-procedures for reuse info

Nancy Mazur Nancy.Mazur at cs.kuleuven.ac.be
Thu Jun 24 12:34:56 AEST 2004


Hi,


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


Estimated hours taken: 0.5
Branches: reuse

hlds_goal.m:
hlds_out.m:
	Bugfix: Add maybe-procedures that fail instead of abort to access 
	reuse-information stored in the hlds_goal_info. 


Index: hlds_goal.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_goal.m,v
retrieving revision 1.76.2.17
diff -u -r1.76.2.17 hlds_goal.m
--- hlds_goal.m	19 Jun 2004 07:35:46 -0000	1.76.2.17
+++ hlds_goal.m	24 Jun 2004 02:10:08 -0000
@@ -769,6 +769,15 @@
 
 :- type maybe_cut	--->	cut ; no_cut.
 
+:- pred goal_info_maybe_get_lfu(hlds_goal_info::in, 
+		set(prog_var)::out) is semidet.
+:- pred goal_info_maybe_get_lbu(hlds_goal_info::in, 
+		set(prog_var)::out) is semidet.
+:- pred goal_info_maybe_get_outscope(hlds_goal_info::in, 
+		set(prog_var)::out) is semidet.
+:- pred goal_info_maybe_get_reuse(hlds_goal_info::in, 
+		reuse_goal_info::out) is semidet.
+
 :- pred goal_info_get_lfu(hlds_goal_info::in, set(prog_var)::out) is det.
 :- pred goal_info_get_lbu(hlds_goal_info::in, set(prog_var)::out) is det.
 :- pred goal_info_get_outscope(hlds_goal_info::in, set(prog_var)::out) is det.
@@ -1342,6 +1351,26 @@
 		GoalInfo0 ^ code_gen_info := CodeGenInfo).
 
 %-----------------------------------------------------------------------------%
+goal_info_maybe_get_lfu(GoalInfo, LFU) :-
+	MaybeSub = GoalInfo ^ goal_reuse_info,
+	MaybeSub = yes(Sub),
+	LFU = Sub ^ lfu.
+
+goal_info_maybe_get_outscope(GoalInfo, Outscope) :- 
+	MaybeSub = GoalInfo ^ goal_reuse_info,
+	MaybeSub = yes(Sub),
+	Outscope = Sub ^ outscope.
+
+goal_info_maybe_get_lbu(GoalInfo, LBU) :-
+	MaybeSub = GoalInfo ^ goal_reuse_info,
+	MaybeSub = yes(Sub),
+	LBU = Sub ^ lbu.
+
+goal_info_maybe_get_reuse(GoalInfo, Reuse) :- 
+	MaybeSub = GoalInfo ^ goal_reuse_info,
+	MaybeSub = yes(Sub),
+	Reuse = Sub ^ reuse.
+
 goal_info_get_lfu(GoalInfo, LFU) :-
 	MaybeSub = GoalInfo ^ goal_reuse_info,
 	(
Index: hlds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_out.m,v
retrieving revision 1.243.2.27
diff -u -r1.243.2.27 hlds_out.m
--- hlds_out.m	2 Jun 2004 10:30:36 -0000	1.243.2.27
+++ hlds_out.m	24 Jun 2004 02:10:20 -0000
@@ -1292,109 +1292,112 @@
 		[]
 	),
 	( { string__contains_char(Verbose, 'p') } ->
-		{ goal_info_get_lfu(GoalInfo, LFU) },
-		{ set__to_sorted_list(LFU, LFU_list) },
+		(
+			{ goal_info_maybe_get_lfu(GoalInfo, LFU) },
+			{ goal_info_maybe_get_reuse(GoalInfo, REUSE) } ,
+			{ goal_info_get_lbu(GoalInfo, Lbu) }
+
+		-> 
+			{ set__to_sorted_list(LFU, LFU_list) },
 			hlds_out__write_indent(Indent),
 			io__write_string("% lfu: "),
 			mercury_output_vars(LFU_list, VarSet, 
 				AppendVarnums),
 			io__write_string("\n"),
 
-		{ goal_info_get_reuse(GoalInfo, REUSE) } ,
-	        (
-			{ 
-			  % REUSE = potential_reuse(no_reuse); 
-			  % REUSE = reuse(no_reuse) ; 
-			  REUSE = empty 
-			}
-		->
-			[]
-		; 
-			{ REUSE = potential_reuse(SR) ; REUSE = reuse(SR) }
-		-> 
-			hlds_out__write_indent(Indent), 
-			io__write_string("% reuse"),
-			( 
-				{ REUSE = potential_reuse(_) }
-			-> 
-				io__write_string(" (potential)")
-			;	
+	        	( 
+				{ REUSE = empty } 
+			->
 				[]
-			),
-			io__write_string(": "),
-			(
-				{ SR = no_reuse },
-				io__write_string("nothing.\n")
-			;
-				{ SR = cell_died },
-				io__write_string("cell just died (deconstruction).\n") 
-			;
-				{ SR = cell_reused(ProgVar,
-						IntroducesCondition,
+			; 
+				( { REUSE = potential_reuse(SR)} 
+				; { REUSE = reuse(SR) } )
+			-> 
+				hlds_out__write_indent(Indent), 
+				io__write_string("% reuse"),
+				( 
+					{ REUSE = potential_reuse(_) }
+				-> 
+					io__write_string(" (potential)")
+				;	
+					[]
+				),
+				io__write_string(": "),
+				(
+					{ SR = no_reuse },
+					io__write_string("nothing.\n")
+				;
+					{ SR = cell_died },
+					io__write_string("cell just died (deconstruction).\n") 
+				;
+					{ SR = cell_reused(ProgVar,
+						WithCond,
 						ConsIds, _ReuseFields) },
-				io__write_string("cell "),
-				mercury_output_var(ProgVar, VarSet, 
+					io__write_string("cell "),
+					mercury_output_var(ProgVar, VarSet, 
 					AppendVarnums),
-				io__write_string(" with possible cons_ids: ["),
-				io__write_list(ConsIds, ", ",
+					io__write_string(" with possible cons_ids: ["),
+					io__write_list(ConsIds, ", ",
 						hlds_out__write_cons_id),
-				io__write_string(
+					io__write_string(
 					"] just reused in a construction "),
-				( { IntroducesCondition = yes } ->
+					( { WithCond = yes } ->
 					io__write_string("conditionally.")
-				;
+					;
 					io__write_string("*unconditionally*.")
-				),
-				io__nl
-			;
-				{ SR = reuse_call(IntroducesCondition) },
-				( { IntroducesCondition = yes } ->
-					io__write_string("Conditional ")
+					),
+					io__nl
 				;
+					{ SR = reuse_call(WithCond) },
+					( { WithCond = yes } ->
+					io__write_string("Conditional ")
+					;
 					io__write_string("*Unconditional* ")
-				),
-				io__write_string("call to procedure with reuse.\n")
+					),
+					io__write_string("call to procedure with reuse.\n")
+				;
+					{ SR = missed_reuse_call(Causes) } ,
+					io__write_string("failed reuse call:\n"),
+					write_missed_reuse_call_text(Indent,Causes)
+				)
 			;
-				{ SR = missed_reuse_call(Causes) } ,
-				io__write_string("failed reuse call:\n"),
-				write_missed_reuse_call_text(Indent,Causes)
-			)
-		;
-			[]
-		),
+				[]
+			),
 
-		{ goal_info_get_lbu(GoalInfo, Lbu) },
-		{ set__to_sorted_list(Lbu, LbuList) },
-		hlds_out__write_indent(Indent),
-		io__write_string("% lbu: "),
-		mercury_output_vars(LbuList, VarSet, AppendVarnums),
-		io__write_string("\n"),
-		(
-			{ goal_info_maybe_get_post_deaths(GoalInfo,
-				PostDeaths) },
-			{ set__to_sorted_list(PostDeaths, PostDeathList) },
-			{ PostDeathList \= [] }
-		->
-			hlds_out__write_indent(Indent),
-			io__write_string("% post-deaths: "),
-			mercury_output_vars(PostDeathList, VarSet,
-				AppendVarnums),
-			io__write_string("\n")
-		;
-			[]
-		),
-		(
-			{ goal_info_maybe_get_post_births(GoalInfo,
-				PostBirths) },
-			{ set__to_sorted_list(PostBirths, PostBirthList) },
-			{ PostBirthList \= [] }
-		->
+			{ set__to_sorted_list(Lbu, LbuList) },
 			hlds_out__write_indent(Indent),
-			io__write_string("% post-births: "),
-			mercury_output_vars(PostBirthList, VarSet,
-				AppendVarnums),
-			io__write_string("\n")
-		;
+			io__write_string("% lbu: "),
+			mercury_output_vars(LbuList, VarSet, AppendVarnums),
+			io__write_string("\n"),
+			(
+				{ goal_info_maybe_get_post_deaths(GoalInfo,
+					PostDeaths) },
+				{ set__to_sorted_list(PostDeaths, PostDeathList) },
+				{ PostDeathList \= [] }
+			->
+				hlds_out__write_indent(Indent),
+				io__write_string("% post-deaths: "),
+				mercury_output_vars(PostDeathList, VarSet,
+					AppendVarnums),
+				io__write_string("\n")
+			;
+				[]
+			),
+			(
+				{ goal_info_maybe_get_post_births(GoalInfo,
+					PostBirths) },
+				{ set__to_sorted_list(PostBirths, PostBirthList) },
+				{ PostBirthList \= [] }
+			->
+				hlds_out__write_indent(Indent),
+				io__write_string("% post-births: "),
+				mercury_output_vars(PostBirthList, VarSet,
+					AppendVarnums),
+				io__write_string("\n")
+			;
+				[]
+			)
+		; 
 			[]
 		)
 	;

-- 
nancy.mazur at cs.kuleuven.ac.be ------------ Katholieke Universiteit Leuven -
tel: +32-16-327596 - fax: +32-16-327996 ------- Dept. of Computer Science -
--------------------------------------------------------------------------
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