[m-rev.] trivial diff: clean up inst_match.m
Julien Fischer
juliensf at cs.mu.OZ.AU
Mon Sep 26 15:00:31 AEST 2005
Estimated hours taken: 0.1
Branches: main
compiler/inst_match.m:
Bring this module into line with our current coding standards.
Julien.
Index: compiler/inst_match.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/inst_match.m,v
retrieving revision 1.65
diff -u -b -r1.65 inst_match.m
--- compiler/inst_match.m 9 Sep 2005 06:12:54 -0000 1.65
+++ compiler/inst_match.m 26 Sep 2005 04:57:09 -0000
@@ -1,4 +1,6 @@
%-----------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et
+%-----------------------------------------------------------------------------%
% Copyright (C) 1995-1998, 2000-2005 The University of Melbourne.
% This file may only be copied under the terms of the GNU General
% Public License - see the file COPYING in the Mercury distribution.
@@ -7,18 +9,17 @@
% file: inst_match.m
% author: fjh
%
-% This module defines some utility routines for comparing insts
-% that are used by modes.m and det_analysis.m.
+% This module defines some utility routines for comparing insts that are used
+% by modes.m and det_analysis.m.
%
% rafe: XXX The following comment needs revising in the light of
% the new solver types design.
%
-% The handling of `any' insts is not complete. (See also inst_util.m)
-% It would be nice to allow `free' to match `any', but right now we
-% only allow a few special cases of that.
-% The reason is that although the mode analysis would be pretty
-% straight-forward, generating the correct code is quite a bit trickier.
-% modes.m would have to be changed to handle the implicit
+% The handling of `any' insts is not complete. (See also inst_util.m) It
+% would be nice to allow `free' to match `any', but right now we only allow a
+% few special cases of that. The reason is that although the mode analysis
+% would be pretty straight-forward, generating the correct code is quite a bit
+% trickier. modes.m would have to be changed to handle the implicit
% conversions from `free'/`bound'/`ground' to `any' at
%
% (1) procedure calls (this is just an extension of implied modes)
@@ -26,13 +27,13 @@
% (2) the end of branched goals
% (3) the end of predicates.
%
-% Since that is not yet done, we currently require the user to
-% insert explicit calls to initialize constraint variables.
+% Since that is not yet done, we currently require the user to insert explicit
+% calls to initialize constraint variables.
%
-% We do allow `bound' and `ground' to match `any', based on the
-% assumption that `bound' and `ground' are represented in the same
-% way as `any', i.e. that we use the type system rather than the
-% mode system to distinguish between different representations.
+% We do allow `bound' and `ground' to match `any', based on the assumption
+% that `bound' and `ground' are represented in the same way as `any', i.e.
+% that we use the type system rather than the mode system to distinguish
+% between different representations.
%-----------------------------------------------------------------------------%
@@ -40,26 +41,27 @@
:- interface.
-:- import_module hlds__hlds_module.
-:- import_module parse_tree__prog_data.
+:- import_module hlds.hlds_module.
+:- import_module parse_tree.prog_data.
:- import_module list.
%-----------------------------------------------------------------------------%
-:- pred inst_expand(module_info::in, (inst)::in, (inst)::out) is det.
-
% inst_expand(ModuleInfo, Inst0, Inst) checks if the top-level
% part of the inst is a defined inst, and if so replaces it
% with the definition.
+ %
+:- pred inst_expand(module_info::in, (inst)::in, (inst)::out) is det.
+
+ % inst_expand_and_remove_constrained_inst_vars is the same as inst_expand
+ % except that it also removes constrained_inst_vars from the top level,
+ % replacing them with the constraining inst.
+ %
:- pred inst_expand_and_remove_constrained_inst_vars(module_info::in,
(inst)::in, (inst)::out) is det.
- % inst_expand_and_remove_constrained_inst_vars is the same as
- % inst_expand except that it also removes constrained_inst_vars from the
- % top level, replacing them with the constraining inst.
-
%-----------------------------------------------------------------------------%
% inst_matches_initial(InstA, InstB, Type, ModuleInfo):
@@ -72,151 +74,148 @@
% than ground - but not vice versa. Similarly,
% inst_matches_initial(bound(a), bound(a;b), _) should
% succeed, but not vice versa.
-
+ %
:- pred inst_matches_initial((inst)::in, (inst)::in, (type)::in,
module_info::in) is semidet.
% This version of inst_matches_initial builds up a substitution map
- % (inst_var_sub). For each inst_var which occurs in InstA there will be
- % a substitution to the corresponding inst in InstB.
-
+ % (inst_var_sub). For each inst_var which occurs in InstA there will be a
+ % substitution to the corresponding inst in InstB.
+ %
:- pred inst_matches_initial((inst)::in, (inst)::in, (type)::in,
module_info::in, module_info::out, inst_var_sub::in, inst_var_sub::out)
is semidet.
- % This version of inst_matches_initial does not allow implied modes.
- % This makes it almost the same as inst_matches_final. The only
- % different is in the way it handles constrained_inst_vars.
-
+ % This version of inst_matches_initial does not allow implied modes. This
+ % makes it almost the same as inst_matches_final. The only different is
+ % in the way it handles constrained_inst_vars.
+ %
:- pred inst_matches_initial_no_implied_modes((inst)::in, (inst)::in,
(type)::in, module_info::in) is semidet.
% A version of the above that also computes the inst_var_sub.
-
+ %
:- pred inst_matches_initial_no_implied_modes((inst)::in, (inst)::in,
(type)::in, module_info::in, module_info::out,
inst_var_sub::in, inst_var_sub::out) is semidet.
% inst_matches_final(InstA, InstB, ModuleInfo):
- % Succeed iff InstA is compatible with InstB,
- % i.e. iff InstA will satisfy the final inst
- % requirement InstB. This is true if the
- % information specified by InstA is at least as
- % great as that specified by InstB, and where the information
- % is the same and both insts specify a binding, the binding
- % must be identical.
-
+ % Succeed iff InstA is compatible with InstB, i.e. iff InstA will
+ % satisfy the final inst requirement InstB. This is true if the
+ % information specified by InstA is at least as great as that specified
+ % by InstB, and where the information is the same and both insts specify
+ % a binding, the binding must be identical.
+ %
:- pred inst_matches_final((inst)::in, (inst)::in, module_info::in) is semidet.
- % This version of inst_matches_final allows you to pass in the type of
- % the variables being compared. This allows it to be more precise
- % (i.e. less conservative) for cases such as
- % inst_matches_final(ground(...), bound(...), ...).
- % This version is to be preferred when the type is available.
-
+ % This version of inst_matches_final allows you to pass in the type of the
+ % variables being compared. This allows it to be more precise (i.e. less
+ % conservative) for cases such as inst_matches_final(ground(...),
+ % bound(...), ...). This version is to be preferred when the type is
+ % available.
+ %
:- pred inst_matches_final((inst)::in, (inst)::in, (type)::in, module_info::in)
is semidet.
- % The difference between inst_matches_initial and
- % inst_matches_final is that inst_matches_initial requires
- % only something which is at least as instantiated,
- % whereas this predicate wants something which is an
- % exact match (or not reachable).
- %
- % Note that this predicate is not symmetric,
- % because of the existence of `not_reached' insts:
- % not_reached matches_final with anything,
- % but not everything matches_final with not_reached -
- % in fact only not_reached matches_final with not_reached.
- % It is also asymmetric with respect to unique insts.
-
+ % The difference between inst_matches_initial and inst_matches_final is
+ % that inst_matches_initial requires only something which is at least as
+ % instantiated, whereas this predicate wants something which is an exact
+ % match (or not reachable).
+ %
+ % Note that this predicate is not symmetric, because of the existence of
+ % `not_reached' insts: not_reached matches_final with anything, but not
+ % everything matches_final with not_reached - in fact only not_reached
+ % matches_final with not_reached. It is also asymmetric with respect to
+ % unique insts.
+ %
% It might be a good idea to fold inst_matches_initial and
- % inst_matches_final into a single predicate inst_matches(When, ...)
- % where When is either `initial' or `final'.
-
+ % inst_matches_final into a single predicate inst_matches(When, ...) where
+ % When is either `initial' or `final'.
+ %
% inst_is_at_least_as_instantiated(InstA, InstB, Type, ModuleInfo)
- % succeeds iff InstA is at least as instantiated as InstB. This
- % defines a partial order which is the same as
- % inst_matches_initial except that uniqueness comparisons are
- % reversed and we don't allow
+ % succeeds iff InstA is at least as instantiated as InstB. This defines
+ % a partial order which is the same as inst_matches_initial except that
+ % uniqueness comparisons are reversed and we don't allow
% inst_is_at_least_as_instantiated(any, any).
-
+ %
:- pred inst_is_at_least_as_instantiated((inst)::in, (inst)::in, (type)::in,
module_info::in) is semidet.
-:- pred unique_matches_initial(uniqueness::in, uniqueness::in) is semidet.
-
% unique_matches_initial(A, B) succeeds if A >= B in the ordering
% clobbered < mostly_clobbered < shared < mostly_unique < unique
-
-:- pred unique_matches_final(uniqueness::in, uniqueness::in) is semidet.
+ %
+:- pred unique_matches_initial(uniqueness::in, uniqueness::in) is semidet.
% unique_matches_final(A, B) succeeds if A >= B in the ordering
% clobbered < mostly_clobbered < shared < mostly_unique < unique
+ %
+:- pred unique_matches_final(uniqueness::in, uniqueness::in) is semidet.
+ % inst_matches_binding(InstA, InstB, ModuleInfo):
+ % Succeed iff the binding of InstA is definitely exactly the same as
+ % that of InstB. This is the same as inst_matches_final except that it
+ % ignores uniqueness, and that `any' does not match itself. It is used
+ % to check whether variables get bound in negated contexts.
+ %
:- pred inst_matches_binding((inst)::in, (inst)::in, (type)::in,
module_info::in) is semidet.
- % inst_matches_binding(InstA, InstB, ModuleInfo):
- % Succeed iff the binding of InstA is definitely exactly the
- % same as that of InstB. This is the same as
- % inst_matches_final except that it ignores uniqueness, and
- % that `any' does not match itself. It is used to check
- % whether variables get bound in negated contexts.
-
+ % inst_matches_binding_allow_any_any is the same as
+ % inst_matches_binding except that it also allows `any' to match `any'.
+ %
:- pred inst_matches_binding_allow_any_any((inst)::in, (inst)::in, (type)::in,
module_info::in) is semidet.
- % inst_matches_binding_allow_any_any is the same as
- % inst_matches_binding except that it also allows `any' to
- % match `any'.
%-----------------------------------------------------------------------------%
% pred_inst_matches(PredInstA, PredInstB, ModuleInfo)
- % Succeeds if PredInstA specifies a pred that can
- % be used wherever and whenever PredInstB could be used.
- % This is true if they both have the same PredOrFunc indicator
- % and the same determinism, and if the arguments match
- % using pred_inst_argmodes_match.
+ % Succeeds if PredInstA specifies a pred that can be used wherever and
+ % whenever PredInstB could be used. This is true if they both have the
+ % same PredOrFunc indicator and the same determinism, and if the
+ % arguments match using pred_inst_argmodes_match.
%
:- pred pred_inst_matches(pred_inst_info::in, pred_inst_info::in,
module_info::in) is semidet.
%-----------------------------------------------------------------------------%
-
%
-% Predicates to test various properties of insts.
-% Note that `not_reached' insts are considered to satisfy
-% all of these predicates except inst_is_clobbered.
+% Predicates to test various properties of insts
+%
+% NOTE: `not_reached' insts are considered to satisfy all of these predicates
+% except inst_is_clobbered.
%
- % succeed if the inst is fully ground (i.e. contains only
- % `ground', `bound', and `not_reached' insts, with no `free'
- % or `any' insts).
+ % succeed if the inst is fully ground (i.e. contains only `ground',
+ % `bound', and `not_reached' insts, with no `free' or `any' insts).
% This predicate succeeds for non-standard function insts so some care
% needs to be taken since these insts may not be replaced by a less
% precise inst that uses the higher-order mode information.
+ %
:- pred inst_is_ground(module_info::in, (inst)::in) is semidet.
- % succeed if the inst is not partly free (i.e. contains only
- % `any', `ground', `bound', and `not_reached' insts, with no
- % `free' insts).
+ % succeed if the inst is not partly free (i.e. contains only `any',
+ % `ground', `bound', and `not_reached' insts, with no `free' insts).
% This predicate succeeds for non-standard function insts so some care
% needs to be taken since these insts may not be replaced by a less
% precise inst that uses the higher-order mode information.
+ %
:- pred inst_is_ground_or_any(module_info::in, (inst)::in) is semidet.
- % succeed if the inst is `mostly_unique' or `unique'
+ % Succeed if the inst is `mostly_unique' or `unique'.
+ %
:- pred inst_is_mostly_unique(module_info::in, (inst)::in) is semidet.
- % succeed if the inst is `unique'
+ % Succeed if the inst is `unique'.
+ %
:- pred inst_is_unique(module_info::in, (inst)::in) is semidet.
- % succeed if the inst is not `mostly_unique' or `unique'
+ % Succeed if the inst is not `mostly_unique' or `unique'.
+ %
:- pred inst_is_not_partly_unique(module_info::in, (inst)::in) is semidet.
- % succeed if the inst is not `unique'
+ % Succeed if the inst is not `unique'.
+ %
:- pred inst_is_not_fully_unique(module_info::in, (inst)::in) is semidet.
:- pred inst_is_clobbered(module_info::in, (inst)::in) is semidet.
@@ -269,31 +268,30 @@
%-----------------------------------------------------------------------------%
- % Succeed iff the specified inst contains (directly or indirectly)
- % the specified inst_name.
-
+ % Succeed iff the specified inst contains (directly or indirectly) the
+ % specified inst_name.
+ %
:- pred inst_contains_instname((inst)::in, module_info::in, inst_name::in)
is semidet.
- % Nondeterministically produce all the inst_vars contained
- % in the specified list of modes.
-
+ % Nondeterministically produce all the inst_vars contained in the
+ % specified list of modes.
+ %
:- pred mode_list_contains_inst_var(list(mode)::in, module_info::in,
inst_var::out) is nondet.
- % Given a list of insts, and a corresponding list of livenesses,
- % return true iff for every element in the list of insts, either
- % the elemement is ground or the corresponding element in the liveness
- % list is dead.
-
+ % Given a list of insts, and a corresponding list of livenesses, return
+ % true iff for every element in the list of insts, either the elemement is
+ % ground or the corresponding element in the liveness list is dead.
+ %
:- pred inst_list_is_ground_or_dead(list(inst)::in, list(is_live)::in,
module_info::in) is semidet.
- % Given a list of insts, and a corresponding list of livenesses,
- % return true iff for every element in the list of insts, either
- % the elemement is ground or any, or the corresponding element
- % in the liveness list is dead.
-
+ % Given a list of insts, and a corresponding list of livenesses, return
+ % true iff for every element in the list of insts, either the elemement is
+ % ground or any, or the corresponding element in the liveness list is
+ % dead.
+ %
:- pred inst_list_is_ground_or_any_or_dead(list(inst)::in, list(is_live)::in,
module_info::in) is semidet.
@@ -302,12 +300,13 @@
:- implementation.
-:- import_module check_hlds__inst_util.
-:- import_module check_hlds__mode_util.
-:- import_module check_hlds__type_util.
-:- import_module hlds__hlds_data.
-:- import_module mdbcomp__prim_data.
-:- import_module parse_tree__prog_data.
+:- import_module check_hlds.inst_util.
+:- import_module check_hlds.mode_util.
+:- import_module check_hlds.type_util.
+:- import_module hlds.hlds_data.
+:- import_module mdbcomp.prim_data.
+:- import_module parse_tree.error_util.
+:- import_module parse_tree.prog_data.
:- import_module bool.
:- import_module int.
@@ -319,6 +318,8 @@
:- import_module svset.
:- import_module term.
+%-----------------------------------------------------------------------------%
+
inst_matches_initial(InstA, InstB, Type, ModuleInfo) :-
inst_matches_initial_1(InstA, InstB, Type, ModuleInfo, _, no, _).
@@ -329,7 +330,7 @@
MaybeSub = yes(!:Sub)
;
MaybeSub = no,
- error("inst_matches_initial: missing inst_var_sub")
+ unexpected(this_file, "inst_matches_initial: missing inst_var_sub")
).
inst_matches_initial_no_implied_modes(InstA, InstB, Type, ModuleInfo) :-
@@ -568,7 +569,7 @@
inst_matches_initial_4(ground(_UniqA, none), abstract_inst(_,_), _, !Info) :-
% I don't know what this should do.
% Abstract insts aren't really supported.
- error("inst_matches_initial(ground, abstract_inst) == ??").
+ unexpected(this_file, "inst_matches_initial(ground, abstract_inst) == ??").
inst_matches_initial_4(abstract_inst(_,_), any(shared), _, !Info).
inst_matches_initial_4(abstract_inst(_,_), free, _, !Info).
inst_matches_initial_4(abstract_inst(Name, ArgsA), abstract_inst(Name, ArgsB),
@@ -1270,7 +1271,7 @@
inst_is_clobbered(_, bound(clobbered, _)).
inst_is_clobbered(_, bound(mostly_clobbered, _)).
inst_is_clobbered(_, inst_var(_)) :-
- error("internal error: uninstantiated inst parameter").
+ unexpected(this_file, "internal error: uninstantiated inst parameter").
inst_is_clobbered(ModuleInfo, constrained_inst_vars(_, Inst)) :-
inst_is_clobbered(ModuleInfo, Inst).
inst_is_clobbered(ModuleInfo, defined_inst(InstName)) :-
@@ -1280,11 +1281,11 @@
% inst_is_free succeeds iff the inst passed is `free'
% or is a user-defined inst which is defined as `free'.
% Abstract insts must not be free.
-
+ %
inst_is_free(_, free).
inst_is_free(_, free(_Type)).
inst_is_free(_, inst_var(_)) :-
- error("internal error: uninstantiated inst parameter").
+ unexpected(this_file, "internal error: uninstantiated inst parameter").
inst_is_free(ModuleInfo, constrained_inst_vars(_, Inst)) :-
inst_is_free(ModuleInfo, Inst).
inst_is_free(ModuleInfo, defined_inst(InstName)) :-
@@ -1293,7 +1294,7 @@
inst_is_any(_, any(_)).
inst_is_any(_, inst_var(_)) :-
- error("internal error: uninstantiated inst parameter").
+ unexpected(this_file, "internal error: uninstantiated inst parameter").
inst_is_any(ModuleInfo, constrained_inst_vars(_, Inst)) :-
inst_is_any(ModuleInfo, Inst).
inst_is_any(ModuleInfo, defined_inst(InstName)) :-
@@ -1303,13 +1304,13 @@
% inst_is_bound succeeds iff the inst passed is not `free'
% or is a user-defined inst which is not defined as `free'.
% Abstract insts must be bound.
-
+ %
inst_is_bound(_, not_reached).
inst_is_bound(_, any(_)).
inst_is_bound(_, ground(_, _)).
inst_is_bound(_, bound(_, _)).
inst_is_bound(_, inst_var(_)) :-
- error("internal error: uninstantiated inst parameter").
+ unexpected(this_file, "internal error: uninstantiated inst parameter").
inst_is_bound(ModuleInfo, constrained_inst_vars(_, Inst)) :-
inst_is_bound(ModuleInfo, Inst).
inst_is_bound(ModuleInfo, defined_inst(InstName)) :-
@@ -1320,10 +1321,10 @@
% inst_is_bound_to_functors succeeds iff the inst passed is
% `bound(_Uniq, Functors)' or is a user-defined inst which expands to
% `bound(_Uniq, Functors)'.
-
+ %
inst_is_bound_to_functors(_, bound(_Uniq, Functors), Functors).
inst_is_bound_to_functors(_, inst_var(_), _) :-
- error("internal error: uninstantiated inst parameter").
+ unexpected(this_file, "internal error: uninstantiated inst parameter").
inst_is_bound_to_functors(ModuleInfo, constrained_inst_vars(_, Inst),
Functors) :-
inst_is_bound_to_functors(ModuleInfo, Inst, Functors).
@@ -1335,7 +1336,7 @@
% inst_is_ground succeeds iff the inst passed is `ground'
% or the equivalent. Abstract insts are not considered ground.
-
+ %
inst_is_ground(ModuleInfo, Inst) :-
inst_is_ground(ModuleInfo, no, Inst).
@@ -1347,10 +1348,9 @@
inst_is_ground_1(ModuleInfo, MaybeType, Inst,
Expansions0, _Expansions).
- % The third arg is the set of insts which have already
- % been expanded - we use this to avoid going into an
- % infinite loop.
-
+ % The third arg is the set of insts which have already been expanded - we
+ % use this to avoid going into an infinite loop.
+ %
:- pred inst_is_ground_1(module_info::in, maybe(type)::in, (inst)::in,
set(inst)::in, set(inst)::out) is semidet.
@@ -1375,7 +1375,7 @@
bound_inst_list_is_ground_2(List, MaybeType, ModuleInfo, !Expansions).
inst_is_ground_2(_, _, ground(_, _), !Expansions).
inst_is_ground_2(_, _, inst_var(_), !Expansions) :-
- error("internal error: uninstantiated inst parameter").
+ unexpected(this_file, "internal error: uninstantiated inst parameter").
inst_is_ground_2(ModuleInfo, MaybeType, Inst, !Expansions) :-
Inst = constrained_inst_vars(_, Inst2),
inst_is_ground_1(ModuleInfo, MaybeType, Inst2, !Expansions).
@@ -1389,15 +1389,14 @@
% inst_is_ground_or_any succeeds iff the inst passed is `ground',
% `any', or the equivalent. Fails for abstract insts.
-
+ %
inst_is_ground_or_any(ModuleInfo, Inst) :-
set__init(Expansions0),
inst_is_ground_or_any_2(ModuleInfo, Inst, Expansions0, _Expansions).
- % The third arg is the set of insts which have already
- % been expanded - we use this to avoid going into an
- % infinite loop.
-
+ % The third arg is the set of insts which have already been expanded - we
+ % use this to avoid going into an infinite loop.
+ %
:- pred inst_is_ground_or_any_2(module_info::in, (inst)::in,
set(inst)::in, set(inst)::out) is semidet.
@@ -1408,7 +1407,7 @@
inst_is_ground_or_any_2(_, ground(_, _), !Expansions).
inst_is_ground_or_any_2(_, any(_), !Expansions).
inst_is_ground_or_any_2(_, inst_var(_), !Expansions) :-
- error("internal error: uninstantiated inst parameter").
+ unexpected(this_file, "internal error: uninstantiated inst parameter").
inst_is_ground_or_any_2(ModuleInfo, Inst, !Expansions) :-
Inst = constrained_inst_vars(_, Inst2),
inst_is_ground_or_any_2(ModuleInfo, Inst2, !Expansions).
@@ -1422,17 +1421,16 @@
inst_is_ground_or_any_2(ModuleInfo, Inst2, !Expansions)
).
- % inst_is_unique succeeds iff the inst passed is unique
- % or free. Abstract insts are not considered unique.
-
+ % inst_is_unique succeeds iff the inst passed is unique or free. Abstract
+ % insts are not considered unique.
+ %
inst_is_unique(ModuleInfo, Inst) :-
set__init(Expansions0),
inst_is_unique_2(ModuleInfo, Inst, Expansions0, _Expansions).
- % The third arg is the set of insts which have already
- % been expanded - we use this to avoid going into an
- % infinite loop.
-
+ % The third arg is the set of insts which have already been expanded - we
+ % use this to avoid going into an infinite loop.
+ %
:- pred inst_is_unique_2(module_info::in, (inst)::in,
set(inst)::in, set(inst)::out) is semidet.
@@ -1443,7 +1441,7 @@
inst_is_unique_2(_, free, !Expansions).
inst_is_unique_2(_, ground(unique, _), !Expansions).
inst_is_unique_2(_, inst_var(_), !Expansions) :-
- error("internal error: uninstantiated inst parameter").
+ unexpected(this_file, "internal error: uninstantiated inst parameter").
inst_is_unique_2(ModuleInfo, Inst, !Expansions) :-
Inst = constrained_inst_vars(_, Inst2),
inst_is_unique_2(ModuleInfo, Inst2, !Expansions).
@@ -1459,15 +1457,14 @@
% inst_is_mostly_unique succeeds iff the inst passed is unique,
% mostly_unique, or free. Abstract insts are not considered unique.
-
+ %
inst_is_mostly_unique(ModuleInfo, Inst) :-
set__init(Expansions0),
inst_is_mostly_unique_2(ModuleInfo, Inst, Expansions0, _Expansions).
- % The third arg is the set of insts which have already
- % been expanded - we use this to avoid going into an
- % infinite loop.
-
+ % The third arg is the set of insts which have already been expanded - we
+ % use this to avoid going into an infinite loop.
+ %
:- pred inst_is_mostly_unique_2(module_info::in, (inst)::in,
set(inst)::in, set(inst)::out) is semidet.
@@ -1482,7 +1479,7 @@
inst_is_mostly_unique_2(_, ground(unique, _), !Expansions).
inst_is_mostly_unique_2(_, ground(mostly_unique, _), !Expansions).
inst_is_mostly_unique_2(_, inst_var(_), !Expansions) :-
- error("internal error: uninstantiated inst parameter").
+ unexpected(this_file, "internal error: uninstantiated inst parameter").
inst_is_mostly_unique_2(ModuleInfo, Inst, !Expansions) :-
Inst = constrained_inst_vars(_, Inst2),
inst_is_mostly_unique_2(ModuleInfo, Inst2, !Expansions).
@@ -1499,7 +1496,7 @@
% inst_is_not_partly_unique succeeds iff the inst passed is
% not unique or mostly_unique, i.e. if it is shared
% or free. It fails for abstract insts.
-
+ %
inst_is_not_partly_unique(ModuleInfo, Inst) :-
set__init(Expansions0),
inst_is_not_partly_unique_2(ModuleInfo, Inst,
@@ -1508,7 +1505,7 @@
% The third arg is the set of insts which have already
% been expanded - we use this to avoid going into an
% infinite loop.
-
+ %
:- pred inst_is_not_partly_unique_2(module_info::in, (inst)::in,
set(inst)::in, set(inst)::out) is semidet.
@@ -1519,7 +1516,7 @@
inst_is_not_partly_unique_2(_, any(shared), !Expansions).
inst_is_not_partly_unique_2(_, ground(shared, _), !Expansions).
inst_is_not_partly_unique_2(_, inst_var(_), !Expansions) :-
- error("internal error: uninstantiated inst parameter").
+ unexpected(this_file, "internal error: uninstantiated inst parameter").
inst_is_not_partly_unique_2(ModuleInfo, Inst, !Expansions) :-
Inst = constrained_inst_vars(_, Inst2),
inst_is_not_partly_unique_2(ModuleInfo, Inst2, !Expansions).
@@ -1533,19 +1530,18 @@
inst_is_not_partly_unique_2(ModuleInfo, Inst2, !Expansions)
).
- % inst_is_not_fully_unique succeeds iff the inst passed is
- % not unique, i.e. if it is mostly_unique, shared,
- % or free. It fails for abstract insts.
-
+ % inst_is_not_fully_unique succeeds iff the inst passed is not unique,
+ % i.e. if it is mostly_unique, shared, or free. It fails for abstract
+ % insts.
+ %
inst_is_not_fully_unique(ModuleInfo, Inst) :-
set__init(Expansions0),
inst_is_not_fully_unique_2(ModuleInfo, Inst,
Expansions0, _Expansions).
- % The third arg is the set of insts which have already
- % been expanded - we use this to avoid going into an
- % infinite loop.
-
+ % The third arg is the set of insts which have already been expanded - we
+ % use this to avoid going into an infinite loop.
+ %
:- pred inst_is_not_fully_unique_2(module_info::in, (inst)::in,
set(inst)::in, set(inst)::out) is semidet.
@@ -1564,7 +1560,7 @@
inst_is_not_fully_unique_2(_, ground(shared, _), !Expansions).
inst_is_not_fully_unique_2(_, ground(mostly_unique, _), !Expansions).
inst_is_not_fully_unique_2(_, inst_var(_), _, _) :-
- error("internal error: uninstantiated inst parameter").
+ unexpected(this_file, "internal error: uninstantiated inst parameter").
inst_is_not_fully_unique_2(ModuleInfo, Inst, !Expansions) :-
Inst = constrained_inst_vars(_, Inst2),
inst_is_not_fully_unique_2(ModuleInfo, Inst2, !Expansions).
@@ -1978,10 +1974,11 @@
%-----------------------------------------------------------------------------%
- % For a non-solver type t (i.e. any type declared without using
- % the `solver' keyword), the inst `any' should be considered
- % to be equivalent to a bound inst i where i contains all
- % the functors of the type t and each argument has inst `any'.
+ % For a non-solver type t (i.e. any type declared without using the
+ % `solver' keyword), the inst `any' should be considered to be equivalent
+ % to a bound inst i where i contains all the functors of the type t and
+ % each argument has inst `any'.
+ %
:- pred maybe_any_to_bound(maybe(type)::in, module_info::in, uniqueness::in,
(inst)::out) is semidet.
@@ -1998,8 +1995,8 @@
type_may_contain_solver_type(Type, ModuleInfo)
->
% For a type for which constructors are not available (e.g. an
- % abstract type) and which may contain solver types, we fail,
- % meaning that we will use `any' for this type.
+ % abstract type) and which may contain solver types, we fail, meaning
+ % that we will use `any' for this type.
fail
;
Inst = ground(Uniq, none)
@@ -2028,4 +2025,11 @@
type_may_contain_solver_type_2(user_ctor_type) = yes.
%-----------------------------------------------------------------------------%
+
+:- func this_file = string.
+
+this_file = "inst_match.m".
+
+%-----------------------------------------------------------------------------%
+:- end_module inst_match.
%-----------------------------------------------------------------------------%
--------------------------------------------------------------------------
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