[m-rev.] for review: better headvar names

Julien Fischer juliensf at csse.unimelb.edu.au
Thu Apr 26 00:42:40 AEST 2007


On Tue, 24 Apr 2007, Zoltan Somogyi wrote:

> Replace names of the form "HeadVar__n" with meaningful names in a larger class
> of cases than we do currently.
>
> compiler/typecheck.m:
> 	Implement the change above.
>
> compiler/clause_to_proc.m:
> compiler/hlds_clauses.m:
> compiler/simplify.m:
> 	Fix some minor issues I found while looking for the right piece of code
> 	to change.
>
> tests/debugger/queens.{inp,exp,exp2}:
> 	Extend the input to the test case to print the names of the arguments
> 	of the nodiag predicate (whose head variables are now named "B" and
> 	"D", not HeadVar__1 and HeadVar__2).
>
> 	Expect fewer conjuncts in the top-level conjunction, since the
> 	unifications HeadVar__1 = B and HeadVar__2 = D can now be
> 	optimized away.
>
> tests/debugger/higher_order.exp:

It looks as though higher_order.exp2 may also needs updating.

> tests/debugger/synth_attr.exp:
> tests/debugger/user_event.exp:
> tests/debugger/user_event_shallow.exp:
> 	Update variable names and/or goal paths as for queens.

...

> Index: compiler/typecheck.m
> ===================================================================
> RCS file: /home/mercury/mercury1/repository/mercury/compiler/typecheck.m,v
> retrieving revision 1.419
> diff -u -b -r1.419 typecheck.m
> --- compiler/typecheck.m	19 Jan 2007 07:04:33 -0000	1.419
> +++ compiler/typecheck.m	19 Apr 2007 09:47:20 -0000

...

> +:- func find_consensus_headvar_names(list(set(prog_var)),
> +    list(var_name_info_map)) = map(prog_var, string).
> +
> +find_consensus_headvar_names(VarsInMapSets, VarNameInfoMaps) = ConsensusMap :-
> +    VarsInMapSet = set.union_list(VarsInMapSets),
> +    set.to_sorted_list(VarsInMapSet, VarsInMaps),
> +    list.foldl(update_consensus_map_for_headvar(VarNameInfoMaps), VarsInMaps,
> +        map.init, ConsensusMap).
> +
> +:- pred update_consensus_map_for_headvar(list(var_name_info_map)::in,
> +    prog_var::in,
> +    map(prog_var, string)::in, map(prog_var, string)::out) is det.
> +
> +update_consensus_map_for_headvar(VarNameInfos, HeadVar, !ConsensusMap) :-
> +    MaybeName = find_consensus_name_for_headvar(VarNameInfos, HeadVar),
> +    (
> +        MaybeName = no
> +    ;
> +        MaybeName = yes(Name),
> +        svmap.det_insert(HeadVar, Name, !ConsensusMap)
> +    ).
> +
> +:- func find_consensus_name_for_headvar(list(var_name_info_map), prog_var)
> +    = maybe(string).
> +
> +find_consensus_name_for_headvar(VarNameInfoMaps, HeadVar)
> +        = MaybeConsensusName :-
> +    group_var_infos(VarNameInfoMaps, HeadVar,
> +        [], Inconsistents, [], Consistents, [], FunctorOnlys),
> +    (
> +        Inconsistents = [_ | _],
> +        % Some clauses are lack consensus even among themselves.

That sentence doesn't parse well.

The rest looks good.

Julien.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list