[m-rev.] for review: refactor mlds_to_il.m

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Jul 10 02:57:22 AEST 2001


On 10-Jul-2001, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> On 09-Jul-2001, Peter Ross <peter.ross at miscrit.be> wrote:
> > +generate_il(MLDS, AssemblyDecls ++ [assembly(IlInfo ^ assembly_name),
> > +		namespace(NamespaceName, ILDecls)], set__init, IO0, IO) :-
> > +	transform_mlds(MLDS) = mlds(MercuryModuleName, _, Imports, Defns),
> 
> I'd prefer to have the LHS contain the output of the function, but
> maybe this is just my inflexible brain...

I agree, this code fragment is hard to read.
I think Pete is trying to do too much all at once.

I'd write this as

generate_il(MLDS0, AssemblyDecls, <some good name here>, IO0, IO) :-
	% <explain what the transform does here>
	MLDS = transform_mlds(MLDS0),

	% <explain what follows here>
	MLDS = mlds(MercuryModuleName, _, Imports, Defns),
	...
	AssemblyDecls = AssemblyDecls0 ++ [assembly(IlInfo ^ assembly_name),
		namespace(NamespaceName, ILDecls)],
	<some good name here> = set__init,

> > +rename_statement(statement(switch(_, _, _, _, _), _Context))
> > +	= _ :- sorry(this_file, "rename switch").
> 
> This isn't good, we should process switches, because they are used for
> string switches, which Fergus has recently made work.

That was my first thought too... but actually it's wrong.
There shouldn't be any switches left at this point, because
switches should get converted into computed_gotos by ml_simplify_switch.m.
But I think it definitely warrants a comment.

It could be useful to handle switches here, though.
If we were generating C#, rather than IL, we'd like to do this
renaming pass on code containing switches.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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