[m-rev.] diff: factor out handling of browser term

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Aug 9 13:04:43 AEST 2004


Factor out common code in the handling of plain terms and synthetic terms.
We already had a mechanism (the browser_term type and operations on it) for
handling them in a unified manner, we just didn't use them everywhere we could.

browser/browser_term.m:
	Add this new module to hold the browser_term type and the operations
	on it, which previously were in two different modules (browser_info
	and browse respectively).

	Make the operations function, since that is their natural form.

browser/mdb.m:
	Add the new module.

browser/browser_into.m:
	Delete the type moved to browser_term.m.

browser/browse.m:
	Delete the operations moved to browser_term.m.

	Replace operation pairs on plain terms and synthetic terms with
	generalized operations on browser terms.

browser/declarative_user.m:
browser/io_action.m:
browser/sized_pretty.m:
trace/mercury_trace_browser.c:
	Conform to the changes listed above.

cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
Index: browser/browse.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/browser/browse.m,v
retrieving revision 1.43
diff -u -r1.43 browse.m
--- browser/browse.m	13 May 2004 08:50:29 -0000	1.43
+++ browser/browse.m	8 Aug 2004 10:44:36 -0000
@@ -21,35 +21,20 @@
 :- interface.
 
 :- import_module mdb__browser_info.
-:- import_module io, bool, std_util, list.
+:- import_module mdb__browser_term.
+:- import_module io, std_util, list.
 
 	% The interactive term browser.  The caller type will be `browse', and
 	% the default format for the `browse' caller type will be used.
 	%
