[m-rev.] Re: construct__get_functor bug
Fergus Henderson
fjh at cs.mu.OZ.AU
Fri Dec 20 04:03:30 AEDT 2002
[From mercury-developers]
On 19-Dec-2002, Peter Ross <pro at missioncriticalit.com> wrote:
> I would like comments [...]
...
> library/construct.m:
> Add a new version of get_functor which takes a term of the
> type we are trying to get the functor for. This allows one to
> handle functors with existentially quantified arguments.
I don't really understand how this is supposed to work,
i.e. what the purpose of the term is.
What happens if you call get_functor with a functor number
that doesn't match the functor in the term?
Also, what happens if you call get_functor with a term
whose type doesn't match the type_desc passed in?
It is probably best to just use the type_info `TypeInfo_for_T',
which gets implicitly passed to the C code, rather than
passing a type_desc in.
> runtime/mercury_construct.c:
> Add missing MR_TYPECTOR_REP_UNIV cases to the switch.
I think it would be better to add cases for that which call
MR_fatal_error("MR_TYPECTOR_REP_UNIV unexpected").
These cases should not occur anymore, since univ is not
treated specially anymore.
> +MR_bool
> +MR_may_contain_existq_type_infos(const MR_Word data,
> + const MR_TypeCtorInfo tci, MR_DuFunctorDesc **functor_desc,
> + MR_Word **arg_vector)
> +{
> + MR_DuTypeLayout du_type_layout;
> + switch(MR_type_ctor_rep(tci)) {
> + case MR_TYPECTOR_REP_DU:
> + case MR_TYPECTOR_REP_DU_USEREQ:
> + case MR_TYPECTOR_REP_UNIV:
> + {
> + const MR_DuPtagLayout *ptag_layout;
> + const MR_DuExistInfo *exist_info;
> + int ptag;
> + MR_Word sectag;
> +
> + ptag = MR_tag(data);
> + du_type_layout = MR_type_ctor_layout(tci).MR_layout_du;
> + ptag_layout = &du_type_layout[ptag];
> +
> + switch (ptag_layout->MR_sectag_locn) {
> + case MR_SECTAG_NONE:
> + *functor_desc = ptag_layout->MR_sectag_alternatives[0];
> + *arg_vector = (MR_Word *) MR_body(data, ptag);
> + break;
> + case MR_SECTAG_LOCAL:
> + sectag = MR_unmkbody(data);
> + *functor_desc =
> + ptag_layout->MR_sectag_alternatives[sectag];
> + *arg_vector = NULL;
> + break;
> + case MR_SECTAG_REMOTE:
> + sectag = MR_field(ptag, data, 0);
> + *functor_desc =
> + ptag_layout->MR_sectag_alternatives[sectag];
> + *arg_vector = (MR_Word *) MR_body(data, ptag) + 1;
> + break;
> + case MR_SECTAG_VARIABLE:
> + /* XXX how do I handle this case */
> + default:
> + MR_fatal_error("MR_may_contain_existq_type_infos"
> + ": invalid sectag_locn");
> + }
> +
> + return MR_TRUE;
> + }
> + default:
> + return MR_FALSE;
> + }
Misleading indentation: the "default:" and "return MR_FALSE" lines
should both be unintended four spaces.
--
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