Files
mercury/tests/valid/testxmlreader.m
Zoltan Somogyi 22cead47a7 Fix bug #28 in Mantis. The only substantive change is to code_info.m; the
Estimated hours taken: 4
Branches: main

Fix bug #28 in Mantis. The only substantive change is to code_info.m; the
changes to the other compiler modules are cosmetic only.

compiler/code_info.m:
	Fix bug #28 in Mantis. The problem was with the code that generated the
	annotation giving the set of live lvalues at calls: it didn't delete
	from the set the registers used for passing dummy arguments, such as
	I/O states. A recursive call for an I/O predicate would thus compute
	the correct set of live lvalues at the start of the predicate body
	(in the case of the test case, {r1}), but the wrong set at the
	recursive call ((in the case of the test case, {r1,r2}, with r2
	being the register assigned to hold the I/O state argument). The bug
	was an abort caused by a sanity check looking for this kind of
	mismatch.

compiler/c_util.m:
	Make two predicates into functions to make them easier to use.

compiler/opt_debug.m:
	Use those functions.

compiler/ml_code_gen.m:
compiler/pragma_c_gen.m:
	Conform to the change to c_util.

compiler/jumpopt.m:
	Delete unnecessary module qualifications.

tests/valid/testxmlreader.m:
tests/valid/xmlreader.m:
	A regression test for this bug. It is in valid rather than hard_coded
	because it cannot be made executable without libraries that not all
	machines have, and which it would be inappropriate to add to the test
	suite itself.

tests/valid/Mmakefile:
	Enable the new test case.
2007-11-19 06:36:31 +00:00

63 lines
1.4 KiB
Mathematica

% vim: ts=4 sw=4 et ft=mercury
%
% This is a regression test for bug #28 in Mantis.
:- module testxmlreader.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module list, maybe, require, string, int.
:- import_module xmlreader.
main(!IO) :-
io.command_line_arguments(Args, !IO),
( Args = [TFN] ->
FN = TFN
;
error("usage: testxmlreader file.xml")
),
xmlreader.open_file(FN, MayR, !IO),
(
MayR = yes(R),
dump_all_and_close(R, !IO)
;
MayR = no,
error("Cannot read '" ++ FN ++ "'.")
).
:- pred dump_all_and_close(xmlreader::di, io::di, io::uo) is det.
dump_all_and_close(R, !IO) :-
read(E, R, R2),
(
E = eof,
close_reader(R2, !IO)
;
E = error(Err),
close_reader(R2, !IO),
error("Parsing error: "++int_to_string(Err))
;
E = node(D, T, N, Empty, MV),
(
MV = yes(V),
( length(V) > 40 ->
UseV = string.left(V, 40)
;
UseV = V
)
;
MV = no,
UseV = ""
),
io.format("%d %d %s %s %s\n",
[i(D), i(T), s(N), s(string(Empty)), s(UseV)], !IO),
dump_all_and_close(R2, !IO),
% io.write_string("", !IO), % prevent tail recursion
true
).