mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 01:13:30 +00:00
trace/mercury_trace_cmd_developer.c:
trace/mercury_trace_tables.[ch]:
Add two options to the mdb command "ambiguity".
Print ambiguities between function and predicate forms of the same
operation, such as list.length, only if the new option -b, or
--both-pred-and-func, is given.
Print ambiguities involving procedures that were created by type
specialization only if the new option -s, or --typespec is given.
(The -t option name was already taken.)
These changes remove from the ambiguity command's output
(some of) the parts that are not useful when one wants to eliminate
ambiguities by renaming.
Clarify a heading.
doc/user_guide.texi:
Document the above changes.
runtime/mercury_proc_id.h:
Fix a field name that has become misleading.
MR_UserProcId_Structs have a field named MR_user_arity.
In this name, the "MR_user_" part is a prefix shared by the other
fields in that structure, to indicate that they are part of the id
of a user-defined procedure, as opposed to a compiler-created
unify, compare or index procedure. However, the arity it contains
is what the compiler now calls a pred_form_arity: it does not count
type_info and typeclass_info arguments added by polymorphism, but
it *does* count function return values for functions. This is now
misleading, because in the compiler, a user_arity does *not* count
function return values for functions.
Replace this field name with MR_user_pred_form_arity, which tells
readers that this arity is a pred_form_arity. The presence of the
"user" part of the name may still cause some confusion, but at least
that confusion should motivate readers to look up the field name,
whose comment should clarify things.
mdbcomp/rtti_access.m:
runtime/mercury_debug.c:
runtime/mercury_deep_profiling.c:
runtime/mercury_ho_call.c:
runtime/mercury_layout_util.c:
runtime/mercury_ml_expand_body.h:
runtime/mercury_stack_layout.h:
runtime/mercury_trace_base.c:
trace/mercury_trace.c:
trace/mercury_trace_external.c:
trace/mercury_trace_util.c:
Conform to the change in mercury_proc_id.h.
tests/debugger/ambiguity.{m,inp,exp}:
tests/debugger/ambiguity_helper.m:
Expand this test case to test the new functionality.
The type specialized predicates are in a new helper module,
because this is the simplest way to avoid dead procedure elimination
deleting any of the predicates whose names we want to test for ambiguities.
72 lines
1.3 KiB
Mathematica
72 lines
1.3 KiB
Mathematica
%---------------------------------------------------------------------------%
|
|
% vim: ts=4 sw=4 et ft=mercury
|
|
%---------------------------------------------------------------------------%
|
|
|
|
:- module ambiguity.
|
|
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io::di, io::uo) is det.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module ambiguity_helper.
|
|
|
|
:- import_module float.
|
|
:- import_module int.
|
|
:- import_module list.
|
|
|
|
%---------------------%
|
|
|
|
:- type t
|
|
---> t1
|
|
; t2.
|
|
|
|
:- type t2
|
|
---> t1(int)
|
|
; t1(int, float)
|
|
; u1(t2).
|
|
|
|
:- type t(T)
|
|
---> u1
|
|
; u2(T).
|
|
|
|
%---------------------%
|
|
|
|
main(!IO) :-
|
|
io.write_line(p(2.5), !IO),
|
|
io.write_line(p(1, t1), !IO),
|
|
io.write_line(p(0, 1, u2(42)), !IO),
|
|
p(1, X),
|
|
io.write_line(X, !IO),
|
|
|
|
ListA = [1, 2],
|
|
ListB = [3.0, 4.0, 5.0],
|
|
get_length_sum(ListA, SumA, LenA),
|
|
get_length_sum_via_acc(ListB, _SumB, LenB),
|
|
add_int(SumA, add_int(LenA, LenB), TotalInt),
|
|
io.write_line(TotalInt, !IO),
|
|
|
|
add_float(3.3, add_float(4.4, 5.5), TotalFloat),
|
|
io.write_line(TotalFloat, !IO).
|
|
|
|
%---------------------%
|
|
|
|
:- func p(float) = float.
|
|
|
|
p(F) = F.
|
|
|
|
:- func p(int, t) = t.
|
|
|
|
p(_, T) = T.
|
|
|
|
:- func p(int, int, t(T)) = t(T).
|
|
|
|
p(_, _, T) = T.
|
|
|
|
:- pred p(int::in, int::out) is det.
|
|
|
|
p(I, I).
|