[m-rev.] diff: add a prefix to type_info_locn/0 constructors

Julien Fischer juliensf at csse.unimelb.edu.au
Thu Apr 12 19:43:21 AEST 2007


Estimated hours taken: 0.1
Branches: main

compiler/hlds_rtti.m:
 	Add a distinguishing prefix to the constructors of the
 	type_info_locn/0 type.  `type_info' and `typeclass_info'
 	are used so much in the compiler that searching these
 	constructors is difficult.

compiler/clause_to_proc.m:
compiler/continuation_info.m:
compiler/higher_order.m:
compiler/hlds_out.m:
compiler/polymorphism.m:
compiler/simplify.m:
compiler/size_prof.m:
 	Conform to the above change.

Julien.

Index: compiler/clause_to_proc.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/clause_to_proc.m,v
retrieving revision 1.77
diff -u -r1.77 clause_to_proc.m
--- compiler/clause_to_proc.m	19 Jan 2007 07:04:08 -0000	1.77
+++ compiler/clause_to_proc.m	12 Apr 2007 09:38:12 -0000
@@ -551,7 +551,7 @@
          ArgType = type_variable(TVar, _),
          \+ rtti_search_type_info_locn(!.RttiVarMaps, TVar, _)
      ->
-        Locn = typeclass_info(Var, Num),
+        Locn = ti_locn_typeclass_info(Var, Num),
          rtti_det_insert_type_info_locn(TVar, Locn, !RttiVarMaps)
      ;
          true
Index: compiler/continuation_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/continuation_info.m,v
retrieving revision 1.88
diff -u -r1.88 continuation_info.m
--- compiler/continuation_info.m	6 Jan 2007 10:56:11 -0000	1.88
+++ compiler/continuation_info.m	12 Apr 2007 09:38:12 -0000
@@ -797,10 +797,10 @@
              ConvertLval = (pred(Locn::out) is nondet :-
                  set.member(Lval, TypeInfoLvalSet),
                  (
-                    TypeInfoLocn = typeclass_info(_, FieldNum),
+                    TypeInfoLocn = ti_locn_typeclass_info(_, FieldNum),
                      Locn = locn_indirect(Lval, FieldNum)
                  ;
-                    TypeInfoLocn = type_info(_),
+                    TypeInfoLocn = ti_locn_type_info(_),
                      Locn = locn_direct(Lval)
                  )
              ),
