[m-dev.] diff: std_util.m changes to mercury_compare_typeinfos() etc.

Tyson Richard DOWD trd at cs.mu.oz.au
Fri May 23 13:19:36 AEST 1997


> Hi Tyson,
> 
> Can you please review these?
> 
> library/std_util.m:
> 	Change mercury_compare_typeinfo so that it expands equivalence
> 	types, because that is needed to ensure consistent results.
> 	Also change it to compare the addresses of the base_type_infos,
> 	rather than the addresses of the unification predicates.
> 	(The unification predicates for `int' and enumeration types
> 	or `char' may be the same, but the base_type_infos are guaranteed
> 	to be distinct and unique.)
> 	Use the `ML_' prefix for C functions defined in the Mercury library,
> 	rather than `mercury_' (or no prefix at all).
> 
>  	typeinfo2 = field(mktag(0), univ2, UNIV_OFFSET_FOR_TYPEINFO);
> -	if (mercury_compare_type_info(typeinfo1, typeinfo2) != COMPARE_EQUAL)
> -	{
> +	save_transient_registers();
> +	comp = ML_compare_type_info(typeinfo1, typeinfo2);
> +	restore_transient_registers();
> +	if (comp != COMPARE_EQUAL) {
>  		unify_output = FALSE;
>  		proceed();
>  	}
> @@ -983,7 +995,7 @@
>  	/* First compare the type_infos */
>  	typeinfo1 = field(mktag(0), univ1, UNIV_OFFSET_FOR_TYPEINFO);
>  	typeinfo2 = field(mktag(0), univ2, UNIV_OFFSET_FOR_TYPEINFO);
> -	compare_output = mercury_compare_type_info(typeinfo1, typeinfo2);
> +	compare_output = ML_compare_type_info(typeinfo1, typeinfo2);
>  	if (compare_output != COMPARE_EQUAL) {
>  		proceed();

You didn't save transient registers here. Either this code has to
save them, or it is a C function itself and needs to be documented that
you need to save regs around calls to it. 

Also, compare_output is a #define for r1, so make sure you also
use a variable (like comp, above).

Otherwise the diff is fine.

-- 
       Tyson Dowd           # 
                            #  Surreal humour isn't eveyone's cup of
     trd at cs.mu.oz.au        #  fur.
http://www.cs.mu.oz.au/~trd #



More information about the developers mailing list