-:- pred browse__browse(T::in, io__input_stream::in,
-	io__output_stream::in, maybe(list(dir))::out,
-	browser_persistent_state::in, browser_persistent_state::out,
-	io::di, io::uo) is cc_multi.
-
-	% As above, except that the supplied format will override the default.
-	%
-:- pred browse__browse_format(T::in, io__input_stream::in,
-	io__output_stream::in, portray_format::in,
-	browser_persistent_state::in, browser_persistent_state::out,
-	io::di, io::uo) is cc_multi.
-
-	% A version of browse__browse that works on synthetic terms
-	% in the sense of browser_info:browser_term.
-	%
-:- pred browse__browse_synthetic(string::in, list(univ)::in, bool::in,
+:- pred browse__browse_browser_term(browser_term::in,
 	io__input_stream::in, io__output_stream::in, maybe(list(dir))::out,
 	browser_persistent_state::in, browser_persistent_state::out,
 	io::di, io::uo) is cc_multi.
 
-	% A version of browse__browse_format that works on synthetic terms
-	% in the sense of browser_info:browser_term.
+	% As above, except that the supplied format will override the default.
 	%
-:- pred browse__browse_format_synthetic(string::in, list(univ)::in, bool::in,
+:- pred browse__browse_browser_term_format(browser_term::in,
 	io__input_stream::in, io__output_stream::in, portray_format::in,
 	browser_persistent_state::in, browser_persistent_state::out,
 	io::di, io::uo) is cc_multi.
@@ -66,26 +51,13 @@
 	% `print' or `print_all'.  The default portray format for that
 	% caller type is used.
 	%
-:- pred browse__print(T::in, io__output_stream::in, browse_caller_type::in,
-	browser_persistent_state::in, io::di, io::uo) is cc_multi.
-
-	% A version of browse__print that works on synthetic terms
-	% in the sense of browser_info:browser_term.
-	%
-:- pred browse__print_synthetic(string::in, list(univ)::in, bool::in,
+:- pred browse__print_browser_term(browser_term::in,
 	io__output_stream::in, browse_caller_type::in,
 	browser_persistent_state::in, io::di, io::uo) is cc_multi.
 
 	% As above, except that the supplied format will override the default.
 	%
-:- pred browse__print_format(T::in, io__output_stream::in,
-	browse_caller_type::in, portray_format::in,
-	browser_persistent_state::in, io::di, io::uo) is cc_multi.
-
-	% A version of browse__print_format that works on synthetic terms
-	% in the sense of browser_info:browser_term.
-	%
-:- pred browse__print_format_synthetic(string::in, list(univ)::in, bool::in,
+:- pred browse__print_browser_term_format(browser_term::in,
 	io__output_stream::in, browse_caller_type::in, portray_format::in,
 	browser_persistent_state::in, io::di, io::uo) is cc_multi.
 
@@ -112,28 +84,6 @@
 
 %---------------------------------------------------------------------------%
 
-	% This predicate converts terms represented as univs to browser terms.
-
-:- pred univ_to_browser_term(univ::in, browser_term::out) is det.
-
-	% This predicate converts plain terms from the representation used
-	% in the trace directory to browser terms.
-
-:- pred plain_term_to_browser_term(T::in, browser_term::out) is det.
-
-	% This predicate converts synthetic terms from the representation used
-	% in the trace directory (as a list of arguments, the last of which
-	% represents the return value for function calls) to the representation
-	% used in the browser directory, in which a function call's return
-	% value is stored separately from the other arguments.
-	%
-	% The reason why the trace directory does not use the latter
-	% representation is that it would require C code to construct values
-	% of type maybe(T).
-
-:- pred synthetic_term_to_browser_term(string::in, list(univ)::in, bool::in,
-	browser_term::out) is det.
-
 	% save_term_to_file(FileName, Format, BrowserTerm, Out, !IO):
 	% Save BrowserTerm to the file FileName. If there is an error,
 	% print an error message to Out.
@@ -153,7 +103,7 @@
 :- import_module mdb__frame.
 :- import_module mdb__sized_pretty.
 
-:- import_module string, int, char, map, std_util.
+:- import_module bool, string, int, char, map, std_util.
 :- import_module parser, require, pprint, getopt, deconstruct.
 
 %---------------------------------------------------------------------------%
@@ -162,31 +112,17 @@
 % they are used in trace/mercury_trace_browser.c.
 %
 
-:- pragma export(browse__browse(in, in, in, out, in, out, di, uo),
-	"ML_BROWSE_browse").
-:- pragma export(browse__browse_format(in, in, in, in, in, out, di, uo),
-	"ML_BROWSE_browse_format").
-:- pragma export(browse__browse_synthetic(in, in, in, in, in, out,
-	in, out, di, uo), "ML_BROWSE_browse_synthetic").
-:- pragma export(browse__browse_format_synthetic(in, in, in, in, in, in,
-	in, out, di, uo), "ML_BROWSE_browse_format_synthetic").
+:- pragma export(browse__browse_browser_term(in, in, in, out, in, out, di, uo),
+	"ML_BROWSE_browse_browser_term").
+:- pragma export(browse__browse_browser_term_format(in, in, in, in, in, out,
+	di, uo), "ML_BROWSE_browse_browser_term_format").
 :- pragma export(browse__browse_external(in, in, in, in, out, di, uo),
 	"ML_BROWSE_browse_external").
-:- pragma export(browse__print(in, in, in, in, di, uo),
-	"ML_BROWSE_print").
-:- pragma export(browse__print_format(in, in, in, in, in, di, uo),
-	"ML_BROWSE_print_format").
-:- pragma export(browse__print_synthetic(in, in, in, in, in, in, di, uo),
-	"ML_BROWSE_print_synthetic").
-:- pragma export(browse__print_format_synthetic(in, in, in, in, in, in, in,
-	di, uo), "ML_BROWSE_print_format_synthetic").
-
-:- pragma export(plain_term_to_browser_term(in, out),
-	"ML_BROWSE_plain_term_to_browser_term").
-:- pragma export(univ_to_browser_term(in, out),
-	"ML_BROWSE_univ_to_browser_term").
-:- pragma export(synthetic_term_to_browser_term(in, in, in, out),
-	"ML_BROWSE_synthetic_term_to_browser_term").
+:- pragma export(browse__print_browser_term(in, in, in, in, di, uo),
+	"ML_BROWSE_print_browser_term").
+:- pragma export(browse__print_browser_term_format(in, in, in, in, in, di, uo),
+	"ML_BROWSE_print_browser_term_format").
+
 :- pragma export(save_term_to_file(in, in, in, in, di, uo),
 	"ML_BROWSE_save_term_to_file").
 
@@ -327,27 +263,13 @@
 % Non-interactive display
 %
 
-browse__print(Term, OutputStream, Caller, State, !IO) :-
-	browse__print_common(plain_term(univ(Term)), OutputStream,
-		Caller, no, State, !IO).
-
-browse__print_format(Term, OutputStream, Caller, Format, State, !IO):-
-	browse__print_common(plain_term(univ(Term)), OutputStream,
-		Caller, yes(Format), State, !IO).
-
-browse__print_synthetic(FunctorString, Args, IsFunc, OutputStream,
-		Caller, State, !IO):-
-	synthetic_term_to_browser_term(FunctorString, Args, IsFunc,
-		BrowserTerm),
-	browse__print_common(BrowserTerm, OutputStream, Caller, no, State,
-		!IO).
-
-browse__print_format_synthetic(FunctorString, Args, IsFunc, OutputStream,
-		Caller, Format, State, !IO):-
-	synthetic_term_to_browser_term(FunctorString, Args, IsFunc,
-		BrowserTerm),
-	browse__print_common(BrowserTerm, OutputStream,
-		Caller, yes(Format), State, !IO).
+browse__print_browser_term(Term, OutputStream, Caller, State, !IO) :-
+	browse__print_common(Term, OutputStream, Caller, no, State, !IO).
+
+browse__print_browser_term_format(Term, OutputStream, Caller, Format,
+		State, !IO):-
+	browse__print_common(Term, OutputStream, Caller, yes(Format),
+		State, !IO).
 
 :- pred browse__print_common(browser_term::in, io__output_stream::in,
 	browse_caller_type::in, maybe(portray_format)::in,
@@ -379,31 +301,18 @@
 % Interactive display
 %
 
-browse__browse(Object, InputStream, OutputStream, MaybeMark, !State, !IO) :-
-	browse_common(internal, plain_term(univ(Object)),
-		InputStream, OutputStream, no, MaybeMark, !State, !IO).
-
-browse__browse_format(Object, InputStream, OutputStream, Format,
+browse__browse_browser_term(Term, InputStream, OutputStream, MaybeMark,
 		!State, !IO) :-
-	browse_common(internal, plain_term(univ(Object)),
-		InputStream, OutputStream, yes(Format), _, !State, !IO).
+	browse_common(internal, Term, InputStream, OutputStream, no,
+		MaybeMark, !State, !IO).
 
-browse__browse_synthetic(FunctorString, Args, IsFunc,
-		InputStream, OutputStream, MaybeMark, !State, !IO) :-
-	synthetic_term_to_browser_term(FunctorString, Args, IsFunc,
-		BrowserTerm),
-	browse_common(internal, BrowserTerm,
-		InputStream, OutputStream, no, MaybeMark, !State, !IO).
-
-browse__browse_format_synthetic(FunctorString, Args, IsFunc,
-		InputStream, OutputStream, Format, !State, !IO) :-
-	synthetic_term_to_browser_term(FunctorString, Args, IsFunc,
-		BrowserTerm),
-	browse_common(internal, BrowserTerm,
-		InputStream, OutputStream, yes(Format), _, !State, !IO).
+browse__browse_browser_term_format(Term, InputStream, OutputStream, Format,
+		!State, !IO) :-
+	browse_common(internal, Term, InputStream, OutputStream, yes(Format),
+		_, !State, !IO).
 
-browse__browse_external(Object, InputStream, OutputStream, !State, !IO) :-
-	browse_common(external, plain_term(univ(Object)),
+browse__browse_external(Term, InputStream, OutputStream, !State, !IO) :-
+	browse_common(external, plain_term(univ(Term)),
 		InputStream, OutputStream, no, _, !State, !IO).
 
 :- pred browse_common(debugger::in, browser_term::in, io__input_stream::in,
@@ -422,23 +331,6 @@
 	io__set_output_stream(OldOutputStream, _, !IO),
 	MaybeMark = Info ^ maybe_mark,
 	!:State = Info ^ state.
-
-univ_to_browser_term(Univ, BrowserTerm) :-
-	BrowserTerm = plain_term(Univ).
-
-plain_term_to_browser_term(Term, BrowserTerm) :-
-	BrowserTerm = plain_term(univ(Term)).
-
-synthetic_term_to_browser_term(FunctorString, Args, IsFunc, BrowserTerm) :-
-	(
-		IsFunc = no,
-		BrowserTerm = synthetic_term(FunctorString, Args, no)
-	;
-		IsFunc = yes,
-		list__split_last_det(Args, FuncArgs, Return),
-		BrowserTerm = synthetic_term(FunctorString, FuncArgs,
-			yes(Return))
-	).
 
 :- pred browse_main_loop(debugger::in, browser_info::in, browser_info::out,
 	io::di, io::uo) is cc_multi.
Index: browser/browser_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/browser/browser_info.m,v
retrieving revision 1.14
diff -u -r1.14 browser_info.m
--- browser/browser_info.m	27 Oct 2003 06:00:31 -0000	1.14
+++ browser/browser_info.m	8 Aug 2004 10:36:47 -0000
@@ -16,23 +16,9 @@
 
 :- import_module mdbcomp.
 :- import_module mdbcomp__program_representation.
+:- import_module mdb__browser_term.
 
 :- import_module bool, list, std_util, io.
-
-:- type browser_term
-	--->	plain_term(
-			univ		% We are browsing a plain term.
-		)
-	;	synthetic_term(
-			string,		% We are browsing a synthetic term,
-					% such as a predicate name applied to
-					% a list of arguments. The string says
-					% what we should print as the functor.
-			list(univ),	% The arguments.
-			maybe(univ)	% If yes, the synthetic term represents
-					% a function call, and the argument
-					% inside the yes() is the return value.
-		).
 
 	% The non-persistent browser information.  A new one of these is
 	% created every time the browser is called, based on the contents
Index: browser/browser_term.m
===================================================================
RCS file: browser/browser_term.m
diff -N browser/browser_term.m
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ browser/browser_term.m	8 Aug 2004 10:44:31 -0000
@@ -0,0 +1,77 @@
+%---------------------------------------------------------------------------%
+% Copyright (C) 2004 The University of Melbourne.
+% This file may only be copied under the terms of the GNU Library General
+% Public License - see the file COPYING.LIB in the Mercury distribution.
+%---------------------------------------------------------------------------%
+
+% This module defines a type to represent both natural and synthetic terms
+% for use by the browser.
+
+:- module mdb__browser_term.
+
+:- interface.
+
+:- import_module bool, std_util, list.
+
+:- type browser_term
+	--->	plain_term(
+			univ		% We are browsing a plain term.
+		)
+	;	synthetic_term(
+			string,		% We are browsing a synthetic term,
+					% such as a predicate name applied to
+					% a list of arguments. The string says
+					% what we should print as the functor.
+			list(univ),	% The arguments.
+			maybe(univ)	% If yes, the synthetic term represents
+					% a function call, and the argument
+					% inside the yes() is the return value.
+		).
+
+	% This predicate converts a term represented as univ to a browser term.
+
+:- func univ_to_browser_term(univ) = browser_term.
+
+	% This predicate converts a plain term from the representation used
+	% in the trace directory to a browser term.
+
+:- func plain_term_to_browser_term(T) = browser_term.
+
+	% This predicate converts a synthetic term from the representation used
+	% in the trace directory (as a list of arguments, the last of which
+	% represents the return value for function calls) to the representation
+	% used in the browser directory, in which a function call's return
+	% value is stored separately from the other arguments.
+	%
+	% The reason why the trace directory does not use the latter
+	% representation is that it would require C code to construct values
+	% of type maybe(T).
+
+:- func synthetic_term_to_browser_term(string, list(univ), bool)
+	= browser_term.
+
+:- implementation.
+
+:- pragma export(plain_term_to_browser_term(in) = out,
+	"ML_BROWSE_plain_term_to_browser_term").
+:- pragma export(univ_to_browser_term(in) = out,
+	"ML_BROWSE_univ_to_browser_term").
+:- pragma export(synthetic_term_to_browser_term(in, in, in) = out,
+	"ML_BROWSE_synthetic_term_to_browser_term").
+
+univ_to_browser_term(Univ) = BrowserTerm :-
+	BrowserTerm = plain_term(Univ).
+
+plain_term_to_browser_term(Term) = BrowserTerm :-
+	BrowserTerm = plain_term(univ(Term)).
+
+synthetic_term_to_browser_term(FunctorString, Args, IsFunc) = BrowserTerm :-
+	(
+		IsFunc = no,
+		BrowserTerm = synthetic_term(FunctorString, Args, no)
+	;
+		IsFunc = yes,
+		list__split_last_det(Args, FuncArgs, Return),
+		BrowserTerm = synthetic_term(FunctorString, FuncArgs,
+			yes(Return))
+	).
Index: browser/declarative_user.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/browser/declarative_user.m,v
retrieving revision 1.28
diff -u -r1.28 declarative_user.m
--- browser/declarative_user.m	7 Jul 2004 05:26:15 -0000	1.28
+++ browser/declarative_user.m	8 Aug 2004 10:51:34 -0000
@@ -54,8 +54,9 @@
 
 :- implementation.
 
-:- import_module mdb__browser_info.
 :- import_module mdb__browse.
+:- import_module mdb__browser_info.
+:- import_module mdb__browser_term.
 :- import_module mdb__io_action.
 :- import_module mdb__util.
 :- import_module mdb__declarative_execution.
@@ -317,71 +318,76 @@
 	user_state::in, user_state::out, io__state::di, io__state::uo)
 	is cc_multi.
 
-browse_io_action(IoAction, MaybeMark, User0, User) -->
-	{ io_action_to_synthetic_term(IoAction, ProcName, Args, IsFunc) },
-	browse_synthetic(ProcName, Args, IsFunc, User0 ^ instr, User0 ^ outstr,
-		MaybeDirs, User0 ^ browser, Browser),
-	{ maybe_convert_dirs_to_path(MaybeDirs, MaybeMark) },
-	{ User = User0 ^ browser := Browser }.
+browse_io_action(IoAction, MaybeMark, !User, !IO) :-
+	Term = io_action_to_browser_term(IoAction),
+	browse_browser_term(Term, !.User ^ instr, !.User ^ outstr, MaybeDirs,
+		!.User ^ browser, Browser, !IO),
+	maybe_convert_dirs_to_path(MaybeDirs, MaybeMark),
+	!:User = !.User ^ browser := Browser.
 
 :- pred browse_decl_bug_arg(decl_bug::in, int::in,
 	user_state::in, user_state::out, io__state::di, io__state::uo)
 	is cc_multi.
 
-browse_decl_bug_arg(Bug, ArgNum, User0, User) -->
-	{ decl_bug_trace_atom(Bug, Atom) },
-	browse_atom_argument(Atom, ArgNum, _, User0, User).
+browse_decl_bug_arg(Bug, ArgNum, !User, !IO) :-
+	decl_bug_trace_atom(Bug, Atom),
+	browse_atom_argument(Atom, ArgNum, _, !User, !IO).
 
 :- pred browse_atom_argument(trace_atom::in, int::in, maybe(term_path)::out,
 	user_state::in, user_state::out, io__state::di, io__state::uo)
 	is cc_multi.
 
-browse_atom_argument(Atom, ArgNum, MaybeMark, User0, User) -->
-	{ Atom = atom(_, Args0) },
-	{ maybe_filter_headvars(chosen_head_vars_presentation, Args0, Args) },
+browse_atom_argument(Atom, ArgNum, MaybeMark, !User, !IO) :-
+	Atom = atom(_, Args0),
+	maybe_filter_headvars(chosen_head_vars_presentation, Args0, Args),
 	(
-		{ list__index1(Args, ArgNum, ArgInfo) },
-		{ ArgInfo = arg_info(_, _, MaybeArg) },
-		{ MaybeArg = yes(Arg) }
+		list__index1(Args, ArgNum, ArgInfo),
+		ArgInfo = arg_info(_, _, MaybeArg),
+		MaybeArg = yes(Arg)
 	->
-		browse(univ_value(Arg), User0 ^ instr, User0 ^ outstr,
-			MaybeDirs, User0 ^ browser, Browser),
-		{ maybe_convert_dirs_to_path(MaybeDirs, MaybeMark) },
-		{ User = User0 ^ browser := Browser }
-	;
-		io__write_string(User ^ outstr, "Invalid argument number\n"),
-		{ MaybeMark = no },
-		{ User = User0 }
+		browse_browser_term(univ_to_browser_term(Arg),
+			!.User ^ instr, !.User ^ outstr,
+			MaybeDirs, !.User ^ browser, Browser, !IO),
+		maybe_convert_dirs_to_path(MaybeDirs, MaybeMark),
+		!:User = !.User ^ browser := Browser
+	;
+		io__write_string(!.User ^ outstr, "Invalid argument number\n",
+			!IO),
+		MaybeMark = no
 	).
 
 :- pred print_atom_arguments(trace_atom::in, int::in, int::in, user_state::in,
 	io__state::di, io__state::uo) is cc_multi.
 
-print_atom_arguments(Atom, From, To, User0) -->
-	print_atom_argument(Atom, From, User0, OK),
-	( { OK = yes, From + 1 =< To } ->
-		print_atom_arguments(Atom, From + 1, To, User0)
+print_atom_arguments(Atom, From, To, User, !IO) :-
+	print_atom_argument(Atom, From, User, OK, !IO),
+	(
+		OK = yes,
+		From + 1 =< To
+	->
+		print_atom_arguments(Atom, From + 1, To, User, !IO)
 	;
-		[]
+		true
 	).
 
 :- pred print_atom_argument(trace_atom::in, int::in, user_state::in, bool::out,
 	io__state::di, io__state::uo) is cc_multi.
 
-print_atom_argument(Atom, ArgNum, User0, OK) -->
-	{ Atom = atom(_, Args0) },
-	{ maybe_filter_headvars(chosen_head_vars_presentation, Args0, Args) },
+print_atom_argument(Atom, ArgNum, User, OK, !IO) :-
+	Atom = atom(_, Args0),
+	maybe_filter_headvars(chosen_head_vars_presentation, Args0, Args),
 	(
-		{ list__index1(Args, ArgNum, ArgInfo) },
-		{ ArgInfo = arg_info(_, _, MaybeArg) },
-		{ MaybeArg = yes(Arg) }
+		list__index1(Args, ArgNum, ArgInfo),
+		ArgInfo = arg_info(_, _, MaybeArg),
+		MaybeArg = yes(Arg)
 	->
-		print(univ_value(Arg), User0 ^ outstr, decl_caller_type,
-			User0 ^ browser),
-		{ OK = yes }
-	;
-		io__write_string(User0 ^ outstr, "Invalid argument number\n"),
-		{ OK = no }
+		print_browser_term(univ_to_browser_term(Arg), User ^ outstr,
+			decl_caller_type, User ^ browser, !IO),
+		OK = yes
+	;
+		io__write_string(User ^ outstr, "Invalid argument number\n",
+			!IO),
+		OK = no
 	).
 
 :- pred maybe_convert_dirs_to_path(maybe(list(dir)), maybe(term_path)).
@@ -694,8 +700,10 @@
 		% Call the term browser to print the atom (or part of it
 		% up to a size limit) as a goal.
 		%
-	browse__print_synthetic(Functor, Args, is_function(PredOrFunc),
-		User ^ outstr, CallerType, User ^ browser, !IO),
+	BrowserTerm = synthetic_term_to_browser_term(Functor, Args,
+		is_function(PredOrFunc)),
+	browse__print_browser_term(BrowserTerm, User ^ outstr, CallerType,
+		User ^ browser, !IO),
 	write_io_actions(User, IoActions, !IO).
 
 :- pred trace_atom_arg_to_univ(trace_atom_arg::in, univ::out) is det.
@@ -736,9 +744,9 @@
 :- pred print_io_action(user_state::in, io_action::in,
 	io__state::di, io__state::uo) is cc_multi.
 
-print_io_action(User, IoAction) -->
-	{ io_action_to_synthetic_term(IoAction, ProcName, Args, IsFunc) },
-	browse__print_synthetic(ProcName, Args, IsFunc, User ^ outstr,
-		print_all, User ^ browser).
+print_io_action(User, IoAction, !IO) :-
+	Term = io_action_to_browser_term(IoAction),
+	browse__print_browser_term(Term, User ^ outstr, print_all,
+		User ^ browser, !IO).
 
 %-----------------------------------------------------------------------------%
Index: browser/io_action.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/browser/io_action.m,v
retrieving revision 1.4
diff -u -r1.4 io_action.m
--- browser/io_action.m	6 Feb 2003 13:37:08 -0000	1.4
+++ browser/io_action.m	8 Aug 2004 10:38:45 -0000
@@ -17,7 +17,8 @@
 :- interface.
 
 :- import_module mdb__util.
-:- import_module bool, list, map, std_util, io.
+:- import_module mdb__browser_term.
+:- import_module list, map, std_util, io.
 
 :- type io_action
 	--->	io_action(
@@ -32,14 +33,13 @@
 :- pred make_io_action_map(int::in, int::in, io_action_map::out,
 	io__state::di, io__state::uo) is det.
 
-:- pred io_action_to_synthetic_term(io_action::in, string::out,
-	list(univ)::out, bool::out) is det.
+:- func io_action_to_browser_term(io_action) = browser_term.
 
 :- implementation.
 
-:- import_module require, int.
+:- import_module bool, int, require.
 
-io_action_to_synthetic_term(IoAction, ProcName, Args, IsFunc) :-
+io_action_to_browser_term(IoAction) = Term :-
 	IoAction = io_action(ProcName, PredFunc, Args),
 	(
 		PredFunc = predicate,
@@ -47,7 +47,8 @@
 	;
 		PredFunc = function,
 		IsFunc = yes
-	).
+	),
+	Term = synthetic_term_to_browser_term(ProcName, Args, IsFunc).
 
 make_io_action_map(Start, End, IoActionMap) -->
 	make_io_action_map_2(Start, End, map__init, IoActionMap).
Index: browser/mdb.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/browser/mdb.m,v
retrieving revision 1.13
diff -u -r1.13 mdb.m
--- browser/mdb.m	27 Oct 2003 06:00:32 -0000	1.13
+++ browser/mdb.m	8 Aug 2004 10:28:53 -0000
@@ -16,6 +16,7 @@
 	% or the libmer_trace library.
 :- include_module browse.
 :- include_module browser_info.
+:- include_module browser_term.
 :- include_module collect_lib.
 :- include_module debugger_interface.
 :- include_module declarative_debugger.
Index: browser/sized_pretty.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/browser/sized_pretty.m,v
retrieving revision 1.8
diff -u -r1.8 sized_pretty.m
--- browser/sized_pretty.m	14 Sep 2003 22:24:28 -0000	1.8
+++ browser/sized_pretty.m	8 Aug 2004 10:37:11 -0000
@@ -162,6 +162,7 @@
 :- interface.
 
 :- import_module mdb__browser_info.
+:- import_module mdb__browser_term.
 :- import_module std_util, int, string.
 
 	% sized_pretty__univ_to_string_line(Univ, LineWidth, Lines, String)
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/mercury_glut
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
Index: trace/mercury_trace_browse.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/trace/mercury_trace_browse.c,v
retrieving revision 1.31
diff -u -r1.31 mercury_trace_browse.c
--- trace/mercury_trace_browse.c	13 May 2004 08:50:32 -0000	1.31
+++ trace/mercury_trace_browse.c	8 Aug 2004 11:06:26 -0000
@@ -31,6 +31,7 @@
 
 #include "mdb.browse.mh"
 #include "mdb.browser_info.mh"
+#include "mdb.browser_term.mh"
 #include "mdb.interactive_query.mh"
 
 #include "type_desc.mh"
@@ -51,8 +52,8 @@
 	MR_Word	browser_term;
 
 	MR_TRACE_CALL_MERCURY(
-		ML_BROWSE_plain_term_to_browser_term((MR_Word) type_info,
-			value, &browser_term);
+		browser_term = ML_BROWSE_plain_term_to_browser_term(
+			(MR_Word) type_info, value);
 	);
 	return browser_term;
 }
@@ -63,7 +64,7 @@
 	MR_Word browser_term;
 
 	MR_TRACE_CALL_MERCURY(
-		ML_BROWSE_univ_to_browser_term(univ, &browser_term);
+		browser_term = ML_BROWSE_univ_to_browser_term(univ);
 	);
 	return browser_term;
 }
@@ -75,9 +76,8 @@
 	MR_Word	browser_term;
 
 	MR_TRACE_CALL_MERCURY(
-		ML_BROWSE_synthetic_term_to_browser_term(
-			(MR_String) (MR_Integer) functor, arg_list, is_func,
-			&browser_term);
+		browser_term = ML_BROWSE_synthetic_term_to_browser_term(
+			(MR_String) (MR_Integer) functor, arg_list, is_func);
 	);
 	return browser_term;
 }
@@ -103,57 +103,65 @@
 void
 MR_trace_browse(MR_Word type_info, MR_Word value, MR_Browse_Format format)
 {
-	MercuryFile	mdb_in, mdb_out;
+	MercuryFile	mdb_in;
+	MercuryFile	mdb_out;
 	MR_Word		maybe_mark;
+	MR_Word		browser_term;
 
 	MR_trace_browse_ensure_init();
 
 	MR_c_file_to_mercury_file(MR_mdb_in, &mdb_in);
 	MR_c_file_to_mercury_file(MR_mdb_out, &mdb_out);
 
+	browser_term = MR_type_value_to_browser_term((MR_TypeInfo) type_info,
+		value);
+
 	if (format != MR_BROWSE_DEFAULT_FORMAT) {
 		MR_TRACE_CALL_MERCURY(
-			ML_BROWSE_browse_format(type_info, value,
+			ML_BROWSE_browse_browser_term_format(browser_term,
 				&mdb_in, &mdb_out, (MR_Word) format,
 				MR_trace_browser_persistent_state,
 				&MR_trace_browser_persistent_state);
 		);
 	} else {
 		MR_TRACE_CALL_MERCURY(
-			ML_BROWSE_browse(type_info, value, &mdb_in, &mdb_out,
-				&maybe_mark, MR_trace_browser_persistent_state,
+			ML_BROWSE_browse_browser_term(browser_term,
+				&mdb_in, &mdb_out, &maybe_mark,
+				MR_trace_browser_persistent_state,
 				&MR_trace_browser_persistent_state);
 		);
 	}
 	MR_trace_browser_persistent_state =
-			MR_make_permanent(MR_trace_browser_persistent_state,
-				MR_trace_browser_persistent_state_type);
+		MR_make_permanent(MR_trace_browser_persistent_state,
+			MR_trace_browser_persistent_state_type);
 }
 
 void
 MR_trace_browse_goal(MR_ConstString name, MR_Word arg_list, MR_Word is_func,
 	MR_Browse_Format format)
 {
-	MercuryFile	mdb_in, mdb_out;
+	MercuryFile	mdb_in;
+	MercuryFile	mdb_out;
 	MR_Word		maybe_mark;
+	MR_Word		browser_term;
 
 	MR_trace_browse_ensure_init();
 
 	MR_c_file_to_mercury_file(MR_mdb_in, &mdb_in);
 	MR_c_file_to_mercury_file(MR_mdb_out, &mdb_out);
 
+	browser_term = MR_synthetic_to_browser_term(name, arg_list, is_func);
+
 	if (format != MR_BROWSE_DEFAULT_FORMAT) {
 		MR_TRACE_CALL_MERCURY(
-			ML_BROWSE_browse_format_synthetic(
-				(MR_String) (MR_Word) name, arg_list, is_func,
+			ML_BROWSE_browse_browser_term_format(browser_term,
 				&mdb_in, &mdb_out, (MR_Word) format,
 				MR_trace_browser_persistent_state,
 				&MR_trace_browser_persistent_state);
 		);
 	} else {
 		MR_TRACE_CALL_MERCURY(
-			ML_BROWSE_browse_synthetic(
-				(MR_String) (MR_Word) name, arg_list, is_func,
+			ML_BROWSE_browse_browser_term(browser_term,
 				&mdb_in, &mdb_out, &maybe_mark,
 				MR_trace_browser_persistent_state,
 				&MR_trace_browser_persistent_state);
@@ -186,31 +194,35 @@
 			&MR_trace_browser_persistent_state);
 	);
 	MR_trace_browser_persistent_state =
-			MR_make_permanent(MR_trace_browser_persistent_state,
-				MR_trace_browser_persistent_state_type);
+		MR_make_permanent(MR_trace_browser_persistent_state,
+			MR_trace_browser_persistent_state_type);
 }
 
 #endif
 
 void
 MR_trace_print(MR_Word type_info, MR_Word value, MR_Browse_Caller_Type caller,
-		MR_Browse_Format format)
+	MR_Browse_Format format)
 {
-	MercuryFile mdb_out;
+	MercuryFile	mdb_out;
+	MR_Word		browser_term;
 
 	MR_trace_browse_ensure_init();
 
 	MR_c_file_to_mercury_file(MR_mdb_out, &mdb_out);
 
+	browser_term = MR_type_value_to_browser_term((MR_TypeInfo) type_info,
+		value);
+
 	if (format != MR_BROWSE_DEFAULT_FORMAT) {
 		MR_TRACE_CALL_MERCURY(
-			ML_BROWSE_print_format(type_info, value,
+			ML_BROWSE_print_browser_term_format(browser_term,
 				&mdb_out, caller, (MR_Word) format,
 				MR_trace_browser_persistent_state);
 		);
 	} else {
 		MR_TRACE_CALL_MERCURY(
-			ML_BROWSE_print(type_info, value, &mdb_out,
+			ML_BROWSE_print_browser_term(browser_term, &mdb_out,
 				(MR_Word) caller,
 				MR_trace_browser_persistent_state);
 		);
@@ -221,23 +233,24 @@
 MR_trace_print_goal(MR_ConstString name, MR_Word arg_list, MR_Word is_func,
 	MR_Browse_Caller_Type caller, MR_Browse_Format format)
 {
-	MercuryFile mdb_out;
+	MercuryFile	mdb_out;
+	MR_Word		browser_term;
 
 	MR_trace_browse_ensure_init();
 
 	MR_c_file_to_mercury_file(MR_mdb_out, &mdb_out);
 
+	browser_term = MR_synthetic_to_browser_term(name, arg_list, is_func);
+
 	if (format != MR_BROWSE_DEFAULT_FORMAT) {
 		MR_TRACE_CALL_MERCURY(
-			ML_BROWSE_print_format_synthetic(
-				(MR_String) (MR_Word) name, arg_list, is_func,
+			ML_BROWSE_print_browser_term_format(browser_term,
 				&mdb_out, caller, (MR_Word) format,
 				MR_trace_browser_persistent_state);
 		);
 	} else {
 		MR_TRACE_CALL_MERCURY(
-			ML_BROWSE_print_synthetic(
-				(MR_String) (MR_Word) name, arg_list, is_func,
+			ML_BROWSE_print_browser_term(browser_term,
 				&mdb_out, (MR_Word) caller,
 				MR_trace_browser_persistent_state);
 		);
@@ -246,10 +259,13 @@
 
 MR_bool
 MR_trace_set_browser_param(MR_Word print, MR_Word browse, MR_Word print_all,
-		MR_Word flat, MR_Word raw_pretty, MR_Word verbose, 
-		MR_Word pretty, const char *param, const char *value)
+	MR_Word flat, MR_Word raw_pretty, MR_Word verbose, 
+	MR_Word pretty, const char *param, const char *value)
 {
-	int			depth, size, width, lines;
+	int			depth;
+	int			size;
+	int			width;
+	int			lines;
 	MR_Browse_Format	new_format;
 
 	MR_trace_browse_ensure_init();
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
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