[m-dev.] for review: naming TypeCtorInfos
Zoltan Somogyi
zs at cs.mu.OZ.AU
Mon Feb 25 16:01:13 AEDT 2002
For review by anyone.
compiler/polymorphism.m:
Give the Mercury variables containing type_ctor_infos a meaningful,
non-misleading name, i.e. name them TypeCtorInfo, not TypeInfo.
Delete some old, misleading comments.
Zoltan.
cvs diff: Diffing .
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/polymorphism.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/polymorphism.m,v
retrieving revision 1.218
diff -u -b -r1.218 polymorphism.m
--- compiler/polymorphism.m 2002/01/11 07:41:31 1.218
+++ compiler/polymorphism.m 2002/02/24 15:37:07
@@ -40,23 +40,10 @@
% TO THE TYPE SPECIALIZATION CODE IN "compiler/higher_order.m".
%
% Type information is represented using one or two cells. The cell which
-% is always present is the type_ctor_info structure, laid out like this:
+% is always present is the type_ctor_info structure, whose structure
+% is documented in runtime/mercury_type_info.h. The other cell is the
+% type_info structure, laid out like this:
%
-% word 0 <arity of type constructor>
-% e.g. 0 for `int', 1 for `list(T)', 2 for `map(K, V)'.
-% word 1 <=/2 predicate for type>
-% word 2 <index/2 predicate for type>
-% word 3 <compare/3 predicate for type>
-% word 4 <MR_TypeCtorRepresentation for type constructor>
-% word 5 <type_ctor_functors for type>
-% word 6 <type_ctor_layout for type>
-% word 7 <string name of type constructor>
-% e.g. "int" for `int', "list" for `list(T)',
-% "map" for `map(K,V)'
-% word 8 <string name of module>
-%
-% The other cell is the type_info structure, laid out like this:
-%
% word 0 <pointer to the type_ctor_info structure>
% word 1+ <the type_infos for the type params, at least one>
%
@@ -127,28 +114,12 @@
% We transform the body of p to this:
%
% p(TypeInfoT1, X) :-
-% TypeCtorInfoT2 = type_ctor_info(
-% 1,
-% '__Unify__'<list/1>,
-% '__Index__'<list/1>,
-% '__Compare__'<list/1>,
-% <type_ctor_layout for list/1>,
-% <type_ctor_functors for list/1>,
-% "list",
-% "list"),
+% TypeCtorInfoT2 = type_ctor_info(...),
% TypeInfoT2 = type_info(
% TypeCtorInfoT2,
% TypeInfoT1),
% q(TypeInfoT2, [X]),
-% TypeInfoT3 = type_ctor_info(
-% 0,
-% builtin_unify_int,
-% builtin_index_int,
-% builtin_compare_int,
-% <type_ctor_layout for int/0>,
-% <type_ctor_functors for int/0>,
-% "int",
-% "builtin"),
+% TypeInfoT3 = type_ctor_info(...),
% r(TypeInfoT3, 0).
%
% Note that type_ctor_infos are actually generated as references to a
@@ -2671,7 +2642,7 @@
% variable to be that type_info variable.
%
polymorphism__new_type_info_var(Type, "type_info",
- Var, Info0, Info1),
+ typeinfo_prefix, Var, Info0, Info1),
map__det_insert(TypeInfoMap0, TypeVar, type_info(Var),
TypeInfoMap),
poly_info_set_type_info_map(TypeInfoMap, Info1, Info),
@@ -2895,8 +2866,8 @@
TypeInfoTerm = functor(ConsId, ArgVars),
% introduce a new variable
- polymorphism__new_type_info_var(Type, Symbol, VarSet0, VarTypes0,
- TypeInfoVar, VarSet, VarTypes),
+ polymorphism__new_type_info_var_raw(Type, Symbol, typeinfo_prefix,
+ VarSet0, VarTypes0, TypeInfoVar, VarSet, VarTypes),
% create the construction unification to initialize the variable
UniMode = (free - ground(shared, none) ->
@@ -2954,8 +2925,9 @@
TypeInfoTerm = functor(ConsId, []),
% introduce a new variable
- polymorphism__new_type_info_var(Type, "type_ctor_info",
- VarSet0, VarTypes0, TypeCtorInfoVar, VarSet, VarTypes),
+ polymorphism__new_type_info_var_raw(Type, "type_ctor_info",
+ typectorinfo_prefix, VarSet0, VarTypes0,
+ TypeCtorInfoVar, VarSet, VarTypes),
% create the construction unification to initialize the variable
RLExprnId = no,
@@ -2985,7 +2957,8 @@
polymorphism__make_head_vars([], _, []) --> [].
polymorphism__make_head_vars([TypeVar|TypeVars], TypeVarSet, TypeInfoVars) -->
{ Type = term__variable(TypeVar) },
- polymorphism__new_type_info_var(Type, "type_info", Var),
+ polymorphism__new_type_info_var(Type, "type_info", typeinfo_prefix,
+ Var),
( { varset__search_name(TypeVarSet, TypeVar, TypeVarName) } ->
=(Info0),
{ poly_info_get_varset(Info0, VarSet0) },
@@ -2998,35 +2971,41 @@
{ TypeInfoVars = [Var | TypeInfoVars1] },
polymorphism__make_head_vars(TypeVars, TypeVarSet, TypeInfoVars1).
-
-:- pred polymorphism__new_type_info_var(type, string, prog_var,
+:- pred polymorphism__new_type_info_var(type, string, string, prog_var,
poly_info, poly_info).
-:- mode polymorphism__new_type_info_var(in, in, out, in, out) is det.
+:- mode polymorphism__new_type_info_var(in, in, in, out, in, out) is det.
-polymorphism__new_type_info_var(Type, Symbol, Var, Info0, Info) :-
+polymorphism__new_type_info_var(Type, Symbol, Prefix, Var, Info0, Info) :-
poly_info_get_varset(Info0, VarSet0),
poly_info_get_var_types(Info0, VarTypes0),
- polymorphism__new_type_info_var(Type, Symbol, VarSet0, VarTypes0,
- Var, VarSet, VarTypes),
+ polymorphism__new_type_info_var_raw(Type, Symbol, Prefix,
+ VarSet0, VarTypes0, Var, VarSet, VarTypes),
poly_info_set_varset_and_types(VarSet, VarTypes, Info0, Info).
-
-:- pred polymorphism__new_type_info_var(type, string, prog_varset,
- map(prog_var, type), prog_var, prog_varset,
- map(prog_var, type)).
-:- mode polymorphism__new_type_info_var(in, in, in, in, out, out, out) is det.
+:- pred polymorphism__new_type_info_var_raw(type, string, string, prog_varset,
+ map(prog_var, type), prog_var, prog_varset, map(prog_var, type)).
+:- mode polymorphism__new_type_info_var_raw(in, in, in, in, in, out, out, out)
+ is det.
-polymorphism__new_type_info_var(Type, Symbol, VarSet0, VarTypes0,
+polymorphism__new_type_info_var_raw(Type, Symbol, Prefix, VarSet0, VarTypes0,
Var, VarSet, VarTypes) :-
% introduce new variable
varset__new_var(VarSet0, Var, VarSet1),
term__var_to_int(Var, VarNum),
string__int_to_string(VarNum, VarNumStr),
- string__append("TypeInfo_", VarNumStr, Name),
+ string__append(Prefix, VarNumStr, Name),
varset__name_var(VarSet1, Var, Name, VarSet),
polymorphism__build_type_info_type(Symbol, Type, TypeInfoType),
map__set(VarTypes0, Var, TypeInfoType, VarTypes).
+:- func typeinfo_prefix = string.
+
+typeinfo_prefix = "TypeInfo_".
+
+:- func typectorinfo_prefix = string.
+
+typectorinfo_prefix = "TypeCtorInfo_".
+
%---------------------------------------------------------------------------%
% Generate code to get the value of a type variable.
@@ -3095,8 +3074,9 @@
polymorphism__make_count_var(Index, VarSet0, VarTypes0, IndexVar,
IndexGoal, VarSet1, VarTypes1),
- polymorphism__new_type_info_var(term__variable(TypeVar), "type_info",
- VarSet1, VarTypes1, TypeInfoVar, VarSet, VarTypes),
+ polymorphism__new_type_info_var_raw(term__variable(TypeVar),
+ "type_info", typeinfo_prefix, VarSet1, VarTypes1,
+ TypeInfoVar, VarSet, VarTypes),
% Make the goal info for the call.
% `type_info_from_typeclass_info' does not require an extra
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing java
cvs diff: Diffing java/library
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
--------------------------------------------------------------------------
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