[m-dev.] for review: support reordering conjunctions in mode inference

David Overton dmo at cs.mu.OZ.AU
Wed Dec 20 14:38:32 AEDT 2000


On Wed, Dec 20, 2000 at 05:01:38AM +1100, Fergus Henderson wrote:
> 
> Change mode inference so that it supports reordering of conjunctions.
> 

[...]

> 
> compiler/mode_info.m:
> 	Add procedures `set_pred_id' and `set_proc_id'; these are used
> 	by mode_errors.m to print out

Is something missing here?

[...]

> Index: compiler/modes.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/modes.m,v
> retrieving revision 1.250
> diff -u -d -r1.250 modes.m
> --- compiler/modes.m	2000/11/17 17:48:07	1.250
> +++ compiler/modes.m	2000/12/19 16:33:44

[...]

> @@ -1853,8 +1901,16 @@
>  
>  	mode_info_get_module_info(ModeInfo0, ModuleInfo0),
>  	(
> -		inst_matches_initial(VarInst, Inst, Type, ModuleInfo0,
> -			ModuleInfo, Subst0, Subst1)
> +		(
> +			NeedExactMatch = no,
> +			inst_matches_initial(VarInst, Inst, Type, ModuleInfo0,
> +				ModuleInfo, Subst0, Subst1)
> +		;
> +			NeedExactMatch = yes,
> +			inst_matches_final(VarInst, Inst, Type, ModuleInfo0),
> +			ModuleInfo = ModuleInfo0,
> +			Subst1 = Subst0
> +		)

If there are any inst variables in the mode of the callee, these will
be ignored here if `NeedExactMatch = yes'.  This is not currently a
problem since 

	1. `NeedExactMatch = yes' only if we are doing mode inference
	    on the callee; and
	2.  mode inference currently will not infer polymorphic modes.

However, either of these conditions may change in the future -- so an XXX
comment here warning of that would be a good idea.

A more robust (although less efficient so you probably don't want to
do it) solution would be to call `inst_matches_initial' in the
`NeedExactMatch = yes' branch to calculate `Subst1' as well as calling
`inst_matches_final' to do the check that this is not an implied mode.

Apart from these comments, this change looks fine.  Thanks Fergus.


David
-- 
David Overton      Department of Computer Science & Software Engineering
PhD Student        The University of Melbourne, Victoria 3010, Australia
+61 3 8344 9159    http://www.cs.mu.oz.au/~dmo
--------------------------------------------------------------------------
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