[m-rev.] diff: remove dependency on type_info arg

Mark Brown mark at cs.mu.OZ.AU
Fri Sep 2 23:57:00 AEST 2005


Hi,

With this change it is now possible to replace the arguments of type_info/1
with `void' and still pass bootcheck.  Zoltan, you can now proceed with
the change to remove the arguments of type_info/1 and typclass_info/1.

Cheers,
Mark.

Estimated hours taken: 3
Branches: main

Remove dependencies on the argument of type_info/1.

compiler/equiv_type_hlds.m:
	Look up the rtti_varmaps data instead of using the type_info
	argument.

compiler/simplify.m:
	Ensure that updates to the rtti_varmaps performed by the call to
	polymorphism.m are reflected in the proc_info and the simplify_info.

Index: compiler/equiv_type_hlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/equiv_type_hlds.m,v
retrieving revision 1.17
diff -u -r1.17 equiv_type_hlds.m
--- compiler/equiv_type_hlds.m	30 Aug 2005 04:11:50 -0000	1.17
+++ compiler/equiv_type_hlds.m	2 Sep 2005 13:44:19 -0000
@@ -36,6 +36,7 @@
 :- import_module hlds__quantification.
 :- import_module mdbcomp__prim_data.
 :- import_module parse_tree__equiv_type.
+:- import_module parse_tree__error_util.
 :- import_module parse_tree__prog_data.
 :- import_module parse_tree__prog_type.
 :- import_module recompilation.
@@ -735,6 +736,7 @@
         Changed, !Info) :-
     module_info_types(!.Info ^ module_info, Types),
     proc_info_vartypes(!.Info ^ proc_info, VarTypes),
+    proc_info_rtti_varmaps(!.Info ^ proc_info, RttiVarMaps),
     map__lookup(VarTypes, Var, VarType),
     classify_type(!.Info ^ module_info, VarType) = TypeCat,
     (
@@ -749,16 +751,20 @@
         TypeCat = type_info_type,
         map__search(Types, TypeCtor, TypeDefn),
         hlds_data__get_type_defn_body(TypeDefn, Body),
-        Body = eqv_type(_),
-        type_to_ctor_and_args(VarType, _TypeInfoCtor,
-            [TypeInfoArgType])
+        Body = eqv_type(_)
     ->
         Changed = yes,
         pred_info_set_typevarset(!.Info ^ tvarset, !.Info ^ pred_info,
             PredInfo0),
         create_poly_info(!.Info ^ module_info, PredInfo0, !.Info ^ proc_info,
             PolyInfo0),
-        polymorphism__make_type_info_var(TypeInfoArgType,
+        rtti_varmaps_var_info(RttiVarMaps, Var, VarInfo),
+        ( VarInfo = type_info_var(TypeInfoType0) ->
+            TypeInfoType = TypeInfoType0
+        ;
+            unexpected(this_file, "replace_in_goal_expr: info not found")
+        ),
+        polymorphism__make_type_info_var(TypeInfoType,
             term__context_init, TypeInfoVar, Goals0, PolyInfo0, PolyInfo),
         poly_info_extract(PolyInfo, PredInfo0, PredInfo,
             !.Info ^ proc_info, ProcInfo, ModuleInfo),
@@ -914,4 +920,11 @@
     ).
 
 %-----------------------------------------------------------------------------%
+
+:- func this_file = string.
+
+this_file = "equiv_type_hlds.m".
+
+%-----------------------------------------------------------------------------%
+:- end_module transform_hlds__equiv_type_hlds.
 %-----------------------------------------------------------------------------%
Index: compiler/simplify.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/simplify.m,v
retrieving revision 1.151
diff -u -r1.151 simplify.m
--- compiler/simplify.m	30 Aug 2005 04:11:59 -0000	1.151
+++ compiler/simplify.m	2 Sep 2005 13:30:12 -0000
@@ -1496,35 +1496,48 @@
     simplify_info_get_det_info(!.Info, DetInfo0),
     simplify_info_get_varset(!.Info, VarSet0),
     simplify_info_get_var_types(!.Info, VarTypes0),
+    simplify_info_get_rtti_varmaps(!.Info, RttiVarMaps0),
     det_info_get_module_info(DetInfo0, ModuleInfo0),
     det_info_get_pred_id(DetInfo0, PredId),
     det_info_get_proc_id(DetInfo0, ProcId),
 
-    % Put the varset and vartypes from the simplify_info back in the proc_info.
-    module_info_pred_proc_info(ModuleInfo0, PredId, ProcId,
-        PredInfo0, ProcInfo0),
-    proc_info_set_vartypes(VarTypes0, ProcInfo0, ProcInfo1),
-    proc_info_set_varset(VarSet0, ProcInfo1, ProcInfo2),
-
-    % Call polymorphism.m to create the type_infos.
-    create_poly_info(ModuleInfo0, PredInfo0, ProcInfo2, PolyInfo0),
-    term__context_init(Context),
-    polymorphism__make_type_info_vars(Types, Context,
-        TypeInfoVars, TypeInfoGoals, PolyInfo0, PolyInfo),
-    poly_info_extract(PolyInfo, PredInfo0, PredInfo,
-        ProcInfo0, ProcInfo, ModuleInfo1),
-
-    % Get the new varset and vartypes from the proc_info
-    % and put them back in the simplify_info.
-    proc_info_vartypes(ProcInfo, VarTypes),
-    proc_info_varset(ProcInfo, VarSet),
-    simplify_info_set_var_types(VarTypes, !Info),
-    simplify_info_set_varset(VarSet, !Info),
-
-    % Put the new proc_info and pred_info back in the module_info
-    % and put the new module_info back in the simplify_info.
-    module_info_set_pred_proc_info(PredId, ProcId, PredInfo, ProcInfo,
-        ModuleInfo1, ModuleInfo),
+    some [!PredInfo, !ProcInfo, !PolyInfo] (
+        % The varset, vartypes and rtti_varmaps get updated by the call to
+        % polymorphism.m, below.  That module will work on the poly_info,
+        % however, which is derived from the information in the proc_info.
+        % Therefore we:
+        %   - copy the info from the simplify_info to the proc_info,
+        %   - create a poly_info from the proc_info,
+        %   - do the polymorphism transformation,
+        %   - extract info from the poly_info and put it in the proc_info,
+        %   - copy the information from the proc_info back into the
+        %     simplify_info.
+ 
+        module_info_pred_proc_info(ModuleInfo0, PredId, ProcId,
+            !:PredInfo, !:ProcInfo),
+        proc_info_set_vartypes(VarTypes0, !ProcInfo),
+        proc_info_set_varset(VarSet0, !ProcInfo),
+        proc_info_set_rtti_varmaps(RttiVarMaps0, !ProcInfo),
+
+        % Call polymorphism.m to create the type_infos.
+        create_poly_info(ModuleInfo0, !.PredInfo, !.ProcInfo, !:PolyInfo),
+        term__context_init(Context),
+        polymorphism__make_type_info_vars(Types, Context,
+            TypeInfoVars, TypeInfoGoals, !PolyInfo),
+        poly_info_extract(!.PolyInfo, !PredInfo, !ProcInfo, ModuleInfo1),
+
+        proc_info_vartypes(!.ProcInfo, VarTypes),
+        proc_info_varset(!.ProcInfo, VarSet),
+        proc_info_rtti_varmaps(!.ProcInfo, RttiVarMaps),
+        simplify_info_set_var_types(VarTypes, !Info),
+        simplify_info_set_varset(VarSet, !Info),
+        simplify_info_set_rtti_varmaps(RttiVarMaps, !Info),
+
+        % Put the new proc_info and pred_info back in the module_info
+        % and put the new module_info back in the simplify_info.
+        module_info_set_pred_proc_info(PredId, ProcId, !.PredInfo, !.ProcInfo,
+            ModuleInfo1, ModuleInfo)
+    ),
     simplify_info_set_module_info(ModuleInfo, !Info).
 
 :- pred simplify__type_info_locn(tvar::in, prog_var::out, list(hlds_goal)::out,
--------------------------------------------------------------------------
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