[m-rev.] for review: printing higher order values and typeinfos in the debugger

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Feb 22 13:15:50 AEDT 2002


On 22-Feb-2002, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> 
> --- browser/browse.m	28 Jan 2002 07:20:09 -0000	1.26
>  portray_flat_write_browser_term(synthetic_term(Functor, Args, MaybeReturn)) -->
>  	io__write_string(Functor),
> +	io__current_output_stream(Stream),
>  	( { Args = [] } ->
>  		[]
>  	;
>  		io__write_string("("),
> -		io__write_list(Args, ", ", io__write_univ),
> +		io__write_list(Args, ", ",
> +			pred(U::in, S0::di, S::uo) is cc_multi :-
> +				io__write_univ(Stream, include_details_cc, U,
> +					S0, S)),

Use a DCG lambda expression:

			pred(U::in, di, uo) is cc_multi -->
				io__write_univ(Stream, include_details_cc, U)

> +++ compiler/pd_debug.m	21 Feb 2002 13:26:28 -0000
> @@ -162,8 +162,10 @@
>  pd_debug__write_pred_proc_id_list(PredProcIds) -->
>  	pd_info_get_module_info(ModuleInfo),
>  	pd_debug__do_io(
> +		pred(S0::di, S::uo) is det :-
>  		io__write_list(PredProcIds, ", ",
> -			pd_debug__write_pred_proc_id(ModuleInfo))
> +				pd_debug__write_pred_proc_id(ModuleInfo),
> +				S0, S)

Likewise.

> +++ compiler/rl_analyse.m	21 Feb 2002 13:29:12 -0000
> @@ -242,10 +242,11 @@
>  
>  rl_analyse__dump_block_data_map(Analysis, Blocks, BlockDataMap, Globals) -->
>  	rl_analyse__do_io(
> +		pred(S0::di, S::uo) is det :-
>  		io__write_list(Blocks, "\n",
>  			rl_analyse__dump_block_data(Analysis,
> -				BlockDataMap, Globals)
> -		)
> +					BlockDataMap, Globals),
> +				S0, S)

Likewise.

> +++ library/deconstruct.m	21 Feb 2002 15:36:46 -0000
> @@ -49,34 +49,36 @@
>  	% The string representation of the functor that these predicates
>  	% return is:
>  	%
> -	% 	- for user defined types, the functor that is given
> -	% 	  in the type definition. For lists, this
> -	% 	  means the functors [|]/2 and []/0 are used, even if
> -	% 	  the list uses the [....] shorthand.
> -	%	  For types with user-defined equality, the functor will be
> -	%	  a constant of the form <<module:type/arity>>/0 except
> +	% 	- for user defined types with standard equality, the functor
> +	%	  that is given in the type definition. For lists, this means
> +	%	  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
>  	%	  with include_details_cc.

The documentation doesn't explain what happens for user-defined types
with user-defined equality when include_details_cc is specified.

> +	%	- for predicates, the string <<predicate>>, and for functions,
> +	%	  the string <<function>>, except with include_details_cc.

Likewise here.

>  	% The arity that these predicates return is:
>  	%
> +	% 	- for user defined types with user-defined equality, zero,
> +	%	  except with include_details_cc.
...
> +	%	- for predicates and functions, zero, except with
> +	%	  include_details_cc.

And here.

> Index: library/io.m

The changes to io.m should be mentioned in the NEWS file.

> Index: runtime/mercury_ml_expand_body.h
...
>          case MR_TYPECTOR_REP_TUPLE:
>              expand_info->arity = MR_TYPEINFO_GET_TUPLE_ARITY(type_info);
> @@ -783,11 +878,79 @@
>                  /* XXX should throw an exception */
>                  MR_fatal_error(MR_STRINGIFY(EXPAND_FUNCTION_NAME)
>                      ": attempt to deconstruct noncanonical term");
> -                break;
> -            }
> -
> +            } else if (noncanon == MR_NONCANON_ALLOW) {
>              handle_functor_name("<<typeinfo>>");
>              handle_zero_arity_args();

For typeinfos, if noncanon == MR_NONCANON_ALLOW,
it would be better to just call MR_collapse_equivalences()
and then proceed as for the noncan == MR_NONCANON_CC case.

> @@ -795,11 +958,17 @@
>                  /* XXX should throw an exception */
>                  MR_fatal_error(MR_STRINGIFY(EXPAND_FUNCTION_NAME)
>                      ": attempt to deconstruct noncanonical term");
> -                break;
> -            }
> -
> +            } else if (noncanon == MR_NONCANON_ALLOW) {
>              handle_functor_name("<<typectorinfo>>");
>              handle_zero_arity_args();
> +            } else {
> +                MR_TypeCtorInfo data_type_ctor_info; 
> +
> +                data_type_ctor_info = (MR_TypeCtorInfo) *data_word_ptr;
> +                handle_functor_name(MR_type_ctor_name(data_type_ctor_info));
> +                handle_zero_arity_args();
> +            }
> +

I don't think type_ctor_infos are a non-canonical type, are they?

You should be able to expand them unconditionally.

> +++ trace/mercury_trace_internal.c	21 Feb 2002 16:22:34 -0000
...
> +MR_bool		MR_print_optionals = MR_FALSE;

The meaning of that variable should be documented here.

> Index: trace/mercury_trace_vars.c
>  static	MR_TypeCtorInfo
> +MR_trace_always_ignored_type_ctors[] =
>  {
> +	/* we ignore these until the debugger can handle their varying arity */
>  	&mercury_data_type_desc__type_ctor_info_type_desc_0,
>  	&mercury_data_type_desc__type_ctor_info_type_ctor_desc_0,

These should not be ignored; they are useful to the user, and if
std_util__deconstruct can't handle them, that is a bug which should
be fixed.

So at very least there should be an XXX with that comment.

Otherwise that change looks fine.

-- 
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