[m-dev.] trivial diff: improve readability of `.rla' files

Simon Taylor stayl at cs.mu.OZ.AU
Tue Mar 14 11:01:47 AEDT 2000


Estimated hours taken: 0.1

Improve the readability of the compiler-generated `.rla' files,
which contain a human-readable version of the Aditi-RL bytecode
for a module.

compiler/rl_file.pp:
	Make control flow and materialise instructions stand
	out in `.rla' files by indenting them less than the
	other instructions.


Index: rl_file.pp
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/rl_file.pp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -u -r1.1 -r1.2
--- rl_file.pp	1999/04/28 01:18:41	1.1
+++ rl_file.pp	2000/03/14 00:00:37	1.2
@@ -1,5 +1,5 @@
 %-----------------------------------------------------------------------------%
-% Copyright (C) 1998-1999 University of Melbourne.
+% Copyright (C) 1998-2000 University of Melbourne.
 % This file may only be copied under the terms of the GNU General
 % Public License - see the file COPYING in the Mercury distribution.
 %-----------------------------------------------------------------------------%
@@ -465,9 +465,41 @@
 	),
 	io__write_string("],\n\n\t"),
 	io__write_int(CodeLength),
-	io__write_string(",\t% code length\n\t[\n\t"),
-	io__write_list(Code, ",\n\t", io__write),
+	io__write_string(",\t% code length\n\t[\n"),
+	io__write_list(Code, ",\n", rl_file__write_instruction),
 	io__write_string("\n\t]\n)").
+
+:- pred rl_file__write_instruction(bytecode::in,
+		io__state::di, io__state::uo) is det.
+
+rl_file__write_instruction(Bytecode) -->
+	(
+		% Make the code easier to read by not indenting
+		% certain instructions.
+		{ Bytecode \= rl_PROC_materialise(_) },
+		{ Bytecode \= rl_PROC_bind_handle(_) },
+		{ Bytecode \= rl_PROC_bind_code(_) },
+		{ Bytecode \= rl_PROC_label(_) },
+		{ Bytecode \= rl_PROC_conditional_goto(_) },
+		{ Bytecode \= rl_PROC_conditional_goto_label(_) },
+		{ Bytecode \= rl_PROC_goto(_) },
+		{ Bytecode \= rl_PROC_goto_label(_) },
+		{ Bytecode \= rl_PROC_call(_) }
+	->
+		io__write_string("\t")
+	;
+		[]
+	),
+	io__write(Bytecode),
+	(
+		% Make it easier to pick out the end of a
+		% materialise instruction.
+		{ Bytecode = rl_PROC_var_list_nil }
+	->
+		io__write_string("\n\t")
+	;
+		[]
+	).
 
 %-----------------------------------------------------------------------------%
 
--------------------------------------------------------------------------
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