[m-dev.] for review: register type_ctor_infos

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Oct 10 20:57:14 AEDT 2000


On 10-Oct-2000, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> runtime/mercury_type_tables.[ch]:
> 	New module that provides a capability of looking up MR_TypeCtorInfos
> 	specified by a modulename/typename pair.

This should take a module name, type name, *and arity*.

Module name and type name is not guaranteed to uniquely identify
a type, but your interface provides no way of returning more than
one MR_TypeCtorInfo.  In any case, for the uses envisaged (e.g. io__read),
we want to index on the arity.

> --- compiler/rtti_out.m	2000/07/12 13:54:39	1.12
> +++ compiler/rtti_out.m	2000/10/10 03:46:24
> +	->
> +		% XXX Registering base_typeclass_infos by themselves is not
> +		% enough. A base_typeclass_info doesn't say which types it
> +		% declares to be members of which typeclass, and for now
> +		% we don't even have any data structures in the runtime system
> +		% to describe such membership information.
> +		%
> +		% io__write_string("\tMR_register_base_typeclass_info(\n\t\t&"),
> +		% output_base_typeclass_info_storage_type_name(ClassId,
> +		% 	InstanceString, no),
> +		% io__write_string(");\n")
>  	;

That's a syntax error (no "then" goal).

> +++ runtime/mercury_dlist.h	2000/10/08 22:13:27
> +#define	MR_for_dlist(p, l) 						\
> +	for (								\
> +		p = (l? MR_dlist_next(l): NULL);			\
> +		p != l && p != NULL;					\
> +		p = MR_dlist_next(p)					\
> +	)

The macro parameters `l' and `p' should be in parentheses here.

Since this is not a function-like macro, its name should be upper case.

> +#define	MR_for_2dlist(p1, p2, l1, l2)					\
> +	for (								\
> +		p1 = (l1? MR_dlist_next(l1): NULL),			\
> +			p2 = (l2? MR_dlist_next(l2): NULL);		\
> +		p1 != l1 && p1 != NULL && p2 != l2 && p2 != NULL;	\
> +		p1 = MR_dlist_next(p1), p2 = MR_dlist_next(p2)		\
> +	)
> +#define MR_for_undlist(p, np, l)					\
> +	for (								\
> +		p = (l? MR_dlist_next(l): NULL),			\
> +			np = (p? MR_dlist_next(p): NULL);		\
> +		p != l && p != NULL;					\
> +		p = np, np = (p? MR_dlist_next(p): NULL)		\
>  	)

Likewise for these two.

> +#define	MR_end_dlist(p, l)						\
>  	(p == l || p == NULL)

The macro parameter names should be in parentheses.

> +++ mercury_type_tables.h	Mon Oct  9 16:12:05 2000
...
> +extern	void		MR_register_type_ctor_info(
> +				MR_TypeCtorInfo type_ctor_info);
> +extern	MR_TypeCtorInfo	MR_lookup_type_ctor_info(const char *module_name,
> +				const char *name);

You should document what these functions do.

Also I suggest s/name/type_name/.

> +++ runtime/mercury_wrapper.c	2000/10/06 23:30:28
> @@ -422,6 +424,30 @@
>  
>  	if (! done) {
>  		(*address_of_init_modules)();
> +		MR_close_prof_decl_file();
> +		done = TRUE;
> +	}
> +}
> +
> +void 
> +do_init_modules_type_tables(void)
> +{
> +	static	bool	done = FALSE;
> +
> +	if (! done) {
> +		(*address_of_init_modules_type_tables)();
> +		MR_close_prof_decl_file();
> +		done = TRUE;
> +	}
> +}
> +
> +void 
> +do_init_modules_debugger(void)
> +{
> +	static	bool	done = FALSE;
> +
> +	if (! done) {
> +		(*address_of_init_modules_debugger)();
>  		MR_close_prof_decl_file();
>  		done = TRUE;

There seem to be too many calls to MR_close_prof_decl_file().

Apart from that, this change looks fine.  But if you make changes to
address the comments above, I'd like to see a relative diff.

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