[m-rev.] [reuse] diff: move remaining printing routines for aliases.

Nancy Mazur Nancy.Mazur at cs.kuleuven.ac.be
Sun Jun 27 20:05:56 AEST 2004


Hi,


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


Estimated hours taken: 4
Branches: reuse

Move and rewrite all the printing routines for "aliases", "aliases_domain" and
"maybe(aliases_domain)" to prog_io_pasr. 

hlds_out.m:
pa_alias_as.m:
pa_alias_set.m:
pa_run.m:
prog_io_pasr.m:
sr_data.m:
	Move/rewrite printing routines.


Index: hlds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_out.m,v
retrieving revision 1.243.2.28
diff -u -r1.243.2.28 hlds_out.m
--- hlds_out.m	24 Jun 2004 02:19:34 -0000	1.243.2.28
+++ hlds_out.m	27 Jun 2004 10:00:56 -0000
@@ -259,6 +259,7 @@
 % Parse tree modules.
 :- import_module parse_tree__prog_out, parse_tree__prog_util.
 :- import_module parse_tree__inst, parse_tree__mercury_to_mercury.
+:- import_module parse_tree__prog_io_pasr.
 
 % HLDS modules.
 :- import_module hlds__special_pred, hlds__instmap, hlds__hlds_llds.
@@ -282,8 +283,6 @@
 :- import_module int, string, set, assoc_list, map, multi_map.
 :- import_module require, getopt, std_util, term_io, varset.
 
-:- import_module possible_alias.
-:- import_module possible_alias__pa_alias_as.
 :- import_module structure_reuse.
 :- import_module structure_reuse__sr_data.
 
@@ -3420,9 +3419,8 @@
 	->
 		hlds_out__write_indent(Indent),
 		io__write_string("% Possible aliases: "),
-		pa_alias_as__print_maybe_possible_aliases(MaybeAliases,
-					Proc, PredInfo),
-		io__nl
+		dump_maybe_aliases_domain(VarSet, TVarSet, 
+				MaybeAliases)
 	;
 		[]
 	),
Index: pa_alias_as.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/pa_alias_as.m,v
retrieving revision 1.1.2.39
diff -u -r1.1.2.39 pa_alias_as.m
--- pa_alias_as.m	25 Jun 2004 07:11:35 -0000	1.1.2.39
+++ pa_alias_as.m	27 Jun 2004 10:00:58 -0000
@@ -218,37 +218,6 @@
 		alias_as::in, alias_as::out) is det.
 
 %-----------------------------------------------------------------------------%
-% Printing routines. 
-%-----------------------------------------------------------------------------%
-	% Dump the alias information (used in hlds_dumps). 
-	% Each alias will be preceded by the string "% ". 
-:- pred print_maybe_possible_aliases(maybe(aliases_domain)::in, proc_info::in, 
-		pred_info::in, io__state::di, io__state::uo) is det.
-
-	% Dump the alias information printing a given string between each alias
-	% expressed by the abstract description. 
-:- pred print_maybe_possible_aliases(string::in, maybe(aliases_domain)::in, 
-		proc_info::in, pred_info::in, 
-		io__state::di, io__state::uo) is det.
-
-	% Print alias information suitable for using in the trans_opt interface
-	% files, and therefore mmc-readable. 
-:- pred print_maybe_interface_aliases(maybe(aliases_domain)::in, 
-		proc_info::in, pred_info::in, 
-		io__state::di, io__state::uo) is det.
-
-	% Print mmc-readable aliases. Mainly used for printing intermediate
-	% aliasing descriptions during the analysis process, with Verbosity
-	% switched on. 
-:- pred print_aliases(aliases_domain, proc_info, pred_info, 
-		io__state, io__state).
-:- mode print_aliases(in, in, in, di, uo) is det.
-
-:- pred print_brief_aliases(int::in, aliases_domain::in, proc_info::in,
-		pred_info::in, io__state::di, io__state::uo) is det.
-
-%-----------------------------------------------------------------------------%
 % Parsing routines. 
 %-----------------------------------------------------------------------------%
@@ -934,99 +903,6 @@
 		ASout = ASin
 	).
 		
