mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 17:33:38 +00:00
Use full error_specs instead of pieces.
compiler/compile_target_code.m:
compiler/fact_table.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/module_cmds.m:
compiler/pred_table.m:
Replace calls to write_error_pieces* with code that constructs
full error_specs and then writes them out.
compiler/error_util.m:
Add a new phase, phase_fact_table_check, for the new code in fact_table.m.
This commit is contained in:
@@ -2759,8 +2759,10 @@ process_link_library(Globals, MercuryLibDirs, LibName, LinkerOpt, !Succeeded,
|
||||
;
|
||||
MaybeDirName = error(Error),
|
||||
LinkerOpt = "",
|
||||
write_error_pieces_maybe_with_context(Globals, no, 0,
|
||||
[words(Error)], !IO),
|
||||
Spec = error_spec($pred, severity_error, phase_read_files,
|
||||
[error_msg(no, treat_as_first, 0,
|
||||
[always([words(Error), suffix(".\n")])])]),
|
||||
write_error_spec_ignore(Globals, Spec, !IO),
|
||||
!:Succeeded = no
|
||||
)
|
||||
else
|
||||
|
||||
@@ -188,6 +188,7 @@
|
||||
; phase_mode_check(mode_report_control)
|
||||
; phase_purity_check
|
||||
; phase_detism_check
|
||||
; phase_fact_table_check
|
||||
; phase_oisu_check
|
||||
; phase_simplify(mode_report_control)
|
||||
; phase_style
|
||||
@@ -1197,6 +1198,7 @@ get_maybe_mode_report_control(phase_polymorphism) = no.
|
||||
get_maybe_mode_report_control(phase_mode_check(Control)) = yes(Control).
|
||||
get_maybe_mode_report_control(phase_purity_check) = no.
|
||||
get_maybe_mode_report_control(phase_detism_check) = no.
|
||||
get_maybe_mode_report_control(phase_fact_table_check) = no.
|
||||
get_maybe_mode_report_control(phase_oisu_check) = no.
|
||||
get_maybe_mode_report_control(phase_simplify(Control)) = yes(Control).
|
||||
get_maybe_mode_report_control(phase_style) = no.
|
||||
|
||||
@@ -1211,12 +1211,13 @@ infer_determinism_pass_2([ProcID - FileName | ProcFiles], Globals,
|
||||
)
|
||||
else
|
||||
io.progname_base("mercury_compile", ProgName, !IO),
|
||||
string.format(
|
||||
"%s: an error occurred in the `sort' program "
|
||||
++ "during fact table determinism inference.",
|
||||
[s(ProgName)], Msg),
|
||||
write_error_pieces_plain(Globals, [words(Msg)], !IO),
|
||||
io.set_exit_status(1, !IO),
|
||||
Pieces =
|
||||
[fixed(ProgName), suffix(":"), words("an error occurred"),
|
||||
words("in the"), quote("sort"), words("program"),
|
||||
words("during fact table determinism inference."), nl],
|
||||
Spec = error_spec($pred, severity_error, phase_fact_table_check,
|
||||
[error_msg(no, treat_as_first, 0, [always(Pieces)])]),
|
||||
write_error_spec_ignore(Globals, Spec, !IO),
|
||||
Determinism = detism_erroneous
|
||||
)
|
||||
;
|
||||
@@ -1399,10 +1400,11 @@ maybe_append_data_table(Globals, yes, OutputFileName, DataFileName, !IO) :-
|
||||
( if ExitStatus = 0 then
|
||||
true
|
||||
else
|
||||
Msg = "An error occurred while concatenating " ++
|
||||
"fact table output files.",
|
||||
write_error_pieces_plain(Globals, [words(Msg)], !IO),
|
||||
io.set_exit_status(1, !IO)
|
||||
Pieces = [words("An error occurred while concatenating"),
|
||||
words("fact table output files."), nl],
|
||||
Spec = error_spec($pred, severity_error, phase_fact_table_check,
|
||||
[error_msg(no, treat_as_first, 0, [always(Pieces)])]),
|
||||
write_error_spec_ignore(Globals, Spec, !IO)
|
||||
)
|
||||
;
|
||||
Result = error(ErrorCode),
|
||||
@@ -1565,11 +1567,13 @@ read_sort_file_line(FactArgInfos, ArgModes, ModuleInfo, MaybeSortFileLine,
|
||||
Result = error(ErrorCode),
|
||||
io.error_message(ErrorCode, ErrorMessage),
|
||||
io.input_stream_name(FileName, !IO),
|
||||
string.format("Error reading file `%s':", [s(FileName)], Msg),
|
||||
Pieces =
|
||||
[words("Error reading file"), quote(FileName), suffix(":"), nl,
|
||||
words(ErrorMessage), nl],
|
||||
Spec = error_spec($pred, severity_error, phase_fact_table_check,
|
||||
[error_msg(no, treat_as_first, 0, [always(Pieces)])]),
|
||||
module_info_get_globals(ModuleInfo, Globals),
|
||||
write_error_pieces_plain(Globals,
|
||||
[words(Msg), nl, words(ErrorMessage)], !IO),
|
||||
io.set_exit_status(1, !IO),
|
||||
write_error_spec_ignore(Globals, Spec, !IO),
|
||||
MaybeSortFileLine = no
|
||||
).
|
||||
|
||||
@@ -3371,11 +3375,12 @@ delete_temporary_file(Globals, FileName, !IO) :-
|
||||
Result = error(ErrorCode),
|
||||
io.error_message(ErrorCode, ErrorMsg),
|
||||
io.progname_base("mercury_compile", ProgName, !IO),
|
||||
string.format("%s: error deleting file `%s:",
|
||||
[s(ProgName), s(FileName)], Msg),
|
||||
Pieces = [words(Msg), nl, words(ErrorMsg), nl],
|
||||
write_error_pieces_plain(Globals, Pieces, !IO),
|
||||
io.set_exit_status(1, !IO)
|
||||
Pieces = [fixed(ProgName), suffix(":"), words("error deleting file"),
|
||||
quote(FileName), suffix(":"), nl,
|
||||
words(ErrorMsg), suffix("."), nl],
|
||||
Spec = error_spec($pred, severity_error, phase_fact_table_check,
|
||||
[error_msg(no, treat_as_first, 0, [always(Pieces)])]),
|
||||
write_error_spec_ignore(Globals, Spec, !IO)
|
||||
).
|
||||
|
||||
:- pred write_call_system_error_msg(globals::in, string::in, io.error::in,
|
||||
@@ -3384,10 +3389,12 @@ delete_temporary_file(Globals, FileName, !IO) :-
|
||||
write_call_system_error_msg(Globals, Cmd, ErrorCode, !IO) :-
|
||||
io.error_message(ErrorCode, ErrorMsg),
|
||||
io.progname_base("mercury_compile", ProgName, !IO),
|
||||
string.format("%s: error executing system command `%s:",
|
||||
[s(ProgName), s(Cmd)], Msg),
|
||||
write_error_pieces_plain(Globals, [words(Msg), nl, words(ErrorMsg)], !IO),
|
||||
io.set_exit_status(1, !IO).
|
||||
Pieces = [fixed(ProgName), suffix(":"),
|
||||
words("error executing system command"), quote(Cmd), suffix(":"), nl,
|
||||
words(ErrorMsg), suffix("."), nl],
|
||||
Spec = error_spec($pred, severity_error, phase_fact_table_check,
|
||||
[error_msg(no, treat_as_first, 0, [always(Pieces)])]),
|
||||
write_error_spec_ignore(Globals, Spec, !IO).
|
||||
|
||||
%-----------------------------------------------------------------------------%
|
||||
|
||||
@@ -3421,14 +3428,9 @@ print_error_reports(Globals, RevErrors, !IO) :-
|
||||
is det.
|
||||
|
||||
print_error_report(Globals, MaybeContext - Pieces, !IO) :-
|
||||
(
|
||||
MaybeContext = yes(Context),
|
||||
write_error_pieces(Globals, Context, 0, Pieces, !IO)
|
||||
;
|
||||
MaybeContext = no,
|
||||
write_error_pieces_plain(Globals, Pieces, !IO)
|
||||
),
|
||||
io.set_exit_status(1, !IO).
|
||||
Spec = error_spec($pred, severity_error, phase_fact_table_check,
|
||||
[error_msg(MaybeContext, treat_as_first, 0, [always(Pieces)])]),
|
||||
write_error_spec_ignore(Globals, Spec, !IO).
|
||||
|
||||
:- pred print_file_open_error(globals::in, maybe(context)::in, string::in,
|
||||
string::in, io.error::in, io::di, io::uo) is det.
|
||||
|
||||
@@ -75,6 +75,7 @@
|
||||
:- import_module top_level.mercury_compile_llds_back_end.
|
||||
|
||||
:- import_module getopt_io.
|
||||
:- import_module maybe.
|
||||
:- import_module pprint.
|
||||
:- import_module require.
|
||||
:- import_module string.
|
||||
@@ -306,12 +307,15 @@ maybe_add_heap_ops(Verbose, Stats, !HLDS, !IO) :-
|
||||
maybe_write_string(Verbose, "% done.\n", !IO),
|
||||
maybe_report_stats(Stats, !IO)
|
||||
else
|
||||
Msg = "Sorry, not implemented: `--high-level-code' and just one of " ++
|
||||
"`--reclaim-heap-on-semidet-failure' and " ++
|
||||
"`--reclaim-heap-on-nondet-failure'. " ++
|
||||
"Use `--(no-)reclaim-heap-on-failure' instead.",
|
||||
write_error_pieces_plain(Globals, [words(Msg)], !IO),
|
||||
io.set_exit_status(1, !IO)
|
||||
Pieces = [words("Sorry, not implemented:"),
|
||||
quote("--high-level-code"), words("and just one of"),
|
||||
quote("--reclaim-heap-on-semidet-failure"), words("and"),
|
||||
quote("--reclaim-heap-on-nondet-failure"), suffix("."),
|
||||
words("Use"), quote("--(no-)reclaim-heap-on-failure"),
|
||||
words("instead."), nl],
|
||||
Spec = error_spec($pred, severity_error, phase_read_files,
|
||||
[error_msg(no, treat_as_first, 0, [always(Pieces)])]),
|
||||
write_error_spec_ignore(Globals, Spec, !IO)
|
||||
).
|
||||
|
||||
:- pred maybe_mark_tail_rec_calls_hlds(bool::in, bool::in,
|
||||
|
||||
@@ -1208,8 +1208,10 @@ find_erlang_library_path(Globals, MercuryLibDirs, LibName, LibPath, !IO) :-
|
||||
;
|
||||
MaybeDirName = error(Error),
|
||||
LibPath = "",
|
||||
write_error_pieces_maybe_with_context(Globals, no, 0, [words(Error)],
|
||||
!IO)
|
||||
Spec = error_spec($pred, severity_error, phase_read_files,
|
||||
[error_msg(no, treat_as_first, 0,
|
||||
[always([words(Error), suffix(".\n")])])]),
|
||||
write_error_spec_ignore(Globals, Spec, !IO)
|
||||
).
|
||||
|
||||
:- func pa_option(bool, bool, dir_name) = string.
|
||||
|
||||
@@ -1063,7 +1063,9 @@ find_matching_pred_id(ModuleInfo, [PredId | PredIds], TVarSet, ExistQTVars,
|
||||
qual_pf_sym_name_orig_arity(OtherPredCallId), suffix("."),
|
||||
words("You need to use an explicit module qualifier."),
|
||||
nl],
|
||||
write_error_pieces(Globals, Context, 0, Pieces, !IO)
|
||||
Spec = simplest_spec($pred, severity_error, phase_type_check,
|
||||
Context, Pieces),
|
||||
write_error_spec_ignore(Globals, Spec, !IO)
|
||||
),
|
||||
unexpected($pred, "unresolvable predicate overloading")
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user