[m-rev.] For review: expand equivalence types and insts in mutable declarations
Ralph Becket
rafe at cs.mu.OZ.AU
Fri Nov 11 15:50:38 AEDT 2005
Estimated hours taken: 4
Branches: main
Ensure that equivalence types and insts in mutable items are properly
expanded.
compiler/equiv_type.m
Make replace_in_item handle mutable/5 items.
compiler/make_hlds_passes.m
Delete an out-of-date comment.
compiler/modules.m
Fix a comment typo.
compiler/recompilation.m
compiler/recompilation.usage.m
Add a new item_type for mutables (the equiv_type.m transformation
needs to track the items where expansions occurr).
Index: compiler/equiv_type.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/equiv_type.m,v
retrieving revision 1.53
diff -u -r1.53 equiv_type.m
--- compiler/equiv_type.m 4 Nov 2005 03:40:43 -0000 1.53
+++ compiler/equiv_type.m 11 Nov 2005 01:27:07 -0000
@@ -415,6 +415,21 @@
ExpandedItems = yes(_ - ItemIds)
).
+replace_in_item(ModuleName,
+ mutable(MutName, Type0, InitValue, Inst0, Attrs),
+ _Context, EqvMap, EqvInstMap,
+ mutable(MutName, Type, InitValue, Inst, Attrs),
+ [], !Info) :-
+ QualName = qualified(ModuleName, MutName),
+ maybe_record_expanded_items(ModuleName, QualName, !.Info, ExpandedItems0),
+ TVarSet0 = varset__init,
+ replace_in_type(EqvMap, Type0, Type, _TypeChanged, TVarSet0, _TVarSet,
+ ExpandedItems0, ExpandedItems1),
+ replace_in_inst(Inst0, EqvInstMap, Inst,
+ ExpandedItems1, ExpandedItems),
+ finish_recording_expanded_items(
+ item_id(mutable_item, QualName - 0), ExpandedItems, !Info).
+
:- pred replace_in_type_defn(eqv_map::in, type_ctor::in,
type_defn::in, type_defn::out, bool::out, tvarset::in, tvarset::out,
equiv_type_info::in, equiv_type_info::out) is semidet.
Index: compiler/make_hlds_passes.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make_hlds_passes.m,v
retrieving revision 1.21
diff -u -r1.21 make_hlds_passes.m
--- compiler/make_hlds_passes.m 8 Nov 2005 03:58:52 -0000 1.21
+++ compiler/make_hlds_passes.m 11 Nov 2005 01:47:56 -0000
@@ -284,7 +284,6 @@
% pass 3:
% Add the clauses one by one to the module.
- % (I supposed this could conceivably be folded into pass 2?)
%
% Check that the declarations for field extraction
% and update functions are sensible.
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.356
diff -u -r1.356 modules.m
--- compiler/modules.m 8 Nov 2005 03:58:53 -0000 1.356
+++ compiler/modules.m 11 Nov 2005 01:26:12 -0000
@@ -1317,7 +1317,7 @@
)
).
- % Expand any mutable declarations in the item list into the type and mode
+ % Expand any mutable declarations in the item list into the pred and mode
% declarations for their access predicates. Only these components of a
% mutable declaration should be written to a private interface file.
%
Index: compiler/recompilation.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/recompilation.m,v
retrieving revision 1.16
diff -u -r1.16 recompilation.m
--- compiler/recompilation.m 28 Oct 2005 02:10:32 -0000 1.16
+++ compiler/recompilation.m 11 Nov 2005 01:00:14 -0000
@@ -77,7 +77,8 @@
; typeclass_item
; functor_item % The RHS of a var-functor unification.
; predicate_item
- ; function_item.
+ ; function_item
+ ; mutable_item.
:- inst simple_item
---> type_item
@@ -158,7 +159,8 @@
typeclasses :: Map,
functors :: Cons,
predicates :: Set,
- functions :: Set
+ functions :: Set,
+ mutables :: Set
).
:- type item_id_set(T) == item_id_set(T, T, T).
@@ -294,17 +296,19 @@
string_to_item_type("predicate", predicate_item).
string_to_item_type("function", function_item).
string_to_item_type("functor", functor_item).
+string_to_item_type("mutable", mutable_item).
%-----------------------------------------------------------------------------%
init_item_id_set(Init) =
- item_id_set(Init, Init, Init, Init, Init, Init, Init, Init).
+ item_id_set(Init, Init, Init, Init, Init, Init, Init, Init, Init).
init_item_id_set(Simple, PorF, Cons) =
- item_id_set(Simple, Simple, Simple, Simple, Simple, Cons, PorF, PorF).
+ item_id_set(Simple, Simple, Simple, Simple, Simple, Cons, PorF, PorF,
+ PorF).
init_used_items = item_id_set(map__init, map__init, map__init, map__init,
- map__init, map__init, map__init, map__init).
+ map__init, map__init, map__init, map__init, map__init).
extract_simple_item_set(Items, type_item) = Items ^ types.
extract_simple_item_set(Items, type_body_item) = Items ^ type_bodies.
@@ -336,6 +340,7 @@
extract_ids(Items, functor_item) = Items ^ functors.
extract_ids(Items, predicate_item) = Items ^ predicates.
extract_ids(Items, function_item) = Items ^ functions.
+extract_ids(Items, mutable_item) = Items ^ mutables.
update_ids(Items, type_item, IdMap) = Items ^ types := IdMap.
update_ids(Items, type_body_item, IdMap) = Items ^ type_bodies := IdMap.
@@ -345,6 +350,7 @@
update_ids(Items, predicate_item, IdMap) = Items ^ predicates := IdMap.
update_ids(Items, function_item, IdMap) = Items ^ functions := IdMap.
update_ids(Items, functor_item, IdMap) = Items ^ functors := IdMap.
+update_ids(Items, mutable_item, IdMap) = Items ^ mutables := IdMap.
map_ids(Func, Items0, Init) = Items :-
Items1 = init_item_id_set(Init),
Index: compiler/recompilation.usage.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/recompilation.usage.m,v
retrieving revision 1.23
diff -u -r1.23 recompilation.usage.m
--- compiler/recompilation.usage.m 28 Oct 2005 02:10:32 -0000 1.23
+++ compiler/recompilation.usage.m 11 Nov 2005 01:45:01 -0000
@@ -542,12 +542,14 @@
set__init(UsedClasses0),
UsedItems = item_id_set(Types, TypeBodies, Modes, Insts, Classes,
- _, _, _),
+ _, _, _, _),
map__init(ResolvedCtors),
map__init(ResolvedPreds),
map__init(ResolvedFuncs),
+ map__init(ResolvedMutables),
ResolvedUsedItems0 = item_id_set(Types, TypeBodies, Modes, Insts,
- Classes, ResolvedCtors, ResolvedPreds, ResolvedFuncs),
+ Classes, ResolvedCtors, ResolvedPreds, ResolvedFuncs,
+ ResolvedMutables),
Info0 = recompilation_usage_info(ModuleInfo, ItemsToProcess0,
ImportedItems1, ModuleUsedClasses, Dependencies,
@@ -949,13 +951,16 @@
;
true
).
-
find_items_used_by_item(predicate_item, ItemId, !Info) :-
record_used_pred_or_func(predicate, ItemId, !Info).
find_items_used_by_item(function_item, ItemId, !Info) :-
record_used_pred_or_func(function, ItemId, !Info).
find_items_used_by_item(functor_item, _, !Info) :-
error("find_items_used_by_item: functor").
+find_items_used_by_item(mutable_item, _MutableItemId, !Info).
+ %
+ % Mutables are expanded into other item types which track the
+ % types, insts, preds, and funcs used.
:- pred find_items_used_by_instances(class_id::in,
list(hlds_instance_defn)::in,
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list