-%-----------------------------------------------------------------------------%
-% printing routines
-%-----------------------------------------------------------------------------%
-
-	% MaybeAs = yes(Alias_as) -> print out Alias_as
-	%         = no		   -> print "not available"
-print_maybe_possible_aliases(MaybeAS, ProcInfo, PredInfo) -->
-	print_maybe_possible_aliases("% ", MaybeAS, ProcInfo, PredInfo). 
-
-print_maybe_possible_aliases(RepeatingStart, MaybeAS, ProcInfo, PredInfo) -->
-	(
-		{ MaybeAS = yes(AS) }
-	->
-		print_possible_aliases(RepeatingStart, AS, ProcInfo, PredInfo)
-	;
-		io__write_string("% not available.")
-	).
-
-	% print_possible_aliases(Abstract Substitution, Proc Info).
-	% print alias abstract substitution
-:- pred print_possible_aliases(string::in, aliases_domain::in, proc_info::in, 
-		pred_info::in, io__state::di, io__state::uo) is det.
-print_possible_aliases(RepeatingStart, AS, ProcInfo, PredInfo) -->
-	(
-		{ AS = real(Aliases) }
-	->
-		io__nl, 
-		print(PredInfo, ProcInfo, Aliases, 
-				RepeatingStart, ",\n", "")
-	;
-		{ AS = top(Msgs) }
-	->
-		{ list__map(
-			pred(S0::in, S::out) is det :- 
-				(string__append_list(["%\t",S0,"\n"], S)),
-			Msgs, 
-			MsgsF) }, 
-		{ string__append_list([RepeatingStart, "aliases are top:\n" |MsgsF],Msg) },
-		io__write_string(Msg)
-	;
-		{ string__append_list([RepeatingStart, "aliases = bottom"],
-			Msg) }, 
-		io__write_string(Msg)
-	).
-
-
-
-	% MaybeAs = yes(Alias_as) -> print `yes(printed Alias_as)'
-	%         = no		  -> print `not_available'
-print_maybe_interface_aliases(MaybeAS, ProcInfo, PredInfo) -->
-	(
-		{ MaybeAS = yes(AS) }
-	->
-		io__write_string("yes("),
-		print_aliases(AS, ProcInfo, PredInfo),
-		io__write_string(")")
-	;
-		io__write_string("not_available")
-	).
-
-print_aliases(AS, ProcInfo, PredInfo) --> 
-	(
-		{ AS = real(Aliases) }
-	->
-		io__write_string("["),
-		print(PredInfo, ProcInfo, Aliases, 
-				" ", ""),
-		io__write_string("]")
-	;
-		{ AS = top(_Msgs) }
-	->
-		io__write_string("top")
-	;
-		io__write_string("bottom")
-	).
-
-print_brief_aliases(Threshold, AS, ProcInfo, PredInfo) --> 
-	(
-		{ AS = real(Aliases) }
-	->
-		io__write_string("["),
-		print_brief(Threshold, PredInfo, ProcInfo, Aliases, 
-				" ", ""),
-		io__write_string("]")
-	;
-		{ AS = top(_Msgs) }
-	->
-		io__write_string("top")
-	;
-		io__write_string("bottom")
-	).
-
-
 %-----------------------------------------------------------------------------%
 % parsing routines
 %-----------------------------------------------------------------------------%
Index: pa_alias_set.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/pa_alias_set.m,v
retrieving revision 1.1.2.15
diff -u -r1.1.2.15 pa_alias_set.m
--- pa_alias_set.m	25 Jun 2004 07:11:36 -0000	1.1.2.15
+++ pa_alias_set.m	27 Jun 2004 10:00:59 -0000
@@ -20,7 +20,7 @@
 :- import_module hlds__hlds_pred.
 :- import_module parse_tree__prog_data. 
 
-:- import_module list, set, map, io, term, bool.
+:- import_module list, set, map, term, bool.
 
 %-----------------------------------------------------------------------------%
 :- type alias_set. 
@@ -105,36 +105,6 @@
 :- pred apply_widening(module_info::in, proc_info::in, int::in, 
 		alias_set::in, alias_set::out, bool::out) is det.
 
