[m-dev.] question

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Jul 17 00:36:15 AEST 1998


On 16-Jul-1998, Erwan Jahier <Erwan.Jahier at irisa.fr> wrote:
> This a question for Fergus, Tyson or Zoltan.
> 
> I am trying to write a function that returns the list of the type of the
> currently live variables (that is an interesting information to provide
> to the user when he wants to know what live variable he wants to
> retrieve/print).
> 
> Thanks to MR_trace_get_type_and_value(var, NULL, &type_info, &value)), I
> can get the type of each live variable.
> 
> But now, I'd like to convert 'type_info' into a string. 
> Is it possible ?

Yes.

> How ?

You can use type_name/1 in std_util.m.

If this is in C code, then you can get an approximation by

        Word base_type_info = MR_TYPEINFO_GET_BASE_TYPEINFO(type_info);
	char *module = MR_BASE_TYPEINFO_GET_TYPE_MODULE_NAME(base_type_info);
	char *name = MR_BASE_TYPEINFO_GET_TYPE_NAME(base_type_info);
	int arity = MR_BASE_TYPEINFO_GET_TYPE_ARITY;
	char full_name[LOTS];
	sprintf(full_name, "%s:%s/%d", module, name, arity);

but this doesn't handle higher-order types properly, doesn't print the
argument types, etc., so it may be easier to just export type_name/1 to C.

> Note: that's an information (the type of the variable) you should
> provide too when the user is asking for the list of live variables
> (command v) under mdb.

Good idea.

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



More information about the developers mailing list