[m-rev.] for review: --warn-non-tail-recursion
Fergus Henderson
fjh at cs.mu.OZ.AU
Wed Feb 13 03:33:39 AEDT 2002
On 12-Feb-2002, Peter Ross <peter.ross at miscrit.be> wrote:
>
> Well as I see it the advantage of including the proc_id is that it would
> allow one to report which mode is non tail recursive. I think this
> would be useful information as not all modes of a procedure will be tail
> recursive. So I suggest that you do it.
Here's the relative diff for that.
--- old/ml_tailcall.m Wed Feb 13 03:15:58 2002
+++ ./ml_tailcall.m Wed Feb 13 03:24:16 2002
@@ -74,8 +74,8 @@
%-----------------------------------------------------------------------------%
:- implementation.
-:- import_module prog_data, hlds_out, error_util, ml_util.
-:- import_module list, std_util.
+:- import_module prog_data, hlds_pred, hlds_out, error_util, ml_util.
+:- import_module string, int, list, std_util.
ml_mark_tailcalls(MLDS0, MLDS) -->
{ MLDS0 = mlds(ModuleName, ForeignCode, Imports, Defns0) },
@@ -564,7 +564,7 @@
:- type tailcall_warning ---> tailcall_warning(
mlds__pred_label,
- % XXX perhaps we should also include the proc_id here
+ proc_id,
mlds__context
).
@@ -616,19 +616,23 @@
QualProcLabel = qual(CallerModule, PredLabel - ProcId),
CallerFuncName = function(PredLabel, ProcId, MaybeSeqNum, _PredId),
% if so, construct an appropriate warning
- Warning = tailcall_warning(PredLabel, Context). % XXX include ProcId?
+ Warning = tailcall_warning(PredLabel, ProcId, Context).
:- pred report_nontailcall_warning(tailcall_warning::in,
io__state::di, io__state::uo) is det.
-report_nontailcall_warning(tailcall_warning(PredLabel, Context)) -->
+report_nontailcall_warning(tailcall_warning(PredLabel, ProcId, Context)) -->
(
{ PredLabel = pred(PredOrFunc, _MaybeModule, Name, Arity,
_CodeModel, _NonOutputFunc) },
{ hlds_out__simple_call_id_to_string(PredOrFunc -
unqualified(Name) / Arity, CallId) },
+ { proc_id_to_int(ProcId, ProcNumber0) },
+ { ProcNumber = ProcNumber0 + 1 },
+ { ProcNumberStr = string__int_to_string(ProcNumber) },
report_warning(mlds__get_prog_context(Context), 0, [
- words("In "), fixed(CallId), nl,
+ words("In mode number"), words(ProcNumberStr),
+ words("of"), fixed(CallId ++ ":"), nl,
words(" warning: recursive call is not tail recursive.")
])
;
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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