-%----------------------------------------------------------------------------%
-% printing predicates
-%----------------------------------------------------------------------------%
-
-	% print(PredInfo, ProcInfo, AliasSet, StartingString, EndString)
-	% Prints each alias as a parsable pair of datastructs, each
-	% alias preceded with the StartingString, and ended with the
-	% EndString.
-:- pred print(pred_info::in, proc_info::in, aliases::in, 
-		string::in, string::in, 
-		io__state::di, io__state::uo) is det.
-
-:- pred print_brief(int::in, pred_info::in, proc_info::in, aliases::in, 
-		string::in, string::in, 
-		io__state::di, io__state::uo) is det.
-
-	% print(PredInfo, ProcInfo, AliasSet, StartingString,
-	% MiddleString, EndString)
-	% Prints each alias as a parsable pair of datastructs. Each alias
-	% is preceded with a StartingString, and Ended with an EndString. 
-	% Between aliases, the MiddleString is printed. 
-:- pred print(pred_info::in, proc_info::in, aliases::in, 
-		string::in, string::in, string::in, 
-		io__state::di, io__state::uo) is det.
-
-:- pred print_brief(maybe(int)::in, pred_info::in, proc_info::in,
-		aliases::in, string::in, 
-		string::in, string::in, 
-		io__state::di, io__state::uo) is det.
-
 %-----------------------------------------------------------------------------%
 
 :- implementation.
@@ -670,43 +640,6 @@
 		AliasSet = AliasSet0, 
 		Widening = no
 	).
-
-print(PredInfo, ProcInfo, AliasList, StartingString, EndString) -->
-	print(PredInfo, ProcInfo, AliasList, StartingString, ", ", EndString).
-
-print_brief(Threshold, PredInfo, ProcInfo, AliasList, 
-		StartingString, EndString) --> 
-	print_brief(yes(Threshold), PredInfo, ProcInfo, AliasList, 
-		StartingString, ", ", EndString).
-
-print(PredInfo, ProcInfo, AliasList, StartingString, MiddleString, 
-		EndString) --> 
-	print_brief(no, PredInfo, ProcInfo, AliasList, 
-		StartingString, MiddleString, EndString).
-
-print_brief(MaybeThreshold, PredInfo, ProcInfo, AliasList, 
-		StartingString, MiddleString, EndString) --> 
-	{ proc_info_varset(ProcInfo, ProgVarSet) }, 
-	{ pred_info_typevarset(PredInfo, TypeVarSet) }, 
-	% { to_pair_alias_list(AliasSet, AliasList) },
-	(
-		{ MaybeThreshold = yes(Limit) }
- 	-> 
-		{ list__take_upto(Limit, AliasList, NewList) }
-	; 
-		{ NewList = AliasList }
-	),
-	io__write_list(NewList, MiddleString, 
-		print_alias(ProgVarSet, TypeVarSet, StartingString, 
-			EndString)),
-	(
-		{ MaybeThreshold = yes(_) }
-	-> 
-		io__write_string("...")
-	;
-		[]
-	).
-
 
 :- pred alias_set_fold(pred(alias_set2, alias_set2), 
 				alias_set, alias_set).
Index: pa_run.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/pa_run.m,v
retrieving revision 1.1.2.33
diff -u -r1.1.2.33 pa_run.m
--- pa_run.m	25 Jun 2004 02:33:50 -0000	1.1.2.33
+++ pa_run.m	27 Jun 2004 10:01:00 -0000
@@ -84,6 +84,7 @@
 :- import_module parse_tree__mercury_to_mercury.
 :- import_module parse_tree__modules.
 :- import_module parse_tree__prog_data.
+:- import_module parse_tree__prog_io_pasr.
 :- import_module parse_tree__prog_out.
 :- import_module parse_tree__prog_util.
 :- import_module possible_alias__pa_alias_as.
@@ -101,6 +102,7 @@
 :- import_module term.
 :- import_module varset, bool.
 
+
 %-----------------------------------------------------------------------------%
 
 possible_aliases(ModuleInfo0, Verbose, Stats, ModuleInfo, MaybeAliasTable) -->
@@ -803,8 +805,10 @@
 		% write alias information
 
 	{ proc_info_possible_aliases(ProcInfo, MaybeAliases) },
