[m-dev.] for review: EDCGs - diff part 3 (final)
Peter Nicholas MALKIN
pnmalk at students.cs.mu.oz.au
Fri Feb 4 00:33:57 AEDT 2000
Hi,
Detailed Description of Change:
compiler/equiv_type.m:
Types in "htype" definition need to be replaced with equivalent types.
compiler/hlds_data.m:
I have added an edcg_table to the hlds data structure. This table
contains information about hidden variables. The information includes,
the type and modes of the hidden variables.
compiler/hlds_module.m:
Changed access predicates to the hlds, to allow for the new edcg table.
Also I have changed the predicate table to also includes entries based
upon the visual arity (not including hidden variables) as well as the
total arity.
compiler/hlds_pred.m:
Added to pred_info a field listing the hidden variables and their forms
for each predicate and a field for the visual arity. Changed access
predicates accordingly.
compiler/mercury_to_goedel.m:
EDCG syntax is not supported under goedel hence any EDCG syntax
results in an error.
compiler/mercury_to_mercury.m:
Added predicates to print out EDCG syntax.
compiler/module_qual.m:
Need to module qualify `htype' and `hmode' definitions and qualify
hidden arguments in pred declarations.
compiler/modules.m:
Trivial changes.
library/assoc_list:
Added new predicate assoc_list__remove_all/4
library/ops.m:
I have added entries in the operator table for "-->>", "$" and "$=".
Index: compiler/equiv_type.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/equiv_type.m,v
retrieving revision 1.21
diff -u -r1.21 equiv_type.m
--- compiler/equiv_type.m 1999/10/03 04:15:21 1.21
+++ compiler/equiv_type.m 1999/12/10 04:03:00
@@ -115,12 +115,18 @@
equiv_type__replace_in_type_defn(TypeDefn0, VarSet0, EqvMap,
TypeDefn, VarSet, ContainsCirc).
+equiv_type__replace_in_item(htype_defn(VarSet0, Name, htype_defn(Type0)),
+ EqvMap, htype_defn(VarSet, Name, htype_defn(Type)), no):-
+ equiv_type__replace_in_type(Type0, VarSet0, EqvMap, Type, VarSet).
+
equiv_type__replace_in_item(
pred(TypeVarSet0, InstVarSet, ExistQVars, PredName,
- TypesAndModes0, Det, Cond, Purity, ClassContext0),
+ TypesAndModes0, HiddenForms, Det, Cond, Purity,
+ ClassContext0),
EqvMap,
pred(TypeVarSet, InstVarSet, ExistQVars, PredName,
- TypesAndModes, Det, Cond, Purity, ClassContext),
+ TypesAndModes, HiddenForms, Det, Cond, Purity,
+ ClassContext),
no) :-
equiv_type__replace_in_class_constraints(ClassContext0, TypeVarSet0,
EqvMap, ClassContext, TypeVarSet1),
Index: compiler/error_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/error_util.m,v
retrieving revision 1.12
diff -u -r1.12 error_util.m
--- compiler/error_util.m 1999/12/08 13:24:43 1.12
+++ compiler/error_util.m 2000/01/28 06:15:00
@@ -79,6 +79,9 @@
:- pred error_util__describe_several_proc_names(module_info::in,
list(pred_proc_id)::in, list(format_component)::out) is det.
+:- pred error_util__describe_several_pred_names(module_info::in,
+ list(pred_id)::in, list(format_component)::out) is det.
+
:- pred error_util__describe_one_call_site(module_info::in,
pair(pred_proc_id, prog_context)::in, string::out) is det.
@@ -366,6 +369,10 @@
ArityPart,
"'"], Piece)
).
+
+error_util__describe_several_pred_names(Module, PIds, Pieces) :-
+ list__map(error_util__describe_one_pred_name(Module), PIds, Pieces0),
+ error_util__list_to_pieces(Pieces0, Pieces).
error_util__describe_one_proc_name(Module, proc(PredId, ProcId), Piece) :-
error_util__describe_one_pred_name(Module, PredId, PredPiece),
Index: compiler/hlds_module.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_module.m,v
retrieving revision 1.50
diff -u -r1.50 hlds_module.m
--- compiler/hlds_module.m 2000/01/13 06:15:41 1.50
+++ compiler/hlds_module.m 2000/02/02 07:35:03
@@ -22,15 +22,15 @@
:- interface.
:- import_module prog_data, module_qual.
-:- import_module hlds_pred, hlds_data, unify_proc, special_pred.
+:- import_module hlds_pred, hlds_data, unify_proc, special_pred, edcg.
:- import_module globals, llds.
:- import_module relation, map, std_util, list, set, multi_map.
:- implementation.
:- import_module hlds_out, prog_out, prog_util.
-:- import_module typecheck, modules.
-:- import_module bool, require, int, string.
+:- import_module typecheck, modules, edcg.
+:- import_module bool, require, int, string, assoc_list.
%-----------------------------------------------------------------------------%
@@ -193,6 +193,12 @@
:- pred module_info_set_instances(module_info, instance_table, module_info).
:- mode module_info_set_instances(in, in, out) is det.
+:- pred module_info_edcgs(module_info, edcg_table).
+:- mode module_info_edcgs(in, out) is det.
+
+:- pred module_info_set_edcgs(module_info, edcg_table, module_info).
+:- mode module_info_set_edcgs(in, in, out) is det.
+
:- pred module_info_superclasses(module_info, superclass_table).
:- mode module_info_superclasses(in, out) is det.
@@ -573,6 +579,7 @@
superclass_table,
assertion_table,
ctor_field_table,
+ edcg_table,
int % cell count, passed into code_info
% and used to generate unique label
% numbers for constant terms in the
@@ -637,6 +644,7 @@
map__init(ClassTable),
map__init(InstanceTable),
+ edcg_table_init(EDCGTable),
map__init(SuperClassTable),
% the builtin modules are automatically imported
@@ -653,7 +661,7 @@
ModuleInfo = module(ModuleSubInfo, PredicateTable, Requests,
UnifyPredMap, QualifierInfo, Types, Insts, Modes, Ctors,
ClassTable, SuperClassTable, InstanceTable, AssertionTable,
- FieldNameTable, 0).
+ FieldNameTable, EDCGTable, 0).
%-----------------------------------------------------------------------------%
@@ -826,6 +834,7 @@
% L superclass_table,
% M assertion_table
% N ctor_field_table,
+% L edcg_table,
% O int % cell count, passed into code_info
% % and used to generate unique label
% % numbers for constant terms in the
@@ -837,113 +846,120 @@
% Various predicates which access the module_info data structure.
module_info_get_sub_info(MI0, A) :-
- MI0 = module(A, _, _, _, _, _, _, _, _, _, _, _, _, _, _).
+ MI0 = module(A, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _).
module_info_get_predicate_table(MI0, B) :-
- MI0 = module(_, B, _, _, _, _, _, _, _, _, _, _, _, _, _).
+ MI0 = module(_, B, _, _, _, _, _, _, _, _, _, _, _, _, _, _).
module_info_get_proc_requests(MI0, C) :-
- MI0 = module(_, _, C, _, _, _, _, _, _, _, _, _, _, _, _).
+ MI0 = module(_, _, C, _, _, _, _, _, _, _, _, _, _, _, _, _).
module_info_get_special_pred_map(MI0, D) :-
- MI0 = module(_, _, _, D, _, _, _, _, _, _, _, _, _, _, _).
+ MI0 = module(_, _, _, D, _, _, _, _, _, _, _, _, _, _, _, _).
module_info_get_partial_qualifier_info(MI0, E) :-
- MI0 = module(_, _, _, _, E, _, _, _, _, _, _, _, _, _, _).
+ MI0 = module(_, _, _, _, E, _, _, _, _, _, _, _, _, _, _, _).
module_info_types(MI0, F) :-
- MI0 = module(_, _, _, _, _, F, _, _, _, _, _, _, _, _, _).
+ MI0 = module(_, _, _, _, _, F, _, _, _, _, _, _, _, _, _, _).
module_info_insts(MI0, G) :-
- MI0 = module(_, _, _, _, _, _, G, _, _, _, _, _, _, _, _).
+ MI0 = module(_, _, _, _, _, _, G, _, _, _, _, _, _, _, _, _).
module_info_modes(MI0, H) :-
- MI0 = module(_, _, _, _, _, _, _, H, _, _, _, _, _, _, _).
+ MI0 = module(_, _, _, _, _, _, _, H, _, _, _, _, _, _, _, _).
module_info_ctors(MI0, I) :-
- MI0 = module(_, _, _, _, _, _, _, _, I, _, _, _, _, _, _).
+ MI0 = module(_, _, _, _, _, _, _, _, I, _, _, _, _, _, _, _).
module_info_classes(MI0, J) :-
- MI0 = module(_, _, _, _, _, _, _, _, _, J, _, _, _, _, _).
+ MI0 = module(_, _, _, _, _, _, _, _, _, J, _, _, _, _, _, _).
module_info_instances(MI0, K) :-
- MI0 = module(_, _, _, _, _, _, _, _, _, _, K, _, _, _, _).
+ MI0 = module(_, _, _, _, _, _, _, _, _, _, K, _, _, _, _, _).
module_info_superclasses(MI0, L) :-
- MI0 = module(_, _, _, _, _, _, _, _, _, _, _, L, _, _, _).
+ MI0 = module(_, _, _, _, _, _, _, _, _, _, _, L, _, _, _, _).
module_info_assertion_table(MI0, M) :-
- MI0 = module(_, _, _, _, _, _, _, _, _, _, _, _, M, _, _).
+ MI0 = module(_, _, _, _, _, _, _, _, _, _, _, _, M, _, _, _).
module_info_ctor_field_table(MI0, N) :-
- MI0 = module(_, _, _, _, _, _, _, _, _, _, _, _, _, N, _).
+ MI0 = module(_, _, _, _, _, _, _, _, _, _, _, _, _, N, _, _).
+
+module_info_edcgs(MI0, O) :-
+ MI0 = module(_, _, _, _, _, _, _, _, _, _, _, _, _, _, O, _).
-module_info_get_cell_count(MI0, O) :-
- MI0 = module(_, _, _, _, _, _, _, _, _, _, _, _, _, _, O).
+module_info_get_cell_count(MI0, P) :-
+ MI0 = module(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, P).
%-----------------------------------------------------------------------------%
% Various predicates which modify the module_info data structure.
module_info_set_sub_info(MI0, A, MI) :-
- MI0 = module(_, B, C, D, E, F, G, H, I, J, K, L, M, N, O),
- MI = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O).
+ MI0 = module(_, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P),
+ MI = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P).
module_info_set_predicate_table(MI0, B, MI) :-
- MI0 = module(A, _, C, D, E, F, G, H, I, J, K, L, M, N, O),
- MI = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O).
+ MI0 = module(A, _, C, D, E, F, G, H, I, J, K, L, M, N, O, P),
+ MI = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P).
module_info_set_proc_requests(MI0, C, MI) :-
- MI0 = module(A, B, _, D, E, F, G, H, I, J, K, L, M, N, O),
- MI = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O).
+ MI0 = module(A, B, _, D, E, F, G, H, I, J, K, L, M, N, O, P),
+ MI = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P).
module_info_set_special_pred_map(MI0, D, MI) :-
- MI0 = module(A, B, C, _, E, F, G, H, I, J, K, L, M, N, O),
- MI = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O).
+ MI0 = module(A, B, C, _, E, F, G, H, I, J, K, L, M, N, O, P),
+ MI = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P).
module_info_set_partial_qualifier_info(MI0, E, MI) :-
- MI0 = module(A, B, C, D, _, F, G, H, I, J, K, L, M, N, O),
- MI = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O).
+ MI0 = module(A, B, C, D, _, F, G, H, I, J, K, L, M, N, O, P),
+ MI = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P).
module_info_set_types(MI0, F, MI) :-
- MI0 = module(A, B, C, D, E, _, G, H, I, J, K, L, M, N, O),
- MI = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O).
+ MI0 = module(A, B, C, D, E, _, G, H, I, J, K, L, M, N, O, P),
+ MI = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P).
module_info_set_insts(MI0, G, MI) :-
- MI0 = module(A, B, C, D, E, F, _, H, I, J, K, L, M, N, O),
- MI = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O).
+ MI0 = module(A, B, C, D, E, F, _, H, I, J, K, L, M, N, O, P),
+ MI = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P).
module_info_set_modes(MI0, H, MI) :-
- MI0 = module(A, B, C, D, E, F, G, _, I, J, K, L, M, N, O),
- MI = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O).
+ MI0 = module(A, B, C, D, E, F, G, _, I, J, K, L, M, N, O, P),
+ MI = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P).
module_info_set_ctors(MI0, I, MI) :-
- MI0 = module(A, B, C, D, E, F, G, H, _, J, K, L, M, N, O),
- MI = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O).
+ MI0 = module(A, B, C, D, E, F, G, H, _, J, K, L, M, N, O, P),
+ MI = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P).
module_info_set_classes(MI0, J, MI) :-
- MI0 = module(A, B, C, D, E, F, G, H, I, _, K, L, M, N, O),
- MI = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O).
+ MI0 = module(A, B, C, D, E, F, G, H, I, _, K, L, M, N, O, P),
+ MI = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P).
module_info_set_instances(MI0, K, MI) :-
- MI0 = module(A, B, C, D, E, F, G, H, I, J, _, L, M, N, O),
- MI = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O).
+ MI0 = module(A, B, C, D, E, F, G, H, I, J, _, L, M, N, O, P),
+ MI = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P).
module_info_set_superclasses(MI0, L, MI) :-
- MI0 = module(A, B, C, D, E, F, G, H, I, J, K, _, M, N, O),
- MI = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O).
+ MI0 = module(A, B, C, D, E, F, G, H, I, J, K, _, M, N, O, P),
+ MI = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P).
module_info_set_assertion_table(MI0, M, MI) :-
- MI0 = module(A, B, C, D, E, F, G, H, I, J, K, L, _, N, O),
- MI = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O).
+ MI0 = module(A, B, C, D, E, F, G, H, I, J, K, L, _, N, O, P),
+ MI = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P).
module_info_set_ctor_field_table(MI0, N, MI) :-
- MI0 = module(A, B, C, D, E, F, G, H, I, J, K, L, M, _, O),
- MI = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O).
+ MI0 = module(A, B, C, D, E, F, G, H, I, J, K, L, M, _, O, P),
+ MI = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P).
-module_info_set_cell_count(MI0, O, MI) :-
- MI0 = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, _),
- MI = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O).
+module_info_set_edcgs(MI0, O, MI) :-
+ MI0 = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, _, P),
+ MI = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P).
+
+module_info_set_cell_count(MI0, P, MI) :-
+ MI0 = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, _),
+ MI = module(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P).
%-----------------------------------------------------------------------------%
@@ -1248,6 +1264,7 @@
map__optimize(Ctors0, Ctors),
module_info_set_ctors(ModuleInfo6, Ctors, ModuleInfo).
+
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
@@ -1362,6 +1379,11 @@
:- pred predicate_table_optimize(predicate_table, predicate_table).
:- mode predicate_table_optimize(in, out) is det.
+ % Get pred_info for a particular pred_id.
+
+:- pred predicate_table_pred_info(predicate_table, pred_id, pred_info).
+:- mode predicate_table_pred_info(in, in, out) is det.
+
% Get the pred_id->pred_info map.
:- pred predicate_table_get_preds(predicate_table, pred_table).
@@ -1529,6 +1551,17 @@
sym_name, list(pred_id)) is semidet.
:- mode predicate_table_search_pf_sym(in, in, in, out) is semidet.
+ % predicate_table_insert(PredTable0, PredInfo, TotalArity, VisualArity,
+ % NeedQual, PartialQualInfo, PredId, PredTable).
+ %
+ % Insert PredInfo into PredTable0 and assign it a new pred_id.
+ % You should check beforehand that the pred doesn't already
+ % occur in the table.
+:- pred predicate_table_insert(predicate_table, pred_info, arity, arity,
+ need_qualifier, partial_qualifier_info, pred_id,
+ predicate_table).
+:- mode predicate_table_insert(in, in, in, in, in, in,out, out) is det.
+
% predicate_table_insert(PredTable0, PredInfo,
% NeedQual, PartialQualInfo, PredId, PredTable).
%
@@ -1594,6 +1627,7 @@
:- type name_index == map(string, list(pred_id)).
:- type name_arity_index == map(name_arity, list(pred_id)).
+
:- type name_arity ---> string / arity.
% First search on module and name, then search on arity. The two
@@ -1601,7 +1635,6 @@
% on module and name only for higher-order terms.
:- type module_name_arity_index == map(pair(module_name, string),
map(arity, list(pred_id))).
-
predicate_table_init(PredicateTable) :-
PredicateTable = predicate_table(Preds, NextPredId, PredIds,
Pred_N_Index, Pred_NA_Index, Pred_MNA_Index,
@@ -1630,6 +1663,18 @@
Pred_N_Index, Pred_NA_Index, Pred_MNA_Index,
Func_N_Index, Func_NA_Index, Func_MNA_Index).
+predicate_table_pred_info(PredicateTable, PredId, PredInfo) :-
+ predicate_table_get_preds(PredicateTable, Preds),
+ ( map__search(Preds, PredId, PredInfoPrime) ->
+ PredInfo = PredInfoPrime
+ ;
+ pred_id_to_int(PredId, PredInt),
+ string__int_to_string(PredInt, PredStr),
+ string__append("cannot find predicate number ", PredStr, Msg),
+ error(Msg)
+ ).
+
+
predicate_table_get_preds(PredicateTable, Preds) :-
PredicateTable = predicate_table(Preds, _, _, _, _, _, _, _, _).
@@ -1974,29 +2019,37 @@
%-----------------------------------------------------------------------------%
+predicate_table_insert(PredicateTable0, PredInfo, TotalArity, VisualArity,
+ NeedQual, QualInfo, PredId, PredicateTable) :-
+ predicate_table_insert_2(PredicateTable0, PredInfo, TotalArity,
+ VisualArity, NeedQual, yes(QualInfo), PredId, PredicateTable).
+
predicate_table_insert(PredicateTable0, PredInfo, PredId, PredicateTable) :-
- predicate_table_insert_2(PredicateTable0, PredInfo,
- must_be_qualified, no, PredId, PredicateTable).
+ pred_info_arity(PredInfo, TotalArity),
+ pred_info_visual_arity(PredInfo, VisualArity),
+ predicate_table_insert_2(PredicateTable0, PredInfo, TotalArity,
+ VisualArity, must_be_qualified, no, PredId, PredicateTable).
predicate_table_insert(PredicateTable0, PredInfo, NeedQual, QualInfo,
PredId, PredicateTable) :-
- predicate_table_insert_2(PredicateTable0, PredInfo,
- NeedQual, yes(QualInfo),
- PredId, PredicateTable).
-
-:- pred predicate_table_insert_2(predicate_table, pred_info, need_qualifier,
- maybe(partial_qualifier_info), pred_id, predicate_table).
-:- mode predicate_table_insert_2(in, in, in, in, out, out) is det.
+ pred_info_arity(PredInfo, TotalArity),
+ pred_info_visual_arity(PredInfo, VisualArity),
+ predicate_table_insert_2(PredicateTable0, PredInfo, TotalArity,
+ VisualArity, NeedQual, yes(QualInfo), PredId, PredicateTable).
+
+:- pred predicate_table_insert_2(predicate_table, pred_info, arity, arity,
+ need_qualifier, maybe(partial_qualifier_info), pred_id,
+ predicate_table).
+:- mode predicate_table_insert_2(in,in, in, in, in, in, out, out) is det.
-predicate_table_insert_2(PredicateTable0, PredInfo, NeedQual, MaybeQualInfo,
- PredId, PredicateTable) :-
+predicate_table_insert_2(PredicateTable0, PredInfo, TotalArity, VisualArity,
+ NeedQual, MaybeQualInfo, PredId, PredicateTable) :-
PredicateTable0 = predicate_table(Preds0, NextPredId0, PredIds0,
Pred_N_Index0, Pred_NA_Index0, Pred_MNA_Index0,
Func_N_Index0, Func_NA_Index0, Func_MNA_Index0),
pred_info_module(PredInfo, Module),
pred_info_name(PredInfo, Name),
- pred_info_arity(PredInfo, Arity),
% allocate a new pred_id
PredId = NextPredId0,
@@ -2007,20 +2060,32 @@
pred_info_get_is_pred_or_func(PredInfo, PredOrFunc),
(
PredOrFunc = predicate,
- predicate_table_do_insert(Module, Name, Arity,
+ predicate_table_do_insert(Module, Name, TotalArity,
NeedQual, MaybeQualInfo, PredId,
- Pred_N_Index0, Pred_N_Index,
- Pred_NA_Index0, Pred_NA_Index,
- Pred_MNA_Index0, Pred_MNA_Index),
+ Pred_N_Index0, Pred_N_Index1,
+ Pred_NA_Index0, Pred_NA_Index1,
+ Pred_MNA_Index0, Pred_MNA_Index1),
+ (
+ TotalArity = VisualArity
+ ->
+ Pred_N_Index = Pred_N_Index1,
+ Pred_NA_Index = Pred_NA_Index1,
+ Pred_MNA_Index = Pred_MNA_Index1
+ ;
+ predicate_table_do_insert(Module, Name, VisualArity,
+ NeedQual, MaybeQualInfo, PredId,
+ Pred_N_Index1, Pred_N_Index,
+ Pred_NA_Index1, Pred_NA_Index,
+ Pred_MNA_Index1, Pred_MNA_Index)
+ ),
Func_N_Index = Func_N_Index0,
Func_NA_Index = Func_NA_Index0,
Func_MNA_Index = Func_MNA_Index0
;
PredOrFunc = function,
+ FuncArity is TotalArity - 1,
- FuncArity is Arity - 1,
-
predicate_table_do_insert(Module, Name, FuncArity,
NeedQual, MaybeQualInfo, PredId,
Func_N_Index0, Func_N_Index,
@@ -2097,6 +2162,7 @@
map__det_insert(MNA_Index0, Module - Name, MN_Arities,
MNA_Index)
).
+
%-----------------------------------------------------------------------------%
Index: compiler/hlds_pred.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_pred.m,v
retrieving revision 1.70
diff -u -r1.70 hlds_pred.m
--- compiler/hlds_pred.m 2000/01/26 02:04:24 1.70
+++ compiler/hlds_pred.m 2000/01/31 03:06:47
@@ -460,6 +460,7 @@
% Various predicates for accessing the information stored in the
% pred_id and pred_info data structures.
+ % Initialise without hidden arguments.
:- pred pred_info_init(module_name, sym_name, arity, tvarset, existq_tvars,
list(type), condition, prog_context, clauses_info, import_status,
pred_markers, goal_type, pred_or_func, class_constraints,
@@ -467,6 +468,16 @@
:- mode pred_info_init(in, in, in, in, in, in, in, in, in, in, in, in, in,
in, in, in, out) is det.
+ % Initialise with hidden arguments.
+:- pred pred_info_init(module_name, sym_name, arity, arity, tvarset,
+ existq_tvars, list(type), hidden_forms, condition,
+ prog_context, clauses_info, import_status, pred_markers, goal_type,
+ pred_or_func, class_constraints, constraint_proof_map, aditi_owner,
+ pred_info).
+:- mode pred_info_init(in, in, in, in, in, in, in, in, in, in, in, in, in, in,
+ in, in, in, in, out) is det.
+
+ % Create without hidden arguments.
:- pred pred_info_create(module_name, sym_name, tvarset, existq_tvars,
list(type), condition, prog_context, import_status, pred_markers,
pred_or_func, class_constraints, aditi_owner, set(assert_id),
@@ -474,17 +485,30 @@
:- mode pred_info_create(in, in, in, in, in, in, in, in, in, in, in, in, in,
in, out, out) is det.
+ % Create with hidden arguments.
+:- pred pred_info_create(module_name, sym_name, tvarset, existq_tvars,
+ list(type), hidden_forms, condition, prog_context,
+ import_status, pred_markers, pred_or_func, class_constraints,
+ aditi_owner, set(assert_id), proc_info, proc_id, pred_info).
+:- mode pred_info_create(in, in, in, in, in, in, in, in, in, in, in, in, in,
+ in, in, out, out) is det.
+
:- pred pred_info_module(pred_info, module_name).
:- mode pred_info_module(in, out) is det.
:- pred pred_info_name(pred_info, string).
:- mode pred_info_name(in, out) is det.
- % pred_info_arity returns the arity of the predicate
+ % pred_info_arity returns the total arity of the predicate
% *not* counting inserted type_info arguments for polymorphic preds.
:- pred pred_info_arity(pred_info, arity).
:- mode pred_info_arity(in, out) is det.
+ % pred_info_visual_arity returns the visual arity of the predicate
+ % *not* counting inserted type_info arguments for polymorphic preds.
+:- pred pred_info_visual_arity(pred_info, arity).
+:- mode pred_info_visual_arity(in, out) is det.
+
% Return a list of all the proc_ids for the different modes
% of this predicate.
:- pred pred_info_procids(pred_info, list(proc_id)).
@@ -516,6 +540,13 @@
:- pred pred_info_get_univ_quant_tvars(pred_info, existq_tvars).
:- mode pred_info_get_univ_quant_tvars(in, out) is det.
+:- pred pred_info_hidden_args(pred_info, hidden_forms).
+:- mode pred_info_hidden_args(in, out) is det.
+
+:- pred pred_info_set_hidden_args(pred_info, hidden_forms,
+ pred_info).
+:- mode pred_info_set_hidden_args(in, in, out) is det.
+
:- type head_type_params == list(tvar).
:- pred pred_info_get_head_type_params(pred_info, head_type_params).
@@ -742,6 +773,8 @@
tvarset, % names of type vars
% in the predicate's type decl
list(type), % argument types
+ % hidden argument declarations
+ hidden_forms,
condition, % formal specification
% (not used)
@@ -755,9 +788,12 @@
module_name, % module in which pred occurs
string, % predicate name
- arity, % the arity of the pred
+ arity, % the total arity of the pred
% (*not* counting any inserted
% type_info arguments)
+ arity, % the visual arity of the pred
+ % (*not* counting any inserted
+ % type_info arguments)
import_status,
tvarset, % names of type vars
% in the predicate's type decl
@@ -818,6 +854,15 @@
pred_info_init(ModuleName, SymName, Arity, TypeVarSet, ExistQVars, Types,
Cond, Context, ClausesInfo, Status, Markers, GoalType,
PredOrFunc, ClassContext, ClassProofs, User, PredInfo) :-
+ pred_info_init(ModuleName, SymName, Arity, Arity, TypeVarSet,
+ ExistQVars, Types, [], Cond, Context, ClausesInfo, Status,
+ Markers, GoalType, PredOrFunc, ClassContext, ClassProofs, User,
+ PredInfo).
+
+pred_info_init(ModuleName, SymName, TotalArity, VisualArity, TypeVarSet,
+ ExistQVars, Types, HiddenTypes, Cond, Context, ClausesInfo,
+ Status, Markers, GoalType, PredOrFunc, ClassContext,
+ ClassProofs, User, PredInfo) :-
map__init(Procs),
unqualify_name(SymName, PredName),
sym_name_get_module_name(SymName, ModuleName, PredModuleName),
@@ -826,15 +871,22 @@
UnprovenBodyConstraints = [],
Indexes = [],
set__init(Assertions),
- PredInfo = predicate(TypeVarSet, Types, Cond, ClausesInfo, Procs,
- Context, PredModuleName, PredName, Arity, Status, TypeVarSet,
- GoalType, Markers, PredOrFunc, ClassContext, ClassProofs,
- ExistQVars, HeadTypeParams, UnprovenBodyConstraints, User,
- Indexes, Assertions).
+ PredInfo = predicate(TypeVarSet, Types, HiddenTypes, Cond, ClausesInfo,
+ Procs, Context, PredModuleName, PredName, TotalArity,
+ VisualArity, Status, TypeVarSet, GoalType, Markers, PredOrFunc,
+ ClassContext, ClassProofs, ExistQVars, HeadTypeParams,
+ UnprovenBodyConstraints, User, Indexes, Assertions).
pred_info_create(ModuleName, SymName, TypeVarSet, ExistQVars, Types, Cond,
Context, Status, Markers, PredOrFunc, ClassContext, User,
Assertions, ProcInfo, ProcId, PredInfo) :-
+ pred_info_create(ModuleName, SymName, TypeVarSet, ExistQVars, Types,
+ [], Cond, Context, Status, Markers, PredOrFunc, ClassContext,
+ User, Assertions, ProcInfo, ProcId, PredInfo).
+
+pred_info_create(ModuleName, SymName, TypeVarSet, ExistQVars, Types,
+ HiddenTypes, Cond, Context, Status, Markers, PredOrFunc,
+ ClassContext, User, Assertions, ProcInfo, ProcId, PredInfo) :-
map__init(Procs0),
proc_info_declared_determinism(ProcInfo, MaybeDetism),
next_mode_id(Procs0, MaybeDetism, ProcId),
@@ -855,15 +907,15 @@
list__delete_elems(TVars, ExistQVars, HeadTypeParams),
UnprovenBodyConstraints = [],
Indexes = [],
- PredInfo = predicate(TypeVarSet, Types, Cond, ClausesInfo, Procs,
- Context, ModuleName, PredName, Arity, Status, TypeVarSet,
- clauses, Markers, PredOrFunc, ClassContext, ClassProofs,
- ExistQVars, HeadTypeParams, UnprovenBodyConstraints, User,
- Indexes, Assertions).
+ PredInfo = predicate(TypeVarSet, Types, HiddenTypes, Cond, ClausesInfo,
+ Procs, Context, ModuleName, PredName, Arity, Arity, Status,
+ TypeVarSet, clauses, Markers, PredOrFunc, ClassContext,
+ ClassProofs, ExistQVars, HeadTypeParams,
+ UnprovenBodyConstraints, User, Indexes, Assertions).
pred_info_procids(PredInfo, ProcIds) :-
- PredInfo = predicate(_, _, _, _, Procs, _, _, _, _, _, _, _,
- _, _, _, _, _, _, _, _, _, _),
+ PredInfo = predicate(_, _, _, _, _, Procs, _, _, _, _, _, _, _,
+ _, _, _, _, _, _, _, _, _, _, _),
map__keys(Procs, ProcIds).
pred_info_non_imported_procids(PredInfo, ProcIds) :-
@@ -895,58 +947,72 @@
).
pred_info_clauses_info(PredInfo, Clauses) :-
- PredInfo = predicate(_, _, _, Clauses, _, _, _, _, _, _, _, _, _,
- _, _, _, _, _, _, _, _, _).
+ PredInfo = predicate(_, _, _, _, Clauses, _, _, _, _, _, _, _, _, _,
+ _, _, _, _, _, _, _, _, _, _).
pred_info_set_clauses_info(PredInfo0, Clauses, PredInfo) :-
- PredInfo0 = predicate(A, B, C, _, E, F, G, H, I, J, K, L, M, N, O, P,
- Q, R, S, T, U, V),
- PredInfo = predicate(A, B, C, Clauses, E, F, G, H, I, J, K,
- L, M, N, O, P, Q, R, S, T, U, V).
+ PredInfo0 = predicate(A, B, C, D, _, F, G, H, I, J, K, L, M, N, O, P,
+ Q, R, S, T, U, V, W, X),
+ PredInfo = predicate(A, B, C, D, Clauses, F, G, H, I, J, K,
+ L, M, N, O, P, Q, R, S, T, U, V, W, X).
pred_info_arg_types(PredInfo, ArgTypes) :-
pred_info_arg_types(PredInfo, _TypeVars, _ExistQVars, ArgTypes).
pred_info_arg_types(PredInfo, TypeVars, ExistQVars, ArgTypes) :-
- PredInfo = predicate(TypeVars, ArgTypes, _, _, _, _, _, _, _, _, _,
- _, _, _, _, _, ExistQVars, _, _, _, _, _).
+ PredInfo = predicate(TypeVars, ArgTypes, _, _, _, _, _, _, _, _, _, _,
+ _, _, _, _, _, _, ExistQVars, _, _, _, _, _).
pred_info_set_arg_types(PredInfo0, TypeVarSet, ExistQVars, ArgTypes,
PredInfo) :-
PredInfo0 = predicate(_, _, C, D, E, F, G, H, I, J, K, L, M, N, O, P,
- _, R, S, T, U, V),
+ Q, R, _, T, U, V, W, X),
PredInfo = predicate(TypeVarSet, ArgTypes, C, D, E, F, G, H, I, J, K,
- L, M, N, O, P, ExistQVars, R, S, T, U, V).
+ L, M, N, O, P, Q, R, ExistQVars, T, U, V, W, X).
+
+pred_info_hidden_args(PredInfo, HiddenArgs) :-
+ PredInfo = predicate(_, _, HiddenArgs, _, _, _, _, _, _, _, _, _, _, _,
+ _, _, _, _, _, _, _, _, _, _).
+
+pred_info_set_hidden_args(PredInfo0, HiddenArgs, PredInfo) :-
+ PredInfo0 = predicate(A, B, _, D, E, F, G, H, I, J, K, L, M, N, O, P,
+ Q, R, S, T, U, V, W, X),
+ PredInfo = predicate(A, B, HiddenArgs, D, E, F, G, H, I, J, K, L, M, N,
+ O, P, Q, R, S, T, U, V, W, X).
pred_info_procedures(PredInfo, Procs) :-
- PredInfo = predicate(_, _, _, _, Procs, _, _, _, _, _, _,
+ PredInfo = predicate(_, _, _, _, _, Procs, _, _, _, _, _, _, _,
_, _, _, _, _, _, _, _, _, _, _).
pred_info_set_procedures(PredInfo0, Procedures, PredInfo) :-
- PredInfo0 = predicate(A, B, C, D, _, F, G, H, I, J, K, L, M, N, O, P,
- Q, R, S, T, U, V),
- PredInfo = predicate(A, B, C, D, Procedures, F, G, H, I, J, K, L, M,
- N, O, P, Q, R, S, T, U, V).
+ PredInfo0 = predicate(A, B, C, D, E, _, G, H, I, J, K, L, M, N, O, P,
+ Q, R, S, T, U, V, W, X),
+ PredInfo = predicate(A, B, C, D, E, Procedures, G, H, I, J, K, L, M,
+ N, O, P, Q, R, S, T, U, V, W, X).
pred_info_context(PredInfo, Context) :-
- PredInfo = predicate(_, _, _, _, _, Context, _, _, _,
+ PredInfo = predicate(_, _, _, _, _, _, Context, _, _, _, _,
_, _, _, _, _, _, _, _, _, _, _, _, _).
pred_info_module(PredInfo, Module) :-
- PredInfo = predicate(_, _, _, _, _, _, Module, _, _, _, _,
+ PredInfo = predicate(_, _, _, _, _, _, _, Module, _, _, _, _, _,
_, _, _, _, _, _, _, _, _, _, _).
pred_info_name(PredInfo, PredName) :-
- PredInfo = predicate(_, _, _, _, _, _, _, PredName, _, _, _,
+ PredInfo = predicate(_, _, _, _, _, _, _, _, PredName, _, _, _, _,
_, _, _, _, _, _, _, _, _, _, _).
pred_info_arity(PredInfo, Arity) :-
- PredInfo = predicate(_, _, _, _, _, _, _, _, Arity, _, _,
+ PredInfo = predicate(_, _, _, _, _, _, _, _, _, Arity, _, _, _,
_, _, _, _, _, _, _, _, _, _, _).
+pred_info_visual_arity(PredInfo, Arity) :-
+ PredInfo = predicate(_, _, _, _, _, _, _, _, _, _, Arity, _, _, _,
+ _, _, _, _, _, _, _, _, _, _).
+
pred_info_import_status(PredInfo, ImportStatus) :-
- PredInfo = predicate(_, _, _, _, _, _, _, _, _, ImportStatus, _, _, _,
- _, _, _, _, _, _, _, _, _).
+ PredInfo = predicate(_, _, _, _, _, _, _, _, _, _, _, ImportStatus, _,
+ _, _, _, _, _, _, _, _, _, _, _).
pred_info_is_imported(PredInfo) :-
pred_info_import_status(PredInfo, imported(_)).
@@ -978,46 +1044,46 @@
).
pred_info_mark_as_external(PredInfo0, PredInfo) :-
- PredInfo0 = predicate(A, B, C, D, E, F, G, H, I, ImportStatus,
- K, L, M, N, O, P, Q, R, S, T, U, V),
+ PredInfo0 = predicate(A, B, C, D, E, F, G, H, I, J, K, ImportStatus,
+ M, N, O, P, Q, R, S, T, U, V, W, X),
status_is_exported(ImportStatus, Exported),
(
Exported = yes,
- PredInfo = predicate(A, B, C, D, E, F, G, H, I,
- imported(interface), K, L, M, N, O,
- P, Q, R, S, T, U, V)
+ PredInfo = predicate(A, B, C, D, E, F, G, H, I, J, K,
+ imported(interface), M, N, O,
+ P, Q, R, S, T, U, V, W, X)
;
Exported = no,
- PredInfo = predicate(A, B, C, D, E, F, G, H, I,
- imported(implementation), K, L, M, N, O,
- P, Q, R, S, T, U, V)
+ PredInfo = predicate(A, B, C, D, E, F, G, H, I, J, K,
+ imported(implementation), M, N, O,
+ P, Q, R, S, T, U, V, W, X)
).
pred_info_set_import_status(PredInfo0, Status, PredInfo) :-
- PredInfo0 = predicate(A, B, C, D, E, F, G, H, I, _, K, L, M, N, O, P,
- Q, R, S, T, U, V),
- PredInfo = predicate(A, B, C, D, E, F, G, H, I, Status, K,
- L, M, N, O, P, Q, R, S, T, U, V).
+ PredInfo0 = predicate(A, B, C, D, E, F, G, H, I, J, K, _, M, N, O, P,
+ Q, R, S, T, U, V, W, X),
+ PredInfo = predicate(A, B, C, D, E, F, G, H, I, J, K, Status,
+ M, N, O, P, Q, R, S, T, U, V, W, X).
pred_info_typevarset(PredInfo, TypeVarSet) :-
- PredInfo = predicate(_, _, _, _, _, _, _, _, _, _, TypeVarSet, _, _,
- _, _, _, _, _, _, _, _, _).
+ PredInfo = predicate(_, _, _, _, _, _, _, _, _, _, _, _, TypeVarSet, _,
+ _, _, _, _, _, _, _, _, _, _).
pred_info_set_typevarset(PredInfo0, TypeVarSet, PredInfo) :-
- PredInfo0 = predicate(A, B, C, D, E, F, G, H, I, J, _, L, M, N, O, P,
- Q, R, S, T, U, V),
- PredInfo = predicate(A, B, C, D, E, F, G, H, I, J, TypeVarSet, L, M,
- N, O, P, Q, R, S, T, U, V).
+ PredInfo0 = predicate(A, B, C, D, E, F, G, H, I, J, K, L, _, N, O, P,
+ Q, R, S, T, U, V, W, X),
+ PredInfo = predicate(A, B, C, D, E, F, G, H, I, J, K, L, TypeVarSet,
+ N, O, P, Q, R, S, T, U, V, W, X).
pred_info_get_goal_type(PredInfo, GoalType) :-
- PredInfo = predicate(_, _, _, _, _, _, _, _, _, _, _, GoalType, _,
- _, _, _, _, _, _, _, _, _).
+ PredInfo = predicate(_, _, _, _, _, _, _, _, _, _, _, _, _, GoalType,
+ _, _, _, _, _, _, _, _, _, _).
pred_info_set_goal_type(PredInfo0, GoalType, PredInfo) :-
- PredInfo0 = predicate(A, B, C, D, E, F, G, H, I, J, K, _, M, N, O, P,
- Q, R, S, T, U, V),
- PredInfo = predicate(A, B, C, D, E, F, G, H, I, J, K, GoalType, M,
- N, O, P, Q, R, S, T, U, V).
+ PredInfo0 = predicate(A, B, C, D, E, F, G, H, I, J, K, L, M, _, O, P,
+ Q, R, S, T, U, V, W, X),
+ PredInfo = predicate(A, B, C, D, E, F, G, H, I, J, K, L, M, GoalType,
+ O, P, Q, R, S, T, U, V, W, X).
pred_info_requested_inlining(PredInfo0) :-
pred_info_get_markers(PredInfo0, Markers),
@@ -1050,41 +1116,41 @@
purity_to_markers(impure, [impure]).
pred_info_get_markers(PredInfo, Markers) :-
- PredInfo = predicate(_, _, _, _, _, _, _, _, _, _, _, _, Markers,
+ PredInfo = predicate(_, _, _, _, _, _, _, _, _, _, _, _, _, _, Markers,
_, _, _, _, _, _, _, _, _).
pred_info_set_markers(PredInfo0, Markers, PredInfo) :-
- PredInfo0 = predicate(A, B, C, D, E, F, G, H, I, J, K, L, _, N, O, P,
- Q, R, S, T, U, V),
- PredInfo = predicate(A, B, C, D, E, F, G, H, I, J, K, L, Markers,
- N, O, P, Q, R, S, T, U, V).
+ PredInfo0 = predicate(A, B, C, D, E, F, G, H, I, J, K, L, M, N, _, P,
+ Q, R, S, T, U, V, W, X),
+ PredInfo = predicate(A, B, C, D, E, F, G, H, I, J, K, L, M, N,
+ Markers, P, Q, R, S, T, U, V, W, X).
pred_info_get_is_pred_or_func(PredInfo, IsPredOrFunc) :-
- PredInfo = predicate(_, _, _, _, _, _, _, _, _, _, _, _, _,
+ PredInfo = predicate(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
IsPredOrFunc, _, _, _, _, _, _, _, _).
pred_info_set_class_context(PredInfo0, ClassContext, PredInfo) :-
- PredInfo0 = predicate(A, B, C, D, E, F, G, H, I, J, K, L, M, N, _, P,
- Q, R, S, T, U, V),
- PredInfo = predicate(A, B, C, D, E, F, G, H, I, J, K, L, M, N,
- ClassContext, P, Q, R, S, T, U, V).
+ PredInfo0 = predicate(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P,
+ _, R, S, T, U, V, W, X),
+ PredInfo = predicate(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O,
+ P, ClassContext, R, S, T, U, V, W, X).
pred_info_get_class_context(PredInfo, ClassContext) :-
- PredInfo = predicate(_, _, _, _, _, _, _, _, _, _, _, _, _, _,
+ PredInfo = predicate(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
ClassContext, _, _, _, _, _, _, _).
pred_info_set_constraint_proofs(PredInfo0, Proofs, PredInfo) :-
- PredInfo0 = predicate(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, _,
- Q, R, S, T, U, V),
+ PredInfo0 = predicate(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P,
+ Q, _, S, T, U, V, W, X),
PredInfo = predicate(A, B, C, D, E, F, G, H, I, J, K, L, M, N,
- O, Proofs, Q, R, S, T, U, V).
+ O, P, Q, Proofs, S, T, U, V, W, X).
pred_info_get_constraint_proofs(PredInfo, ConstraintProofs) :-
- PredInfo = predicate(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
+ PredInfo = predicate(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
ConstraintProofs, _, _, _, _, _, _).
pred_info_get_exist_quant_tvars(PredInfo, ExistQVars) :-
- PredInfo = predicate(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
+ PredInfo = predicate(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
_, ExistQVars, _, _, _, _, _).
pred_info_get_univ_quant_tvars(PredInfo, UnivQVars) :-
@@ -1095,58 +1161,57 @@
list__delete_elems(ArgTypeVars, ExistQVars, UnivQVars).
pred_info_get_head_type_params(PredInfo, HeadTypeParams) :-
- PredInfo = predicate(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
+ PredInfo = predicate(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
_, _, HeadTypeParams, _, _, _, _).
pred_info_set_head_type_params(PredInfo0, HeadTypeParams, PredInfo) :-
PredInfo0 = predicate(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P,
- Q, _, S, T, U, V),
+ Q, R, S, _, U, V, W, X),
PredInfo = predicate(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P,
- Q, HeadTypeParams, S, T, U, V).
+ Q, R, S, HeadTypeParams, U, V, W, X).
pred_info_get_unproven_body_constraints(PredInfo, UnprovenBodyConstraints) :-
- PredInfo = predicate(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
- _, _, UnprovenBodyConstraints, _, _, _).
+ PredInfo = predicate(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
+ _, _, _, UnprovenBodyConstraints, _, _, _).
pred_info_set_unproven_body_constraints(PredInfo0, UnprovenBodyConstraints,
PredInfo) :-
PredInfo0 = predicate(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P,
- Q, R, _, T, U, V),
+ Q, R, S, T, _, V, W, X),
PredInfo = predicate(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P,
- Q, R, UnprovenBodyConstraints, T, U, V).
+ Q, R, S, T, UnprovenBodyConstraints, V, W, X).
pred_info_get_aditi_owner(PredInfo, Owner) :-
- PredInfo = predicate(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
+ PredInfo = predicate(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
_, _, _, _, Owner, _, _).
pred_info_set_aditi_owner(PredInfo0, Owner, PredInfo) :-
PredInfo0 = predicate(A, B, C, D, E, F, G, H, I, J, K, L, M, N,
- O, P, Q, R, S, _, U, V),
+ O, P, Q, R, S, T, U, _, W, X),
PredInfo = predicate(A, B, C, D, E, F, G, H, I, J, K, L, M, N,
- O, P, Q, R, S, Owner, U, V).
+ O, P, Q, R, S, T, U, Owner, W, X).
pred_info_get_indexes(PredInfo, Indexes) :-
- PredInfo = predicate(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
+ PredInfo = predicate(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
_, _, _, _, _, Indexes, _).
pred_info_set_indexes(PredInfo0, Indexes, PredInfo) :-
PredInfo0 = predicate(A, B, C, D, E, F, G, H, I, J, K, L, M, N,
- O, P, Q, R, S, T, _, V),
+ O, P, Q, R, S, T, U, V, _, X),
PredInfo = predicate(A, B, C, D, E, F, G, H, I, J, K, L, M, N,
- O, P, Q, R, S, T, Indexes, V).
+ O, P, Q, R, S, T, U, V, Indexes, X).
pred_info_get_assertions(PredInfo, Assertions) :-
- PredInfo = predicate(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
+ PredInfo = predicate(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _,
_, _, _, _, _, _, Assertions).
pred_info_set_assertions(PredInfo0, Assertions, PredInfo) :-
PredInfo0 = predicate(A, B, C, D, E, F, G, H, I, J, K, L, M, N,
- O, P, Q, R, S, T, U, _),
+ O, P, Q, R, S, T, U, V, W, _),
PredInfo = predicate(A, B, C, D, E, F, G, H, I, J, K, L, M, N,
- O, P, Q, R, S, T, U, Assertions).
+ O, P, Q, R, S, T, U, V, W, Assertions).
-%-----------------------------------------------------------------------------%
pred_info_get_call_id(PredInfo, PredOrFunc - qualified(Module, Name)/Arity) :-
pred_info_get_is_pred_or_func(PredInfo, PredOrFunc),
Index: compiler/mercury_to_goedel.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_to_goedel.m,v
retrieving revision 1.69
diff -u -r1.69 mercury_to_goedel.m
--- compiler/mercury_to_goedel.m 2000/01/13 06:16:17 1.69
+++ compiler/mercury_to_goedel.m 2000/01/17 05:36:13
@@ -143,10 +143,13 @@
goedel_output_item(mode_defn(VarSet, ModeDefn, _Cond), Context) -->
goedel_output_mode_defn(VarSet, ModeDefn, Context).
+ % XXX Should we ignore ClassContext, or give an error?
+
% XXX Should we ignore ClassContext and ExistQVars,
% or give an error if they're non-empty?
goedel_output_item(pred(TypeVarSet, InstVarSet, _ExistQVars, PredName,
- TypesAndModes, _Det, _Cond, Purity, _ClassContext), Context) -->
+ TypesAndModes, [], _Det, _Cond, Purity, _ClassContext),
+ Context) -->
io__write_string("\n"),
maybe_write_line_number(Context),
( { Purity = pure } ->
@@ -159,6 +162,15 @@
goedel_output_pred(TypeVarSet, InstVarSet, PredName, TypesAndModes,
Context).
+goedel_output_item(pred(_, _, _, _, _, [_HiddenArgs|_], _, _, _, _), _) -->
+ { error("Error: hidden arguments are not supported.\n") }.
+
+goedel_output_item(htype_defn(_, _, _), _) -->
+ { error("Error: hidden arguments are not supported.\n") }.
+
+goedel_output_item(hmode_defn(_, _, _), _) -->
+ { error("Error: hidden arguments are not supported.\n") }.
+
% XXX Should we ignore ClassContext and ExistQVars,
% or give an error if they're non-empty?
goedel_output_item(func(TypeVarSet, InstVarSet, _ExistQVars, PredName,
@@ -186,10 +198,13 @@
% io__write_string("warning: module declarations not yet supported.\n").
[].
-goedel_output_item(pred_clause(VarSet, PredName, Args, Body), Context) -->
+goedel_output_item(pred_clause(VarSet, PredName, Args, Body, no), Context) -->
maybe_write_line_number(Context),
goedel_output_pred_clause(VarSet, PredName, Args, Body, Context).
+goedel_output_item(pred_clause(_, _, _, _, yes), _) -->
+ { error("Error: hidden_arguments are not supported.\n") }.
+
goedel_output_item(func_clause(VarSet, PredName, Args, Result, Body), Context)
-->
maybe_write_line_number(Context),
@@ -655,7 +670,8 @@
io__write_string(")").
% XXX should preserve some of the qualification information?
-goedel_output_goal_2(call(Name, Term, Purity), VarSet, Indent) -->
+% XXX should issue warning about hidden arguments, since they printed to goedel.
+goedel_output_goal_2(call(Name, Term, _, Purity), VarSet, Indent) -->
( { Purity = pure } ->
[]
;
Index: compiler/mercury_to_mercury.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_to_mercury.m,v
retrieving revision 1.166
diff -u -r1.166 mercury_to_mercury.m
--- compiler/mercury_to_mercury.m 2000/01/25 04:09:52 1.166
+++ compiler/mercury_to_mercury.m 2000/02/01 03:08:39
@@ -37,7 +37,14 @@
:- pred mercury_output_pred_type(tvarset, existq_tvars, sym_name, list(type),
maybe(determinism), purity, class_constraints,
prog_context, io__state, io__state).
-:- mode mercury_output_pred_type(in, in, in, in, in, in, in, in, di, uo) is det.
+:- mode mercury_output_pred_type(in, in, in, in, in, in, in, in,
+ di, uo) is det.
+
+:- pred mercury_output_pred_type(tvarset, existq_tvars, sym_name, list(type),
+ hidden_forms, maybe(determinism), purity,
+ class_constraints, prog_context, io__state, io__state).
+:- mode mercury_output_pred_type(in, in, in, in, in, in, in, in, in,
+ di, uo) is det.
:- pred mercury_output_func_type(tvarset, existq_tvars, sym_name,
list(type), type,
@@ -92,6 +99,14 @@
io__state, io__state).
:- mode mercury_output_type_defn(in, in, in, di, uo) is det.
+:- pred mercury_output_htype_decl(tvarset, sym_name, htype_defn, term__context,
+ io__state, io__state).
+:- mode mercury_output_htype_decl(in, in, in, in, di, uo) is det.
+
+:- pred mercury_output_hmode_decl(inst_varset, sym_name, hmode_defn,
+ term__context, io__state, io__state).
+:- mode mercury_output_hmode_decl(in, in, in, in, di, uo) is det.
+
:- pred mercury_output_ctor(constructor, tvarset, io__state, io__state).
:- mode mercury_output_ctor(in, in, di, uo) is det.
@@ -272,11 +287,20 @@
maybe_output_line_number(Context),
mercury_output_mode_defn(VarSet, ModeDefn, Context).
+mercury_output_item(htype_defn(VarSet, Name, TypeDefn), Context) -->
+ maybe_output_line_number(Context),
+ mercury_output_htype_decl(VarSet, Name, TypeDefn, Context).
+
+mercury_output_item(hmode_defn(VarSet, Name, ModeDefn), Context) -->
+ maybe_output_line_number(Context),
+ mercury_output_hmode_decl(VarSet, Name, ModeDefn, Context).
+
mercury_output_item(pred(TypeVarSet, InstVarSet, ExistQVars, PredName,
- TypesAndModes, Det, _Cond, Purity, ClassContext), Context) -->
+ TypesAndModes, HiddenForms, Det, _Cond, Purity, ClassContext),
+ Context) -->
maybe_output_line_number(Context),
mercury_output_pred_decl(TypeVarSet, InstVarSet, ExistQVars, PredName,
- TypesAndModes, Det, Purity, ClassContext, Context,
+ TypesAndModes, HiddenForms, Det, Purity, ClassContext, Context,
":- ", ".\n", ".\n").
mercury_output_item(func(TypeVarSet, InstVarSet, ExistQVars, PredName,
@@ -303,9 +327,11 @@
maybe_output_line_number(Context),
mercury_output_module_defn(VarSet, ModuleDefn, Context).
-mercury_output_item(pred_clause(VarSet, PredName, Args, Body), Context) -->
+mercury_output_item(pred_clause(VarSet, PredName, Args, Body, MaybeEDCG),
+ Context) -->
maybe_output_line_number(Context),
- mercury_output_pred_clause(VarSet, PredName, Args, Body, Context).
+ mercury_output_pred_clause(VarSet, PredName, Args, Body, Context,
+ MaybeEDCG).
mercury_output_item(func_clause(VarSet, FuncName, Args, Result, Body),
Context) -->
@@ -503,7 +529,7 @@
TypesAndModes, Detism, _Condition, ClassContext,
Context) },
mercury_output_pred_decl(TypeVarSet, InstVarSet, ExistQVars,
- Name, TypesAndModes, Detism, pure, ClassContext,
+ Name, TypesAndModes, [], Detism, pure, ClassContext,
Context, "", ",\n\t", "")
;
{ Method = func(TypeVarSet, InstVarSet, ExistQVars, Name,
@@ -546,7 +572,6 @@
mercury_output_bracketed_sym_name(Name2).
%-----------------------------------------------------------------------------%
-
:- pred mercury_output_module_defn(prog_varset, module_defn, term__context,
io__state, io__state).
:- mode mercury_output_module_defn(in, in, in, di, uo) is det.
@@ -1304,47 +1329,111 @@
io__write_string(" :: ").
%-----------------------------------------------------------------------------%
+% Should remove the term__context argument some time later.
+
+mercury_output_hmode_decl(VarSet, Name, HmodeDefn, Context) -->
+ mercury_output_hmode_decl_2(VarSet, Name, HmodeDefn, Context,
+ ":- ", ".\n").
+
+:- pred mercury_output_hmode_decl_2(inst_varset, sym_name, hmode_defn,
+ term__context, string, string, io__state, io__state).
+:- mode mercury_output_hmode_decl_2(in, in, in, in, in, in, di, uo) is det.
+
+mercury_output_hmode_decl_2(VarSet, Name, HmodeDefn, _Context,
+ StartString, Separator) -->
+ io__write_string(StartString),
+ io__write_string("hmode("),
+ mercury_output_sym_name(Name),
+ mercury_output_hmode_decl_3(changed, HmodeDefn, VarSet),
+ mercury_output_hmode_decl_3(passed, HmodeDefn, VarSet),
+ mercury_output_hmode_decl_3(produced, HmodeDefn, VarSet),
+ io__write_string(")"),
+ io__write_string(Separator).
+
+:- pred mercury_output_hmode_decl_3(form, hmode_defn, inst_varset,
+ io__state, io__state).
+:- mode mercury_output_hmode_decl_3(in, in, in, di, uo) is det.
+mercury_output_hmode_decl_3(Form, HmodeDefn, VarSet) -->
+ ( { get_hidden_modes(Form, HmodeDefn, ModeList) } ->
+ { form_to_string(Form, FormString) },
+ io__write_string(", "),
+ io__write_strings([FormString, "("]),
+ mercury_output_mode_list(ModeList, VarSet),
+ io__write_string(")")
+ ;
+ { true }
+ ).
+
+%-----------------------------------------------------------------------------%
+
+mercury_output_htype_decl(VarSet, Name, HtypeDefn, Context) -->
+ mercury_output_htype_decl_2(VarSet, Name, HtypeDefn, Context,
+ ":- ", ".\n").
+
+:- pred mercury_output_htype_decl_2(tvarset, sym_name, htype_defn,
+ term__context, string, string, io__state, io__state).
+:- mode mercury_output_htype_decl_2(in, in, in, in, in, in, di, uo) is det.
+mercury_output_htype_decl_2(VarSet, HiddenName, htype_defn(Type),
+ _Context, StartString, Separator) -->
+ io__write_string(StartString),
+ io__write_string("htype("),
+ mercury_output_sym_name(HiddenName),
+ io__write_string(", "),
+ mercury_output_term(Type, VarSet, no),
+ io__write_string(")"),
+ io__write_string(Separator).
+
+%-----------------------------------------------------------------------------%
+
:- pred mercury_output_pred_decl(tvarset, inst_varset, existq_tvars,
- sym_name, list(type_and_mode),
+ sym_name, list(type_and_mode), hidden_forms,
maybe(determinism), purity, class_constraints,
prog_context, string, string, string, io__state, io__state).
:- mode mercury_output_pred_decl(in, in, in, in, in, in, in, in, in, in, in, in,
- di, uo) is det.
+ in, di, uo) is det.
mercury_output_pred_decl(TypeVarSet, InstVarSet, ExistQVars, PredName,
- TypesAndModes, MaybeDet, Purity, ClassContext, Context,
- StartString, Separator, Terminator) -->
+ TypesAndModes, HiddenForms, MaybeDet, Purity, ClassContext,
+ Context, StartString, Separator, Terminator) -->
{ split_types_and_modes(TypesAndModes, Types, MaybeModes) },
(
{ MaybeModes = yes(Modes) },
{ Modes \= [] }
->
mercury_output_pred_type_2(TypeVarSet, ExistQVars, PredName,
- Types, MaybeDet, Purity, ClassContext, Context,
- StartString, Separator),
+ Types, HiddenForms, MaybeDet, Purity, ClassContext,
+ Context, StartString, Separator),
mercury_output_pred_mode_decl_2(InstVarSet, PredName, Modes,
MaybeDet, Context, StartString, Terminator)
;
mercury_output_pred_type_2(TypeVarSet, ExistQVars, PredName,
- Types, MaybeDet, Purity, ClassContext, Context,
- StartString, Terminator)
+ Types, HiddenForms, MaybeDet, Purity, ClassContext,
+ Context, StartString, Terminator)
).
-mercury_output_pred_type(VarSet, ExistQVars, PredName, Types, MaybeDet, Purity,
- ClassContext, Context) -->
- mercury_output_pred_type_2(VarSet, ExistQVars, PredName, Types,
- MaybeDet, Purity, ClassContext, Context, ":- ", ".\n").
+mercury_output_pred_type(VarSet, ExistQVars, PredName, Types, MaybeDet,
+ Purity, ClassContext, Context) -->
+ mercury_output_pred_type_2(VarSet, ExistQVars, PredName, Types,
+ [], MaybeDet, Purity, ClassContext, Context,
+ ":- ", ".\n").
+mercury_output_pred_type(VarSet, ExistQVars, PredName, Types, HiddenForms,
+ MaybeDet, Purity, ClassContext, Context) -->
+ mercury_output_pred_type_2(VarSet, ExistQVars, PredName, Types,
+ HiddenForms, MaybeDet, Purity, ClassContext,
+ Context, ":- ", ".\n").
:- pred mercury_output_pred_type_2(tvarset, existq_tvars, sym_name, list(type),
- maybe(determinism), purity, class_constraints,
- prog_context, string, string, io__state, io__state).
-:- mode mercury_output_pred_type_2(in, in, in, in, in, in, in, in, in, in,
+ hidden_forms, maybe(determinism), purity,
+ class_constraints, prog_context, string, string, io__state,
+ io__state).
+:- mode mercury_output_pred_type_2(in, in, in, in, in, in, in, in, in, in, in,
di, uo) is det.
-mercury_output_pred_type_2(VarSet, ExistQVars, PredName, Types, MaybeDet,
- Purity, ClassContext, _Context, StartString, Separator) -->
+mercury_output_pred_type_2(VarSet, ExistQVars, PredName, Types, HiddenForms,
+ MaybeDet, Purity, ClassContext, _Context, StartString,
+ Separator) -->
io__write_string(StartString),
mercury_output_quantifier(VarSet, ExistQVars),
( { ExistQVars = [], ClassContext = constraints(_, []) } ->
@@ -1362,9 +1451,11 @@
mercury_output_term(Type, VarSet, no),
mercury_output_remaining_terms(Rest, VarSet, no),
io__write_string(")"),
+ mercury_output_hidden_args(HiddenForms, VarSet),
mercury_output_class_context(ClassContext, ExistQVars, VarSet)
;
mercury_output_bracketed_sym_name(PredName),
+ mercury_output_hidden_args(HiddenForms, VarSet),
mercury_output_class_context(ClassContext, ExistQVars, VarSet),
mercury_output_det_annotation(MaybeDet)
),
@@ -1392,6 +1483,32 @@
),
io__write_string(Separator).
+:- pred mercury_output_hidden_args(hidden_forms, tvarset,
+ io__state, io__state).
+:- mode mercury_output_hidden_args(in, in, di, uo) is det.
+mercury_output_hidden_args([], _) --> [].
+mercury_output_hidden_args([HiddenForm|Others], VarSet) -->
+ io__write_string("+hidden("),
+ mercury_output_hidden_args_2([HiddenForm|Others], VarSet),
+ io__write_string(")").
+
+:- pred mercury_output_hidden_args_2(hidden_forms, tvarset,
+ io__state, io__state).
+:- mode mercury_output_hidden_args_2(in, in, di, uo) is det.
+mercury_output_hidden_args_2([], _) --> [].
+mercury_output_hidden_args_2([SymName - Form|Rest],
+ VarSet) -->
+ { form_to_string(Form, FormString) },
+ io__write_string(FormString),
+ io__write_string("("),
+ mercury_output_sym_name(SymName),
+ io__write_string(")"),
+ ( { Rest \= [] } ->
+ io__write_string(", "),
+ mercury_output_hidden_args_2(Rest, VarSet)
+ ;
+ { true }
+ ).
%-----------------------------------------------------------------------------%
@@ -1698,10 +1815,11 @@
% Output a clause.
:- pred mercury_output_pred_clause(prog_varset, sym_name, list(prog_term), goal,
- prog_context, io__state, io__state).
-:- mode mercury_output_pred_clause(in, in, in, in, in, di, uo) is det.
+ prog_context, maybe_edcg, io__state, io__state).
+:- mode mercury_output_pred_clause(in, in, in, in, in, in, di, uo) is det.
-mercury_output_pred_clause(VarSet, PredName, Args, Body, _Context) -->
+mercury_output_pred_clause(VarSet, PredName, Args, Body, _Context,
+ MaybeEDCG) -->
mercury_output_sym_name(PredName),
(
{ Args = [Arg | Args0] }
@@ -1718,7 +1836,11 @@
->
[]
;
- io__write_string(" :-\n\t"),
+ ( { MaybeEDCG = no } ->
+ io__write_string(" :-\n\t")
+ ;
+ io__write_string(" -->>\n\t")
+ ),
mercury_output_goal(Body, VarSet, 1)
),
io__write_string(".\n").
@@ -1884,9 +2006,10 @@
mercury_output_newline(Indent),
io__write_string(")").
-mercury_output_goal_2(call(Name, Term, Purity), VarSet, Indent) -->
+mercury_output_goal_2(call(Name, Term, HTerms, Purity), VarSet, Indent) -->
write_purity_prefix(Purity),
- mercury_output_call(Name, Term, VarSet, Indent).
+ mercury_output_call(Name, Term, VarSet, Indent),
+ mercury_output_hidden_terms(HTerms, VarSet, Indent).
mercury_output_goal_2(unify(A, B), VarSet, _Indent) -->
mercury_output_term(A, VarSet, no),
@@ -1914,6 +2037,16 @@
Term, Context0), VarSet, no, next_to_graphic_token)
).
+:- pred mercury_output_hidden_terms(list(prog_term), prog_varset, int,
+ io__state, io__state).
+:- mode mercury_output_hidden_terms(in, in, in, di, uo) is det.
+
+mercury_output_hidden_terms(HiddenTerms, VarSet, _Ident) -->
+ io__write_string(" +"),
+ { term__context_init(Context0) },
+ mercury_output_term(term__functor(term__atom("hidden"),
+ HiddenTerms, Context0), VarSet, no, next_to_graphic_token).
+
:- pred mercury_output_disj(goal, prog_varset, int, io__state, io__state).
:- mode mercury_output_disj(in, in, in, di, uo) is det.
@@ -2771,6 +2904,8 @@
:- mode mercury_infix_op(in) is semidet.
mercury_infix_op("--->").
+
+mercury_infix_op("-->>"). % EDCG
mercury_infix_op("-->").
mercury_infix_op(":-").
mercury_infix_op("::").
@@ -2869,6 +3004,8 @@
mercury_unary_prefix_op("useIf").
mercury_unary_prefix_op("wait").
mercury_unary_prefix_op("~").
+mercury_unary_prefix_op("$").
+mercury_unary_prefix_op("$=").
mercury_unary_prefix_op("^").
:- pred mercury_unary_postfix_op(string).
Index: compiler/module_qual.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/module_qual.m,v
retrieving revision 1.53
diff -u -r1.53 module_qual.m
--- compiler/module_qual.m 2000/01/13 04:29:40 1.53
+++ compiler/module_qual.m 2000/02/01 02:50:23
@@ -7,15 +7,15 @@
:- module module_qual.
% Main authors: stayl, fjh.
%
-% Module qualifies types, insts and modes within declaration items.
-% The head of all declarations should be module qualified in prog_io.m.
-% This module qualifies the bodies of the declarations.
-% Checks for undefined types, insts and modes.
-% Uses two passes over the item list, one to collect all type, mode
-% and inst ids and a second to do the qualification and report errors.
-% If the --warn-interface-imports option is set, warns about modules
-% imported in the interface that do not need to be in the interface.
-% The modes of lambda expressions are qualified in modes.m.
+% Module qualifies types, insts, modes and hidden variables within
+% declaration items. The head of all declarations should be module
+% qualified in prog_io.m. This module qualifies the bodies of the
+% declarations. Checks for undefined types, insts, modes hidden
+% variables. Uses two passes over the item list, one to collect all type,
+% mode, inst and hidden variable ids and a second to do the qualification
+% and report errors. If the --warn-interface-imports option is set, warns
+% about modules imported in the interface that do not need to be in the
+% interface. The modes of lambda expressions are qualified in modes.m.
%
:- interface.
@@ -51,6 +51,7 @@
:- mode module_qual__qualify_type_qualification(in, out, in, in,
out, di, uo) is det.
+
% The type mq_info holds information needed for doing module
% qualification.
:- type mq_info.
@@ -138,12 +139,14 @@
set(module_name),
% Sets of all modules, types, insts, modes,
- % and typeclasses visible in this module.
+ % hidden variables and typeclasses visible in
+ % this module.
module_id_set,
type_id_set,
inst_id_set,
mode_id_set,
class_id_set,
+ hidden_id_set,
set(module_name), % modules imported in the
% interface that are not definitely
@@ -183,7 +186,7 @@
:- pred collect_mq_info_2(item::in, mq_info::in, mq_info::out) is det.
-collect_mq_info_2(pred_clause(_,_,_,_), Info, Info).
+collect_mq_info_2(pred_clause(_,_,_,_,_), Info, Info).
collect_mq_info_2(func_clause(_,_,_,_,_), Info, Info).
collect_mq_info_2(type_defn(_, TypeDefn, _), Info0, Info) :-
add_type_defn(TypeDefn, Info0, Info).
@@ -191,10 +194,13 @@
add_inst_defn(InstDefn, Info0, Info).
collect_mq_info_2(mode_defn(_, ModeDefn, _), Info0, Info) :-
add_mode_defn(ModeDefn, Info0, Info).
+collect_mq_info_2(hmode_defn(_,_,_), Info, Info).
+collect_mq_info_2(htype_defn(_,Name,HtypeDefn), Info0, Info) :-
+ add_htype_defn(Name,HtypeDefn, Info0, Info).
collect_mq_info_2(module_defn(_, ModuleDefn), Info0, Info) :-
process_module_defn(ModuleDefn, Info0, Info).
-collect_mq_info_2(pred(_,__,_,_,_,_,_,_,_), Info, Info).
-collect_mq_info_2(func(_,_,__,_,_,_,_,_,_,_), Info, Info).
+collect_mq_info_2(pred(_,_,_,_,_,_,_,_,_,_), Info, Info).
+collect_mq_info_2(func(_,_,_,_,_,_,_,_,_,_), Info, Info).
collect_mq_info_2(pred_mode(_,_,_,_,_), Info, Info).
collect_mq_info_2(func_mode(_,_,_,_,_,_), Info, Info).
collect_mq_info_2(pragma(_), Info, Info).
@@ -247,6 +253,16 @@
id_set_insert(NeedQualifier, SymName - Arity, Types0, Types),
mq_info_set_types(Info0, Types, Info).
+:- pred add_htype_defn(sym_name::in, htype_defn::in, mq_info::in,
+ mq_info::out) is det.
+
+add_htype_defn(SymName, _HtypeDefn, Info0, Info) :-
+ mq_info_get_htypes(Info0, Htypes0),
+ mq_info_get_need_qual_flag(Info0, NeedQualifier),
+ hidden_name_to_id(SymName, HiddenId),
+ id_set_insert(NeedQualifier, HiddenId, Htypes0, Htypes),
+ mq_info_set_htypes(Info0, Htypes, Info).
+
:- pred add_inst_defn(inst_defn::in, mq_info::in, mq_info::out) is det.
add_inst_defn(InstDefn, Info0, Info) :-
@@ -403,15 +419,18 @@
list__append(Symbols0, SymbolsC, Symbols),
bool__and(SuccessA, SuccessB, Success0),
bool__and(Success0, SuccessC, Success).
-process_assert(call(SymName, Args0, _) - _, Symbols, Success) :-
+process_assert(call(SymName, Args0, HiddenArgs0, _) - _, Symbols, Success) :-
(
SymName = qualified(_, _)
->
list__map(term__coerce, Args0, Args),
+ list__map(term__coerce, HiddenArgs0, HiddenArgs),
(
- term_qualified_symbols_list(Args, Symbols0)
+ term_qualified_symbols_list(Args, Symbols0),
+ term_qualified_symbols_list(HiddenArgs, Symbols1),
+ list__append(Symbols0, Symbols1, Symbols2)
->
- Symbols = [SymName | Symbols0],
+ Symbols = [SymName | Symbols2],
Success = yes
;
Symbols = [],
@@ -487,7 +506,7 @@
mq_info::in, mq_info::out, bool::out,
io__state::di, io__state::uo) is det.
-module_qualify_item(pred_clause(A,B,C,D) - Con, pred_clause(A,B,C,D) - Con,
+module_qualify_item(pred_clause(A,B,C,D,E) - Con, pred_clause(A,B,C,D,E) - Con,
Info, Info, yes) --> [].
module_qualify_item(func_clause(A,B,C,D,E) - Con, func_clause(A,B,C,D,E) - Con,
@@ -505,21 +524,31 @@
mode_defn(A, ModeDefn, C) - Context, Info0, Info, yes) -->
qualify_mode_defn(ModeDefn0, ModeDefn, Info0, Info, Context).
+% May have to change.
+module_qualify_item(htype_defn(A, Name, HtypeDefn0) - Context,
+ htype_defn(A, Name, HtypeDefn) - Context, Info0, Info, yes) -->
+ qualify_htype_defn(Name, HtypeDefn0, HtypeDefn, Info0, Info, Context).
+
+module_qualify_item(hmode_defn(A, Name, HmodeDefn0) - Context,
+ hmode_defn(A, Name, HmodeDefn) - Context, Info0, Info, yes) -->
+ qualify_hmode_defn(Name, HmodeDefn0, HmodeDefn, Info0, Info, Context).
+
module_qualify_item(module_defn(A, ModuleDefn) - Context,
module_defn(A, ModuleDefn) - Context, Info0, Info, Continue) -->
{ update_import_status(ModuleDefn, Info0, Info, Continue) }.
module_qualify_item(
- pred(A, IVs, B, SymName, TypesAndModes0, C, D, E,
- Constraints0) - Context,
- pred(A, IVs, B, SymName, TypesAndModes, C, D, E,
+ pred(A, IVs, B, SymName, TypesAndModes0, FormsAndNames0, D, E,
+ F, Constraints0) - Context,
+ pred(A, IVs, B, SymName, TypesAndModes, FormsAndNames, D, E, F,
Constraints) - Context,
Info0, Info, yes) -->
{ list__length(TypesAndModes0, Arity) },
{ mq_info_set_error_context(Info0, pred(SymName - Arity) - Context,
Info1) },
qualify_types_and_modes(TypesAndModes0, TypesAndModes, Info1, Info2),
- qualify_class_constraints(Constraints0, Constraints, Info2, Info).
+ qualify_hidden_args(FormsAndNames0, FormsAndNames, Info2, Info3),
+ qualify_class_constraints(Constraints0, Constraints, Info3, Info).
module_qualify_item(
func(A, IVs, B, SymName, TypesAndModes0, TypeAndMode0, F, G, H,
@@ -873,6 +902,70 @@
Info = Info2
}.
+ % Qualify the type of a hidden argument declaration.
+:- pred qualify_htype_defn(sym_name::in, htype_defn::in, htype_defn::out,
+ mq_info::in, mq_info::out, term__context::in,
+ io__state::di, io__state::uo) is det.
+
+qualify_htype_defn(Name, htype_defn(Type0),
+ htype_defn(Type),
+ Info0, Info, Context) -->
+ { Arity is 0 },
+ { mq_info_set_error_context(Info0, hidden(Name - Arity) - Context,
+ Info1) },
+ qualify_type(Type0, Type, Info1, Info).
+
+ % Qualify the mode(s) of a hidden argument mode declaration.
+:- pred qualify_hmode_defn(sym_name::in, hmode_defn::in, hmode_defn::out,
+ mq_info::in, mq_info::out, term__context::in,
+ io__state::di, io__state::uo) is det.
+
+qualify_hmode_defn(Name, HmodeDefn0, HmodeDefn,
+ Info0, Info, Context) -->
+ { Arity is 0 },
+ { mq_info_set_error_context(Info0, hmode(Name - Arity) - Context,
+ Info1) },
+ qualify_hmode_defn_2(changed, HmodeDefn0, HmodeDefn1, Info1, Info2),
+ qualify_hmode_defn_2(passed, HmodeDefn1, HmodeDefn, Info2, Info).
+
+:- pred qualify_hmode_defn_2(form, hmode_defn, hmode_defn, mq_info, mq_info,
+ io__state, io__state).
+:- mode qualify_hmode_defn_2(in, in, out, in, out, di, uo) is det.
+
+qualify_hmode_defn_2(Form, HmodeDefn0, HmodeDefn, Info0, Info) -->
+ ( { get_hidden_modes(Form, HmodeDefn0, ModeList0) } ->
+ qualify_mode_list(ModeList0, ModeList, Info0, Info),
+ (
+ % Fails if ModeList is the wrong length.
+ % This was checked earlier.
+ { set_hidden_modes(Form, HmodeDefn0, ModeList,
+ HmodeDefn1) }
+ ->
+ { HmodeDefn1 = HmodeDefn }
+ ;
+ { error("hmode_defn data structure access error.") }
+ )
+ ;
+ % No mode declaration for Form.
+ { Info0 = Info },
+ { HmodeDefn0 = HmodeDefn }
+ ).
+
+
+:- pred qualify_hidden_args(hidden_forms, hidden_forms, mq_info, mq_info,
+ io__state, io__state).
+:- mode qualify_hidden_args(in, out, in, out, di, uo) is det.
+
+qualify_hidden_args([], [], Info, Info) --> [].
+qualify_hidden_args([HiddenArg0 - Form|Others0],
+ [HiddenArg - Form|Others], Info0, Info) -->
+ { mq_info_get_htypes(Info0, Htypes) },
+ { hidden_name_to_id(HiddenArg0, HiddenId0) },
+ find_unique_match(HiddenId0, HiddenId, Htypes, hidden_id,
+ Info0, Info1),
+ { id_to_hidden_name(HiddenId, HiddenArg) },
+ qualify_hidden_args(Others0, Others, Info1, Info).
+
% Qualify the modes in a pragma c_code(...) decl.
:- pred qualify_pragma((pragma_type)::in, (pragma_type)::out,
mq_info::in, mq_info::out, io__state::di, io__state::uo) is det.
@@ -1156,7 +1249,8 @@
type_id
; mode_id
; inst_id
- ; class_id.
+ ; class_id
+ ; hidden_id.
:- type error_context == pair(error_context2, prog_context).
@@ -1166,6 +1260,8 @@
type(id)
; inst(id)
; mode(id)
+ ; hidden(id)
+ ; hmode(id)
; pred(id)
; func(id)
; pred_mode(id)
@@ -1176,6 +1272,14 @@
; class(id)
; instance(id).
+ % Hidden arguments have no arguments so their arity is assigned to 0.
+:- pred hidden_name_to_id(sym_name::in, id::out) is det.
+hidden_name_to_id(SymName, SymName - 0).
+
+ % Hidden arguments have no arguments so their arity is irrelevant.
+:- pred id_to_hidden_name(id::in, sym_name::out) is det.
+id_to_hidden_name(SymName - _, SymName).
+
% Report an undefined type, inst or mode.
:- pred report_undefined(mq_info, pair(sym_name, int),
id_type, io__state, io__state).
@@ -1257,6 +1361,12 @@
write_error_context2(inst(Id)) -->
io__write_string("definition of inst "),
write_id(Id).
+write_error_context2(hidden(Id)) -->
+ io__write_string("type declaration for hidden argument "),
+ write_id(Id).
+write_error_context2(hmode(Id)) -->
+ io__write_string("mode declaration for hidden argument "),
+ write_id(Id).
write_error_context2(pred(Id)) -->
io__write_string("definition of predicate "),
write_id(Id).
@@ -1288,6 +1398,7 @@
id_type_to_string(mode_id, "mode").
id_type_to_string(inst_id, "inst").
id_type_to_string(class_id, "typeclass").
+id_type_to_string(hidden_id, "htype").
% Write sym_name/arity.
:- pred write_id(id::in, io__state::di, io__state::uo) is det.
@@ -1398,8 +1509,8 @@
ImportedModules),
id_set_init(Empty),
Info0 = mq_info(ImportedModules, Empty, Empty, Empty, Empty,
- Empty, InterfaceModules0, not_exported, 0, no, no,
- ReportErrors, ErrorContext, may_be_unqualified).
+ Empty, Empty, InterfaceModules0, not_exported, 0, no,
+ no, ReportErrors, ErrorContext, may_be_unqualified).
:- pred mq_info_get_imported_modules(mq_info::in, set(module_name)::out) is det.
:- pred mq_info_get_modules(mq_info::in, module_id_set::out) is det.
@@ -1407,6 +1518,7 @@
:- pred mq_info_get_insts(mq_info::in, inst_id_set::out) is det.
:- pred mq_info_get_modes(mq_info::in, mode_id_set::out) is det.
:- pred mq_info_get_classes(mq_info::in, class_id_set::out) is det.
+:- pred mq_info_get_htypes(mq_info::in, hidden_id_set::out) is det.
:- pred mq_info_get_unused_interface_modules(mq_info::in,
set(module_name)::out) is det.
:- pred mq_info_get_import_status(mq_info::in, import_status::out) is det.
@@ -1416,27 +1528,29 @@
:- pred mq_info_get_report_error_flag(mq_info::in, bool::out) is det.
:- pred mq_info_get_error_context(mq_info::in, error_context::out) is det.
-mq_info_get_imported_modules(mq_info(ImportedModules, _,_,_,_,_,_,_,_,_,_,_,
+mq_info_get_imported_modules(mq_info(ImportedModules, _,_,_,_,_,_,_,_,_,_,_,_,
_,_), ImportedModules).
-mq_info_get_modules(mq_info(_, Modules, _,_,_,_,_,_,_,_,_,_,_,_), Modules).
-mq_info_get_types(mq_info(_,_, Types, _,_,_,_,_,_,_,_,_,_,_), Types).
-mq_info_get_insts(mq_info(_,_,_, Insts, _,_,_,_,_,_,_,_,_,_), Insts).
-mq_info_get_modes(mq_info(_,_,_,_, Modes, _,_,_,_,_,_,_,_,_), Modes).
-mq_info_get_classes(mq_info(_,_,_,_,_, Classes, _,_,_,_,_,_,_,_), Classes).
-mq_info_get_unused_interface_modules(mq_info(_,_,_,_,_,_, Modules, _,_,_,_,_,
+mq_info_get_modules(mq_info(_, Modules, _,_,_,_,_,_,_,_,_,_,_,_,_), Modules).
+mq_info_get_types(mq_info(_,_, Types, _,_,_,_,_,_,_,_,_,_,_,_), Types).
+mq_info_get_insts(mq_info(_,_,_, Insts, _,_,_,_,_,_,_,_,_,_,_), Insts).
+mq_info_get_modes(mq_info(_,_,_,_, Modes, _,_,_,_,_,_,_,_,_,_), Modes).
+mq_info_get_classes(mq_info(_,_,_,_,_, Classes, _,_,_,_,_,_,_,_,_), Classes).
+mq_info_get_htypes(mq_info(_,_,_,_,_,_, Htypes, _,_,_,_,_,_,_,_), Htypes).
+mq_info_get_unused_interface_modules(mq_info(_,_,_,_,_,_,_, Modules, _,_,_,_,_,
_,_), Modules).
-mq_info_get_import_status(mq_info(_,_,_,_,_,_,_, Status, _,_,_,_,_,_), Status).
-mq_info_get_num_errors(mq_info(_,_,_,_,_,_,_,_, NumErrors, _,_,_,_,_),
+mq_info_get_import_status(mq_info(_,_,_,_,_,_,_,_, Status, _,_,_,_,_,_),
+ Status).
+mq_info_get_num_errors(mq_info(_,_,_,_,_,_,_,_,_, NumErrors, _,_,_,_,_),
NumErrors).
-mq_info_get_type_error_flag(mq_info(_,_,_,_,_,_,_,_,_, TypeErrs, _,_,_,_),
+mq_info_get_type_error_flag(mq_info(_,_,_,_,_,_,_,_,_,_, TypeErrs, _,_,_,_),
TypeErrs).
-mq_info_get_mode_error_flag(mq_info(_,_,_,_,_,_,_,_,_,_, ModeError, _,_,_),
+mq_info_get_mode_error_flag(mq_info(_,_,_,_,_,_,_,_,_,_,_, ModeError, _,_,_),
ModeError).
-mq_info_get_report_error_flag(mq_info(_,_,_,_,_,_,_,_,_,_,_, Report, _,_),
+mq_info_get_report_error_flag(mq_info(_,_,_,_,_,_,_,_,_,_,_,_, Report, _,_),
Report).
-mq_info_get_error_context(mq_info(_,_,_,_,_,_,_,_,_,_,_,_, Context, _),
+mq_info_get_error_context(mq_info(_,_,_,_,_,_,_,_,_,_,_,_,_, Context, _),
Context).
-mq_info_get_need_qual_flag(mq_info(_,_,_,_,_,_,_,_,_,_,_,_,_, UseModule),
+mq_info_get_need_qual_flag(mq_info(_,_,_,_,_,_,_,_,_,_,_,_,_,_, UseModule),
UseModule).
:- pred mq_info_set_imported_modules(mq_info::in, set(module_name)::in,
@@ -1447,6 +1561,7 @@
:- pred mq_info_set_insts(mq_info::in, inst_id_set::in, mq_info::out) is det.
:- pred mq_info_set_modes(mq_info::in, mode_id_set::in, mq_info::out) is det.
:- pred mq_info_set_classes(mq_info::in, class_id_set::in, mq_info::out) is det.
+:- pred mq_info_set_htypes(mq_info::in, hidden_id_set::in, mq_info::out) is det.
:- pred mq_info_set_unused_interface_modules(mq_info::in, set(module_name)::in,
mq_info::out) is det.
:- pred mq_info_set_import_status(mq_info::in, import_status::in,
@@ -1456,37 +1571,39 @@
:- pred mq_info_set_error_context(mq_info::in, error_context::in,
mq_info::out) is det.
-mq_info_set_imported_modules(mq_info(_, B,C,D,E,F,G,H,I,J,K,L,M,N),
+mq_info_set_imported_modules(mq_info(_, B,C,D,E,F,G,H,I,J,K,L,M,N,O),
ImportedModules,
- mq_info(ImportedModules, B,C,D,E,F,G,H,I,J,K,L,M,N)).
-mq_info_set_modules(mq_info(A, _, C,D,E,F,G,H,I,J,K,L,M,N), Modules,
- mq_info(A, Modules, C,D,E,F,G,H,I,J,K,L,M,N)).
-mq_info_set_types(mq_info(A,B, _, D,E,F,G,H,I,J,K,L,M,N), Types,
- mq_info(A,B, Types, D,E,F,G,H,I,J,K,L,M,N)).
-mq_info_set_insts(mq_info(A,B,C, _, E,F,G,H,I,J,K,L,M,N), Insts,
- mq_info(A,B,C, Insts, E,F,G,H,I,J,K,L,M,N)).
-mq_info_set_modes(mq_info(A,B,C,D, _, F,G,H,I,J,K,L,M,N), Modes,
- mq_info(A,B,C,D, Modes, F,G,H,I,J,K,L,M,N)).
-mq_info_set_classes(mq_info(A,B,C,D,E, _, G,H,I,J,K,L,M,N), Classes,
- mq_info(A,B,C,D,E, Classes, G,H,I,J,K,L,M,N)).
-mq_info_set_unused_interface_modules(mq_info(A,B,C,D,E,F, _, H,I,J,K,L,M,N),
+ mq_info(ImportedModules, B,C,D,E,F,G,H,I,J,K,L,M,N,O)).
+mq_info_set_modules(mq_info(A, _, C,D,E,F,G,H,I,J,K,L,M,N,O), Modules,
+ mq_info(A, Modules, C,D,E,F,G,H,I,J,K,L,M,N,O)).
+mq_info_set_types(mq_info(A,B, _, D,E,F,G,H,I,J,K,L,M,N,O), Types,
+ mq_info(A,B, Types, D,E,F,G,H,I,J,K,L,M,N,O)).
+mq_info_set_insts(mq_info(A,B,C, _, E,F,G,H,I,J,K,L,M,N,O), Insts,
+ mq_info(A,B,C, Insts, E,F,G,H,I,J,K,L,M,N,O)).
+mq_info_set_modes(mq_info(A,B,C,D, _, F,G,H,I,J,K,L,M,N,O), Modes,
+ mq_info(A,B,C,D, Modes, F,G,H,I,J,K,L,M,N,O)).
+mq_info_set_classes(mq_info(A,B,C,D,E, _, G,H,I,J,K,L,M,N,O), Classes,
+ mq_info(A,B,C,D,E, Classes, G,H,I,J,K,L,M,N,O)).
+mq_info_set_htypes(mq_info(A,B,C,D,E,F,_,H,I,J,K,L,M,N,O), Htypes,
+ mq_info(A,B,C,D,E,F, Htypes, H,I,J,K,L,M,N,O)).
+mq_info_set_unused_interface_modules(mq_info(A,B,C,D,E,F,G, _, I,J,K,L,M,N,O),
Modules,
- mq_info(A,B,C,D,E,F, Modules, H,I,J,K,L,M,N)).
-mq_info_set_import_status(mq_info(A,B,C,D,E,F,G, _, I,J,K,L,M,N), Status,
- mq_info(A,B,C,D,E,F,G, Status, I,J,K,L,M,N)).
-mq_info_set_type_error_flag(mq_info(A,B,C,D,E,F,G,H,I, _, K,L,M,N),
- mq_info(A,B,C,D,E,F,G,H,I, yes, K,L,M,N)).
-mq_info_set_mode_error_flag(mq_info(A,B,C,D,E,F,G,H,I,J, _, L,M,N),
- mq_info(A,B,C,D,E,F,G,H,I,J, yes, L,M,N)).
-mq_info_set_error_context(mq_info(A,B,C,D,E,F,G,H,I,J,K,L, _, N), Context,
- mq_info(A,B,C,D,E,F,G,H,I,J,K,L, Context, N)).
-mq_info_set_need_qual_flag(mq_info(A,B,C,D,E,F,G,H,I,J,K,L,M, _), Flag,
- mq_info(A,B,C,D,E,F,G,H,I,J,K,L,M, Flag)).
+ mq_info(A,B,C,D,E,F,G, Modules, I,J,K,L,M,N,O)).
+mq_info_set_import_status(mq_info(A,B,C,D,E,F,G,H, _, J,K,L,M,N,O), Status,
+ mq_info(A,B,C,D,E,F,G,H, Status, J,K,L,M,N,O)).
+mq_info_set_type_error_flag(mq_info(A,B,C,D,E,F,G,H,I,J, _, L,M,N,O),
+ mq_info(A,B,C,D,E,F,G,H,I,J, yes, L,M,N,O)).
+mq_info_set_mode_error_flag(mq_info(A,B,C,D,E,F,G,H,I,J,K, _, M,N,O),
+ mq_info(A,B,C,D,E,F,G,H,I,J,K, yes, M,N,O)).
+mq_info_set_error_context(mq_info(A,B,C,D,E,F,G,H,I,J,K,L,M, _, O), Context,
+ mq_info(A,B,C,D,E,F,G,H,I,J,K,L,M, Context, O)).
+mq_info_set_need_qual_flag(mq_info(A,B,C,D,E,F,G,H,I,J,K,L,M,N, _), Flag,
+ mq_info(A,B,C,D,E,F,G,H,I,J,K,L,M,N, Flag)).
:- pred mq_info_incr_errors(mq_info::in, mq_info::out) is det.
-mq_info_incr_errors(mq_info(A,B,C,D,E,F,G,H, NumErrors0, J,K,L,M,N),
- mq_info(A,B,C,D,E,F,G,H, NumErrors, J,K,L,M,N)) :-
+mq_info_incr_errors(mq_info(A,B,C,D,E,F,G,H,I, NumErrors0, K,L,M,N,O),
+ mq_info(A,B,C,D,E,F,G,H,I, NumErrors, K,L,M,N,O)) :-
NumErrors is NumErrors0 + 1.
:- pred mq_info_set_error_flag(mq_info::in, id_type::in, mq_info::out) is det.
@@ -1499,6 +1616,8 @@
mq_info_set_mode_error_flag(Info0, Info).
mq_info_set_error_flag(Info0, class_id, Info) :-
mq_info_set_type_error_flag(Info0, Info).
+mq_info_set_error_flag(Info0, hidden_id, Info) :-
+ mq_info_set_type_error_flag(Info0, Info).
% If the current item is in the interface, remove its module
% name from the list of modules not used in the interface
@@ -1556,6 +1675,7 @@
:- type mode_id_set == id_set.
:- type inst_id_set == id_set.
:- type class_id_set == id_set.
+:- type hidden_id_set == id_set.
% Modules don't have an arity, but for simplicity we use the same
% data structure here, assigning arity zero to all module names.
:- type module_id_set == id_set.
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.115
diff -u -r1.115 modules.m
--- compiler/modules.m 2000/01/11 07:53:40 1.115
+++ compiler/modules.m 2000/01/12 05:00:14
@@ -824,7 +824,7 @@
check_for_clauses_in_interface([ItemAndContext0 | Items0], Items) -->
{ ItemAndContext0 = Item0 - Context },
(
- ( { Item0 = pred_clause(_,_,_,_) }
+ ( { Item0 = pred_clause(_,_,_,_,_) }
; { Item0 = func_clause(_,_,_,_,_) }
)
->
@@ -871,7 +871,7 @@
->
split_clauses_and_decls(Items0, ClauseItems, InterfaceItems)
;
- ( Item0 = pred_clause(_,_,_,_)
+ ( Item0 = pred_clause(_,_,_,_,_)
; Item0 = func_clause(_,_,_,_,_)
; Item0 = pragma(Pragma),
pragma_allowed_in_interface(Pragma, no)
@@ -4124,7 +4124,7 @@
Items1 = Items0,
Imports1 = [ItemAndContext | Imports0],
NeedsImports1 = NeedsImports0
- ; make_abstract_type_defn(Item0, Item1) ->
+ ; make_abstract_defns(Item0, Item1) ->
Imports1 = Imports0,
Items1 = [Item1 - Context | Items0],
NeedsImports1 = NeedsImports0
@@ -4148,13 +4148,15 @@
include_in_short_interface(mode_defn(_, _, _)).
include_in_short_interface(module_defn(_, _)).
include_in_short_interface(typeclass(_, _, _, _, _)).
+include_in_short_interface(htype_defn(_,_,_)).
+include_in_short_interface(hmode_defn(_,_,_)).
-:- pred make_abstract_type_defn(item, item).
-:- mode make_abstract_type_defn(in, out) is semidet.
+:- pred make_abstract_defns(item, item).
+:- mode make_abstract_defns(in, out) is semidet.
-make_abstract_type_defn(type_defn(VarSet, du_type(Name, Args, _, _), Cond),
+make_abstract_defns(type_defn(VarSet, du_type(Name, Args, _, _), Cond),
type_defn(VarSet, abstract_type(Name, Args), Cond)).
-make_abstract_type_defn(type_defn(VarSet, abstract_type(Name, Args), Cond),
+make_abstract_defns(type_defn(VarSet, abstract_type(Name, Args), Cond),
type_defn(VarSet, abstract_type(Name, Args), Cond)).
% All instance declarations must be written
Index: library/assoc_list.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/assoc_list.m,v
retrieving revision 1.10
diff -u -r1.10 assoc_list.m
--- library/assoc_list.m 1999/10/30 04:15:57 1.10
+++ library/assoc_list.m 1999/12/10 04:05:32
@@ -61,6 +61,12 @@
assoc_list(K, V)).
:- mode assoc_list__remove(in, in, out, out) is semidet.
+ % assoc_list__remove_all(AssocList0, Elem, AssocList) is true iff
+ % List is List0 with all occurences of Elem removed.
+
+:- pred assoc_list__remove_all(assoc_list(K, V), K, assoc_list(K, V)).
+:- mode assoc_list__remove_all(in, in, out) is det.
+
%-----------------------------------------------------------------------------%
:- implementation.
@@ -126,6 +132,16 @@
assoc_list__remove(KVs, Key, Value, Rest1),
Rest = [K - V | Rest1]
).
+
+assoc_list__remove_all([], _, []).
+assoc_list__remove_all([K - V | KVs], Key, Rest) :-
+ ( K = Key ->
+ assoc_list__remove_all(KVs, Key, Rest)
+ ;
+ assoc_list__remove_all(KVs, Key, Rest1),
+ Rest = [K - V | Rest1]
+ ).
+
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
Index: library/ops.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/ops.m,v
retrieving revision 1.29
diff -u -r1.29 ops.m
--- library/ops.m 2000/01/25 04:10:07 1.29
+++ library/ops.m 2000/01/28 01:27:24
@@ -130,6 +130,9 @@
ops__op_table("&", after, xfy, 1025). % Mercury extension
ops__op_table("-", after, yfx, 500). % standard ISO Prolog
ops__op_table("-", before, fx, 200). % standard ISO Prolog
+ops__op_table("-->>", after, xfx, 1200). % EDCG clause functor
+ops__op_table("$", before, fy, 150). % EDCG operator
+ops__op_table("$=", before, fy, 150). % EDCG operator
ops__op_table("--->", after, xfy, 1179). % Mercury extension
ops__op_table("-->", after, xfx, 1200). % standard ISO Prolog
ops__op_table("->", after, xfy, 1050). % standard ISO Prolog
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list