For review: change type_info to typecheck_info.
Tyson Richard DOWD
trd at hydra.cs.mu.oz.au
Tue Apr 8 12:25:15 AEST 1997
Fergus,
Could you review this? The addition of support for io__read will use
a type called type_info, and it seems easiest to just avoid confusion.
(It's a pretty boring diff, the review is more of the idea).
===================================================================
Estimated hours taken: 1
compiler/typecheck.m:
Rename the type `type_info' as `typecheck_info', also
rename predicates `type_info_get_foo' as
`typecheck_info_get_foo'.
This change is aimed at avoiding confusion and the need for
module qualifiers, as a new type will soon be introduced into
the library with the name type_info.
Index: typecheck.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/typecheck.m,v
retrieving revision 1.191
diff -u -r1.191 typecheck.m
--- typecheck.m 1997/03/23 19:01:11 1.191
+++ typecheck.m 1997/03/24 00:14:10
@@ -20,14 +20,14 @@
% single type assignment, as opposed to a type assignment set
% are called type_assign_*.
%
-% Access predicates for the type_info data structure are called
-% type_info_*.
+% Access predicates for the typecheck_info data structure are called
+% typecheck_info_*.
%
% Note that DCGS are used for THREE different purposes in this file:
%
% 1. For accumulating io__states as usual.
%
-% 2. For accumulating type_infos, which contain:
+% 2. For accumulating typecheck_infos, which contain:
% - an io_state, which is modified if we need to
% to write out an error message
% - various semi-global info which doesn't change often,
@@ -338,12 +338,12 @@
),
bool(Inferring), % dummy pred call to avoid type ambiguity
- type_info_init(IOState1, ModuleInfo, PredId,
+ typecheck_info_init(IOState1, ModuleInfo, PredId,
TypeVarSet0, VarSet, VarTypes0, HeadTypeParams,
Status, TypeInfo1),
typecheck_clause_list(Clauses0, HeadVars, ArgTypes0, Clauses,
TypeInfo1, TypeInfo2),
- type_info_get_final_info(TypeInfo2, TypeVarSet, VarTypes1),
+ typecheck_info_get_final_info(TypeInfo2, TypeVarSet, VarTypes1),
map__optimize(VarTypes1, VarTypes),
ClausesInfo = clauses_info(VarSet, VarTypes0, VarTypes,
HeadVars, Clauses),
@@ -362,7 +362,7 @@
Changed = yes
)
),
- type_info_get_found_error(TypeInfo2, Error),
+ typecheck_info_get_found_error(TypeInfo2, Error),
(
Error = yes,
MaybePredInfo = no
@@ -370,7 +370,7 @@
Error = no,
MaybePredInfo = yes(PredInfo)
),
- type_info_get_io_state(TypeInfo2, IOState)
+ typecheck_info_get_io_state(TypeInfo2, IOState)
)
).
@@ -383,9 +383,9 @@
% Iterate over the list of clauses for a predicate.
:- pred typecheck_clause_list(list(clause), list(var), list(type), list(clause),
- type_info, type_info).
-:- mode typecheck_clause_list(in, in, in, out, type_info_di, type_info_uo)
- is det.
+ typecheck_info, typecheck_info).
+:- mode typecheck_clause_list(in, in, in, out, typecheck_info_di,
+ typecheck_info_uo) is det.
typecheck_clause_list([], _, _, []) --> [].
typecheck_clause_list([Clause0|Clauses0], HeadVars, ArgTypes,
@@ -416,20 +416,21 @@
% we should perhaps do manual garbage collection here
:- pred typecheck_clause(clause, list(var), list(type), clause,
- type_info, type_info).
-:- mode typecheck_clause(in, in, in, out, type_info_di, type_info_uo) is det.
+ typecheck_info, typecheck_info).
+:- mode typecheck_clause(in, in, in, out, typecheck_info_di, typecheck_info_uo)
+ is det.
typecheck_clause(Clause0, HeadVars, ArgTypes, Clause) -->
% XXX abstract clause/3
{ Clause0 = clause(Modes, Body0, Context) },
- type_info_set_context(Context),
+ typecheck_info_set_context(Context),
% typecheck the clause - first the head unification, and
% then the body
typecheck_var_has_type_list(HeadVars, ArgTypes, 0),
typecheck_goal(Body0, Body),
{ Clause = clause(Modes, Body, Context) },
% check for type ambiguities
- type_info_set_context(Context),
+ typecheck_info_set_context(Context),
typecheck_finish_clause.
%-----------------------------------------------------------------------------%
@@ -437,23 +438,25 @@
% If there are still multiple type assignments for the clause,
% then we issue an error message here.
-:- pred typecheck_finish_clause(type_info, type_info).
-:- mode typecheck_finish_clause(type_info_di, type_info_uo) is det.
+:- pred typecheck_finish_clause(typecheck_info, typecheck_info).
+:- mode typecheck_finish_clause(typecheck_info_di, typecheck_info_uo) is det.
typecheck_finish_clause(TypeInfo0, TypeInfo) :-
- type_info_get_type_assign_set(TypeInfo0, TypeAssignSet),
+ typecheck_info_get_type_assign_set(TypeInfo0, TypeAssignSet),
( TypeAssignSet = [_TypeAssign] ->
TypeInfo = TypeInfo0
; TypeAssignSet = [TypeAssign1, TypeAssign2 | _] ->
% we only report an ambiguity error if
% there weren't any other errors in the clause
- type_info_get_found_error(TypeInfo0, FoundError),
+ typecheck_info_get_found_error(TypeInfo0, FoundError),
( FoundError = no ->
- type_info_set_found_error(TypeInfo0, yes, TypeInfo1),
- type_info_get_io_state(TypeInfo1, IOState0),
+ typecheck_info_set_found_error(TypeInfo0, yes,
+ TypeInfo1),
+ typecheck_info_get_io_state(TypeInfo1, IOState0),
report_ambiguity_error(TypeInfo1, TypeAssign1,
TypeAssign2, IOState0, IOState),
- type_info_set_io_state(TypeInfo1, IOState, TypeInfo)
+ typecheck_info_set_io_state(TypeInfo1, IOState,
+ TypeInfo)
;
TypeInfo = TypeInfo0
)
@@ -476,11 +479,11 @@
% for the variables in the clause do not contain any unbound type
% variables other than the HeadTypeParams.
-:- pred check_type_bindings(type_assign, type_info, type_info).
-:- mode check_type_bindings(in, type_info_di, type_info_uo) is det.
+:- pred check_type_bindings(type_assign, typecheck_info, typecheck_info).
+:- mode check_type_bindings(in, typecheck_info_di, typecheck_info_uo) is det.
check_type_bindings(TypeAssign, TypeInfo0, TypeInfo) :-
- type_info_get_head_type_params(TypeInfo0, HeadTypeParams),
+ typecheck_info_get_head_type_params(TypeInfo0, HeadTypeParams),
type_assign_get_type_bindings(TypeAssign, TypeBindings),
type_assign_get_var_types(TypeAssign, VarTypes),
map__values(VarTypes, Types),
@@ -511,23 +514,26 @@
% report an error: uninstantiated type parameter
-:- pred report_unresolved_type_error(list(var), tvarset, type_info, type_info).
-:- mode report_unresolved_type_error(in, in, type_info_di, type_info_uo) is det.
+:- pred report_unresolved_type_error(list(var), tvarset, typecheck_info,
+ typecheck_info).
+:- mode report_unresolved_type_error(in, in, typecheck_info_di,
+ typecheck_info_uo) is det.
report_unresolved_type_error(TVars, TVarSet, TypeInfo0, TypeInfo) :-
- type_info_get_io_state(TypeInfo0, IOState0),
+ typecheck_info_get_io_state(TypeInfo0, IOState0),
report_unresolved_type_error_2(TypeInfo0, TVars, TVarSet,
IOState0, IOState),
- type_info_set_io_state(TypeInfo0, IOState, TypeInfo1),
- type_info_set_found_error(TypeInfo1, yes, TypeInfo).
+ typecheck_info_set_io_state(TypeInfo0, IOState, TypeInfo1),
+ typecheck_info_set_found_error(TypeInfo1, yes, TypeInfo).
-:- pred report_unresolved_type_error_2(type_info, list(var), tvarset,
+:- pred report_unresolved_type_error_2(typecheck_info, list(var), tvarset,
io__state, io__state).
-:- mode report_unresolved_type_error_2(type_info_no_io, in, in, di, uo) is det.
+:- mode report_unresolved_type_error_2(typecheck_info_no_io, in, in, di, uo)
+ is det.
report_unresolved_type_error_2(TypeInfo, TVars, TVarSet) -->
- write_type_info_context(TypeInfo),
- { type_info_get_context(TypeInfo, Context) },
+ write_typecheck_info_context(TypeInfo),
+ { typecheck_info_get_context(TypeInfo, Context) },
io__write_string(" type error: unresolved polymorphism.\n"),
prog_out__write_context(Context),
io__write_string(" Unbound type vars were: "),
@@ -567,8 +573,8 @@
%-----------------------------------------------------------------------------%
-:- pred typecheck_goal(hlds_goal, hlds_goal, type_info, type_info).
-:- mode typecheck_goal(in, out, type_info_di, type_info_uo) is det.
+:- pred typecheck_goal(hlds_goal, hlds_goal, typecheck_info, typecheck_info).
+:- mode typecheck_goal(in, out, typecheck_info_di, typecheck_info_uo) is det.
% Typecheck a goal.
% Note that we save the context of the goal in the typeinfo for
@@ -581,12 +587,12 @@
goal_info_get_context(GoalInfo0, Context),
term__context_init(EmptyContext),
( Context = EmptyContext ->
- type_info_get_context(TypeInfo0, EnclosingContext),
+ typecheck_info_get_context(TypeInfo0, EnclosingContext),
goal_info_set_context(GoalInfo0, EnclosingContext, GoalInfo),
TypeInfo1 = TypeInfo0
;
GoalInfo = GoalInfo0,
- type_info_set_context(Context, TypeInfo0, TypeInfo1)
+ typecheck_info_set_context(Context, TypeInfo0, TypeInfo1)
),
% type-check the goal
@@ -595,8 +601,8 @@
check_warn_too_much_overloading(TypeInfo2, TypeInfo).
:- pred typecheck_goal_2(hlds_goal_expr, hlds_goal_expr,
- type_info, type_info).
-:- mode typecheck_goal_2(in, out, type_info_di, type_info_uo) is det.
+ typecheck_info, typecheck_info).
+:- mode typecheck_goal_2(in, out, typecheck_info_di, typecheck_info_uo) is det.
typecheck_goal_2(conj(List0), conj(List)) -->
checkpoint("conj"),
@@ -629,8 +635,8 @@
typecheck_goal_2(unify(A, B0, Mode, Info, UnifyContext),
unify(A, B, Mode, Info, UnifyContext)) -->
checkpoint("unify"),
- type_info_set_arg_num(0),
- type_info_set_unify_context(UnifyContext),
+ typecheck_info_set_arg_num(0),
+ typecheck_info_set_unify_context(UnifyContext),
typecheck_unification(A, B0, B).
typecheck_goal_2(switch(_, _, _, _), _) -->
{ error("unexpected switch") }.
@@ -641,8 +647,9 @@
%-----------------------------------------------------------------------------%
:- pred typecheck_goal_list(list(hlds_goal), list(hlds_goal),
- type_info, type_info).
-:- mode typecheck_goal_list(in, out, type_info_di, type_info_uo) is det.
+ typecheck_info, typecheck_info).
+:- mode typecheck_goal_list(in, out, typecheck_info_di, typecheck_info_uo)
+ is det.
typecheck_goal_list([], []) --> [].
typecheck_goal_list([Goal0 | Goals0], [Goal | Goals]) -->
@@ -651,15 +658,17 @@
%-----------------------------------------------------------------------------%
-:- pred typecheck_higher_order_call(var, list(var), type_info, type_info).
-:- mode typecheck_higher_order_call(in, in, type_info_di, type_info_uo) is det.
+:- pred typecheck_higher_order_call(var, list(var), typecheck_info,
+ typecheck_info).
+:- mode typecheck_higher_order_call(in, in, typecheck_info_di,
+ typecheck_info_uo) is det.
typecheck_higher_order_call(PredVar, Args) -->
{ list__length(Args, Arity) },
{ higher_order_pred_type(Arity, TypeVarSet, PredVarType, ArgTypes) },
{ Arity1 is Arity + 1 },
{ PredCallId = unqualified("call")/Arity1 },
- type_info_set_called_predid(PredCallId),
+ typecheck_info_set_called_predid(PredCallId),
typecheck_var_has_polymorphic_type_list([PredVar|Args], TypeVarSet,
[PredVarType|ArgTypes]).
@@ -701,17 +710,18 @@
%-----------------------------------------------------------------------------%
-:- pred typecheck_call_pred(sym_name, list(var), pred_id, type_info,
- type_info).
-:- mode typecheck_call_pred(in, in, out, type_info_di, type_info_uo) is det.
+:- pred typecheck_call_pred(sym_name, list(var), pred_id, typecheck_info,
+ typecheck_info).
+:- mode typecheck_call_pred(in, in, out, typecheck_info_di,
+ typecheck_info_uo) is det.
typecheck_call_pred(PredName, Args, PredId, TypeInfo0, TypeInfo) :-
list__length(Args, Arity),
PredCallId = PredName/Arity,
- type_info_set_called_predid(PredCallId, TypeInfo0, TypeInfo1),
+ typecheck_info_set_called_predid(PredCallId, TypeInfo0, TypeInfo1),
% look up the called predicate's arg types
- type_info_get_module_info(TypeInfo1, ModuleInfo),
+ typecheck_info_get_module_info(TypeInfo1, ModuleInfo),
module_info_get_predicate_table(ModuleInfo, PredicateTable),
(
predicate_table_search_pred_sym_arity(PredicateTable,
@@ -725,7 +735,7 @@
predicate_table_get_preds(PredicateTable, Preds),
map__lookup(Preds, PredId0, PredInfo),
pred_info_import_status(PredInfo, CalledStatus),
- type_info_get_pred_import_status(TypeInfo1,
+ typecheck_info_get_pred_import_status(TypeInfo1,
CallingStatus),
(
% Only opt_imported preds can look at
@@ -760,7 +770,7 @@
)
;
- type_info_get_pred_import_status(TypeInfo1,
+ typecheck_info_get_pred_import_status(TypeInfo1,
CallingStatus),
typecheck_call_overloaded_pred(PredIdList, Args,
CallingStatus, TypeInfo1, TypeInfo),
@@ -783,15 +793,15 @@
PredicateTable, PredCallId, TypeInfo)
).
-:- pred report_pred_call_error(type_info, module_info, predicate_table,
- pred_call_id, type_info).
-:- mode report_pred_call_error(type_info_di, in, in,
- in, type_info_uo) is det.
+:- pred report_pred_call_error(typecheck_info, module_info, predicate_table,
+ pred_call_id, typecheck_info).
+:- mode report_pred_call_error(typecheck_info_di, in, in,
+ in, typecheck_info_uo) is det.
report_pred_call_error(TypeInfo1, _ModuleInfo, PredicateTable,
PredCallId, TypeInfo) :-
PredCallId = PredName/_Arity,
- type_info_get_io_state(TypeInfo1, IOState0),
+ typecheck_info_get_io_state(TypeInfo1, IOState0),
(
predicate_table_search_pred_sym(PredicateTable,
PredName, OtherIds0),
@@ -815,8 +825,8 @@
report_error_undef_pred(TypeInfo1, PredCallId,
IOState0, IOState)
),
- type_info_set_io_state(TypeInfo1, IOState, TypeInfo2),
- type_info_set_found_error(TypeInfo2, yes, TypeInfo).
+ typecheck_info_set_io_state(TypeInfo1, IOState, TypeInfo2),
+ typecheck_info_set_found_error(TypeInfo2, yes, TypeInfo).
:- pred typecheck_find_arities(pred_table, list(pred_id), list(int)).
:- mode typecheck_find_arities(in, in, out) is det.
@@ -842,9 +852,9 @@
list__filter(FilterOptDecls, PredIds0, PredIds).
:- pred typecheck_call_overloaded_pred(list(pred_id), list(var),
- import_status, type_info, type_info).
+ import_status, typecheck_info, typecheck_info).
:- mode typecheck_call_overloaded_pred(in, in, in,
- type_info_di, type_info_uo) is det.
+ typecheck_info_di, typecheck_info_uo) is det.
typecheck_call_overloaded_pred(PredIdList, Args, CallingPredStatus,
TypeInfo0, TypeInfo) :-
@@ -854,10 +864,10 @@
% lists of argument types for the overloaded predicate,
% suitable renamed apart
%
- type_info_get_module_info(TypeInfo0, ModuleInfo),
+ typecheck_info_get_module_info(TypeInfo0, ModuleInfo),
module_info_get_predicate_table(ModuleInfo, PredicateTable),
predicate_table_get_preds(PredicateTable, Preds),
- type_info_get_type_assign_set(TypeInfo0, TypeAssignSet0),
+ typecheck_info_get_type_assign_set(TypeInfo0, TypeAssignSet0),
get_overloaded_pred_arg_types(PredIdList, Preds, CallingPredStatus,
TypeAssignSet0, [], ArgsTypeAssignSet),
%
@@ -985,13 +995,13 @@
% the expected types.
:- pred typecheck_var_has_polymorphic_type_list(list(var), tvarset, list(type),
- type_info, type_info).
+ typecheck_info, typecheck_info).
:- mode typecheck_var_has_polymorphic_type_list(in, in, in,
- type_info_di, type_info_uo) is det.
+ typecheck_info_di, typecheck_info_uo) is det.
typecheck_var_has_polymorphic_type_list(Args, PredTypeVarSet, PredArgTypes,
TypeInfo0, TypeInfo) :-
- type_info_get_type_assign_set(TypeInfo0, TypeAssignSet0),
+ typecheck_info_get_type_assign_set(TypeInfo0, TypeAssignSet0),
rename_apart(TypeAssignSet0, PredTypeVarSet, PredArgTypes,
[], ArgsTypeAssignSet),
typecheck_var_has_arg_type_list(Args, 0, ArgsTypeAssignSet,
@@ -1027,18 +1037,18 @@
% that each variable has the corresponding type.
:- pred typecheck_var_has_arg_type_list(list(var), int, args_type_assign_set,
- type_info, type_info).
-:- mode typecheck_var_has_arg_type_list(in, in, in,
- type_info_di, type_info_uo) is det.
+ typecheck_info, typecheck_info).
+:- mode typecheck_var_has_arg_type_list(in, in, in,
+ typecheck_info_di, typecheck_info_uo) is det.
typecheck_var_has_arg_type_list([], _, ArgTypeAssignSet,
TypeInfo0, TypeInfo) :-
convert_args_type_assign_set(ArgTypeAssignSet, TypeAssignSet),
- type_info_set_type_assign_set(TypeInfo0, TypeAssignSet, TypeInfo).
+ typecheck_info_set_type_assign_set(TypeInfo0, TypeAssignSet, TypeInfo).
typecheck_var_has_arg_type_list([Var|Vars], ArgNum, ArgTypeAssignSet0) -->
{ ArgNum1 is ArgNum + 1 },
- type_info_set_arg_num(ArgNum1),
+ typecheck_info_set_arg_num(ArgNum1),
typecheck_var_has_arg_type(Var, ArgTypeAssignSet0, ArgTypeAssignSet1),
typecheck_var_has_arg_type_list(Vars, ArgNum1, ArgTypeAssignSet1).
@@ -1059,13 +1069,13 @@
:- pred typecheck_var_has_arg_type(var,
args_type_assign_set, args_type_assign_set,
- type_info, type_info).
+ typecheck_info, typecheck_info).
:- mode typecheck_var_has_arg_type(in, in, out,
- type_info_di, type_info_uo) is det.
+ typecheck_info_di, typecheck_info_uo) is det.
typecheck_var_has_arg_type(VarId, ArgTypeAssignSet0, ArgTypeAssignSet,
TypeInfo0, TypeInfo) :-
- type_info_get_head_type_params(TypeInfo0, HeadTypeParams),
+ typecheck_info_get_head_type_params(TypeInfo0, HeadTypeParams),
typecheck_var_has_arg_type_2(ArgTypeAssignSet0, HeadTypeParams,
VarId, [], ArgTypeAssignSet1),
(
@@ -1073,11 +1083,11 @@
ArgTypeAssignSet0 \= []
->
skip_arg(ArgTypeAssignSet0, ArgTypeAssignSet),
- type_info_get_io_state(TypeInfo0, IOState0),
+ typecheck_info_get_io_state(TypeInfo0, IOState0),
report_error_arg_var(TypeInfo0, VarId,
ArgTypeAssignSet0, IOState0, IOState),
- type_info_set_io_state(TypeInfo0, IOState, TypeInfo1),
- type_info_set_found_error(TypeInfo1, yes, TypeInfo)
+ typecheck_info_set_io_state(TypeInfo0, IOState, TypeInfo1),
+ typecheck_info_set_found_error(TypeInfo1, yes, TypeInfo)
;
ArgTypeAssignSet = ArgTypeAssignSet1,
TypeInfo = TypeInfo0
@@ -1142,10 +1152,10 @@
% Given a list of variables and a list of types, ensure
% that each variable has the corresponding type.
-:- pred typecheck_var_has_type_list(list(var), list(type), int, type_info,
- type_info).
-:- mode typecheck_var_has_type_list(in, in, in, type_info_di, type_info_uo)
- is det.
+:- pred typecheck_var_has_type_list(list(var), list(type), int, typecheck_info,
+ typecheck_info).
+:- mode typecheck_var_has_type_list(in, in, in, typecheck_info_di,
+ typecheck_info_uo) is det.
typecheck_var_has_type_list([], [_|_], _) -->
{ error("typecheck_var_has_type_list: length mismatch") }.
@@ -1154,29 +1164,30 @@
typecheck_var_has_type_list([], [], _) --> [].
typecheck_var_has_type_list([Var|Vars], [Type|Types], ArgNum) -->
{ ArgNum1 is ArgNum + 1 },
- type_info_set_arg_num(ArgNum1),
+ typecheck_info_set_arg_num(ArgNum1),
typecheck_var_has_type(Var, Type),
typecheck_var_has_type_list(Vars, Types, ArgNum1).
-:- pred typecheck_var_has_type(var, type, type_info, type_info).
-:- mode typecheck_var_has_type(in, in, type_info_di, type_info_uo) is det.
+:- pred typecheck_var_has_type(var, type, typecheck_info, typecheck_info).
+:- mode typecheck_var_has_type(in, in, typecheck_info_di, typecheck_info_uo)
+ is det.
typecheck_var_has_type(VarId, Type, TypeInfo0, TypeInfo) :-
- type_info_get_type_assign_set(TypeInfo0, TypeAssignSet0),
- type_info_get_head_type_params(TypeInfo0, HeadTypeParams),
+ typecheck_info_get_type_assign_set(TypeInfo0, TypeAssignSet0),
+ typecheck_info_get_head_type_params(TypeInfo0, HeadTypeParams),
typecheck_var_has_type_2(TypeAssignSet0, HeadTypeParams, VarId, Type,
[], TypeAssignSet),
(
TypeAssignSet = [],
TypeAssignSet0 \= []
->
- type_info_get_io_state(TypeInfo0, IOState0),
+ typecheck_info_get_io_state(TypeInfo0, IOState0),
report_error_var(TypeInfo0, VarId,
Type, TypeAssignSet0, IOState0, IOState),
- type_info_set_io_state(TypeInfo0, IOState, TypeInfo1),
- type_info_set_found_error(TypeInfo1, yes, TypeInfo)
+ typecheck_info_set_io_state(TypeInfo0, IOState, TypeInfo1),
+ typecheck_info_set_found_error(TypeInfo1, yes, TypeInfo)
;
- type_info_set_type_assign_set(TypeInfo0, TypeAssignSet,
+ typecheck_info_set_type_assign_set(TypeInfo0, TypeAssignSet,
TypeInfo)
).
@@ -1296,8 +1307,8 @@
% list__append(TAs, TypeAssignSet0, TypeAssignSet).
:- pred type_assign_var_has_type_list(list(var), list(type), type_assign,
- type_info, type_assign_set, type_assign_set).
-:- mode type_assign_var_has_type_list(in, in, in, type_info_ui, in, out)
+ typecheck_info, type_assign_set, type_assign_set).
+:- mode type_assign_var_has_type_list(in, in, in, typecheck_info_ui, in, out)
is det.
type_assign_var_has_type_list([], [_|_], _, _, _, _) :-
@@ -1308,7 +1319,7 @@
TypeAssignSet, [TypeAssign|TypeAssignSet]).
type_assign_var_has_type_list([Arg | Args], [Type | Types], TypeAssign0,
TypeInfo, TypeAssignSet0, TypeAssignSet) :-
- type_info_get_head_type_params(TypeInfo, HeadTypeParams),
+ typecheck_info_get_head_type_params(TypeInfo, HeadTypeParams),
type_assign_var_has_type(TypeAssign0, HeadTypeParams, Arg, Type,
[], TypeAssignSet1),
type_assign_list_var_has_type_list(TypeAssignSet1,
@@ -1322,9 +1333,9 @@
% list__append(TAs, TypeAssignSet0, TypeAssignSet).
:- pred type_assign_list_var_has_type_list(type_assign_set, list(var),
- list(type), type_info, type_assign_set, type_assign_set).
-:- mode type_assign_list_var_has_type_list(in, in, in, type_info_ui, in, out)
- is det.
+ list(type), typecheck_info, type_assign_set, type_assign_set).
+:- mode type_assign_list_var_has_type_list(in, in, in, typecheck_info_ui,
+ in, out) is det.
type_assign_list_var_has_type_list([], _, _, _) --> [].
type_assign_list_var_has_type_list([TA | TAs], Args, Types, TypeInfo) -->
@@ -1339,23 +1350,24 @@
% is arbitrarily defined as anthing which results in
% more than 50 possible type assignments.
-:- pred check_warn_too_much_overloading(type_info, type_info).
-:- mode check_warn_too_much_overloading(type_info_di, type_info_uo) is det.
+:- pred check_warn_too_much_overloading(typecheck_info, typecheck_info).
+:- mode check_warn_too_much_overloading(typecheck_info_di, typecheck_info_uo)
+ is det.
check_warn_too_much_overloading(TypeInfo0, TypeInfo) :-
(
- type_info_get_warned_about_overloading(TypeInfo0,
+ typecheck_info_get_warned_about_overloading(TypeInfo0,
AlreadyWarned),
AlreadyWarned = no,
- type_info_get_type_assign_set(TypeInfo0, TypeAssignSet),
+ typecheck_info_get_type_assign_set(TypeInfo0, TypeAssignSet),
list__length(TypeAssignSet, Count),
Count > 50
->
- type_info_get_io_state(TypeInfo0, IOState0),
+ typecheck_info_get_io_state(TypeInfo0, IOState0),
report_warning_too_much_overloading(TypeInfo0,
IOState0, IOState1),
- type_info_set_io_state(TypeInfo0, IOState1, TypeInfo1),
- type_info_set_warned_about_overloading(TypeInfo1, yes,
+ typecheck_info_set_io_state(TypeInfo0, IOState1, TypeInfo1),
+ typecheck_info_set_warned_about_overloading(TypeInfo1, yes,
TypeInfo)
;
TypeInfo = TypeInfo0
@@ -1365,21 +1377,21 @@
% used for debugging
-:- pred checkpoint(string, type_info, type_info).
-:- mode checkpoint(in, type_info_di, type_info_uo) is det.
+:- pred checkpoint(string, typecheck_info, typecheck_info).
+:- mode checkpoint(in, typecheck_info_di, typecheck_info_uo) is det.
checkpoint(Msg, T0, T) :-
- type_info_get_io_state(T0, I0),
+ typecheck_info_get_io_state(T0, I0),
globals__io_lookup_bool_option(debug_types, DoCheckPoint, I0, I1),
( DoCheckPoint = yes ->
checkpoint_2(Msg, T0, I1, I)
;
I = I1
),
- type_info_set_io_state(T0, I, T).
+ typecheck_info_set_io_state(T0, I, T).
-:- pred checkpoint_2(string, type_info, io__state, io__state).
-:- mode checkpoint_2(in, type_info_no_io, di, uo) is det.
+:- pred checkpoint_2(string, typecheck_info, io__state, io__state).
+:- mode checkpoint_2(in, typecheck_info_no_io, di, uo) is det.
checkpoint_2(Msg, T0) -->
io__write_string("At "),
@@ -1388,7 +1400,7 @@
globals__io_lookup_bool_option(statistics, Statistics),
maybe_report_stats(Statistics),
io__write_string("\n"),
- { type_info_get_type_assign_set(T0, TypeAssignSet) },
+ { typecheck_info_get_type_assign_set(T0, TypeAssignSet) },
(
{ Statistics = yes },
{ TypeAssignSet = [TypeAssign | _] }
@@ -1400,7 +1412,7 @@
;
[]
),
- { type_info_get_varset(T0, VarSet) },
+ { typecheck_info_get_varset(T0, VarSet) },
write_type_assign_set(TypeAssignSet, VarSet).
:- pred checkpoint_tree_stats(string, map(_K, _V), io__state, io__state).
@@ -1422,8 +1434,9 @@
% Get the type assignment set from the type info and then just
% iterate over all the possible type assignments.
-:- pred typecheck_unification(var, unify_rhs, unify_rhs, type_info, type_info).
-:- mode typecheck_unification(in, in, out, type_info_di, type_info_uo) is det.
+:- pred typecheck_unification(var, unify_rhs, unify_rhs, typecheck_info, typecheck_info).
+:- mode typecheck_unification(in, in, out, typecheck_info_di,
+ typecheck_info_uo) is det.
:- typecheck_unification(_, Y, _, _, _) when Y.
@@ -1436,28 +1449,29 @@
typecheck_lambda_var_has_type(PredOrFunc, X, Vars),
typecheck_goal(Goal0, Goal).
-:- pred typecheck_unify_var_var(var, var, type_info, type_info).
-:- mode typecheck_unify_var_var(in, in, type_info_di, type_info_uo) is det.
+:- pred typecheck_unify_var_var(var, var, typecheck_info, typecheck_info).
+:- mode typecheck_unify_var_var(in, in, typecheck_info_di, typecheck_info_uo)
+ is det.
typecheck_unify_var_var(X, Y, TypeInfo0, TypeInfo) :-
- type_info_get_type_assign_set(TypeInfo0, TypeAssignSet0),
+ typecheck_info_get_type_assign_set(TypeInfo0, TypeAssignSet0),
typecheck_unify_var_var_2(TypeAssignSet0, X, Y, TypeInfo0,
[], TypeAssignSet),
( TypeAssignSet = [], TypeAssignSet0 \= [] ->
- type_info_get_io_state(TypeInfo0, IOState0),
+ typecheck_info_get_io_state(TypeInfo0, IOState0),
report_error_unif_var_var(TypeInfo0, X, Y, TypeAssignSet0,
IOState0, IOState1),
- type_info_set_io_state(TypeInfo0, IOState1, TypeInfo1),
- type_info_set_found_error(TypeInfo1, yes, TypeInfo)
+ typecheck_info_set_io_state(TypeInfo0, IOState1, TypeInfo1),
+ typecheck_info_set_found_error(TypeInfo1, yes, TypeInfo)
;
- type_info_set_type_assign_set(TypeInfo0, TypeAssignSet,
+ typecheck_info_set_type_assign_set(TypeInfo0, TypeAssignSet,
TypeInfo)
).
-:- pred typecheck_unify_var_functor(var, cons_id, list(var),
- type_info, type_info).
-:- mode typecheck_unify_var_functor(in, in, in, type_info_di, type_info_uo)
- is det.
+:- pred typecheck_unify_var_functor(var, cons_id, list(var), typecheck_info,
+ typecheck_info).
+:- mode typecheck_unify_var_functor(in, in, in, typecheck_info_di,
+ typecheck_info_uo) is det.
typecheck_unify_var_functor(Var, Functor, Args, TypeInfo0, TypeInfo) :-
%
@@ -1465,19 +1479,19 @@
% if there aren't any, report an undefined constructor error
%
list__length(Args, Arity),
- type_info_get_ctor_list(TypeInfo0, Functor, Arity, ConsDefnList),
+ typecheck_info_get_ctor_list(TypeInfo0, Functor, Arity, ConsDefnList),
( ConsDefnList = [] ->
- type_info_get_io_state(TypeInfo0, IOState0),
+ typecheck_info_get_io_state(TypeInfo0, IOState0),
report_error_undef_cons(TypeInfo0, Functor, Arity,
IOState0, IOState1),
- type_info_set_io_state(TypeInfo0, IOState1, TypeInfo1),
- type_info_set_found_error(TypeInfo1, yes, TypeInfo)
+ typecheck_info_set_io_state(TypeInfo0, IOState1, TypeInfo1),
+ typecheck_info_set_found_error(TypeInfo1, yes, TypeInfo)
;
%
% produce the ConsTypeAssignSet, which is essentially the
% cross-product of the TypeAssignSet0 and the ConsDefnList
%
- type_info_get_type_assign_set(TypeInfo0, TypeAssignSet0),
+ typecheck_info_get_type_assign_set(TypeInfo0, TypeAssignSet0),
typecheck_unify_var_functor_get_ctors(TypeAssignSet0,
TypeInfo0, ConsDefnList, [], ConsTypeAssignSet),
( ConsTypeAssignSet = [], TypeAssignSet0 \= [] ->
@@ -1495,13 +1509,15 @@
typecheck_functor_type( ConsTypeAssignSet, Var,
TypeInfo0, [], ArgsTypeAssignSet),
( ArgsTypeAssignSet = [], ConsTypeAssignSet \= [] ->
- type_info_get_io_state(TypeInfo0, IOState0),
+ typecheck_info_get_io_state(TypeInfo0, IOState0),
report_error_functor_type(TypeInfo0,
Var, ConsDefnList, Functor, Arity,
TypeAssignSet0,
IOState0, IOState1),
- type_info_set_io_state(TypeInfo0, IOState1, TypeInfo1),
- type_info_set_found_error(TypeInfo1, yes, TypeInfo2)
+ typecheck_info_set_io_state(TypeInfo0, IOState1,
+ TypeInfo1),
+ typecheck_info_set_found_error(TypeInfo1, yes,
+ TypeInfo2)
;
TypeInfo2 = TypeInfo0
),
@@ -1513,13 +1529,15 @@
typecheck_functor_arg_types( ArgsTypeAssignSet, Args,
TypeInfo2, [], TypeAssignSet),
( TypeAssignSet = [], ArgsTypeAssignSet \= [] ->
- type_info_get_io_state(TypeInfo2, IOState2),
+ typecheck_info_get_io_state(TypeInfo2, IOState2),
report_error_functor_arg_types(TypeInfo2,
Var, ConsDefnList, Functor, Args,
TypeAssignSet0,
IOState2, IOState3),
- type_info_set_io_state(TypeInfo2, IOState3, TypeInfo3),
- type_info_set_found_error(TypeInfo3, yes, TypeInfo4)
+ typecheck_info_set_io_state(TypeInfo2, IOState3,
+ TypeInfo3),
+ typecheck_info_set_found_error(TypeInfo3, yes,
+ TypeInfo4)
;
TypeInfo4 = TypeInfo2
),
@@ -1528,11 +1546,11 @@
% original type assign set
%
( TypeAssignSet = [] ->
- type_info_set_type_assign_set(TypeInfo4, TypeAssignSet0,
- TypeInfo)
+ typecheck_info_set_type_assign_set(TypeInfo4,
+ TypeAssignSet0, TypeInfo)
;
- type_info_set_type_assign_set(TypeInfo4, TypeAssignSet,
- TypeInfo)
+ typecheck_info_set_type_assign_set(TypeInfo4,
+ TypeAssignSet, TypeInfo)
)
).
@@ -1556,7 +1574,7 @@
:- type args_type_assign_set == list(pair(type_assign, list(type))).
:- pred typecheck_unify_var_functor_get_ctors(type_assign_set,
- type_info, list(cons_type_info),
+ typecheck_info, list(cons_type_info),
cons_type_assign_set, cons_type_assign_set).
:- mode typecheck_unify_var_functor_get_ctors(in, in, in, in, out) is det.
@@ -1571,9 +1589,9 @@
% Iterate over all the different cons defns.
-:- pred typecheck_unify_var_functor_get_ctors_2(list(cons_type_info), type_info,
- type_assign,
- cons_type_assign_set, cons_type_assign_set).
+:- pred typecheck_unify_var_functor_get_ctors_2(list(cons_type_info),
+ typecheck_info, type_assign, cons_type_assign_set,
+ cons_type_assign_set).
:- mode typecheck_unify_var_functor_get_ctors_2(in, in, in, in, out) is det.
typecheck_unify_var_functor_get_ctors_2([], _, _) --> [].
@@ -1591,9 +1609,9 @@
% for each possible constructor type,
% check that the type of `Var' matches this type.
-:- pred typecheck_functor_type(cons_type_assign_set, var, type_info,
+:- pred typecheck_functor_type(cons_type_assign_set, var, typecheck_info,
args_type_assign_set, args_type_assign_set).
-:- mode typecheck_functor_type(in, in, type_info_ui, in, out) is det.
+:- mode typecheck_functor_type(in, in, typecheck_info_ui, in, out) is det.
typecheck_functor_type([], _, _) --> [].
typecheck_functor_type([TypeAssign - ConsType | ConsTypeAssigns],
@@ -1610,8 +1628,9 @@
% check that the types of `Args' matches these types.
:- pred typecheck_functor_arg_types(args_type_assign_set, list(var),
- type_info, type_assign_set, type_assign_set).
-:- mode typecheck_functor_arg_types(in, in, type_info_ui, in, out)
+ typecheck_info, type_assign_set,
+ type_assign_set).
+:- mode typecheck_functor_arg_types(in, in, typecheck_info_ui, in, out)
is det.
typecheck_functor_arg_types([], _, _) --> [].
@@ -1622,9 +1641,10 @@
% iterate over all the possible type assignments.
-:- pred typecheck_unify_var_var_2(type_assign_set, var, var,
- type_info, type_assign_set, type_assign_set).
-:- mode typecheck_unify_var_var_2(in, in, in, type_info_ui, in, out) is det.
+:- pred typecheck_unify_var_var_2(type_assign_set, var, var, typecheck_info,
+ type_assign_set, type_assign_set).
+:- mode typecheck_unify_var_var_2(in, in, in, typecheck_info_ui, in, out)
+ is det.
typecheck_unify_var_var_2([], _, _, _) --> [].
typecheck_unify_var_var_2([TypeAssign0 | TypeAssigns0], X, Y, TypeInfo) -->
@@ -1641,9 +1661,10 @@
% any type assignment(s) resulting from TypeAssign0 and this
% unification.
-:- pred type_assign_unify_var_var(var, var, type_assign, type_info,
+:- pred type_assign_unify_var_var(var, var, type_assign, typecheck_info,
type_assign_set, type_assign_set).
-:- mode type_assign_unify_var_var(in, in, in, type_info_ui, in, out) is det.
+:- mode type_assign_unify_var_var(in, in, in, typecheck_info_ui, in, out)
+ is det.
type_assign_unify_var_var(X, Y, TypeAssign0, TypeInfo, TypeAssignSet0,
TypeAssignSet) :-
@@ -1656,7 +1677,7 @@
->
% both X and Y already have types - just
% unify their types
- type_info_get_head_type_params(TypeInfo,
+ typecheck_info_get_head_type_params(TypeInfo,
HeadTypeParams),
(
type_assign_unify_type(TypeAssign0,
@@ -1705,9 +1726,9 @@
%-----------------------------------------------------------------------------%
:- pred type_assign_check_functor_type(type, list(type),
- var, type_assign, type_info,
+ var, type_assign, typecheck_info,
args_type_assign_set, args_type_assign_set).
-:- mode type_assign_check_functor_type(in, in, in, in, type_info_ui,
+:- mode type_assign_check_functor_type(in, in, in, in, typecheck_info_ui,
in, out) is det.
type_assign_check_functor_type(ConsType, ArgTypes, Y, TypeAssign1,
@@ -1718,7 +1739,7 @@
( %%% if some [TypeY]
map__search(VarTypes0, Y, TypeY)
->
- type_info_get_head_type_params(TypeInfo, HeadTypeParams),
+ typecheck_info_get_head_type_params(TypeInfo, HeadTypeParams),
( %%% if some [TypeAssign2]
type_assign_unify_type(TypeAssign1, HeadTypeParams,
ConsType, TypeY, TypeAssign2)
@@ -1741,7 +1762,7 @@
% suitable renamed apart from the current type_assign's
% typevarset.
-:- pred get_cons_stuff(cons_type_info, type_assign, type_info,
+:- pred get_cons_stuff(cons_type_info, type_assign, typecheck_info,
type, list(type), type_assign).
:- mode get_cons_stuff(in, in, in, out, out, out) is det.
@@ -1777,26 +1798,26 @@
% T1, T2, ... are the types of the `ArgVars'.
:- pred typecheck_lambda_var_has_type(pred_or_func, var, list(var),
- type_info, type_info).
-:- mode typecheck_lambda_var_has_type(in, in, in, type_info_di, type_info_uo)
- is det.
+ typecheck_info, typecheck_info).
+:- mode typecheck_lambda_var_has_type(in, in, in, typecheck_info_di,
+ typecheck_info_uo) is det.
typecheck_lambda_var_has_type(PredOrFunc, Var, ArgVars, TypeInfo0, TypeInfo) :-
- type_info_get_type_assign_set(TypeInfo0, TypeAssignSet0),
- type_info_get_head_type_params(TypeInfo0, HeadTypeParams),
+ typecheck_info_get_type_assign_set(TypeInfo0, TypeAssignSet0),
+ typecheck_info_get_head_type_params(TypeInfo0, HeadTypeParams),
typecheck_lambda_var_has_type_2(TypeAssignSet0, HeadTypeParams,
PredOrFunc, Var, ArgVars, [], TypeAssignSet),
(
TypeAssignSet = [],
TypeAssignSet0 \= []
->
- type_info_get_io_state(TypeInfo0, IOState0),
+ typecheck_info_get_io_state(TypeInfo0, IOState0),
report_error_lambda_var(TypeInfo0, PredOrFunc, Var, ArgVars,
TypeAssignSet0, IOState0, IOState),
- type_info_set_io_state(TypeInfo0, IOState, TypeInfo1),
- type_info_set_found_error(TypeInfo1, yes, TypeInfo)
+ typecheck_info_set_io_state(TypeInfo0, IOState, TypeInfo1),
+ typecheck_info_set_found_error(TypeInfo1, yes, TypeInfo)
;
- type_info_set_type_assign_set(TypeInfo0, TypeAssignSet,
+ typecheck_info_set_type_assign_set(TypeInfo0, TypeAssignSet,
TypeInfo)
).
@@ -1896,12 +1917,12 @@
% (hence PredTypeParams = [K,V]) and argument types [map(K,V)].
-:- pred builtin_pred_type(type_info, cons_id, int, list(cons_type_info)).
-:- mode builtin_pred_type(type_info_ui, in, in, out) is semidet.
+:- pred builtin_pred_type(typecheck_info, cons_id, int, list(cons_type_info)).
+:- mode builtin_pred_type(typecheck_info_ui, in, in, out) is semidet.
builtin_pred_type(TypeInfo, Functor, Arity, PredConsInfoList) :-
Functor = cons(SymName, _),
- type_info_get_module_info(TypeInfo, ModuleInfo),
+ typecheck_info_get_module_info(TypeInfo, ModuleInfo),
module_info_get_predicate_table(ModuleInfo, PredicateTable),
( predicate_table_search_sym(PredicateTable, SymName, PredIdList) ->
predicate_table_get_preds(PredicateTable, Preds),
@@ -1911,9 +1932,10 @@
PredConsInfoList = []
).
-:- pred make_pred_cons_info_list(type_info, list(pred_id), pred_table, int,
+:- pred make_pred_cons_info_list(typecheck_info, list(pred_id), pred_table, int,
module_info, list(cons_type_info), list(cons_type_info)).
-:- mode make_pred_cons_info_list(type_info_ui, in, in, in, in, in, out) is det.
+:- mode make_pred_cons_info_list(typecheck_info_ui, in, in, in, in, in,
+ out) is det.
make_pred_cons_info_list(_, [], _PredTable, _Arity, _ModuleInfo, L, L).
make_pred_cons_info_list(TypeInfo, [PredId|PredIds], PredTable, Arity,
@@ -1925,9 +1947,9 @@
:- type cons_type_info ---> cons_type_info(tvarset, type, list(type)).
-:- pred make_pred_cons_info(type_info, pred_id, pred_table, int, module_info,
- list(cons_type_info), list(cons_type_info)).
-:- mode make_pred_cons_info(type_info_ui, in, in, in, in, in, out) is det.
+:- pred make_pred_cons_info(typecheck_info, pred_id, pred_table, int,
+ module_info, list(cons_type_info), list(cons_type_info)).
+:- mode make_pred_cons_info(typecheck_info_ui, in, in, in, in, in, out) is det.
make_pred_cons_info(TypeInfo, PredId, PredTable, FuncArity,
_ModuleInfo, L0, L) :-
@@ -1935,7 +1957,7 @@
pred_info_arity(PredInfo, PredArity),
pred_info_get_is_pred_or_func(PredInfo, IsPredOrFunc),
pred_info_import_status(PredInfo, CalledStatus),
- type_info_get_pred_import_status(TypeInfo, CallingStatus),
+ typecheck_info_get_pred_import_status(TypeInfo, CallingStatus),
(
% Only opt_imported preds can look at the declarations of
% predicates from .opt files.
@@ -2010,8 +2032,8 @@
% If so, bind ConsTypeInfos to a singleton list containing
% the appropriate type for apply/N of the specified Arity.
-:- pred builtin_apply_type(type_info, cons_id, int, list(cons_type_info)).
-:- mode builtin_apply_type(type_info_ui, in, in, out) is semidet.
+:- pred builtin_apply_type(typecheck_info, cons_id, int, list(cons_type_info)).
+:- mode builtin_apply_type(typecheck_info_ui, in, in, out) is semidet.
builtin_apply_type(_TypeInfo, Functor, Arity, ConsTypeInfos) :-
Functor = cons(unqualified(ApplyName), _),
@@ -2025,10 +2047,10 @@
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
- % The type_info data structure and access predicates.
+ % The typecheck_info data structure and access predicates.
-:- type type_info
- ---> type_info(
+:- type typecheck_info
+ ---> typecheck_info(
io__state, % The io state
module_info, % The global symbol tables
@@ -2066,13 +2088,13 @@
% being checked
).
- % The normal inst of a type_info struct: ground, with
+ % The normal inst of a typecheck_info struct: ground, with
% the io_state and the struct itself unique, but with
% multiple references allowed for the other parts.
/*
-:- inst uniq_type_info = bound_unique(
- type_info(
+:- inst uniq_typecheck_info = bound_unique(
+ typecheck_info(
unique, ground,
ground, ground, ground, ground,
ground, ground, ground, ground,
@@ -2080,18 +2102,18 @@
)
).
*/
-:- inst uniq_type_info = ground.
+:- inst uniq_typecheck_info = ground.
-:- mode type_info_uo :: (free -> uniq_type_info).
-:- mode type_info_ui :: (uniq_type_info -> uniq_type_info).
-:- mode type_info_di :: (uniq_type_info -> dead).
+:- mode typecheck_info_uo :: (free -> uniq_typecheck_info).
+:- mode typecheck_info_ui :: (uniq_typecheck_info -> uniq_typecheck_info).
+:- mode typecheck_info_di :: (uniq_typecheck_info -> dead).
% Some fiddly modes used when we want to extract
- % the io_state from a type_info struct and then put it back again.
+ % the io_state from a typecheck_info struct and then put it back again.
/*
-:- inst type_info_no_io = bound_unique(
- type_info(
+:- inst typecheck_info_no_io = bound_unique(
+ typecheck_info(
dead, ground,
ground, ground, ground, ground,
ground, ground, ground, ground,
@@ -2099,19 +2121,22 @@
)
).
*/
-:- inst type_info_no_io = ground.
+:- inst typecheck_info_no_io = ground.
-:- mode type_info_get_io_state :: (uniq_type_info -> type_info_no_io).
-:- mode type_info_no_io :: (type_info_no_io -> type_info_no_io).
-:- mode type_info_set_io_state :: (type_info_no_io -> dead).
+:- mode typecheck_info_get_io_state ::
+ (uniq_typecheck_info -> typecheck_info_no_io).
+:- mode typecheck_info_no_io ::
+ (typecheck_info_no_io -> typecheck_info_no_io).
+:- mode typecheck_info_set_io_state :: (typecheck_info_no_io -> dead).
%-----------------------------------------------------------------------------%
-:- pred type_info_init(io__state, module_info, pred_id, varset,
- varset, map(var, type), headtypes, import_status, type_info).
-:- mode type_info_init(di, in, in, in, in, in, in, in, type_info_uo) is det.
+:- pred typecheck_info_init(io__state, module_info, pred_id, varset,
+ varset, map(var, type), headtypes, import_status, typecheck_info).
+:- mode typecheck_info_init(di, in, in, in, in, in, in, in, typecheck_info_uo)
+ is det.
-type_info_init(IOState0, ModuleInfo, PredId, TypeVarSet, VarSet,
+typecheck_info_init(IOState0, ModuleInfo, PredId, TypeVarSet, VarSet,
VarTypes, HeadTypeParams, Status, TypeInfo) :-
CallPredId = unqualified("") / 0,
term__context_init(Context),
@@ -2119,7 +2144,7 @@
FoundTypeError = no,
WarnedAboutOverloading = no,
copy(IOState0, IOState), % XXX
- TypeInfo = type_info(
+ TypeInfo = typecheck_info(
IOState, ModuleInfo, CallPredId, 0, PredId, Context,
unify_context(explicit, []),
VarSet, [type_assign(VarTypes, TypeVarSet, TypeBindings)],
@@ -2129,152 +2154,173 @@
%-----------------------------------------------------------------------------%
-:- pred type_info_get_io_state(type_info, io__state).
-:- mode type_info_get_io_state(type_info_get_io_state, uo) is det.
+:- pred typecheck_info_get_io_state(typecheck_info, io__state).
+:- mode typecheck_info_get_io_state(typecheck_info_get_io_state, uo) is det.
-type_info_get_io_state(type_info(IOState0,_,_,_,_,_,_,_,_,_,_,_,_), IOState) :-
+typecheck_info_get_io_state(typecheck_info(IOState0,_,_,_,_,_,_,_,_,_,_,_,_),
+ IOState) :-
copy(IOState0, IOState). % XXX
%-----------------------------------------------------------------------------%
-:- pred type_info_set_io_state(type_info, io__state, type_info).
-:- mode type_info_set_io_state(type_info_set_io_state, di, type_info_uo) is det.
+:- pred typecheck_info_set_io_state(typecheck_info, io__state, typecheck_info).
+:- mode typecheck_info_set_io_state(typecheck_info_set_io_state, di,
+ typecheck_info_uo) is det.
-type_info_set_io_state( type_info(_,B,C,D,E,F,G,H,I,J,K,L,M), IOState0,
- type_info(IOState,B,C,D,E,F,G,H,I,J,K,L,M)) :-
+typecheck_info_set_io_state(typecheck_info(_,B,C,D,E,F,G,H,I,J,K,L,M), IOState0,
+ typecheck_info(IOState,B,C,D,E,F,G,H,I,J,K,L,M)) :-
copy(IOState0, IOState). % XXX
%-----------------------------------------------------------------------------%
-:- pred type_info_get_module_name(type_info, string).
-:- mode type_info_get_module_name(in, out) is det.
+:- pred typecheck_info_get_module_name(typecheck_info, string).
+:- mode typecheck_info_get_module_name(in, out) is det.
-type_info_get_module_name(type_info(_,ModuleInfo,_,_,_,_,_,_,_,_,_,_,_),
- Name) :-
+typecheck_info_get_module_name(TypeInfo, Name) :-
+ TypeInfo = typecheck_info(_,ModuleInfo,_,_,_,_,_,_,_,_,_,_,_),
module_info_name(ModuleInfo, Name).
%-----------------------------------------------------------------------------%
-:- pred type_info_get_module_info(type_info, module_info).
-:- mode type_info_get_module_info(in, out) is det.
+:- pred typecheck_info_get_module_info(typecheck_info, module_info).
+:- mode typecheck_info_get_module_info(in, out) is det.
-type_info_get_module_info(type_info(_,ModuleInfo,_,_,_,_,_,_,_,_,_,_,_),
- ModuleInfo).
+typecheck_info_get_module_info(TypeInfo, ModuleInfo) :-
+ TypeInfo = typecheck_info(_,ModuleInfo,_,_,_,_,_,_,_,_,_,_,_).
%-----------------------------------------------------------------------------%
-:- pred type_info_get_preds(type_info, predicate_table).
-:- mode type_info_get_preds(in, out) is det.
+:- pred typecheck_info_get_preds(typecheck_info, predicate_table).
+:- mode typecheck_info_get_preds(in, out) is det.
-type_info_get_preds(type_info(_,ModuleInfo,_,_,_,_,_,_,_,_,_,_,_), Preds) :-
+typecheck_info_get_preds(TypeInfo, Preds) :-
+ TypeInfo = typecheck_info(_,ModuleInfo,_,_,_,_,_,_,_,_,_,_,_),
module_info_get_predicate_table(ModuleInfo, Preds).
%-----------------------------------------------------------------------------%
-:- pred type_info_get_types(type_info, type_table).
-:- mode type_info_get_types(in, out) is det.
+:- pred typecheck_info_get_types(typecheck_info, type_table).
+:- mode typecheck_info_get_types(in, out) is det.
-type_info_get_types(type_info(_,ModuleInfo,_,_,_,_,_,_,_,_,_,_,_), Types) :-
+typecheck_info_get_types(TypeInfo, Types) :-
+ TypeInfo = typecheck_info(_,ModuleInfo,_,_,_,_,_,_,_,_,_,_,_),
module_info_types(ModuleInfo, Types).
%-----------------------------------------------------------------------------%
-:- pred type_info_get_ctors(type_info, cons_table).
-:- mode type_info_get_ctors(in, out) is det.
+:- pred typecheck_info_get_ctors(typecheck_info, cons_table).
+:- mode typecheck_info_get_ctors(in, out) is det.
-type_info_get_ctors(type_info(_,ModuleInfo,_,_,_,_,_,_,_,_,_,_,_), Ctors) :-
+typecheck_info_get_ctors(TypeInfo, Ctors) :-
+ TypeInfo = typecheck_info(_,ModuleInfo,_,_,_,_,_,_,_,_,_,_,_),
module_info_ctors(ModuleInfo, Ctors).
%-----------------------------------------------------------------------------%
-:- pred type_info_get_called_predid(type_info, pred_call_id).
-:- mode type_info_get_called_predid(in, out) is det.
+:- pred typecheck_info_get_called_predid(typecheck_info, pred_call_id).
+:- mode typecheck_info_get_called_predid(in, out) is det.
-type_info_get_called_predid(type_info(_,_,PredId,_,_,_,_,_,_,_,_,_,_), PredId).
+typecheck_info_get_called_predid(TypeInfo, PredId) :-
+ TypeInfo = typecheck_info(_,_,PredId,_,_,_,_,_,_,_,_,_,_).
%-----------------------------------------------------------------------------%
-:- pred type_info_set_called_predid(pred_call_id, type_info, type_info).
-:- mode type_info_set_called_predid(in, type_info_di, type_info_uo) is det.
+:- pred typecheck_info_set_called_predid(pred_call_id, typecheck_info,
+ typecheck_info).
+:- mode typecheck_info_set_called_predid(in, typecheck_info_di,
+ typecheck_info_uo) is det.
-type_info_set_called_predid(PredCallId, type_info(A,B,_,D,E,F,G,H,I,J,K,L,M),
- type_info(A,B,PredCallId,D,E,F,G,H,I,J,K,L,M)).
+typecheck_info_set_called_predid(PredCallId, TypeInfo0, TypeInfo) :-
+ TypeInfo0 = typecheck_info(A,B,_,D,E,F,G,H,I,J,K,L,M),
+ TypeInfo = typecheck_info(A,B,PredCallId,D,E,F,G,H,I,J,K,L,M).
%-----------------------------------------------------------------------------%
-:- pred type_info_get_arg_num(type_info, int).
-:- mode type_info_get_arg_num(in, out) is det.
+:- pred typecheck_info_get_arg_num(typecheck_info, int).
+:- mode typecheck_info_get_arg_num(in, out) is det.
-type_info_get_arg_num(type_info(_,_,_,ArgNum,_,_,_,_,_,_,_,_,_), ArgNum).
+typecheck_info_get_arg_num(TypeInfo, ArgNum) :-
+ TypeInfo = typecheck_info(_,_,_,ArgNum,_,_,_,_,_,_,_,_,_).
%-----------------------------------------------------------------------------%
-:- pred type_info_set_arg_num(int, type_info, type_info).
-:- mode type_info_set_arg_num(in, type_info_di, type_info_uo) is det.
+:- pred typecheck_info_set_arg_num(int, typecheck_info, typecheck_info).
+:- mode typecheck_info_set_arg_num(in, typecheck_info_di,
+ typecheck_info_uo) is det.
-type_info_set_arg_num(ArgNum, type_info(A,B,C,_, E,F,G,H,I,J,K,L,M),
- type_info(A,B,C,ArgNum,E,F,G,H,I,J,K,L,M)).
+typecheck_info_set_arg_num(ArgNum, TypeInfo0, TypeInfo) :-
+ TypeInfo0 = typecheck_info(A,B,C,_,E,F,G,H,I,J,K,L,M),
+ TypeInfo = typecheck_info(A,B,C,ArgNum,E,F,G,H,I,J,K,L,M).
%-----------------------------------------------------------------------------%
-:- pred type_info_get_predid(type_info, pred_id).
-:- mode type_info_get_predid(in, out) is det.
+:- pred typecheck_info_get_predid(typecheck_info, pred_id).
+:- mode typecheck_info_get_predid(in, out) is det.
-type_info_get_predid(type_info(_,_,_,_,PredId,_,_,_,_,_,_,_,_), PredId).
+typecheck_info_get_predid(TypeInfo, PredId) :-
+ TypeInfo = typecheck_info(_,_,_,_,PredId,_,_,_,_,_,_,_,_).
%-----------------------------------------------------------------------------%
-:- pred type_info_get_context(type_info, term__context).
-:- mode type_info_get_context(in, out) is det.
+:- pred typecheck_info_get_context(typecheck_info, term__context).
+:- mode typecheck_info_get_context(in, out) is det.
-type_info_get_context(type_info(_,_,_,_,_,Context,_,_,_,_,_,_,_), Context).
+typecheck_info_get_context(TypeInfo, Context) :-
+ TypeInfo = typecheck_info(_,_,_,_,_,Context,_,_,_,_,_,_,_).
%-----------------------------------------------------------------------------%
-:- pred type_info_set_context(term__context, type_info, type_info).
-:- mode type_info_set_context(in, type_info_di, type_info_uo) is det.
+:- pred typecheck_info_set_context(term__context, typecheck_info,
+ typecheck_info).
+:- mode typecheck_info_set_context(in, typecheck_info_di,
+ typecheck_info_uo) is det.
-type_info_set_context(Context, type_info(A,B,C,D,E,_,G,H,I,J,K,L,M),
- type_info(A,B,C,D,E,Context,G,H,I,J,K,L,M)).
+typecheck_info_set_context(Context, TypeInfo0, TypeInfo) :-
+ TypeInfo0 = typecheck_info(A,B,C,D,E,_,G,H,I,J,K,L,M),
+ TypeInfo = typecheck_info(A,B,C,D,E,Context,G,H,I,J,K,L,M).
%-----------------------------------------------------------------------------%
-:- pred type_info_get_unify_context(type_info, unify_context).
-:- mode type_info_get_unify_context(in, out) is det.
+:- pred typecheck_info_get_unify_context(typecheck_info, unify_context).
+:- mode typecheck_info_get_unify_context(in, out) is det.
-type_info_get_unify_context(type_info(_,_,_,_,_,_,UnifyContext,_,_,_,_,_,_),
- UnifyContext).
+typecheck_info_get_unify_context(TypeInfo, UnifyContext) :-
+ TypeInfo = typecheck_info(_,_,_,_,_,_,UnifyContext,_,_,_,_,_,_).
%-----------------------------------------------------------------------------%
-:- pred type_info_set_unify_context(unify_context, type_info, type_info).
-:- mode type_info_set_unify_context(in, type_info_di, type_info_uo) is det.
+:- pred typecheck_info_set_unify_context(unify_context, typecheck_info,
+ typecheck_info).
+:- mode typecheck_info_set_unify_context(in, typecheck_info_di,
+ typecheck_info_uo) is det.
-type_info_set_unify_context(UnifyContext, type_info(A,B,C,D,E,F,_,H,I,J,K,L,M),
- type_info(A,B,C,D,E,F,UnifyContext,H,I,J,K,L,M)).
+typecheck_info_set_unify_context(UnifyContext, TypeInfo0, TypeInfo) :-
+ TypeInfo0 = typecheck_info(A,B,C,D,E,F,_,H,I,J,K,L,M),
+ TypeInfo = typecheck_info(A,B,C,D,E,F,UnifyContext,H,I,J,K,L,M).
%-----------------------------------------------------------------------------%
-:- pred type_info_get_varset(type_info, varset).
-:- mode type_info_get_varset(in, out) is det.
+:- pred typecheck_info_get_varset(typecheck_info, varset).
+:- mode typecheck_info_get_varset(in, out) is det.
-type_info_get_varset(type_info(_,_,_,_,_,_,_,VarSet,_,_,_,_,_), VarSet).
+typecheck_info_get_varset(TypeInfo, VarSet) :-
+ TypeInfo = typecheck_info(_,_,_,_,_,_,_,VarSet,_,_,_,_,_).
%-----------------------------------------------------------------------------%
-:- pred type_info_get_type_assign_set(type_info, type_assign_set).
-:- mode type_info_get_type_assign_set(in, out) is det.
+:- pred typecheck_info_get_type_assign_set(typecheck_info, type_assign_set).
+:- mode typecheck_info_get_type_assign_set(in, out) is det.
-type_info_get_type_assign_set(type_info(_,_,_,_,_,_,_,_,TypeAssignSet,_,_,_,_),
- TypeAssignSet).
+typecheck_info_get_type_assign_set(TypeInfo, TypeAssignSet) :-
+ TypeInfo = typecheck_info(_,_,_,_,_,_,_,_,TypeAssignSet,_,_,_,_).
%-----------------------------------------------------------------------------%
-:- pred type_info_get_final_info(type_info, tvarset, map(var, type)).
-:- mode type_info_get_final_info(in, out, out) is det.
+:- pred typecheck_info_get_final_info(typecheck_info, tvarset, map(var, type)).
+:- mode typecheck_info_get_final_info(in, out, out) is det.
-type_info_get_final_info(TypeInfo, TypeVarSet, VarTypes) :-
- type_info_get_type_assign_set(TypeInfo, TypeAssignSet),
+typecheck_info_get_final_info(TypeInfo, TypeVarSet, VarTypes) :-
+ typecheck_info_get_type_assign_set(TypeInfo, TypeAssignSet),
( TypeAssignSet = [TypeAssign | _] ->
type_assign_get_typevarset(TypeAssign, TypeVarSet),
type_assign_get_var_types(TypeAssign, VarTypes0),
@@ -2282,7 +2328,7 @@
map__keys(VarTypes0, Vars),
expand_types(Vars, TypeBindings, VarTypes0, VarTypes)
;
- error("internal error in type_info_get_vartypes")
+ error("internal error in typecheck_info_get_vartypes")
).
% fully expand the types of the variables by applying the type
@@ -2300,104 +2346,114 @@
%-----------------------------------------------------------------------------%
-:- pred type_info_set_type_assign_set(type_info, type_assign_set, type_info).
-:- mode type_info_set_type_assign_set(type_info_di, in, type_info_uo) is det.
+:- pred typecheck_info_set_type_assign_set(typecheck_info, type_assign_set,
+ typecheck_info).
+:- mode typecheck_info_set_type_assign_set(typecheck_info_di, in,
+ typecheck_info_uo) is det.
-type_info_set_type_assign_set( type_info(A,B,C,D,E,F,G,H,_,J,K,L,M),
- TypeAssignSet, type_info(A,B,C,D,E,F,G,H,TypeAssignSet,J,K,L,M)).
+typecheck_info_set_type_assign_set(TypeInfo0, TypeAssignSet, TypeInfo) :-
+ TypeInfo0 = typecheck_info(A,B,C,D,E,F,G,H,_,J,K,L,M),
+ TypeInfo = typecheck_info(A,B,C,D,E,F,G,H,TypeAssignSet,J,K,L,M).
%-----------------------------------------------------------------------------%
-:- pred type_info_get_found_error(type_info, bool).
-:- mode type_info_get_found_error(type_info_ui, out) is det.
+:- pred typecheck_info_get_found_error(typecheck_info, bool).
+:- mode typecheck_info_get_found_error(typecheck_info_ui, out) is det.
-type_info_get_found_error(type_info(_,_,_,_,_,_,_,_,_,FoundError,_,_,_),
- FoundError).
+typecheck_info_get_found_error(TypeInfo, FoundError) :-
+ TypeInfo = typecheck_info(_,_,_,_,_,_,_,_,_,FoundError,_,_,_).
%-----------------------------------------------------------------------------%
-:- pred type_info_set_found_error(type_info, bool, type_info).
-:- mode type_info_set_found_error(type_info_di, in, type_info_uo) is det.
+:- pred typecheck_info_set_found_error(typecheck_info, bool, typecheck_info).
+:- mode typecheck_info_set_found_error(typecheck_info_di, in,
+ typecheck_info_uo) is det.
-type_info_set_found_error( type_info(A,B,C,D,E,F,G,H,I,_,K,L,M), FoundError,
- type_info(A,B,C,D,E,F,G,H,I,FoundError,K,L,M)).
+typecheck_info_set_found_error(TypeInfo0, FoundError, TypeInfo) :-
+ TypeInfo0 = typecheck_info(A,B,C,D,E,F,G,H,I,_,K,L,M),
+ TypeInfo = typecheck_info(A,B,C,D,E,F,G,H,I,FoundError,K,L,M).
%-----------------------------------------------------------------------------%
-:- pred type_info_get_head_type_params(type_info, headtypes).
-:- mode type_info_get_head_type_params(type_info_ui, out) is det.
+:- pred typecheck_info_get_head_type_params(typecheck_info, headtypes).
+:- mode typecheck_info_get_head_type_params(typecheck_info_ui, out) is det.
-type_info_get_head_type_params(
- type_info(_,_,_,_,_,_,_,_,_,_,HeadTypeParams,_,_),
- HeadTypeParams).
+typecheck_info_get_head_type_params(TypeInfo, HeadTypeParams) :-
+ TypeInfo = typecheck_info(_,_,_,_,_,_,_,_,_,_,HeadTypeParams,_,_).
%-----------------------------------------------------------------------------%
-:- pred type_info_set_head_type_params(type_info, headtypes, type_info).
-:- mode type_info_set_head_type_params(type_info_di, in, type_info_uo) is det.
+:- pred typecheck_info_set_head_type_params(typecheck_info, headtypes,
+ typecheck_info).
+:- mode typecheck_info_set_head_type_params(typecheck_info_di, in,
+ typecheck_info_uo) is det.
-type_info_set_head_type_params( type_info(A,B,C,D,E,F,G,H,I,J,_,L,M),
- HeadTypeParams,
- type_info(A,B,C,D,E,F,G,H,I,J,HeadTypeParams,L,M)).
+typecheck_info_set_head_type_params(TypeInfo0, HeadTypeParams, TypeInfo) :-
+ TypeInfo0 = typecheck_info(A,B,C,D,E,F,G,H,I,J,_,L,M),
+ TypeInfo = typecheck_info(A,B,C,D,E,F,G,H,I,J,HeadTypeParams,L,M).
%-----------------------------------------------------------------------------%
-:- pred type_info_get_warned_about_overloading(type_info, bool).
-:- mode type_info_get_warned_about_overloading(type_info_ui, out) is det.
+:- pred typecheck_info_get_warned_about_overloading(typecheck_info, bool).
+:- mode typecheck_info_get_warned_about_overloading(typecheck_info_ui, out)
+ is det.
-type_info_get_warned_about_overloading(
- type_info(_,_,_,_,_,_,_,_,_,_,_,Warned,_), Warned).
+typecheck_info_get_warned_about_overloading(TypeInfo, Warned) :-
+ TypeInfo = typecheck_info(_,_,_,_,_,_,_,_,_,_,_,Warned,_).
%-----------------------------------------------------------------------------%
-:- pred type_info_set_warned_about_overloading(type_info, bool, type_info).
-:- mode type_info_set_warned_about_overloading(type_info_di, in, type_info_uo)
- is det.
+:- pred typecheck_info_set_warned_about_overloading(typecheck_info, bool,
+ typecheck_info).
+:- mode typecheck_info_set_warned_about_overloading(typecheck_info_di, in,
+ typecheck_info_uo) is det.
-type_info_set_warned_about_overloading( type_info(A,B,C,D,E,F,G,H,I,J,K,_,M),
- Warned,
- type_info(A,B,C,D,E,F,G,H,I,J,K,Warned,M)).
+typecheck_info_set_warned_about_overloading(TypeInfo0, Warned, TypeInfo) :-
+ TypeInfo0 = typecheck_info(A,B,C,D,E,F,G,H,I,J,K,_,M),
+ TypeInfo = typecheck_info(A,B,C,D,E,F,G,H,I,J,K,Warned,M).
%-----------------------------------------------------------------------------%
-:- pred type_info_get_pred_import_status(type_info, import_status).
-:- mode type_info_get_pred_import_status(type_info_ui, out) is det.
+:- pred typecheck_info_get_pred_import_status(typecheck_info, import_status).
+:- mode typecheck_info_get_pred_import_status(typecheck_info_ui, out) is det.
-type_info_get_pred_import_status(type_info(_,_,_,_,_,_,_,_,_,_,_,_,Status),
- Status).
+typecheck_info_get_pred_import_status(TypeInfo, Status) :-
+ TypeInfo = typecheck_info(_,_,_,_,_,_,_,_,_,_,_,_,Status).
-:- pred type_info_set_pred_import_status(type_info, import_status, type_info).
-:- mode type_info_set_pred_import_status(type_info_di, in,
- type_info_uo) is det.
+:- pred typecheck_info_set_pred_import_status(typecheck_info, import_status,
+ typecheck_info).
+:- mode typecheck_info_set_pred_import_status(typecheck_info_di, in,
+ typecheck_info_uo) is det.
-type_info_set_pred_import_status( type_info(A,B,C,D,E,F,G,H,I,J,K,L,_),
- Status,
- type_info(A,B,C,D,E,F,G,H,I,J,K,L,Status)).
+typecheck_info_set_pred_import_status(TypeInfo0, Status, TypeInfo) :-
+ TypeInfo0 = typecheck_info(A,B,C,D,E,F,G,H,I,J,K,L,_),
+ TypeInfo = typecheck_info(A,B,C,D,E,F,G,H,I,J,K,L,Status).
%-----------------------------------------------------------------------------%
-:- pred type_info_get_ctor_list(type_info, cons_id, int, list(cons_type_info)).
-:- mode type_info_get_ctor_list(type_info_ui, in, in, out) is det.
+:- pred typecheck_info_get_ctor_list(typecheck_info, cons_id, int,
+ list(cons_type_info)).
+:- mode typecheck_info_get_ctor_list(typecheck_info_ui, in, in, out) is det.
-type_info_get_ctor_list(TypeInfo, Functor, Arity, ConsInfoList) :-
+typecheck_info_get_ctor_list(TypeInfo, Functor, Arity, ConsInfoList) :-
(
builtin_apply_type(TypeInfo, Functor, Arity, ApplyConsInfoList)
->
ConsInfoList = ApplyConsInfoList
;
- type_info_get_ctor_list_2(TypeInfo, Functor, Arity,
+ typecheck_info_get_ctor_list_2(TypeInfo, Functor, Arity,
ConsInfoList)
).
-:- pred type_info_get_ctor_list_2(type_info, cons_id,
+:- pred typecheck_info_get_ctor_list_2(typecheck_info, cons_id,
int, list(cons_type_info)).
-:- mode type_info_get_ctor_list_2(type_info_ui, in, in, out) is det.
+:- mode typecheck_info_get_ctor_list_2(typecheck_info_ui, in, in, out) is det.
-type_info_get_ctor_list_2(TypeInfo, Functor, Arity, ConsInfoList) :-
+typecheck_info_get_ctor_list_2(TypeInfo, Functor, Arity, ConsInfoList) :-
% Check if `Functor/Arity' has been defined as a constructor
% in some discriminated union type(s). This gives
% us a list of possible cons_type_infos.
- type_info_get_ctors(TypeInfo, Ctors),
+ typecheck_info_get_ctors(TypeInfo, Ctors),
(
Functor = cons(_, _),
map__search(Ctors, Functor, HLDS_ConsDefnList)
@@ -2434,9 +2490,9 @@
ConsInfoList = ConsInfoList1
).
-:- pred convert_cons_defn_list(type_info, list(hlds_cons_defn),
+:- pred convert_cons_defn_list(typecheck_info, list(hlds_cons_defn),
list(cons_type_info)).
-:- mode convert_cons_defn_list(type_info_ui, in, out) is det.
+:- mode convert_cons_defn_list(typecheck_info_ui, in, out) is det.
:- convert_cons_defn_list(_, L, _) when L. % NU-Prolog indexing.
@@ -2450,14 +2506,14 @@
convert_cons_defn_list(TypeInfo, Xs, Ys)
).
-:- pred convert_cons_defn(type_info, hlds_cons_defn, cons_type_info).
-:- mode convert_cons_defn(type_info_ui, in, out) is semidet.
+:- pred convert_cons_defn(typecheck_info, hlds_cons_defn, cons_type_info).
+:- mode convert_cons_defn(typecheck_info_ui, in, out) is semidet.
convert_cons_defn(TypeInfo, HLDS_ConsDefn, ConsTypeInfo) :-
HLDS_ConsDefn = hlds_cons_defn(ArgTypes, TypeId, Context),
- type_info_get_types(TypeInfo, Types),
+ typecheck_info_get_types(TypeInfo, Types),
map__lookup(Types, TypeId, TypeDefn),
- type_info_get_pred_import_status(TypeInfo, PredStatus),
+ typecheck_info_get_pred_import_status(TypeInfo, PredStatus),
hlds_data__get_type_defn_status(TypeDefn, TypeStatus),
% Don't match constructors in local preds that shouldn't be visible.
( PredStatus = opt_imported
@@ -2598,11 +2654,13 @@
%-----------------------------------------------------------------------------%
-:- pred report_warning_too_much_overloading(type_info, io__state, io__state).
-:- mode report_warning_too_much_overloading(type_info_no_io, di, uo) is det.
+:- pred report_warning_too_much_overloading(typecheck_info, io__state,
+ io__state).
+:- mode report_warning_too_much_overloading(typecheck_info_no_io, di, uo)
+ is det.
report_warning_too_much_overloading(TypeInfo) -->
- { type_info_get_context(TypeInfo, Context) },
+ { typecheck_info_get_context(TypeInfo, Context) },
write_context_and_pred_id(TypeInfo),
prog_out__write_context(Context),
report_warning(" warning: highly ambiguous overloading.\n"),
@@ -2622,15 +2680,16 @@
%-----------------------------------------------------------------------------%
-:- pred report_error_unif_var_var(type_info, var, var, type_assign_set,
+:- pred report_error_unif_var_var(typecheck_info, var, var, type_assign_set,
io__state, io__state).
-:- mode report_error_unif_var_var(type_info_no_io, in, in, in, di, uo) is det.
+:- mode report_error_unif_var_var(typecheck_info_no_io, in, in, in, di, uo)
+ is det.
report_error_unif_var_var(TypeInfo, X, Y, TypeAssignSet) -->
- { type_info_get_context(TypeInfo, Context) },
- { type_info_get_varset(TypeInfo, VarSet) },
- { type_info_get_unify_context(TypeInfo, UnifyContext) },
+ { typecheck_info_get_context(TypeInfo, Context) },
+ { typecheck_info_get_varset(TypeInfo, VarSet) },
+ { typecheck_info_get_unify_context(TypeInfo, UnifyContext) },
write_context_and_pred_id(TypeInfo),
hlds_out__write_unify_context(UnifyContext, Context),
@@ -2660,19 +2719,19 @@
write_type_assign_set_msg(TypeAssignSet, VarSet).
-:- pred report_error_functor_type(type_info, var, list(cons_type_info),
+:- pred report_error_functor_type(typecheck_info, var, list(cons_type_info),
cons_id, int,
type_assign_set,
io__state, io__state).
-:- mode report_error_functor_type(type_info_no_io, in, in, in, in, in,
+:- mode report_error_functor_type(typecheck_info_no_io, in, in, in, in, in,
di, uo) is det.
report_error_functor_type(TypeInfo, Var, ConsDefnList, Functor, Arity,
TypeAssignSet) -->
- { type_info_get_context(TypeInfo, Context) },
- { type_info_get_varset(TypeInfo, VarSet) },
- { type_info_get_unify_context(TypeInfo, UnifyContext) },
+ { typecheck_info_get_context(TypeInfo, Context) },
+ { typecheck_info_get_varset(TypeInfo, VarSet) },
+ { typecheck_info_get_unify_context(TypeInfo, UnifyContext) },
write_context_and_pred_id(TypeInfo),
hlds_out__write_unify_context(UnifyContext, Context),
@@ -2700,15 +2759,16 @@
write_type_assign_set_msg(TypeAssignSet, VarSet).
-:- pred report_error_lambda_var(type_info, pred_or_func, var, list(var),
+:- pred report_error_lambda_var(typecheck_info, pred_or_func, var, list(var),
type_assign_set, io__state, io__state).
-:- mode report_error_lambda_var(type_info_no_io, in, in, in, in, di, uo) is det.
+:- mode report_error_lambda_var(typecheck_info_no_io, in, in, in, in, di, uo)
+ is det.
report_error_lambda_var(TypeInfo, PredOrFunc, Var, ArgVars, TypeAssignSet) -->
- { type_info_get_context(TypeInfo, Context) },
- { type_info_get_varset(TypeInfo, VarSet) },
- { type_info_get_unify_context(TypeInfo, UnifyContext) },
+ { typecheck_info_get_context(TypeInfo, Context) },
+ { typecheck_info_get_varset(TypeInfo, VarSet) },
+ { typecheck_info_get_unify_context(TypeInfo, UnifyContext) },
write_context_and_pred_id(TypeInfo),
hlds_out__write_unify_context(UnifyContext, Context),
@@ -2773,19 +2833,18 @@
write_type_assign_set_msg(TypeAssignSet, VarSet).
-:- pred report_error_functor_arg_types(type_info, var, list(cons_type_info),
- cons_id, list(var),
- type_assign_set,
- io__state, io__state).
-:- mode report_error_functor_arg_types(type_info_no_io, in, in, in, in, in,
- di, uo) is det.
+:- pred report_error_functor_arg_types(typecheck_info, var,
+ list(cons_type_info), cons_id, list(var),
+ type_assign_set, io__state, io__state).
+:- mode report_error_functor_arg_types(typecheck_info_no_io, in, in, in, in,
+ in, di, uo) is det.
report_error_functor_arg_types(TypeInfo, Var, ConsDefnList, Functor, Args,
TypeAssignSet) -->
- { type_info_get_context(TypeInfo, Context) },
- { type_info_get_varset(TypeInfo, VarSet) },
- { type_info_get_unify_context(TypeInfo, UnifyContext) },
+ { typecheck_info_get_context(TypeInfo, Context) },
+ { typecheck_info_get_varset(TypeInfo, VarSet) },
+ { typecheck_info_get_unify_context(TypeInfo, UnifyContext) },
{ list__length(Args, Arity) },
write_context_and_pred_id(TypeInfo),
@@ -2816,9 +2875,9 @@
write_type_assign_set_msg(TypeAssignSet, VarSet).
-:- pred write_types_of_vars(list(var), varset, term__context, type_info,
+:- pred write_types_of_vars(list(var), varset, term__context, typecheck_info,
type_assign_set, io__state, io__state).
-:- mode write_types_of_vars(in, in, in, type_info_ui, in, di, uo) is det.
+:- mode write_types_of_vars(in, in, in, typecheck_info_ui, in, di, uo) is det.
write_types_of_vars([], _, _, _, _) -->
io__write_string(".\n").
@@ -2860,9 +2919,9 @@
),
io__write_string("'").
-:- pred write_type_of_var(type_info, type_assign_set, var,
+:- pred write_type_of_var(typecheck_info, type_assign_set, var,
io__state, io__state).
-:- mode write_type_of_var(type_info_no_io, in, in, di, uo) is det.
+:- mode write_type_of_var(typecheck_info_no_io, in, in, di, uo) is det.
write_type_of_var(_TypeInfo, TypeAssignSet, Var) -->
{ get_type_stuff(TypeAssignSet, Var, TypeStuffList) },
@@ -3059,17 +3118,17 @@
%-----------------------------------------------------------------------------%
-:- pred report_error_var(type_info, var, type, type_assign_set,
+:- pred report_error_var(typecheck_info, var, type, type_assign_set,
io__state, io__state).
-:- mode report_error_var(type_info_no_io, in, in, in, di, uo) is det.
+:- mode report_error_var(typecheck_info_no_io, in, in, in, di, uo) is det.
report_error_var(TypeInfo, VarId, Type, TypeAssignSet0) -->
- { type_info_get_called_predid(TypeInfo, CalledPredId) },
- { type_info_get_arg_num(TypeInfo, ArgNum) },
- { type_info_get_context(TypeInfo, Context) },
- { type_info_get_unify_context(TypeInfo, UnifyContext) },
+ { typecheck_info_get_called_predid(TypeInfo, CalledPredId) },
+ { typecheck_info_get_arg_num(TypeInfo, ArgNum) },
+ { typecheck_info_get_context(TypeInfo, Context) },
+ { typecheck_info_get_unify_context(TypeInfo, UnifyContext) },
{ get_type_stuff(TypeAssignSet0, VarId, TypeStuffList) },
- { type_info_get_varset(TypeInfo, VarSet) },
+ { typecheck_info_get_varset(TypeInfo, VarSet) },
write_context_and_pred_id(TypeInfo),
write_call_context(Context, CalledPredId, ArgNum, UnifyContext),
prog_out__write_context(Context),
@@ -3104,17 +3163,17 @@
),
write_type_assign_set_msg(TypeAssignSet0, VarSet).
-:- pred report_error_arg_var(type_info, var, args_type_assign_set,
+:- pred report_error_arg_var(typecheck_info, var, args_type_assign_set,
io__state, io__state).
-:- mode report_error_arg_var(type_info_no_io, in, in, di, uo) is det.
+:- mode report_error_arg_var(typecheck_info_no_io, in, in, di, uo) is det.
report_error_arg_var(TypeInfo, VarId, ArgTypeAssignSet0) -->
- { type_info_get_called_predid(TypeInfo, CalledPredId) },
- { type_info_get_arg_num(TypeInfo, ArgNum) },
- { type_info_get_context(TypeInfo, Context) },
- { type_info_get_unify_context(TypeInfo, UnifyContext) },
+ { typecheck_info_get_called_predid(TypeInfo, CalledPredId) },
+ { typecheck_info_get_arg_num(TypeInfo, ArgNum) },
+ { typecheck_info_get_context(TypeInfo, Context) },
+ { typecheck_info_get_unify_context(TypeInfo, UnifyContext) },
{ get_arg_type_stuff(ArgTypeAssignSet0, VarId, ArgTypeStuffList) },
- { type_info_get_varset(TypeInfo, VarSet) },
+ { typecheck_info_get_varset(TypeInfo, VarSet) },
write_context_and_pred_id(TypeInfo),
write_call_context(Context, CalledPredId, ArgNum, UnifyContext),
prog_out__write_context(Context),
@@ -3217,13 +3276,14 @@
%-----------------------------------------------------------------------------%
-:- pred report_error_undef_pred(type_info, pred_call_id, io__state, io__state).
-:- mode report_error_undef_pred(type_info_no_io, in, di, uo) is det.
+:- pred report_error_undef_pred(typecheck_info, pred_call_id,
+ io__state, io__state).
+:- mode report_error_undef_pred(typecheck_info_no_io, in, di, uo) is det.
report_error_undef_pred(TypeInfo, PredCallId) -->
{ PredCallId = PredName/Arity },
- { type_info_get_context(TypeInfo, Context) },
- write_type_info_context(TypeInfo),
+ { typecheck_info_get_context(TypeInfo, Context) },
+ write_typecheck_info_context(TypeInfo),
(
{ PredName = unqualified("->"), Arity = 2 }
->
@@ -3272,24 +3332,26 @@
io__write_string("'.\n")
).
-:- pred report_error_func_instead_of_pred(type_info, pred_call_id,
+:- pred report_error_func_instead_of_pred(typecheck_info, pred_call_id,
io__state, io__state).
-:- mode report_error_func_instead_of_pred(type_info_no_io, in, di, uo) is det.
+:- mode report_error_func_instead_of_pred(typecheck_info_no_io, in, di, uo)
+ is det.
report_error_func_instead_of_pred(TypeInfo, PredCallId) -->
report_error_undef_pred(TypeInfo, PredCallId),
- { type_info_get_context(TypeInfo, Context) },
+ { typecheck_info_get_context(TypeInfo, Context) },
prog_out__write_context(Context),
io__write_string(" (There is a *function* with that name, however.\n"),
prog_out__write_context(Context),
io__write_string(" Perhaps you forgot to add ` = ...'?)\n").
-:- pred report_error_apply_instead_of_pred(type_info, io__state, io__state).
-:- mode report_error_apply_instead_of_pred(type_info_no_io, di, uo) is det.
+:- pred report_error_apply_instead_of_pred(typecheck_info, io__state,
+ io__state).
+:- mode report_error_apply_instead_of_pred(typecheck_info_no_io, di, uo) is det.
report_error_apply_instead_of_pred(TypeInfo) -->
io__write_string(" error: the language construct `apply' should\n"),
- { type_info_get_context(TypeInfo, Context) },
+ { typecheck_info_get_context(TypeInfo, Context) },
prog_out__write_context(Context),
io__write_string(" be used as an expression, not as a goal.\n"),
globals__io_lookup_bool_option(verbose_errors, VerboseErrors),
@@ -3304,18 +3366,18 @@
[]
).
-:- pred report_error_pred_num_args(type_info, pred_call_id, list(int),
+:- pred report_error_pred_num_args(typecheck_info, pred_call_id, list(int),
io__state, io__state).
-:- mode report_error_pred_num_args(type_info_no_io, in, in, di, uo) is det.
+:- mode report_error_pred_num_args(typecheck_info_no_io, in, in, di, uo) is det.
report_error_pred_num_args(TypeInfo, Name / Arity, Arities) -->
- write_type_info_context(TypeInfo),
+ write_typecheck_info_context(TypeInfo),
io__write_string(" error: wrong number of arguments ("),
io__write_int(Arity),
io__write_string("; should be "),
report_error_pred_num_right_args(Arities),
io__write_string(")\n"),
- { type_info_get_context(TypeInfo, Context) },
+ { typecheck_info_get_context(TypeInfo, Context) },
prog_out__write_context(Context),
io__write_string(" in call to pred `"),
prog_out__write_sym_name(Name),
@@ -3336,14 +3398,15 @@
),
report_error_pred_num_right_args(Arities).
-:- pred report_error_undef_cons(type_info, cons_id, int, io__state, io__state).
-:- mode report_error_undef_cons(type_info_no_io, in, in, di, uo) is det.
+:- pred report_error_undef_cons(typecheck_info, cons_id, int, io__state,
+ io__state).
+:- mode report_error_undef_cons(typecheck_info_no_io, in, in, di, uo) is det.
report_error_undef_cons(TypeInfo, Functor, Arity) -->
- { type_info_get_called_predid(TypeInfo, CalledPredId) },
- { type_info_get_arg_num(TypeInfo, ArgNum) },
- { type_info_get_context(TypeInfo, Context) },
- { type_info_get_unify_context(TypeInfo, UnifyContext) },
+ { typecheck_info_get_called_predid(TypeInfo, CalledPredId) },
+ { typecheck_info_get_arg_num(TypeInfo, ArgNum) },
+ { typecheck_info_get_context(TypeInfo, Context) },
+ { typecheck_info_get_unify_context(TypeInfo, UnifyContext) },
write_context_and_pred_id(TypeInfo),
write_call_context(Context, CalledPredId, ArgNum, UnifyContext),
prog_out__write_context(Context),
@@ -3453,21 +3516,21 @@
%-----------------------------------------------------------------------------%
-:- pred write_type_info_context(type_info, io__state, io__state).
-:- mode write_type_info_context(type_info_no_io, di, uo) is det.
+:- pred write_typecheck_info_context(typecheck_info, io__state, io__state).
+:- mode write_typecheck_info_context(typecheck_info_no_io, di, uo) is det.
-write_type_info_context(TypeInfo) -->
+write_typecheck_info_context(TypeInfo) -->
write_context_and_pred_id(TypeInfo),
- { type_info_get_context(TypeInfo, Context) },
+ { typecheck_info_get_context(TypeInfo, Context) },
prog_out__write_context(Context).
-:- pred write_context_and_pred_id(type_info, io__state, io__state).
-:- mode write_context_and_pred_id(type_info_no_io, di, uo) is det.
+:- pred write_context_and_pred_id(typecheck_info, io__state, io__state).
+:- mode write_context_and_pred_id(typecheck_info_no_io, di, uo) is det.
write_context_and_pred_id(TypeInfo) -->
- { type_info_get_module_info(TypeInfo, ModuleInfo) },
- { type_info_get_context(TypeInfo, Context) },
- { type_info_get_predid(TypeInfo, PredId) },
+ { typecheck_info_get_module_info(TypeInfo, ModuleInfo) },
+ { typecheck_info_get_context(TypeInfo, Context) },
+ { typecheck_info_get_predid(TypeInfo, PredId) },
prog_out__write_context(Context),
io__write_string("In clause for "),
hlds_out__write_pred_id(ModuleInfo, PredId),
@@ -3475,20 +3538,20 @@
%-----------------------------------------------------------------------------%
-:- pred report_ambiguity_error(type_info, type_assign, type_assign,
+:- pred report_ambiguity_error(typecheck_info, type_assign, type_assign,
io__state, io__state).
-:- mode report_ambiguity_error(type_info_no_io, in, in, di, uo) is det.
+:- mode report_ambiguity_error(typecheck_info_no_io, in, in, di, uo) is det.
report_ambiguity_error(TypeInfo, TypeAssign1, TypeAssign2) -->
- write_type_info_context(TypeInfo),
+ write_typecheck_info_context(TypeInfo),
io__write_string(" error: ambiguous overloading causes type ambiguity.\n"),
- { type_info_get_varset(TypeInfo, VarSet) },
+ { typecheck_info_get_varset(TypeInfo, VarSet) },
{ type_assign_get_var_types(TypeAssign1, VarTypes1) },
{ map__keys(VarTypes1, Vars1) },
report_ambiguity_error_2(Vars1, VarSet, TypeInfo,
TypeAssign1, TypeAssign2, no, Found),
globals__io_lookup_bool_option(verbose_errors, VerboseErrors),
- { type_info_get_context(TypeInfo, Context) },
+ { typecheck_info_get_context(TypeInfo, Context) },
( { Found = no } ->
prog_out__write_context(Context),
io__write_string(" One or more of the predicates or functions called\n"),
@@ -3506,10 +3569,10 @@
[]
).
-:- pred report_ambiguity_error_2(list(var), varset, type_info,
+:- pred report_ambiguity_error_2(list(var), varset, typecheck_info,
type_assign, type_assign, bool, bool,
io__state, io__state).
-:- mode report_ambiguity_error_2(in, in, type_info_no_io, in, in, in, out,
+:- mode report_ambiguity_error_2(in, in, typecheck_info_no_io, in, in, in, out,
di, uo) is det.
report_ambiguity_error_2([], _VarSet, _, _TypeAssign1, _TypeAssign2,
@@ -3527,7 +3590,7 @@
term__apply_rec_substitution(Type2, TypeBindings2, T2a),
\+ identical_types(T1a, T2a)
} ->
- { type_info_get_context(TypeInfo, Context) },
+ { typecheck_info_get_context(TypeInfo, Context) },
( { Found0 = no } ->
prog_out__write_context(Context),
io__write_string(
--
Tyson Dowd #
# Sign on refridgerator:
trd at cs.mu.oz.au # Refrigerate after opening.
http://www.cs.mu.oz.au/~trd # - C. J. Owen.
More information about the developers
mailing list