[m-rev.] for review: MR_DEFINE_ENUM_CONST
Fergus Henderson
fjh at cs.mu.OZ.AU
Wed May 30 17:01:59 AEST 2001
On 30-May-2001, David Jeffery <dgj at cs.mu.OZ.AU> wrote:
> Index: runtime/mercury_tags.h
> ===================================================================
> RCS file: /home/staff/zs/imp/mercury/runtime/mercury_tags.h,v
> retrieving revision 1.11
> diff -u -t -r1.11 mercury_tags.h
> --- runtime/mercury_tags.h 2001/03/18 23:10:13 1.11
> +++ runtime/mercury_tags.h 2001/05/30 05:28:03
> @@ -137,4 +137,23 @@
>
> #endif
>
> +/*
> +** Convert an enumeration declaration into one which assigns the same
> +** values to the enumeration constants as Mercury's tag allocation scheme
> +** assigns. (This is necessary because in .rt grades Mercury enumerations are
> +** not assigned the same values as 'normal' C enumerations).
> +**
> +*/
> +#ifdef MR_RESERVE_TAG
> + #define MR_CONVERT_C_ENUM_CONSTANT(x) \
> + MR_mkword(MR_mktag(MR_FIRST_UNRESERVED_RAW_TAG), MR_mkbody(x))
> +#else
> + #define MR_CONVERT_C_ENUM_CONSTANT(x) (x)
> +#endif
> +
> +#define MR_DEFINE_ENUM_CONST(x) \
> + MR_PASTE2(x, _val), \
> + x = MR_CONVERT_C_ENUM_CONSTANT(MR_PASTE2(x, _val)), \
> + MR_PASTE2(x, _dummy) = MR_PASTE2(x, _val)
I think you might as well put the MR_DEFINE_ENUM_CONST() inside the
#ifdef too, for the same reason that MR_CONVERT_C_ENUM_CONSTANT is
inside the #ifdef: making it easier to understand what happens in the
usual case. In the #else case it can be just
#define MR_DEFINE_ENUM_CONST(x) (x)
can't it?
I think it might be slightly clearer to name MR_DEFINE_ENUM_CONST
as MR_DEFINE_MERCURY_ENUM_CONST.
Otherwise that change looks fine -- thanks.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
| 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