mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-16 18:03:36 +00:00
Estimated hours taken: 16
Extend the layout scheme to handle typeinfos inside typeclass infos,
and thus enable the debugger (and later native gc) to work with programs
that use type classes and existential types.
compiler/llds.m:
Change the data structure that holds information about the locations
of the typeinfo variables of the tvars active at call return sites
from set(pair(tvar, lval)) to map(tvar, set(layout_locn)).
The change from set to map avoids the possibility of inadvertently
duplicating the info for a give type variable.
The change to explicitly keep a set of locations in which the typeinfo
var may be found allows us to use set intersection on those sets if
(a) the program point may be reached via more than one path, and
(b) not all paths have the same sets. Both of these can happen in
programs that use type classes.
The change from lval to layout_locn (which encodes either an lval,
or an lval representing a typeclass info and an (indirect) offset
inside that typeclass info) is necessary support programs with
type classes.
compiler/continuation_info.m:
Change the data structure that holds information about the locations
of the typeinfo variables of the tvars active at a particular program
point the same way and for the same reasons as in llds.m.
Take set intersections of typeinfo var locations whenever we find
multiple live variable info records for the same label.
compiler/call_gen.m:
Delay the construction of the return live variable information
until the code generator state has been updated to reflect where
things will be on return, instead of trying to cobble up this
info into the code generator state that reflects the point just
before the call. Apart from being cleaner, this is necessary
to avoid compiler aborts for programs that use existential types.
The old compiler could not find the typeinfos of any existentially
quantified type vars, since they do not exist before the call.
compiler/code_info.m:
Rewrite and generalize the code for generating live value information.
compiler/trace.m:
Remove the specialized code for generating live value information;
call code_info instead.
compiler/stack_layout.m:
Pick one of several possible locations for a typeinfo var.
Generate the new indirect layout location descriptions.
Reduce the number of tag bits used to describe different kinds of
lvals, to leave more room for the indirect information.
compiler/*.m:
Conform to the above data structure changes.
compiler/hlds_pred.m:
Clarify the documentation of type_info_locn.
runtime/mercury_stack_layout.h:
Update the section that deals with MR_Live_Lval to take
indirect typeinfo locations into account.
runtime/mercury_layout_util.c:
Handle indirect typeinfo locations when interpreting layout structures.
runtime/mercury_layout_util.c:
trace/mercury_trace_internal.c:
Ignore variables whose names start with TypeClassInfo.
runtime/mercury_accurate_gc.c:
runtime/mercury_agc_debug.c:
Add markers to remind Tyson to handle indirect typeinfo locations.
tests/debugger/implied_instance.{m,inp,exp}:
tests/debugger/multi_paramster.{m,inp,exp}:
tests/debugger/existential_type_classes.{m,inp,exp}:
Copies of the tests in tests/hard_coded/typeclasses, modified to
avoid or delay I/O, so that the calls to I/O preds that may or may
not be traced to do not affect the output.
tests/debugger/Mmakefile:
Add the new test cases.
Remove references to the *_lib variants of the old test cases.
They are not necessary if I/O is delayed until after the last
reported trace event.
tests/hard_coded/typeclasses/Mmakefile:
Remove --trace deep from existential_type_classes, since that
aspect of the test case is now covered in the debugger directory.
33 lines
463 B
Mathematica
33 lines
463 B
Mathematica
|
|
:- module multi_parameter.
|
|
|
|
:- interface.
|
|
|
|
:- import_module io.
|
|
|
|
:- pred main(io__state::di, io__state::uo) is det.
|
|
|
|
:- implementation.
|
|
|
|
:- import_module char.
|
|
|
|
:- typeclass m(A, B) where [
|
|
pred a(A, B),
|
|
mode a(in, out) is det
|
|
].
|
|
|
|
:- instance m(char, int) where [
|
|
pred(a/2) is char__to_int
|
|
].
|
|
|
|
main -->
|
|
{ foo('z', X) },
|
|
io__write_int(X),
|
|
io__nl.
|
|
|
|
:- pred foo(A, B) <= m(A,B).
|
|
:- mode foo(in, out) is det.
|
|
:- pragma no_inline(foo/2).
|
|
|
|
foo(X, Y) :- a(X, Y).
|