[m-rev.] for review: printing higher order values and typeinfos in the debugger
Zoltan Somogyi
zs at cs.mu.OZ.AU
Mon Feb 25 01:25:39 AEDT 2002
On 24-Feb-2002, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > % the [....] shorthand.
> > % - for user-defined types with user-defined equality, the
> > % functor will be of the form <<module:type/arity>>/0, except
>
> I think the "/0" doesn't belong there.
Fixed.
> This is wrong.
>
> For example, if I have
>
> :- type foo(X, Y) == bar(Y, X).
>
> then the type constructor foo/2 is definitely not equivalent to
> the type constructor bar/2.
Ok, that convinces me. I don't know why, but I didn't even think about
switching tvars like that.
> This is wrong because it uses MR_collapse_ctor_equivalences().
Is simply returning the name of the type_ctor_info the right thing then?
I think it is, because I don't think we have any mechanism that allows users
(as opposed to implementors) to extract a type_ctor_info from a type_info.
BTW, the predicate type_ctor_and_args, which among other things extracts a
type_ctor_desc from a type_desc, is det, not cc_multi, but it is documented
to expand equivalences in the type_desc first.
> Also, don't you need to append "/<arity>" to the name returned
> by MR_type_ctor_name()?
Yes.
Here is the proposed diff.
Zoltan.
cvs diff: Diffing .
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing java
cvs diff: Diffing java/library
cvs diff: Diffing java/runtime
cvs diff: Diffing library
Index: library/deconstruct.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/deconstruct.m,v
retrieving revision 1.5
diff -u -b -r1.5 deconstruct.m
--- library/deconstruct.m 2002/02/24 11:53:29 1.5
+++ library/deconstruct.m 2002/02/24 13:12:16
@@ -54,7 +54,7 @@
% the functors [|]/2 and []/0 are used, even if the list uses
% the [....] shorthand.
% - for user-defined types with user-defined equality, the
- % functor will be of the form <<module:type/arity>>/0, except
+ % functor will be of the form <<module:type/arity>>, except
% with include_details_cc, in which case the type will be
% handled as if it had standard equality.
% - for integers, the string is a base 10 number;
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
Index: runtime/mercury_deconstruct.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_deconstruct.c,v
retrieving revision 1.7
diff -u -b -r1.7 mercury_deconstruct.c
--- runtime/mercury_deconstruct.c 2002/02/22 01:14:18 1.7
+++ runtime/mercury_deconstruct.c 2002/02/24 13:56:10
@@ -18,7 +18,7 @@
#include "mercury_deconstruct.h"
#include "mercury_deconstruct_macros.h"
-static MR_ConstString MR_expand_type_name(MR_TypeCtorInfo tci);
+static MR_ConstString MR_expand_type_name(MR_TypeCtorInfo tci, MR_bool);
#define EXPAND_FUNCTION_NAME MR_expand_functor_args
#define EXPAND_TYPE_NAME MR_Expand_Functor_Args_Info
@@ -265,19 +265,20 @@
}
static MR_ConstString
-MR_expand_type_name(MR_TypeCtorInfo tci)
+MR_expand_type_name(MR_TypeCtorInfo tci, MR_bool wrap)
{
MR_String str;
int len;
len = 0;
- len += 2; /* << */
len += strlen(tci->MR_type_ctor_module_name);
len += 1; /* : */
len += strlen(tci->MR_type_ctor_name);
len += 1; /* / */
len += 4; /* arity; we do not support arities above 1024 */
- len += 2; /* >> */
+ if (wrap) {
+ len += 4; /* <<>> */
+ }
len += 1; /* NULL */
if (tci->MR_type_ctor_arity > 9999) {
@@ -288,11 +289,17 @@
MR_allocate_aligned_string_msg(str, len, "MR_expand_type_name");
MR_save_transient_hp();
+ if (wrap) {
sprintf(str, "<<%s:%s/%d>>",
tci->MR_type_ctor_module_name,
tci->MR_type_ctor_name,
tci->MR_type_ctor_arity);
-
+ } else {
+ sprintf(str, "%s:%s/%d",
+ tci->MR_type_ctor_module_name,
+ tci->MR_type_ctor_name,
+ tci->MR_type_ctor_arity);
+ }
return (MR_ConstString) str;
}
Index: runtime/mercury_ml_expand_body.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_ml_expand_body.h,v
retrieving revision 1.16
diff -u -b -r1.16 mercury_ml_expand_body.h
--- runtime/mercury_ml_expand_body.h 2002/02/24 11:53:33 1.16
+++ runtime/mercury_ml_expand_body.h 2002/02/24 13:56:27
@@ -162,17 +162,29 @@
do { \
MR_ConstString name; \
\
- name = MR_expand_type_name(tci); \
+ name = MR_expand_type_name(tci, MR_TRUE); \
MR_restore_transient_hp(); \
MR_make_aligned_string(expand_info->EXPAND_FUNCTOR_FIELD,\
name); \
MR_save_transient_hp(); \
} while (0)
+ #define handle_type_ctor_name(tci) \
+ do { \
+ MR_ConstString name; \
+ \
+ name = MR_expand_type_name(tci, MR_FALSE); \
+ MR_restore_transient_hp(); \
+ MR_make_aligned_string(expand_info->EXPAND_FUNCTOR_FIELD,\
+ name); \
+ MR_save_transient_hp(); \
+ } while (0)
#else /* EXPAND_FUNCTOR_FIELD */
#define handle_functor_name(name) \
((void) 0)
#define handle_noncanonical_name(tci) \
((void) 0)
+ #define handle_type_ctor_name(tci) \
+ ((void) 0)
#endif /* EXPAND_FUNCTOR_FIELD */
/* set up macros for the common code handling zero arity terms */
@@ -969,36 +981,14 @@
{
MR_TypeCtorInfo data_type_ctor_info;
- /*
- ** The only source of noncanonicality in typeinfos is due
- ** to type equivalences, Unfortunately, for type_ctor_infos,
- ** there is another source: after expanding out equivalences,
- ** the resulting `type' may be a type variable. Since the
- ** printable representation of this type variable is arbitrary,
- ** we avoid noncanonicality by always printing it the same way.
- ** Note that the outermost type_ctor_info cannot be a variable.
- */
-
if (noncanon == MR_NONCANON_ABORT) {
/* XXX should throw an exception */
MR_fatal_error(MR_STRINGIFY(EXPAND_FUNCTION_NAME)
": attempt to deconstruct noncanonical term");
}
-
data_type_ctor_info = (MR_TypeCtorInfo) *data_word_ptr;
-
- if (noncanon == MR_NONCANON_ALLOW) {
- data_type_ctor_info =
- MR_collapse_ctor_equivalences(data_type_ctor_info);
- }
-
- if (data_type_ctor_info == NULL) {
- handle_functor_name("<<typevariable>>");
- } else {
- handle_functor_name(MR_type_ctor_name(data_type_ctor_info));
- }
-
+ handle_type_ctor_name(data_type_ctor_info);
handle_zero_arity_args();
}
@@ -1132,6 +1122,7 @@
#undef EXPAND_ONE_ARG
#undef handle_functor_name
#undef handle_noncanonical_name
+#undef handle_type_ctor_name
#undef handle_zero_arity_args
#undef handle_zero_arity_all_args
#undef handle_zero_arity_one_arg
Index: runtime/mercury_type_info.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_type_info.c,v
retrieving revision 1.48
diff -u -b -r1.48 mercury_type_info.c
--- runtime/mercury_type_info.c 2002/02/24 11:53:34 1.48
+++ runtime/mercury_type_info.c 2002/02/24 13:20:33
@@ -247,29 +247,6 @@
return maybe_equiv_type_info;
}
-MR_TypeCtorInfo
-MR_collapse_ctor_equivalences(MR_TypeCtorInfo type_ctor_info)
-{
- MR_PseudoTypeInfo pseudo_type_info;
-
- /* Look past equivalences */
- while (MR_type_ctor_rep(type_ctor_info) == MR_TYPECTOR_REP_EQUIV_GROUND
- || MR_type_ctor_rep(type_ctor_info) == MR_TYPECTOR_REP_EQUIV)
- {
-
- pseudo_type_info = MR_type_ctor_layout(type_ctor_info).
- layout_equiv;
- if (MR_PSEUDO_TYPEINFO_IS_VARIABLE(pseudo_type_info)) {
- return NULL;
- }
-
- type_ctor_info =
- MR_PSEUDO_TYPEINFO_GET_TYPE_CTOR_INFO(pseudo_type_info);
- }
-
- return type_ctor_info;
-}
-
/*
** MR_deallocate() frees up a list of memory cells
*/
Index: runtime/mercury_type_info.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_type_info.h,v
retrieving revision 1.86
diff -u -b -r1.86 mercury_type_info.h
--- runtime/mercury_type_info.h 2002/02/24 11:53:35 1.86
+++ runtime/mercury_type_info.h 2002/02/24 13:20:52
@@ -1244,19 +1244,6 @@
extern MR_TypeInfo MR_collapse_equivalences(MR_TypeInfo type_info);
-/*
-** MR_collapse_ctor_equivalences expands out all the top-level equivalences in
-** the argument type constructor. It guarantees that the returned type
-** constructor will not have a MR_TYPE_CTOR_REP_EQUIV* representation.
-** However, it is possible that a chain of equivalences ends in a type
-** variable. If this happens, MR_collapse_ctor_equivalences will return NULL.
-**
-** You need to wrap MR_{save/restore}_transient_hp() around
-** calls to this function.
-*/
-
-extern MR_TypeCtorInfo MR_collapse_ctor_equivalences(MR_TypeCtorInfo tci);
-
/*
** MR_create_type and MR_make_type_info both turn a pseudo typeinfo into
** a typeinfo, looking up the typeinfos associated with the type variables
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
--------------------------------------------------------------------------
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