-	pa_alias_as__print_maybe_interface_aliases(MaybeAliases, 
-					ProcInfo, PredInfo),
+	{ proc_info_varset(ProcInfo, ProgVarSet) }, 
+	{ pred_info_typevarset(PredInfo, TVarSet) }, 
+	print_interface_maybe_aliases_domain(ProgVarSet, TVarSet, 
+		MaybeAliases),
 
 	io__write_string(").\n").
 
Index: prog_io_pasr.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/prog_io_pasr.m,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 prog_io_pasr.m
--- prog_io_pasr.m	25 Jun 2004 07:11:36 -0000	1.1.2.2
+++ prog_io_pasr.m	27 Jun 2004 10:01:00 -0000
@@ -14,7 +14,7 @@
 
 :- import_module parse_tree__prog_data.
 
-:- import_module io, term.
+:- import_module io, term, std_util.
 
 %-----------------------------------------------------------------------------%
 % Printing routines. 
@@ -32,6 +32,40 @@
 :- pred print_alias(prog_varset::in, tvarset::in, string::in, string::in, 
 		alias::in, io__state::di, io__state::uo) is det.
 
+% 4. aliases.
+	% print_aliases(ProgVarSet, TypeVarSet, MaybeThreshold, 
+	%	StartString, Separator, EndString, Aliases, !IO).
+	% Print the set of aliases using StartString to precede the set of
+	% aliases, using EndString to end the set of aliases, using Separator
+	% to separate each of the aliases occuring in the list. If a threshold,
+	% say N, is given, then only the first N aliases are printed. 
+:- pred print_aliases(prog_varset::in, tvarset::in, maybe(int)::in, 
+		string::in, string::in, string::in, aliases::in, 
+		io__state::di, io__state::uo) is det.
+
+% 5. aliases_domain.
+	% Print the aliases as either "top", "bottom", or as a list of 
+	% alias-pairs. If a threshold N is given, then only print the first N
+	% aliases of the list of aliases.
+:- pred print_aliases_domain(prog_varset::in, tvarset::in, 
+		maybe(int)::in, aliases_domain::in,
+		io__state::di, io__state::uo) is det.
+
+% 6. maybe(aliases_domain).
+	% Print the aliases as a mercury-comment, used in the hlds-dump. 
+	% The msg's in top-aliases are fully printed. 
+:- pred dump_maybe_aliases_domain(prog_varset::in, tvarset::in, 
+		maybe(aliases_domain)::in, 
+		io__state::di, io__state::uo) is det.
+
+	% Print the aliases in a form suitable for the transitive-optimisation
+	% files. The msg's in top-aliases are discarded: a top alias set is
+	% simply printed as "top". 
+:- pred print_interface_maybe_aliases_domain(prog_varset::in, tvarset::in, 
+		maybe(aliases_domain)::in, 
+		io__state::di, io__state::uo) is det.
+
+
 %-----------------------------------------------------------------------------%
 % Transform to string routines. 
 
@@ -71,7 +105,7 @@
 :- import_module parse_tree__mercury_to_mercury.
 :- import_module parse_tree__prog_io.
 
-:- import_module string, list, require, bool, varset, std_util. 
+:- import_module string, list, require, bool, varset, std_util, int. 
 
 %-----------------------------------------------------------------------------%
 print_selector(TVarSet, Selector, !IO) :-
@@ -93,6 +127,78 @@
 	print_datastruct(ProgVarSet, TypeVarSet, D2, !IO),
 	io__write_string(") ", !IO),
 	io__write_string(EndString, !IO).
