[m-rev.] for review: fix construct__get_functor/6
Simon Taylor
stayl at cs.mu.OZ.AU
Fri Nov 22 02:13:51 AEDT 2002
On 21-Nov-2002, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On 21-Nov-2002, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> >
> > Estimated hours taken: 0.5
> > Branches: main, release
> >
> > runtime/mercury_type_info.c:
> > Fix a segfault in MR_arg_name_vector_to_list() (called by
> > construct__get_functor/6) when none of the fields of the
> > constructor being examined have names.
>
> You should update the documentation for this function in
> runtime/mercury_type_info.h to reflect this change.
Done.
>
> > tests/hard_coded/construct.{m,exp}:
> > Test construct__get_functor/6.
>
> The file names are test_construct.{m,exp} not construct.{m,exp}.
> Also you didn't post the diff for test_construct.m.
See below.
> > Index: library/construct.m
> ...
> > + for (i = 0; i < Arity; i++) {
> > + ArgNameList = MR_list_cons_msg(NULL,
> > + ArgNameList, MR_PROC_LABEL);
> > + }
>
> Here you are calling MR_list_cons_msg() with the argument NULL,
> whose type may be either an integer type or `void *',
> The argument to MR_list_cons_msg() should have type MR_Word,
> or something compatible with that, not `void *', so you need
> to cast NULL to type MR_Word.
>
> Check that this file compiles with warnings from the C compiler.
Done.
Simon.
Estimated hours taken: 0.5
Branches: main, release
runtime/mercury_type_info.c:
Fix a segfault in MR_arg_name_vector_to_list() (called by
construct__get_functor/6) when none of the fields of the
constructor being examined have names.
library/construct.m:
construct__get_functor/6 was returning an empty list of field names
for tuples. The correct result is a list of Arity `no's.
tests/hard_coded/construct_test.{m,exp}:
Test construct__get_functor/6.
diff -u library/construct.m library/construct.m
--- library/construct.m
+++ library/construct.m
@@ -241,7 +241,7 @@
MR_TYPEINFO_GET_VAR_ARITY_ARG_VECTOR(type_info));
ArgNameList = MR_list_empty();
for (i = 0; i < Arity; i++) {
- ArgNameList = MR_list_cons_msg(NULL,
+ ArgNameList = MR_list_cons_msg((MR_Word) NULL,
ArgNameList, MR_PROC_LABEL);
}
MR_restore_transient_registers();
only in patch2:
--- tests/hard_coded/construct_test.m 30 Jan 2002 05:09:09 -0000 1.1
+++ tests/hard_coded/construct_test.m 21 Nov 2002 08:20:59 -0000
@@ -26,8 +26,8 @@
:- type enum ---> one ; two ; three.
-:- type fruit ---> apple(list(int))
- ; banana(list(enum)).
+:- type fruit ---> apple(apple_list :: list(int))
+ ; banana(banana_list :: list(enum)).
:- type thingie ---> foo ; bar(int) ; bar(int, int) ; qux(int) ;
quux(int) ; quuux(int, int) ; wombat ;
@@ -38,7 +38,7 @@
poly_three(B, A, poly(B, A));
poly_four(A, B).
-:- type no_tag ---> qwerty(int).
+:- type no_tag ---> qwerty(qwerty_field :: int).
%----------------------------------------------------------------------------%
@@ -174,13 +174,24 @@
;
io__write_int(N),
(
- { get_functor(TypeInfo, N, Name, Arity, _List) }
+ { get_functor(TypeInfo, N, Name, Arity, _List, Names) }
->
io__write_string(" - "),
io__write_string(Name),
io__write_string("/"),
io__write_int(Arity),
- newline
+ io__write_string(" ["),
+ io__write_list(Names, ", ",
+ (pred(MaybeName::in, di, uo) is det -->
+ (
+ { MaybeName = yes(FieldName) },
+ io__write_string(FieldName)
+ ;
+ { MaybeName = no },
+ io__write_string("_")
+ )
+ )),
+ io__write_string("]\n")
;
io__write_string(" failed "),
newline
only in patch2:
--- runtime/mercury_type_info.h 19 Aug 2002 06:04:36 -0000 1.96
+++ runtime/mercury_type_info.h 21 Nov 2002 14:58:11 -0000
@@ -1553,6 +1553,9 @@
** Copy `arity' argument names from the `arg_names' vector, which starts
** at index 0, onto the Mercury heap in a list.
**
+** If `arg_names' is NULL (meaning that none of the arguments were named),
+** the output list will contain `arity' NULL entries.
+**
** You need to save and restore transient registers around
** calls to this function.
*/
--------------------------------------------------------------------------
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