[m-dev.] for review: The .NET MSIL backend.

Tyson Dowd trd at cs.mu.OZ.AU
Thu Oct 12 18:29:26 AEDT 2000


On 06-Oct-2000, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> 
> Hmm, are the arguments here really supposed to be signed ints?
> For float64, that looks particularly unappealing, since Mercury ints
> need not have 64 bits...
> 
> Oh, I see, those arguments are of type int32, int64, etc.
> but currently int32, int64 etc. are typedef'd as just `int'.
> Well, at very least there should be an XXX comment here.
> 
> But it would be nice to fix it, at least for int64, e.g.
> defining `:- type int64 == integer' and then doing
> s/io__write_int(Int)/io__write_string(integer__to_string(Int))/
> here.
> 
> Also perhaps the variable names should reflect their types (s/Int/Int64/
> or s/Int/Int32/).

I'm going to use no-tag types:

:- type int64 ---> int64(integer).
:- type int32 ---> int32(int).
	... etc ...

This way you have to explicitly unwrap the types if you want to see
their underlying representation (and more importantly, it will show you
when you manipulate them whether you are using the right size).

Also, there will be output_int64, output_int32, etc.
And I'll also fix the varnames.

> > +	% We need to escape all the IDs we output to avoid bumping into
> > +	% keywords that assembler uses (there are a lot of them, and
> > +	% there is no list available).
> > +:- pred escape_id(ilds__id::in, string::out) is det.
> > +escape_id(Id, EscapedId) :-
> > +	string__append_list(["'", Id, "'"], EscapedId).
> 
> What happens if the Mercury identifier contains a single quote,
> e.g. for code like
> 	
> 	:- func 'why don''t we allow quotes in identifiers' = int.
> 	'why don''t we allow quotes in identifiers' = 42.

That gets mangled during code generation.  We call llds_out__name_mangle
so it becomes
'f_119_104_121_32_100_111_110_39_116_32_119_101_32_97_108_108_111_119_32_113_117_111_116_101_115_32_105_110_32_105_100_101_110_116_105_102_105_101_114_115_95_49_95_102_95_48'

Obviously this is a usability problem, but the mangling code in
mlds_to_il.m is nowhere near final.

I have added a pass to fix this if it should ever become important, and 
also turn embedded whitespace in strings to the escaped versions of
whitespace.

> > +	% return types
> > +:- type ret_type
> > +	--->	void
> > +	;	simple_type(simple_type).
> > +
> > +:- type ilds__type
> > +	--->	ilds__type(list(ilds__type_modifier), simple_type).
> > +
> > +:- type ilds__type_modifier
> > +	--->	const
> > +	;	readonly
> > +	;	volatile.
> 
> Is it really true that a return type can't be const or readonly?

No.

But it was when I transcribed the assembler syntax.

Now ret_type == ilds__type, and void is a possible simple_type.

I'll keep my comments about this to myself.

I'd rather make a single pass through the assembler syntax and fix it
all in one go than try to fix this by itself.  So I think I should just
put in some XXXs.


Other comments are all cool and have been addressed.


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