[m-rev.] diff: C# interface for .NET backend.

Tyson Dowd trd at cs.mu.OZ.AU
Thu May 3 03:56:16 AEST 2001


On 03-May-2001, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On 01-May-2001, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> mlds.m:
> > +	;	outline_target_code(
> > +				foreign_language,
> > +					% the foreign language of this code
> > +				list(mlds__lval),
> > +					% where to store return value(s)
> > +				string
> > +					% the user's foreign language code
> > +		)
> > +			% Do whatever is specified by the string, which
> > +			% can be any piece of code in the specified
> > +			% foreign language (C#, managed C++, or
> > +			% whatever).
> > +			% This is implemented by calling an externally
> > +			% defined function, which the backend must
> > +			% generate the definition for (in some other
> > +			% file perhaps) and calling it.
> 
> Why does this have a list of where to store the return values?

Because otherwise you can't generate a fowarding call correctly -- in
the same way that a call has to have a list of lvals to store the return
values, so does this operation.

> And why doesn't it have a list of the input argument rvals (or their names)?

Well in general it will need the rvals in future, but in this particular
backend we don't need them.

It might be arguably more correct to generate the code using input
argument rvals instead of generating ldarg.0 ldarg.1 ldarg.2 all the way
up to the arity of the signature.

> > +	generate_foreign_header_code(mercury_module_name_to_mlds(ModuleName),
> > +		ForeignCode),
> > +
> > +	{ Namespace0 = get_class_namespace(ClassName) },
> > +	{ list__reverse(Namespace0) = [Head | Tail] ->
> > +		Namespace = list__reverse([Head ++ "__csharp_code" | Tail])
> > +	;
> > +		Namespace = Namespace0
> > +	},
> > +
> > +	io__write_list(Namespace, "\n", 
> > +		(pred(N::in, di, uo) is det -->
> > +			io__format("namespace %s {", [s(N)])
> > +	)),
> 
> The namespace name here should be (1) escaped (by prefixing it with "@") and/or
> (2) mangled, in case it (1) is a C# keyword or (2) contains special characters
> ((2) is not very important, but (1) is not unlikely and should be handled
> correctly).

Ok, (1) is worthwhile at the moment.

(2) requires extra work that isn't worthwhile until it actually causes
problems or we finish the rest of the to-do list.

> ...
> > +		;
> > +			% IL doesn't support multiple return values
> > +			sorry(this_file, "multiple return values")
> 
> s/IL/C#/ ?

Well both really....

The other things I have fixed and I will post and commit soon.

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