@@ -857,11 +857,11 @@
      FindLocn = (pred(TypeInfoLocn::in, Locn::out) is det :-
          (
              (
-                TypeInfoLocn = typeclass_info(TypeInfoVar, FieldNum),
+                TypeInfoLocn = ti_locn_typeclass_info(TypeInfoVar, FieldNum),
                  assoc_list.search(NumberedVars, TypeInfoVar, Slot),
                  LocnPrime = table_locn_indirect(Slot, FieldNum)
              ;
-                TypeInfoLocn = type_info(TypeInfoVar),
+                TypeInfoLocn = ti_locn_type_info(TypeInfoVar),
                  assoc_list.search(NumberedVars, TypeInfoVar, Slot),
                  LocnPrime = table_locn_direct(Slot)
              )
Index: compiler/higher_order.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/higher_order.m,v
retrieving revision 1.166
diff -u -r1.166 higher_order.m
--- compiler/higher_order.m	19 Jan 2007 07:04:13 -0000	1.166
+++ compiler/higher_order.m	12 Apr 2007 09:38:12 -0000
@@ -2886,7 +2886,7 @@
          ExtraTypeInfoVars, ExtraTypeInfoTVarTypes,
          RttiVarMaps1, RttiVarMaps2),
      Pred = (pred(TVar::in, Var::in, !.R::in, !:R::out) is det :-
-            Locn = type_info(Var),
+            Locn = ti_locn_type_info(Var),
              rtti_set_type_info_locn(TVar, Locn, !R)
          ),
      list.foldl_corresponding(Pred, ExtraTypeInfoTVars, ExtraTypeInfoVars,
@@ -3156,7 +3156,7 @@
          VarInfo = type_info_var(TypeInfoType),
          rtti_det_insert_type_info_type(Var, TypeInfoType, !RttiVarMaps),
          ( TypeInfoType = type_variable(TVar, _) ->
-            maybe_set_typeinfo_locn(TVar, type_info(Var), !RttiVarMaps)
+            maybe_set_typeinfo_locn(TVar, ti_locn_type_info(Var), !RttiVarMaps)
          ;
              true
          )
@@ -3180,7 +3180,7 @@
  update_type_info_locn(Var, ConstraintType, Index, Index + 1, !RttiVarMaps) :-
      ( ConstraintType = type_variable(ConstraintTVar, _) ->
          maybe_set_typeinfo_locn(ConstraintTVar,
-            typeclass_info(Var, Index), !RttiVarMaps)
+            ti_locn_typeclass_info(Var, Index), !RttiVarMaps)
      ;
          true
      ).
Index: compiler/hlds_out.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_out.m,v
retrieving revision 1.425
diff -u -r1.425 hlds_out.m
--- compiler/hlds_out.m	19 Jan 2007 07:04:14 -0000	1.425
+++ compiler/hlds_out.m	12 Apr 2007 09:38:12 -0000
@@ -3014,12 +3014,12 @@
      io.write_string(" -> ", !IO),
      rtti_lookup_type_info_locn(RttiVarMaps, TVar, Locn),
      (
-        Locn = type_info(Var),
+        Locn = ti_locn_type_info(Var),
          io.write_string("type_info(", !IO),
          mercury_output_var(VarSet, AppendVarNums, Var, !IO),
          io.write_string(") ", !IO)
      ;
-        Locn = typeclass_info(Var, Index),
+        Locn = ti_locn_typeclass_info(Var, Index),
          io.write_string("typeclass_info(", !IO),
          mercury_output_var(VarSet, AppendVarNums, Var, !IO),
          io.write_string(", ", !IO),
Index: compiler/hlds_rtti.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_rtti.m,v
retrieving revision 1.11
diff -u -r1.11 hlds_rtti.m
--- compiler/hlds_rtti.m	1 Dec 2006 15:04:00 -0000	1.11
+++ compiler/hlds_rtti.m	12 Apr 2007 09:38:12 -0000
@@ -107,11 +107,11 @@
      %  A type_info_locn specifies how to access a type_info.
      %
  :- type type_info_locn
-    --->    type_info(prog_var)
+    --->    ti_locn_type_info(prog_var)
                  % It is a normal type_info, i.e. the type
                  % is not constrained.

-    ;       typeclass_info(prog_var, int).
+    ;       ti_locn_typeclass_info(prog_var, int).
                  % The type_info is packed inside a
                  % typeclass_info. If the int is N, it is
                  % the Nth type_info inside the typeclass_info,
@@ -320,11 +320,12 @@

  %-----------------------------------------------------------------------------%

-type_info_locn_var(type_info(Var), Var).
-type_info_locn_var(typeclass_info(Var, _), Var).
+type_info_locn_var(ti_locn_type_info(Var), Var).
+type_info_locn_var(ti_locn_typeclass_info(Var, _), Var).

-type_info_locn_set_var(Var, type_info(_), type_info(Var)).
-type_info_locn_set_var(Var, typeclass_info(_, Num), typeclass_info(Var, Num)).
+type_info_locn_set_var(Var, ti_locn_type_info(_), ti_locn_type_info(Var)).
+type_info_locn_set_var(Var, ti_locn_typeclass_info(_, Num),
+    ti_locn_typeclass_info(Var, Num)).

  :- type rtti_varmaps
      --->    rtti_varmaps(
@@ -412,7 +413,7 @@
  :- pred maybe_check_type_info_var(type_info_locn::in, tvar::in,
      rtti_varmaps::in, rtti_varmaps::out) is det.

-maybe_check_type_info_var(type_info(Var), TVar, !VarMaps) :-
+maybe_check_type_info_var(ti_locn_type_info(Var), TVar, !VarMaps) :-
      ( map.search(!.VarMaps ^ ti_type_map, Var, Type) ->
          ( Type = type_variable(TVar, _) ->
              true
@@ -422,7 +423,7 @@
      ;
          unexpected(this_file, "missing info in rtti_varmaps")
      ).
-maybe_check_type_info_var(typeclass_info(_, _), _, !VarMaps).
+maybe_check_type_info_var(ti_locn_typeclass_info(_, _), _, !VarMaps).

  rtti_det_insert_typeclass_info_var(Constraint, ProgVar, !VarMaps) :-
      Map0 = !.VarMaps ^ tci_constraint_map,
Index: compiler/polymorphism.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/polymorphism.m,v
retrieving revision 1.318
diff -u -r1.318 polymorphism.m
--- compiler/polymorphism.m	19 Jan 2007 07:04:26 -0000	1.318
+++ compiler/polymorphism.m	12 Apr 2007 09:38:12 -0000
@@ -780,7 +780,7 @@

      % Make a fresh variable for each class constraint, returning a list of
      % variables that appear in the constraints, along with the location of
-    % the type infos for them.  For the existential constraints, we want
+    % the type_infos for them.  For the existential constraints, we want
      % the rtti_varmaps to contain the internal view of the types (that is,
      % with type variables bound) so we may need to look up the actual
      % constraints in the constraint map.  For the universal constraints there
@@ -886,7 +886,7 @@
          poly_info_get_rtti_varmaps(!.Info, !:RttiVarMaps),

          ToLocn = (pred(TheVar::in, TheLocn::out) is det :-
-            TheLocn = type_info(TheVar)),
+            TheLocn = ti_locn_type_info(TheVar)),

          list.map(ToLocn, UnivHeadTypeInfoVars, UnivTypeLocns),
          list.foldl_corresponding(rtti_det_insert_type_info_locn,
@@ -2436,9 +2436,9 @@
      poly_info_get_rtti_varmaps(!.Info, RttiVarMaps),
      (
          rtti_search_type_info_locn(OldRttiVarMaps, TVar,
-            type_info(TypeInfoVar0)),
+            ti_locn_type_info(TypeInfoVar0)),
          rtti_search_type_info_locn(RttiVarMaps, TVar,
-            typeclass_info(TypeClassInfoVar, Index))
+            ti_locn_typeclass_info(TypeClassInfoVar, Index))
      ->
          polymorphism_extract_type_info(TVar, TypeClassInfoVar, Index, NewGoals,
              TypeInfoVar1, !Info),
@@ -2518,7 +2518,7 @@
          get_tvar_kind(!.Info ^ tvar_kinds, TypeVar, Kind),
          Type = type_variable(TypeVar, Kind),
          new_type_info_var(Type, type_info, Var, !Info),
-        TypeInfoLocn = type_info(Var),
+        TypeInfoLocn = ti_locn_type_info(Var),
          poly_info_get_rtti_varmaps(!.Info, RttiVarMaps0),
          rtti_det_insert_type_info_locn(TypeVar, TypeInfoLocn,
              RttiVarMaps0, RttiVarMaps),
@@ -2835,13 +2835,13 @@
  get_type_info(TypeInfoLocn, TypeVar, ExtraGoals, Var, !Info) :-
      (
          % If the typeinfo is available in a variable, just use it
-        TypeInfoLocn = type_info(TypeInfoVar),
+        TypeInfoLocn = ti_locn_type_info(TypeInfoVar),
          Var = TypeInfoVar,
          ExtraGoals = []
      ;
          % If the typeinfo is in a typeclass_info, then we need to extract it
          % before using it
-        TypeInfoLocn = typeclass_info(TypeClassInfoVar, Index),
+        TypeInfoLocn = ti_locn_typeclass_info(TypeClassInfoVar, Index),
          polymorphism_extract_type_info(TypeVar, TypeClassInfoVar, Index,
              ExtraGoals, Var, !Info)
      ).
@@ -2961,7 +2961,7 @@
          TypeAndIndex = Type - Index,
          Type = type_variable(TypeVar, _),
          ( rtti_search_type_info_locn(RttiVarMaps0, TypeVar, TypeInfoLocn) ->
-            TypeInfoLocn = type_info(_)
+            TypeInfoLocn = ti_locn_type_info(_)
          ;
              true
          ),
@@ -2975,7 +2975,7 @@
      MakeEntry =
          (pred(IndexedTypeVar::in, R0::in, R::out) is det :-
              IndexedTypeVar = TheTypeVar - Index,
-            Location = typeclass_info(ExtraHeadVar, Index),
+            Location = ti_locn_typeclass_info(ExtraHeadVar, Index),
              rtti_set_type_info_locn(TheTypeVar, Location, R0, R)
          ),
      list.foldl(MakeEntry, NewClassTypeVars, RttiVarMaps0, RttiVarMaps),
Index: compiler/simplify.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/simplify.m,v
retrieving revision 1.207
diff -u -r1.207 simplify.m
--- compiler/simplify.m	22 Feb 2007 03:50:36 -0000	1.207
+++ compiler/simplify.m	12 Apr 2007 09:38:12 -0000
@@ -2242,11 +2242,11 @@
      rtti_lookup_type_info_locn(RttiVarMaps, TypeVar, TypeInfoLocn),
      (
          % If the typeinfo is available in a variable, just use it.
-        TypeInfoLocn = type_info(TypeInfoVar),
+        TypeInfoLocn = ti_locn_type_info(TypeInfoVar),
          Goals = []
      ;
          % If the typeinfo is in a typeclass_info then we need to extract it.
-        TypeInfoLocn = typeclass_info(TypeClassInfoVar, Index),
+        TypeInfoLocn = ti_locn_typeclass_info(TypeClassInfoVar, Index),
          extract_type_info(TypeVar, Kind, TypeClassInfoVar, Index, Goals,
              TypeInfoVar, !Info)
      ).
Index: compiler/size_prof.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/size_prof.m,v
retrieving revision 1.52
diff -u -r1.52 size_prof.m
--- compiler/size_prof.m	19 Jan 2007 07:04:30 -0000	1.52
+++ compiler/size_prof.m	12 Apr 2007 09:38:12 -0000
@@ -863,10 +863,10 @@
      ; Type = type_variable(TVar, _) ->
          rtti_lookup_type_info_locn(!.Info ^ rtti_varmaps, TVar, TVarLocn),
          (
-            TVarLocn = type_info(TypeInfoVar),
+            TVarLocn = ti_locn_type_info(TypeInfoVar),
              TypeInfoGoals = []
          ;
-            TVarLocn = typeclass_info(TypeClassInfoVar, Slot),
+            TVarLocn = ti_locn_typeclass_info(TypeClassInfoVar, Slot),
              TargetTypeInfoMap = !.Info ^ target_type_info_map,
              VarSet0 = !.Info ^ varset,
              VarTypes0 = !.Info ^ vartypes,
@@ -1134,10 +1134,10 @@
      % we assume the kind is `star'.
      Type = type_variable(TVar, kind_star),
      (
-        TypeInfoLocn = type_info(TypeInfoVar),
+        TypeInfoLocn = ti_locn_type_info(TypeInfoVar),
          record_type_info_var(Type, TypeInfoVar, !Info)
      ;
-        TypeInfoLocn = typeclass_info(_TypeClassInfoVar, _Offset)
+        TypeInfoLocn = ti_locn_typeclass_info(_TypeClassInfoVar, _Offset)
          % We could record this information and then look for calls that
          % extract typeinfos from typeclass_infos, but code that does
          % that is rare enough that it is not worth optimizing.


--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list