[m-dev.] for review: cleanup of type_ctor_infos, relative diff 1

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Mar 8 19:14:27 AEDT 2000


On 08-Mar-2000, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> diff -rub --exclude CVS ws15.base/compiler/hlds_module.m /home/ender2/zs/ws15/compiler/hlds_module.m
> --- ws15.base/compiler/hlds_module.m	Sat Feb 26 11:50:25 2000
> +++ /home/ender2/zs/ws15/compiler/hlds_module.m	Wed Mar  1 13:36:44 2000
...
> -:- type module_sub_info
> -	--->	module_sub(
> +:- type module_sub_info --->
> +	module_sub(

That change does not match the layout conventions documented
in the "Layout" section of our Mercury coding standard.

> diff -rub --exclude CVS ws15.base/runtime/mercury_deep_copy_body.h /home/ender2/zs/ws15/runtime/mercury_deep_copy_body.h
...
> @@ -513,9 +556,14 @@
>      case MR_TYPECTOR_REP_STRING:
>          {
>              Word    *data_value;
> -            int     data_tag; 
> +			Word	data_tag;
> +
> +			/*
> +			** Not all Mercury strings are aligned; in particular,
> +			** string constants containing the empty string may be
> +			** allocated unaligned storage by the C compiler.
> +			*/
>  
> -            /* XXX simplify: tag should be zero */
>              data_tag = MR_tag(data);
>              data_value = (Word *) MR_body(data, data_tag);

Hmm, the code here doesn't make sense in light of the comment.
If the pointer is not aligned, won't stripping off the tag
give the wrong result?

> diff -rub --exclude CVS ws15.base/runtime/mercury_type_info.h /home/ender2/zs/ws15/runtime/mercury_type_info.h
> +#define	MR_arg_type_may_contain_var(functor_desc, arg_num)		     \
> +	(arg_num >= MR_ARG_TYPE_CONTAINS_VAR_BIT_VECTOR_SIZE ||		     \
> +	(functor_desc->MR_du_functor_arg_type_contains_var & (1 << arg_num)) \
> +		!= 0)
> +
> +#define	MR_any_arg_type_may_contain_var(functor_desc)			     \
> +	(functor_desc->MR_du_functor_orig_arity >			     \
> +		MR_ARG_TYPE_CONTAINS_VAR_BIT_VECTOR_SIZE ||		     \
> +	functor_desc->MR_du_functor_arg_type_contains_var > 0)

The uses of arguments to those macros should be in parentheses.

> +** A value of type MR_DuTypeLayout points to an array of MR_DuPtagLayout
> +** structures. The element at index k gives information primary tag value k.

s/information/information about/

>  ** This type describes the layout in any kind of discriminated union
>  ** type: du, enum and notag. In an equivalence type, it gives the identity
>  ** of the equivalent-to type.
> +** 
> +** The layout_init alternative is used only for initialization.

It's still not clear to me why the layout_init alternative is needed.

> +** The functors_init alternative is used only for initialization.

Likewise.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list