[m-rev.] for review: More modifications to the Java back-end

Michael Wybrow mjwybrow at students.cs.mu.oz.au
Fri Feb 8 10:30:53 AEDT 2002



On Wed, 6 Feb 2002, Fergus Henderson wrote:

> > +:- func remove_dummy_vars(list(mlds__rval)) = list(mlds__rval).
> > +:- mode remove_dummy_vars(in) = out is det.
> > +
> > +remove_dummy_vars([]) = [].
> > +remove_dummy_vars([Var|Vars0]) = VarList :-
> > +	Vars = remove_dummy_vars(Vars0),
> > +	( 
> > +   		Var = mlds__lval(Lval),
> > +   		Lval = var(VarName, _),
> > +   		VarName = qual(_, UnqualName),
> > +   		UnqualName = var_name("dummy_var", no) 
> > +	->
> > +		VarList = Vars
> > +	;
> > +		VarList = [Var|Vars]	
> > +	).
> 
> It's not right to just remove the dummy variables like this.
> Instead, you need to substitute an appropriate dummy value.
> Otherwise the number of return values won't match up in the
> caller and callee.
> 
> Anyway, this should be handled in output_lval, not in output_stmt.
> 
> The right way to handle it is to check for `dummy_var' in the `var'
> clause for output_lval, and output a reference to a static variable
> `dummy_var' defined in a fixed class (e.g. some class in the
> mercury/java directory, or mercury.private_builtin).

I think there might be a bug in the MLDS here since the dummy variables 
do not seem to appear in the function params. If I don't remove the
dummy variable I get an error like:

Software Error: assoc_list__from_corresponding_lists: lists have different
lengths.
        Key list type: list:list(mlds:type)
        Key list length: 1
        Value list type: list:list(mlds:rval)
        Value list length: 2

where the extra rval is the dummy variable I currently remove. I'm going
to commit this with an XXX saying this, which includes your "right way to
handle it" paragraph from above.


I followed all your other suggestions.

Cheers,
Michael



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