+
+:- pred print_alias(prog_varset::in, tvarset::in, alias::in, 
+		io__state::di, io__state::uo) is det.
+print_alias(ProgVarSet, TypeVarSet, Alias0, !IO) :- 
+	Alias0 = D1 - D2,
+	io__write_string("pair(", !IO),
+	print_datastruct(ProgVarSet, TypeVarSet, D1, !IO),
+	io__write_string(", ", !IO),
+	print_datastruct(ProgVarSet, TypeVarSet, D2, !IO),
+	io__write_string(")", !IO).
+
+print_aliases(ProgVarSet, TypeVarSet, yes(Limit), Start, Sep, End, 
+		Aliases, !IO) :- 
+	list__take_upto(Limit, Aliases, Aliases1), 
+	io__write_string(Start, !IO), 
+	print_aliases_2(ProgVarSet, TypeVarSet, Sep, 
+			Aliases1, !IO), 
+	io__write_string(Sep, !IO), 
+	io__write_string("...", !IO), 
+	io__write_string(End, !IO). 
+
+print_aliases(ProgVarSet, TypeVarSet, no, 
+		Start, Sep, End, Aliases, !IO) :- 
+	io__write_string(Start, !IO), 
+	print_aliases_2(ProgVarSet, TypeVarSet, Sep, 
+			Aliases, !IO), 
+	io__write_string(End, !IO).
+
+:- pred print_aliases_2(prog_varset::in, tvarset::in, string::in, 
+		aliases::in, io__state::di, io__state::uo) is det.
+
+print_aliases_2(ProgVarSet, TypeVarSet, Sep, Aliases, !IO) :- 
+	io__write_list(Aliases, Sep, 
+		print_alias(ProgVarSet, TypeVarSet), !IO).
+
+dump_maybe_aliases_domain(_ProgVarSet, _TypeVarSet, no, !IO) :- 
+	io__write_string("not available.\n", !IO).
+dump_maybe_aliases_domain(ProgVarSet, TypeVarSet, yes(AliasesDomain), !IO) :- 
+	(
+		AliasesDomain = bottom,
+		io__write_string("aliases are bottom.\n", !IO)
+	; 
+		AliasesDomain = top(Msgs),
+		TopString = string__join_list("\n%\t", Msgs),
+		io__write_string("aliases are top: \n%\t", !IO),
+		io__write_string(TopString, !IO),
+		io__nl(!IO)
+	;
+		AliasesDomain = real(Aliases),
+		print_aliases(ProgVarSet, TypeVarSet, no, 
+			"\n% ", "\n% ", "\n", Aliases, !IO)
+	).
+
+print_interface_maybe_aliases_domain(_ProgVarSet, _TVarSet, no, !IO) :- 
+	io__write_string("not_available", !IO). 
+print_interface_maybe_aliases_domain(ProgVarSet, TVarSet, yes(Aliases), !IO) :-
+	io__write_string("yes(", !IO), 
+	print_aliases_domain(ProgVarSet, TVarSet, no, Aliases, !IO). 
+
+print_aliases_domain(ProgVarSet, TVarSet, MaybeThreshold, Aliases, !IO) :- 
+	(
+		Aliases = top(_),
+		io__write_string("top", !IO)
+	; 
+		Aliases = bottom,
+		io__write_string("bottom", !IO)
+	; 
+		Aliases = real(AliasList), 
+		print_aliases(ProgVarSet, TVarSet, MaybeThreshold, "[", ", ", 
+			"]", AliasList, !IO)
+	).
+	
 %-----------------------------------------------------------------------------%
 to_user_declared_selector(TVarSet, Selector, String):- 
 	(
Index: sr_data.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/sr_data.m,v
retrieving revision 1.1.2.27
diff -u -r1.1.2.27 sr_data.m
--- sr_data.m	25 Jun 2004 06:23:26 -0000	1.1.2.27
+++ sr_data.m	27 Jun 2004 10:01:03 -0000
@@ -362,14 +362,13 @@
 
 		% write out LUiH, list of prog_vars
 	io__write_string("["),
-	{ proc_info_varset(ProcInfo, ProgVarset) },
 	{ set__to_sorted_list(LUiH, ListLUiH) },
-	mercury_output_vars(ListLUiH, ProgVarset, bool__no), 
+	mercury_output_vars(ListLUiH, ProgVarSet, bool__no), 
 	io__write_string("], "),
 
 		% write out LAiH, the aliases at the reuse-point
 	{ from_alias_as_to_aliases_domain(LAiH, PublicLAiH) },
-	pa_alias_as__print_aliases(PublicLAiH, ProcInfo, PredInfo),	
+	print_aliases_domain(ProgVarSet, TypeVarSet, no, PublicLAiH),
 
 	io__write_string(")").
 


-- 
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