[m-rev.] for review: Arrays for the .NET backend

Tyson Dowd trd at cs.mu.OZ.AU
Fri Aug 3 19:40:39 AEST 2001


On 03-Aug-2001, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On 02-Aug-2001, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> > 
> > Implement arrays in the .NET backend.
> ...
> > compiler/ml_call_gen.m:
> > 	Implement the cast to the known instance of array(T) for return
> > 	values of array.
> 
> You should also implement a cast for the other direction, IMHO.
> We should avoid relying on any implicit conversions in the MLDS.

Ok, that's fine.

> > Index: compiler/mlds_to_il.m
> > @@ -2523,7 +2531,7 @@
> >  		(
> >  			type_id_is_array(TypeId)
> >  		->
> > -			ILType = il_array_type
> > +			ILType = il_object_array_type
> >  		;
> >  			ml_gen_type_name(TypeId, ClassName, Arity),
> >  			ILType = ilds__type([], class(
> 
> Is that one correct??
> It looks a bit dubious to me.  Please check it.

Actually, this code is for --high-level-data, and so it should be
completely removed.  It was correct with the previous representation of
arrays, but now it is just a dead code path because we will not create
mercury_types that will pass the type_id_is_array check.

> > compiler/mlds_to_java.m:
> >         Map mlds__mercury_array_type(ElemType) to class Object[] if
> >         ElemType is a type variable, or ElemType[] otherwise.
> >         (type variables are mapped to Object anyway, so this falls
> >         out of the code anyway).
> >         (This is untested).
> ...
> > Index: compiler/mlds_to_java.m
> > @@ -1206,6 +1207,10 @@
> >  
> >  output_type(mercury_type(Type, TypeCategory)) -->
> >  	output_mercury_type(Type, TypeCategory).
> > +
> > +output_type(mercury_array_type(_MLDSType)) -->
> > +	io__write_string("java.lang.Object").
> 
> The code here definitely doesn't match the log message.

Oops, I changed it to be 

	output_type(MLDSType),
	io__write_string("[]")

which is the same as what is done for mlds__array_type.

But I think Java uses stupid C-style array syntax.

So this is wrong for variable declarations -- it should be
	output_type(MLDSType),
	output_varname(Var),
	io__write_string("[]")

but this bug was already present, I've just added an XXX about it.

> Otherwise this looks fine.

I've fixed these problems and will commit RSN.

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