[m-dev.] for review: add MC++ implementation of library and runtime

Tyson Dowd trd at cs.mu.OZ.AU
Fri Dec 29 11:25:58 AEDT 2000


On 24-Dec-2000, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On 24-Dec-2000, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> > +++ library/int.m
> > @@ -472,6 +472,10 @@
> >  	#define ML_BITS_PER_INT		(sizeof(MR_Integer) * CHAR_BIT)
> >  ").
> >  
> > +:- pragma foreign_decl("MC++", "
> > +	#define ML_BITS_PER_INT		32
> > +").
> 
> I think an XXX here is warranted.
> 
> Why do you have to hard-code this?
> Is it just because CHAR_BIT isn't defined,
> because you haven't included the appropriate system header?

This number corresponds with the choice of the .NET type System.Int32 to
represent the Mercury type int.

The ideal solution would be to ask the System.Int32 type how many bits
it has, in some manner that is going to be as efficient as a #define.

I have changed the code to use sizeof(MR_Integer) * CHAR_BIT.
However, I am not confident that the value computed by this will always
be correct -- the size of an int or a char may change, yet we will still
generate code that expects Int32.

I'm not saying there isn't such a technique already available, there
might well be.  But it will require some fossicking around in the MC++
and .NET documentation.  So I've put an XXX to remind me to look into
it.

> > +static int MR_TYPECTOR_REP_ENUM 			= MR_TYPECTOR_REP_ENUM_val;
> > +static int MR_TYPECTOR_REP_ENUM_USEREQ 		= MR_TYPECTOR_REP_ENUM_USEREQ_val;
> > +static int MR_TYPECTOR_REP_DU				= MR_TYPECTOR_REP_DU_val;
> > +static int MR_TYPECTOR_REP_DU_USEREQ		= 3;
> 
> There should be some comments before here explaining
> why you use `static int' rather than `enum' or `static const int'.

This is explained in mercury_mcpp.cpp, I've inserted a pointer to it
here.

All the other comments were addressed.

> Apart from that, this diff looks fine.

I'm bootchecking it under Linux now, if it bootchecks, I'll commit it
today.

-- 
       Tyson Dowd           # 
                            #  Surreal humour isn't everyone's cup of fur.
     trd at cs.mu.oz.au        # 
http://www.cs.mu.oz.au/~trd #
--------------------------------------------------------------------------
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