[m-rev.] for review: base_typeclass_info rtti refs
Zoltan Somogyi
zs at cs.mu.OZ.AU
Thu May 1 20:09:09 AEST 2003
For review by Fergus. The diff has been successfully bootchecked in grades
hlc.gc, asm_fast.gc and asm_fast.gc.debug.tr.
Zoltan.
Fix two related anomalies. One was that base_typeclass_infos were being
created using the fcailities of rtti.m, but they were being referred to
using data_addr, not rtti_addr, in the LLDS backend, and they had similar
special treatment in the MLDS backend. The second is the special treatment of
base_typeclass_infos within rtti.m, rtti_out.m and rtti_to_mlds.m, due
to the fact that unlike the other data structures defined in rtti.m,
their id does not include an rtti_type_ctor. When we move over to the
proposed data structures for representing type class and instance
information, base_typeclass_infos won't be alone in not including
an rtti_type_ctor in their id.
compiler/rtti.m:
Introduce the notion of an rtti_id, which includes an rtti_type_ctor
only for references to data structures for which that is appropriate.
compiler/llds.m:
compiler/mlds.m:
Delete the redundant data_name base_typeclass_info.
Use rtti_ids where appropriate.
compiler/llds_out.m:
Delete the code handling the deleted data_name base_typeclass_info.
Conform to the changes to rtti.m and llds.m.
compiler/ll_pseudo_type_info.m:
compiler/ml_closure_gen.m:
compiler/ml_unify_gen.m:
compiler/ml_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/opt_debug.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/stack_layout.m:
compiler/unify_gen.m:
Conform to the changes above, which in several cases allows us to
eliminate the special handling of base_typeclass_infos.
compiler/base_typeclass_info.m:
Follow up on an old XXX, and make a predicate tail recursive.
cvs diff: Diffing .
cvs diff: Diffing analysis
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/base_typeclass_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/base_typeclass_info.m,v
retrieving revision 1.24
diff -u -b -r1.24 base_typeclass_info.m
--- compiler/base_typeclass_info.m 16 Mar 2003 08:01:26 -0000 1.24
+++ compiler/base_typeclass_info.m 25 Apr 2003 23:56:35 -0000
@@ -55,35 +55,32 @@
module_info_instances(ModuleInfo, InstanceTable),
map__to_assoc_list(InstanceTable, AllInstances),
base_typeclass_info__gen_infos_for_classes(AllInstances, ModuleName,
- ModuleInfo, RttiDataList).
+ ModuleInfo, [], RttiDataList).
-:- pred base_typeclass_info__gen_infos_for_classes(assoc_list(class_id,
- list(hlds_instance_defn)), module_name, module_info,
- list(rtti_data)).
-:- mode base_typeclass_info__gen_infos_for_classes(in, in, in, out) is det.
+:- pred base_typeclass_info__gen_infos_for_classes(
+ assoc_list(class_id, list(hlds_instance_defn))::in, module_name::in,
+ module_info::in, list(rtti_data)::in, list(rtti_data)::out) is det.
-base_typeclass_info__gen_infos_for_classes([], _ModuleName, _ModuleInfo, []).
+base_typeclass_info__gen_infos_for_classes([], _ModuleName, _ModuleInfo,
+ RttiDataList, RttiDataList).
base_typeclass_info__gen_infos_for_classes([C|Cs], ModuleName, ModuleInfo,
- RttiDataList) :-
+ RttiDataList0, RttiDataList) :-
base_typeclass_info__gen_infos_for_instance_list(C, ModuleName,
- ModuleInfo, RttiDataList1),
+ ModuleInfo, RttiDataList0, RttiDataList1),
base_typeclass_info__gen_infos_for_classes(Cs, ModuleName,
- ModuleInfo, RttiDataList2),
- % XXX make it use an accumulator
- list__append(RttiDataList1, RttiDataList2, RttiDataList).
+ ModuleInfo, RttiDataList1, RttiDataList).
% XXX make it use an accumulator
:- pred base_typeclass_info__gen_infos_for_instance_list(
- pair(class_id, list(hlds_instance_defn)), module_name, module_info,
- list(rtti_data)).
-:- mode base_typeclass_info__gen_infos_for_instance_list(in, in, in, out)
- is det.
+ pair(class_id, list(hlds_instance_defn))::in, module_name::in,
+ module_info::in, list(rtti_data)::in, list(rtti_data)::out) is det.
-base_typeclass_info__gen_infos_for_instance_list(_ - [], _, _, []).
+base_typeclass_info__gen_infos_for_instance_list(_ - [], _, _,
+ RttiDataList, RttiDataList).
base_typeclass_info__gen_infos_for_instance_list(ClassId - [InstanceDefn|Is],
- ModuleName, ModuleInfo, RttiDataList) :-
+ ModuleName, ModuleInfo, RttiDataList0, RttiDataList) :-
base_typeclass_info__gen_infos_for_instance_list(ClassId - Is,
- ModuleName, ModuleInfo, RttiDataList1),
+ ModuleName, ModuleInfo, RttiDataList0, RttiDataList1),
InstanceDefn = hlds_instance_defn(InstanceModule, ImportStatus,
_TermContext, InstanceConstraints, InstanceTypes, Body,
PredProcIds, _Varset, _SuperClassProofs),
Index: compiler/ll_pseudo_type_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ll_pseudo_type_info.m,v
retrieving revision 1.7
diff -u -b -r1.7 ll_pseudo_type_info.m
--- compiler/ll_pseudo_type_info.m 15 Mar 2003 03:08:55 -0000 1.7
+++ compiler/ll_pseudo_type_info.m 26 Apr 2003 00:10:01 -0000
@@ -87,7 +87,8 @@
C = C0
;
Pseudo = plain_arity_zero_pseudo_type_info(RttiTypeCtor),
- DataAddr = rtti_addr(RttiTypeCtor, pseudo_type_info(Pseudo)),
+ DataAddr = rtti_addr(
+ rtti_id(RttiTypeCtor, pseudo_type_info(Pseudo))),
Rval = const(data_addr_const(DataAddr)),
LldsType = data_ptr,
C = C0
@@ -110,7 +111,8 @@
convert_plain_type_info(TypeInfo, Rval, LldsType, C0, C) :-
(
TypeInfo = plain_arity_zero_type_info(RttiTypeCtor),
- DataAddr = rtti_addr(RttiTypeCtor, type_info(TypeInfo)),
+ DataAddr = rtti_addr(
+ rtti_id(RttiTypeCtor, type_info(TypeInfo))),
Rval = const(data_addr_const(DataAddr)),
LldsType = data_ptr,
C = C0
@@ -133,7 +135,8 @@
convert_compound_pseudo_type_info(RttiTypeCtor, ArgRvals0, Args,
Rval, LldsType, C0, C) :-
- TypeCtorInfoDataAddr = rtti_addr(RttiTypeCtor, type_ctor_info),
+ TypeCtorInfoDataAddr = rtti_addr(
+ rtti_id(RttiTypeCtor, type_ctor_info)),
TypeCtorInfoRval = yes(const(data_addr_const(TypeCtorInfoDataAddr))),
LldsType = data_ptr,
counter__allocate(CNum, C0, C1),
@@ -158,7 +161,8 @@
convert_compound_type_info(RttiTypeCtor, ArgRvals0, Args,
Rval, LldsType, C0, C) :-
TypeCtorInfoData = type_info(plain_arity_zero_type_info(RttiTypeCtor)),
- TypeCtorInfoDataAddr = rtti_addr(RttiTypeCtor, TypeCtorInfoData),
+ TypeCtorInfoDataAddr = rtti_addr(
+ rtti_id(RttiTypeCtor, TypeCtorInfoData)),
TypeCtorInfoRval = yes(const(data_addr_const(TypeCtorInfoDataAddr))),
LldsType = data_ptr,
counter__allocate(CNum, C0, C1),
Index: compiler/llds.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/llds.m,v
retrieving revision 1.292
diff -u -b -r1.292 llds.m
--- compiler/llds.m 30 Apr 2003 18:15:44 -0000 1.292
+++ compiler/llds.m 30 Apr 2003 18:25:11 -0000
@@ -21,7 +21,6 @@
:- import_module backend_libs__foreign.
:- import_module backend_libs__proc_label.
:- import_module backend_libs__rtti.
-:- import_module hlds__hlds_data.
:- import_module hlds__hlds_goal.
:- import_module hlds__hlds_pred.
:- import_module libs__tree.
@@ -874,17 +873,13 @@
:- type data_addr
---> data_addr(module_name, data_name)
% module name; which var
- ; rtti_addr(rtti_type_ctor, rtti_name)
- % type id; which var
+ ; rtti_addr(rtti_id)
; layout_addr(layout_name).
:- type data_name
---> common(int, int)
% The first int is the cell number; the second is the
% cell type number.
- ; base_typeclass_info(class_id, string)
- % class name & class arity, names and arities of the
- % types
; tabling_pointer(proc_label).
% A variable that contains a pointer that points to
% the table used to implement memoization, loopcheck
Index: compiler/llds_out.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/llds_out.m,v
retrieving revision 1.210
diff -u -b -r1.210 llds_out.m
--- compiler/llds_out.m 30 Apr 2003 18:15:44 -0000 1.210
+++ compiler/llds_out.m 30 Apr 2003 19:02:48 -0000
@@ -2368,8 +2368,8 @@
data_addr_may_include_non_static_code_address(data_addr(_, DataName)) =
data_name_may_include_non_static_code_address(DataName).
-data_addr_may_include_non_static_code_address(rtti_addr(_, RttiName)) =
- rtti_name_would_include_code_addr(RttiName).
+data_addr_may_include_non_static_code_address(rtti_addr(RttiId)) =
+ rtti_id_would_include_code_addr(RttiId).
data_addr_may_include_non_static_code_address(layout_addr(LayoutName)) =
layout_name_would_include_code_addr(LayoutName).
@@ -2378,7 +2378,6 @@
% Common structures can include code addresses, but only in grades with
% static code addresses.
data_name_may_include_non_static_code_address(common(_, _)) = no.
-data_name_may_include_non_static_code_address(base_typeclass_info(_, _)) = yes.
data_name_may_include_non_static_code_address(tabling_pointer(_)) = no.
:- pred output_decl_id(decl_id, io__state, io__state).
@@ -2672,9 +2671,8 @@
output_data_addr_storage_type_name(ModuleName, DataVarName, no,
LaterIndent)
;
- { DataAddr = rtti_addr(RttiTypector, RttiVarName) },
- output_rtti_addr_storage_type_name(RttiTypector, RttiVarName,
- no)
+ { DataAddr = rtti_addr(RttiId) },
+ output_rtti_addr_storage_type_name(RttiId, no)
;
{ DataAddr = layout_addr(LayoutName) },
output_layout_name_storage_type_name(LayoutName, no)
@@ -2736,14 +2734,10 @@
output_data_addr_storage_type_name(ModuleName, DataVarName, BeingDefined,
LaterIndent) -->
- ( { DataVarName = base_typeclass_info(ClassId, Instance) } ->
- output_base_typeclass_info_storage_type_name(
- ModuleName, ClassId, Instance, no)
- ;
{ data_name_linkage(DataVarName, Linkage) },
globals__io_get_globals(Globals),
- { LinkageStr = c_data_linkage_string(Globals, Linkage,
- no, BeingDefined) },
+ { LinkageStr = c_data_linkage_string(Globals, Linkage, no,
+ BeingDefined) },
io__write_string(LinkageStr),
{ InclCodeAddr =
@@ -2757,13 +2751,11 @@
io__write_string("_struct\n"),
io__write_string(LaterIndent),
io__write_string("\t"),
- output_data_addr(ModuleName, DataVarName)
- ).
+ output_data_addr(ModuleName, DataVarName).
:- pred data_name_linkage(data_name::in, linkage::out) is det.
data_name_linkage(common(_, _), static).
-data_name_linkage(base_typeclass_info(_, _), extern).
data_name_linkage(tabling_pointer(_), static).
%-----------------------------------------------------------------------------%
@@ -3027,8 +3019,8 @@
output_data_addr(data_addr(ModuleName, DataName)) -->
output_data_addr(ModuleName, DataName).
-output_data_addr(rtti_addr(RttiTypeCtor, RttiName)) -->
- output_rtti_addr(RttiTypeCtor, RttiName).
+output_data_addr(rtti_addr(RttiId)) -->
+ output_rtti_id(RttiId).
output_data_addr(layout_addr(LayoutName)) -->
output_layout_name(LayoutName).
@@ -3043,14 +3035,6 @@
io__write_string(MangledModuleName),
io__write_string("__common_"),
io__write_int(CellNum)
- ;
- % We don't want to include the module name as part
- % of the name if it is a base_typeclass_info, since
- % we _want_ to cause a link error for overlapping
- % instance decls, even if they are in a different
- % module
- { VarName = base_typeclass_info(ClassId, TypeNames) },
- output_base_typeclass_info_name(ClassId, TypeNames)
;
{ VarName = tabling_pointer(ProcLabel) },
output_tabling_pointer_var_name(ProcLabel)
Index: compiler/ml_closure_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_closure_gen.m,v
retrieving revision 1.16
diff -u -b -r1.16 ml_closure_gen.m
--- compiler/ml_closure_gen.m 16 Mar 2003 08:01:28 -0000 1.16
+++ compiler/ml_closure_gen.m 26 Apr 2003 01:39:00 -0000
@@ -361,6 +361,7 @@
RttiTypeCtor0 = rtti_type_ctor(ModuleName0, _, _),
ModuleName = fixup_builtin_module(ModuleName0),
RttiTypeCtor = RttiTypeCtor0,
+ RttiId = rtti_id(RttiTypeCtor, RttiName),
MLDS_Defns = MLDS_Defns0
;
% for other types, we need to generate a definition
@@ -368,7 +369,7 @@
% in the the current module
module_info_name(ModuleInfo, ModuleName),
RttiData = pseudo_type_info(PseudoTypeInfo),
- rtti_data_to_name(RttiData, RttiTypeCtor, RttiName),
+ rtti_data_to_id(RttiData, RttiId),
RttiDefns0 = rtti_data_list_to_mlds(ModuleInfo,
[RttiData]),
% rtti_data_list_to_mlds assumes that the result
@@ -387,8 +388,8 @@
),
MLDS_ModuleName = mercury_module_name_to_mlds(ModuleName),
Rval = const(data_addr_const(data_addr(MLDS_ModuleName,
- rtti(RttiTypeCtor, RttiName)))),
- Type = mlds__rtti_type(RttiName)
+ rtti(RttiId)))),
+ Type = mlds__rtti_type(RttiId)
).
:- pred ml_gen_type_info(module_info::in, rtti_type_info::in,
@@ -403,14 +404,14 @@
RttiName = type_ctor_info,
RttiTypeCtor0 = rtti_type_ctor(ModuleName0, _, _),
ModuleName = fixup_builtin_module(ModuleName0),
- RttiTypeCtor = RttiTypeCtor0,
+ RttiId = rtti_id(RttiTypeCtor0, RttiName),
MLDS_Defns = MLDS_Defns0
;
% for other types, we need to generate a definition
% of the type_info for that type, in the the current module
module_info_name(ModuleInfo, ModuleName),
RttiData = type_info(TypeInfo),
- rtti_data_to_name(RttiData, RttiTypeCtor, RttiName),
+ rtti_data_to_id(RttiData, RttiId),
RttiDefns0 = rtti_data_list_to_mlds(ModuleInfo, [RttiData]),
% rtti_data_list_to_mlds assumes that the result
% will be at file scope, but here we're generating it
@@ -426,8 +427,8 @@
),
MLDS_ModuleName = mercury_module_name_to_mlds(ModuleName),
Rval = const(data_addr_const(data_addr(MLDS_ModuleName,
- rtti(RttiTypeCtor, RttiName)))),
- Type = mlds__rtti_type(RttiName).
+ rtti(RttiId)))),
+ Type = mlds__rtti_type(RttiId).
:- func arg_maybe_pseudo_type_infos(rtti_pseudo_type_info)
= list(rtti_maybe_pseudo_type_info).
Index: compiler/ml_unify_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_unify_gen.m,v
retrieving revision 1.64
diff -u -b -r1.64 ml_unify_gen.m
--- compiler/ml_unify_gen.m 15 Mar 2003 07:11:56 -0000 1.64
+++ compiler/ml_unify_gen.m 26 Apr 2003 01:40:54 -0000
@@ -419,7 +419,7 @@
{ MLDS_Module = mercury_module_name_to_mlds(ModuleName) },
{ RttiTypeCtor = rtti_type_ctor(ModuleName, TypeName, TypeArity) },
{ DataAddr = data_addr(MLDS_Module,
- rtti(RttiTypeCtor, type_ctor_info)) },
+ rtti(rtti_id(RttiTypeCtor, type_ctor_info))) },
{ Rval = unop(cast(MLDS_VarType),
const(data_addr_const(DataAddr))) }.
@@ -427,8 +427,8 @@
Instance), VarType, Rval) -->
ml_gen_type(VarType, MLDS_VarType),
{ MLDS_Module = mercury_module_name_to_mlds(ModuleName) },
- { DataAddr = data_addr(MLDS_Module,
- base_typeclass_info(ClassId, Instance)) },
+ { DataAddr = data_addr(MLDS_Module, rtti(tc_rtti_id(
+ base_typeclass_info(ModuleName, ClassId, Instance)))) },
{ Rval = unop(cast(MLDS_VarType),
const(data_addr_const(DataAddr))) }.
Index: compiler/ml_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_util.m,v
retrieving revision 1.24
diff -u -b -r1.24 ml_util.m
--- compiler/ml_util.m 15 Mar 2003 03:09:00 -0000 1.24
+++ compiler/ml_util.m 26 Apr 2003 01:30:09 -0000
@@ -500,7 +500,8 @@
defn_is_type_ctor_info(Defn) :-
Defn = mlds__defn(_Name, _Context, _Flags, Body),
Body = mlds__data(Type, _, _),
- Type = mlds__rtti_type(RttiName),
+ Type = mlds__rtti_type(RttiId),
+ RttiId = rtti_id(_, RttiName),
RttiName = type_ctor_info.
defn_is_commit_type_var(Defn) :-
Index: compiler/mlds.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mlds.m,v
retrieving revision 1.99
diff -u -b -r1.99 mlds.m
--- compiler/mlds.m 15 Mar 2003 03:09:00 -0000 1.99
+++ compiler/mlds.m 26 Apr 2003 01:34:33 -0000
@@ -292,7 +292,6 @@
:- import_module backend_libs__foreign.
:- import_module backend_libs__rtti.
:- import_module check_hlds__type_util.
-:- import_module hlds__hlds_data.
:- import_module hlds__hlds_module.
:- import_module hlds__hlds_pred.
:- import_module libs__globals.
@@ -701,7 +700,7 @@
; mlds__pseudo_type_info_type
- ; mlds__rtti_type(rtti_name)
+ ; mlds__rtti_type(rtti_id)
% A type used by the ML code generator for references
% to variables that have yet to be declared. This occurs
@@ -1562,14 +1561,7 @@
%
% Stuff for handling polymorphism/RTTI and type classes.
%
- ; rtti(rtti_type_ctor, rtti_name)
- ; base_typeclass_info(
- hlds_data__class_id, % class name & class arity,
- string % a mangled string that encodes
- % the names and arities of the
- % types in the instance
- % declaration
- )
+ ; rtti(rtti_id)
%
% Stuff for handling debugging and accurate garbage collection.
% (Those features are not yet implemented for the MLDS back-end,
@@ -1662,6 +1654,7 @@
:- import_module backend_libs__foreign.
:- import_module hlds__error_util.
+:- import_module hlds__hlds_data.
:- import_module libs__globals.
:- import_module parse_tree__modules.
Index: compiler/mlds_to_c.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mlds_to_c.m,v
retrieving revision 1.146
diff -u -b -r1.146 mlds_to_c.m
--- compiler/mlds_to_c.m 18 Mar 2003 02:43:38 -0000 1.146
+++ compiler/mlds_to_c.m 1 May 2003 06:57:48 -0000
@@ -1637,7 +1637,7 @@
% instance decls, even if they are in a different
% module
%
- { Name = data(base_typeclass_info(_, _)) }
+ { Name = data(rtti(tc_rtti_id(_))) }
;
% We don't module qualify pragma export names.
{ Name = export(_) }
@@ -1749,12 +1749,9 @@
mlds_output_data_name(common(Num)) -->
io__write_string("common_"),
io__write_int(Num).
-mlds_output_data_name(rtti(RttiTypeCtor, RttiName)) -->
- { rtti__addr_to_string(RttiTypeCtor, RttiName, RttiAddrName) },
+mlds_output_data_name(rtti(RttiId)) -->
+ { rtti__addr_to_string(RttiId, RttiAddrName) },
io__write_string(RttiAddrName).
-mlds_output_data_name(base_typeclass_info(ClassId, InstanceStr)) -->
- { Name = make_base_typeclass_info_name(ClassId, InstanceStr) },
- io__write_string(Name).
mlds_output_data_name(module_layout) -->
{ error("mlds_to_c.m: NYI: module_layout") }.
mlds_output_data_name(proc_layout(_ProcLabel)) -->
@@ -1874,8 +1871,8 @@
;
io__write_string("jmp_buf")
).
-mlds_output_type_prefix(mlds__rtti_type(RttiName)) -->
- { rtti_name_c_type(RttiName, CType, _IsArray) },
+mlds_output_type_prefix(mlds__rtti_type(RttiId)) -->
+ { rtti_id_c_type(RttiId, CType, _IsArray) },
io__write_string(CType).
mlds_output_type_prefix(mlds__unknown_type) -->
{ error("mlds_to_c.m: prefix has unknown type") }.
@@ -2010,8 +2007,8 @@
io__write_string(")")
).
mlds_output_type_suffix(mlds__commit_type, _) --> [].
-mlds_output_type_suffix(mlds__rtti_type(RttiName), ArraySize) -->
- ( { rtti_name_has_array_type(RttiName) = yes } ->
+mlds_output_type_suffix(mlds__rtti_type(RttiId), ArraySize) -->
+ ( { rtti_id_has_array_type(RttiId) = yes } ->
mlds_output_array_type_suffix(ArraySize)
;
[]
@@ -3474,8 +3471,8 @@
(
% if its an array type, then we just use the name,
% otherwise we must prefix the name with `&'.
- { DataName = rtti(_, RttiName) },
- { rtti_name_has_array_type(RttiName) = yes }
+ { DataName = rtti(RttiId) },
+ { rtti_id_has_array_type(RttiId) = yes }
->
mlds_output_data_var_name(ModuleName, DataName)
;
@@ -3499,7 +3496,7 @@
% instance decls, even if they are in a different
% module
%
- { DataName = base_typeclass_info(_, _) }
+ { DataName = rtti(tc_rtti_id(base_typeclass_info(_, _, _))) }
->
[]
;
Index: compiler/mlds_to_gcc.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mlds_to_gcc.m,v
retrieving revision 1.84
diff -u -b -r1.84 mlds_to_gcc.m
--- compiler/mlds_to_gcc.m 26 Mar 2003 07:48:45 -0000 1.84
+++ compiler/mlds_to_gcc.m 26 Apr 2003 01:43:15 -0000
@@ -1931,25 +1931,32 @@
% XXX it would be more efficient to construct these types once,
% at initialization time, rather than every time they are used.
-:- pred build_rtti_type(rtti_name, initializer_array_size, gcc__type,
- io__state, io__state).
-:- mode build_rtti_type(in, in, out, di, uo) is det.
+:- pred build_rtti_type(rtti_id::in, initializer_array_size::in,
+ gcc__type::out, io__state::di, io__state::uo) is det.
+
+build_rtti_type(rtti_id(_, RttiName), Size, GCC_Type) -->
+ build_rtti_type_name(RttiName, Size, GCC_Type).
+build_rtti_type(tc_rtti_id(TCRttiName), Size, GCC_Type) -->
+ build_rtti_type_tc_name(TCRttiName, Size, GCC_Type).
+
+:- pred build_rtti_type_name(rtti_name::in, initializer_array_size::in,
+ gcc__type::out, io__state::di, io__state::uo) is det.
-build_rtti_type(exist_locns(_), Size, GCC_Type) -->
+build_rtti_type_name(exist_locns(_), Size, GCC_Type) -->
build_du_exist_locn_type(MR_DuExistLocn),
build_sized_array_type(MR_DuExistLocn, Size, GCC_Type).
-build_rtti_type(exist_info(_), _, MR_DuExistInfo) -->
+build_rtti_type_name(exist_info(_), _, MR_DuExistInfo) -->
build_du_exist_info_type(MR_DuExistInfo).
-build_rtti_type(field_names(_), Size, GCC_Type) -->
+build_rtti_type_name(field_names(_), Size, GCC_Type) -->
build_sized_array_type('MR_ConstString', Size, GCC_Type).
-build_rtti_type(field_types(_), Size, GCC_Type) -->
+build_rtti_type_name(field_types(_), Size, GCC_Type) -->
build_sized_array_type('MR_PseudoTypeInfo', Size, GCC_Type).
-build_rtti_type(res_addrs, Size, GCC_Type) -->
+build_rtti_type_name(res_addrs, Size, GCC_Type) -->
build_sized_array_type(gcc__ptr_type_node, Size, GCC_Type).
-build_rtti_type(res_addr_functors, Size, GCC_Type) -->
+build_rtti_type_name(res_addr_functors, Size, GCC_Type) -->
{ MR_ReservedAddrFunctorDescPtr = gcc__ptr_type_node },
build_sized_array_type(MR_ReservedAddrFunctorDescPtr, Size, GCC_Type).
-build_rtti_type(enum_functor_desc(_), _, GCC_Type) -->
+build_rtti_type_name(enum_functor_desc(_), _, GCC_Type) -->
% typedef struct {
% MR_ConstString MR_enum_functor_name;
% MR_int_least32_t MR_enum_functor_ordinal;
@@ -1958,7 +1965,7 @@
['MR_ConstString' - "MR_enum_functor_name",
'MR_int_least32_t' - "MR_enum_functor_ordinal"],
GCC_Type).
-build_rtti_type(notag_functor_desc, _, GCC_Type) -->
+build_rtti_type_name(notag_functor_desc, _, GCC_Type) -->
% typedef struct {
% MR_ConstString MR_notag_functor_name;
% MR_PseudoTypeInfo MR_notag_functor_arg_type;
@@ -1969,7 +1976,7 @@
'MR_PseudoTypeInfo' - "MR_notag_functor_arg_type",
'MR_ConstString' - "MR_notag_functor_arg_name"],
GCC_Type).
-build_rtti_type(du_functor_desc(_), _, GCC_Type) -->
+build_rtti_type_name(du_functor_desc(_), _, GCC_Type) -->
% typedef struct {
% MR_ConstString MR_du_functor_name;
% MR_int_least16_t MR_du_functor_orig_arity;
@@ -1998,7 +2005,7 @@
MR_ConstStringPtr - "MR_du_functor_arg_names",
MR_DuExistInfoPtr - "MR_du_functor_exist_info"],
GCC_Type).
-build_rtti_type(res_functor_desc(_), _, GCC_Type) -->
+build_rtti_type_name(res_functor_desc(_), _, GCC_Type) -->
% typedef struct {
% MR_ConstString MR_ra_functor_name;
% MR_int_least32_t MR_ra_functor_ordinal;
@@ -2009,19 +2016,19 @@
'MR_int_least32_t' - "MR_ra_functor_ordinal",
gcc__ptr_type_node - "MR_ra_functor_reserved_addr"],
GCC_Type).
-build_rtti_type(enum_name_ordered_table, Size, GCC_Type) -->
+build_rtti_type_name(enum_name_ordered_table, Size, GCC_Type) -->
{ MR_EnumFunctorDescPtr = gcc__ptr_type_node },
build_sized_array_type(MR_EnumFunctorDescPtr, Size, GCC_Type).
-build_rtti_type(enum_value_ordered_table, Size, GCC_Type) -->
+build_rtti_type_name(enum_value_ordered_table, Size, GCC_Type) -->
{ MR_EnumFunctorDescPtr = gcc__ptr_type_node },
build_sized_array_type(MR_EnumFunctorDescPtr, Size, GCC_Type).
-build_rtti_type(du_name_ordered_table, Size, GCC_Type) -->
+build_rtti_type_name(du_name_ordered_table, Size, GCC_Type) -->
{ MR_DuFunctorDescPtr = gcc__ptr_type_node },
build_sized_array_type(MR_DuFunctorDescPtr, Size, GCC_Type).
-build_rtti_type(du_stag_ordered_table(_), Size, GCC_Type) -->
+build_rtti_type_name(du_stag_ordered_table(_), Size, GCC_Type) -->
{ MR_DuFunctorDescPtr = gcc__ptr_type_node },
build_sized_array_type(MR_DuFunctorDescPtr, Size, GCC_Type).
-build_rtti_type(du_ptag_ordered_table, Size, GCC_Type) -->
+build_rtti_type_name(du_ptag_ordered_table, Size, GCC_Type) -->
% typedef struct {
% MR_int_least32_t MR_sectag_sharers;
% MR_Sectag_Locn MR_sectag_locn;
@@ -2033,7 +2040,7 @@
gcc__ptr_type_node - "MR_sectag_alternatives"],
MR_DuPtagLayout),
build_sized_array_type(MR_DuPtagLayout, Size, GCC_Type).
-build_rtti_type(res_value_ordered_table, _, GCC_Type) -->
+build_rtti_type_name(res_value_ordered_table, _, GCC_Type) -->
% typedef struct {
% MR_int_least16_t MR_ra_num_res_numeric_addrs;
% MR_int_least16_t MR_ra_num_res_symbolic_addrs;
@@ -2048,7 +2055,7 @@
gcc__ptr_type_node - "MR_ra_constants",
gcc__ptr_type_node - "MR_ra_other_functors"
], GCC_Type).
-build_rtti_type(res_name_ordered_table, _, GCC_Type) -->
+build_rtti_type_name(res_name_ordered_table, _, GCC_Type) -->
% typedef union {
% MR_DuFunctorDesc *MR_maybe_res_du_ptr;
% MR_ReservedAddrFunctorDesc *MR_maybe_res_res_ptr;
@@ -2069,7 +2076,7 @@
'MR_bool' - "MR_maybe_res_is_res",
MR_MaybeResAddrFunctorDesc - "MR_maybe_res_ptr"
], GCC_Type).
-build_rtti_type(type_ctor_info, _, GCC_Type) -->
+build_rtti_type_name(type_ctor_info, _, GCC_Type) -->
% MR_Integer MR_type_ctor_arity;
% MR_int_least8_t MR_type_ctor_version;
% MR_int_least8_t MR_type_ctor_num_ptags; /* if DU */
@@ -2105,21 +2112,25 @@
'MR_int_least32_t' - "MR_type_ctor_num_functors",
'MR_int_least16_t' - "MR_type_ctor_flags"],
GCC_Type).
-build_rtti_type(base_typeclass_info(_, _, _), Size, GCC_Type) -->
- { MR_BaseTypeclassInfo = gcc__ptr_type_node },
- build_sized_array_type(MR_BaseTypeclassInfo, Size, GCC_Type).
-build_rtti_type(type_info(TypeInfo), _, GCC_Type) -->
+build_rtti_type_name(type_info(TypeInfo), _, GCC_Type) -->
build_type_info_type(TypeInfo, GCC_Type).
-build_rtti_type(pseudo_type_info(PseudoTypeInfo), _, GCC_Type) -->
+build_rtti_type_name(pseudo_type_info(PseudoTypeInfo), _, GCC_Type) -->
build_pseudo_type_info_type(PseudoTypeInfo, GCC_Type).
-build_rtti_type(type_hashcons_pointer, _, MR_TableNodePtrPtr) -->
+build_rtti_type_name(type_hashcons_pointer, _, MR_TableNodePtrPtr) -->
{ MR_TableNodePtrPtr = gcc__ptr_type_node }.
+:- pred build_rtti_type_tc_name(tc_rtti_name::in, initializer_array_size::in,
+ gcc__type::out, io__state::di, io__state::uo) is det.
+
+build_rtti_type_tc_name(base_typeclass_info(_, _, _), Size, GCC_Type) -->
+ { MR_BaseTypeclassInfo = gcc__ptr_type_node },
+ build_sized_array_type(MR_BaseTypeclassInfo, Size, GCC_Type).
+
:- pred build_type_info_type(rtti_type_info::in,
gcc__type::out, io__state::di, io__state::uo) is det.
build_type_info_type(plain_arity_zero_type_info(_), GCC_Type) -->
- build_rtti_type(type_ctor_info, no_size, GCC_Type).
+ build_rtti_type_name(type_ctor_info, no_size, GCC_Type).
build_type_info_type(plain_type_info(_TypeCtor, ArgTypes),
GCC_Type) -->
{ Arity = list__length(ArgTypes) },
@@ -2161,7 +2172,7 @@
% rather than pointers, so there is no pointed-to type
{ error("mlds_rtti_type: type_var") }.
build_pseudo_type_info_type(plain_arity_zero_pseudo_type_info(_), GCC_Type) -->
- build_rtti_type(type_ctor_info, no_size, GCC_Type).
+ build_rtti_type_name(type_ctor_info, no_size, GCC_Type).
build_pseudo_type_info_type(plain_pseudo_type_info(_TypeCtor, ArgTypes),
GCC_Type) -->
{ Arity = list__length(ArgTypes) },
@@ -2336,7 +2347,7 @@
% instance decls, even if they are in a different
% module
%
- Name = data(base_typeclass_info(_, _))
+ Name = data(rtti(tc_rtti_id(_)))
;
% We don't module qualify pragma export names.
Name = export(_)
@@ -2368,12 +2379,9 @@
build_data_name(var(Name)) = name_mangle(ml_var_name_to_string(Name)).
build_data_name(common(Num)) =
string__format("common_%d", [i(Num)]).
-build_data_name(rtti(RttiTypeCtor0, RttiName0)) = RttiAddrName :-
- RttiTypeCtor = fixup_rtti_type_ctor(RttiTypeCtor0),
- RttiName = fixup_rtti_name(RttiName0),
- rtti__addr_to_string(RttiTypeCtor, RttiName, RttiAddrName).
-build_data_name(base_typeclass_info(ClassId, InstanceStr)) =
- make_base_typeclass_info_name(ClassId, InstanceStr).
+build_data_name(rtti(RttiId0)) = RttiAddrName :-
+ RttiId = fixup_rtti_id(RttiId0),
+ rtti__addr_to_string(RttiId, RttiAddrName).
build_data_name(module_layout) = _ :-
sorry(this_file, "module_layout").
build_data_name(proc_layout(_ProcLabel)) = _ :-
@@ -2390,6 +2398,14 @@
get_func_name(Name, _FuncName, AsmFuncName),
TablingPointerName = string__append("table_for_", AsmFuncName).
+:- func fixup_rtti_id(rtti_id) = rtti_id.
+
+fixup_rtti_id(rtti_id(RttiTypeCtor0, RttiName0))
+ = rtti_id(RttiTypeCtor, RttiName) :-
+ RttiTypeCtor = fixup_rtti_type_ctor(RttiTypeCtor0),
+ RttiName = fixup_rtti_name(RttiName0).
+fixup_rtti_id(tc_rtti_id(TCRttiName)) = tc_rtti_id(TCRttiName).
+
% XXX sometimes earlier stages of the compiler forget to add
% the appropriate qualifiers for stuff in the `builtin' module;
% we fix that here.
@@ -3486,7 +3502,7 @@
% instance decls, even if they are in a different
% module
%
- DataName = base_typeclass_info(_, _)
+ DataName = rtti(tc_rtti_id(_))
->
ModuleQualifier = ""
;
Index: compiler/mlds_to_il.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mlds_to_il.m,v
retrieving revision 1.129
diff -u -b -r1.129 mlds_to_il.m
--- compiler/mlds_to_il.m 16 Mar 2003 08:01:29 -0000 1.129
+++ compiler/mlds_to_il.m 1 May 2003 06:59:24 -0000
@@ -1271,10 +1271,10 @@
= mangle_mlds_var_name(MLDSVarName).
mangle_dataname(common(Int))
= string__format("common_%s", [i(Int)]).
-mangle_dataname(rtti(RttiTypeCtor, RttiName)) = MangledName :-
- rtti__addr_to_string(RttiTypeCtor, RttiName, MangledName).
-mangle_dataname(base_typeclass_info(ClassId, InstanceStr)) =
- make_base_typeclass_info_name(ClassId, InstanceStr).
+mangle_dataname(rtti(RttiId)) = MangledName :-
+ rtti__addr_to_string(RttiId, MangledName).
+% mangle_dataname(base_typeclass_info(ClassId, InstanceStr)) =
+% make_base_typeclass_info_name(ClassId, InstanceStr).
mangle_dataname(module_layout) = _MangledName :-
error("unimplemented: mangling module_layout").
mangle_dataname(proc_layout(_)) = _MangledName :-
@@ -3327,7 +3327,8 @@
SymName = qualified(qualified(unqualified("mercury"),
LibModuleName0), wrapper_class_name),
(
- DataName = rtti(RttiTypeCtor, RttiName),
+ DataName = rtti(RttiId),
+ RttiId = rtti_id(RttiTypeCtor, RttiName),
RttiTypeCtor = rtti_type_ctor(_, Name, Arity),
% Only the type_ctor_infos for the following
@@ -3336,12 +3337,13 @@
RttiName = type_ctor_info
;
RttiName = type_info(TypeInfo),
- TypeInfo =
- plain_arity_zero_type_info(RttiTypeCtor)
+ TypeInfo = plain_arity_zero_type_info(
+ RttiTypeCtor)
;
RttiName = pseudo_type_info(PseudoTypeInfo),
PseudoTypeInfo =
- plain_arity_zero_pseudo_type_info(RttiTypeCtor)
+ plain_arity_zero_pseudo_type_info(
+ RttiTypeCtor)
),
( LibModuleName0 = "builtin",
(
@@ -3397,10 +3399,8 @@
Name = mangle_mlds_var_name(MLDSVarName).
mangle_dataname(common(Int), MangledName) :-
string__format("common_%s", [i(Int)], MangledName).
-mangle_dataname(rtti(RttiTypeCtor, RttiName), MangledName) :-
- rtti__addr_to_string(RttiTypeCtor, RttiName, MangledName).
-mangle_dataname(base_typeclass_info(ClassId, InstanceStr), MangledName) :-
- MangledName = make_base_typeclass_info_name(ClassId, InstanceStr).
+mangle_dataname(rtti(RttiId), MangledName) :-
+ rtti__addr_to_string(RttiId, MangledName).
mangle_dataname(module_layout, _MangledName) :-
error("unimplemented: mangling module_layout").
mangle_dataname(proc_layout(_), _MangledName) :-
Index: compiler/mlds_to_java.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mlds_to_java.m,v
retrieving revision 1.38
diff -u -b -r1.38 mlds_to_java.m
--- compiler/mlds_to_java.m 16 Mar 2003 08:01:29 -0000 1.38
+++ compiler/mlds_to_java.m 1 May 2003 06:59:40 -0000
@@ -1647,11 +1647,9 @@
% XXX Most of this code doesn't yet work/hasn't been implemented in the Java
% backend.
%
-output_data_name(rtti(RttiTypeCtor, RttiName)) -->
- { rtti__addr_to_string(RttiTypeCtor, RttiName, RttiAddrName) },
+output_data_name(rtti(RttiId)) -->
+ { rtti__addr_to_string(RttiId, RttiAddrName) },
io__write_string(RttiAddrName).
-output_data_name(base_typeclass_info(ClassId, InstanceStr)) -->
- io__write_string(make_base_typeclass_info_name(ClassId, InstanceStr)).
output_data_name(module_layout) -->
{ error("mlds_to_java.m: NYI: module_layout") }.
output_data_name(proc_layout(_ProcLabel)) -->
@@ -1734,8 +1732,8 @@
% XXX The RTTI data should actually be static but it isn't being
% generated as such.
%
-output_type(mlds__rtti_type(RttiName)) -->
- { rtti_name_java_type(RttiName, JavaTypeName, _IsArray) },
+output_type(mlds__rtti_type(RttiId)) -->
+ { rtti_id_java_type(RttiId, JavaTypeName, _IsArray) },
io__write_string("static "),
io__write_string(JavaTypeName).
output_type(mlds__unknown_type) -->
Index: compiler/opt_debug.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/opt_debug.m,v
retrieving revision 1.128
diff -u -b -r1.128 opt_debug.m
--- compiler/opt_debug.m 30 Apr 2003 18:15:45 -0000 1.128
+++ compiler/opt_debug.m 30 Apr 2003 18:37:20 -0000
@@ -75,6 +75,9 @@
:- pred opt_debug__dump_rtti_name(rtti_name, string).
:- mode opt_debug__dump_rtti_name(in, out) is det.
+:- pred opt_debug__dump_tc_rtti_name(tc_rtti_name, string).
+:- mode opt_debug__dump_tc_rtti_name(in, out) is det.
+
:- pred opt_debug__dump_layout_name(layout_name, string).
:- mode opt_debug__dump_layout_name(in, out) is det.
@@ -343,12 +346,17 @@
opt_debug__dump_data_name(DataName, DataName_str),
string__append_list(
["data_addr(", ModuleName_str, ", ", DataName_str, ")"], Str).
-opt_debug__dump_data_addr(rtti_addr(RttiTypeCtor, DataName), Str) :-
+opt_debug__dump_data_addr(rtti_addr(rtti_id(RttiTypeCtor, DataName)), Str) :-
opt_debug__dump_rtti_type_ctor(RttiTypeCtor, RttiTypeCtor_str),
opt_debug__dump_rtti_name(DataName, DataName_str),
string__append_list(
["rtti_addr(", RttiTypeCtor_str, ", ", DataName_str, ")"],
Str).
+opt_debug__dump_data_addr(rtti_addr(tc_rtti_id(TCDataName)), Str) :-
+ opt_debug__dump_tc_rtti_name(TCDataName, TCDataName_str),
+ string__append_list(
+ ["tc_rtti_addr(", TCDataName_str, ")"],
+ Str).
opt_debug__dump_data_addr(layout_addr(LayoutName), Str) :-
opt_debug__dump_layout_name(LayoutName, LayoutName_str),
string__append_list(["layout_addr(", LayoutName_str, ")"], Str).
@@ -357,8 +365,6 @@
string__int_to_string(CellNum, C_str),
string__int_to_string(TypeNum, T_str),
string__append_list(["common(", C_str, ", ", T_str, ")"], Str).
-opt_debug__dump_data_name(base_typeclass_info(ClassId, InstanceNum), Str) :-
- Str = make_base_typeclass_info_name(ClassId, InstanceNum).
opt_debug__dump_data_name(tabling_pointer(ProcLabel), Str) :-
opt_debug__dump_proclabel(ProcLabel, ProcLabelStr),
string__append_list(["tabling_pointer(", ProcLabelStr, ")"], Str).
@@ -415,9 +421,6 @@
Str = "res_name_ordered_table".
opt_debug__dump_rtti_name(type_ctor_info, Str) :-
Str = "type_ctor_info".
-opt_debug__dump_rtti_name(base_typeclass_info(_ModuleName, ClassId,
- InstanceStr), Str) :-
- Str = make_base_typeclass_info_name(ClassId, InstanceStr).
opt_debug__dump_rtti_name(type_info(_TypeInfo), Str) :-
% XXX should give more info than this
Str = "type_info".
@@ -426,6 +429,10 @@
Str = "pseudo_type_info".
opt_debug__dump_rtti_name(type_hashcons_pointer, Str) :-
Str = "type_hashcons_pointer".
+
+opt_debug__dump_tc_rtti_name(base_typeclass_info(_ModuleName, ClassId,
+ InstanceStr), Str) :-
+ Str = make_base_typeclass_info_name(ClassId, InstanceStr).
opt_debug__dump_layout_name(label_layout(Label, LabelVars), Str) :-
opt_debug__dump_label(Label, LabelStr),
Index: compiler/rtti.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rtti.m,v
retrieving revision 1.29
diff -u -b -r1.29 rtti.m
--- compiler/rtti.m 21 Mar 2003 05:52:07 -0000 1.29
+++ compiler/rtti.m 30 Apr 2003 06:31:34 -0000
@@ -480,6 +480,10 @@
base_typeclass_info
).
+:- type rtti_id
+ ---> rtti_id(rtti_type_ctor, rtti_name)
+ ; tc_rtti_id(tc_rtti_name).
+
:- type rtti_name
---> exist_locns(int) % functor ordinal
; exist_info(int) % functor ordinal
@@ -501,13 +505,15 @@
; type_ctor_info
; type_info(rtti_type_info)
; pseudo_type_info(rtti_pseudo_type_info)
- ; base_typeclass_info(
+ ; type_hashcons_pointer.
+
+:- type tc_rtti_name
+ ---> base_typeclass_info(
module_name, % module containing instance decl.
class_id, % specifies class name & class arity
string % encodes the names and arities of the
% types in the instance declaration
- )
- ; type_hashcons_pointer.
+ ).
%-----------------------------------------------------------------------------%
%
@@ -521,8 +527,7 @@
% Convert a rtti_data to a rtti_type_ctor and a rtti_name.
% This calls error/1 if the argument is a type_var/1 rtti_data,
% since there is no rtti_type_ctor to return in that case.
-:- pred rtti_data_to_name(rtti_data::in, rtti_type_ctor::out, rtti_name::out)
- is det.
+:- pred rtti_data_to_id(rtti_data::in, rtti_id::out) is det.
% Convert an id that specifies a kind of variable arity type_info
% or pseudo_type_info into the type_ctor of the canonical (arity-zero)
@@ -530,12 +535,26 @@
:- func var_arity_id_to_rtti_type_ctor(var_arity_ctor_id) = rtti_type_ctor.
% return yes iff the specified rtti_name is an array
+:- func rtti_id_has_array_type(rtti_id) = bool.
+
+ % return yes iff the specified rtti_name is an array
:- func rtti_name_has_array_type(rtti_name) = bool.
+ % return yes iff the specified rtti_name is an array
+:- func tc_rtti_name_has_array_type(tc_rtti_name) = bool.
+
+ % Return yes iff the specified rtti_name should be exported
+ % for use by other modules.
+:- func rtti_id_is_exported(rtti_id) = bool.
+
% Return yes iff the specified rtti_name should be exported
% for use by other modules.
:- func rtti_name_is_exported(rtti_name) = bool.
+ % Return yes iff the specified tc_rtti_name should be exported
+ % for use by other modules.
+:- func tc_rtti_name_is_exported(tc_rtti_name) = bool.
+
% Construct an rtti_proc_label for a given procedure.
:- func rtti__make_rtti_proc_label(module_info, pred_id, proc_id)
= rtti_proc_label.
@@ -546,8 +565,7 @@
% Return the C variable name of the RTTI data structure identified
% by the input arguments.
-:- pred rtti__addr_to_string(rtti_type_ctor::in, rtti_name::in, string::out)
- is det.
+:- pred rtti__addr_to_string(rtti_id::in, string::out) is det.
% Return the C representation of a secondary tag location.
:- pred rtti__sectag_locn_to_string(sectag_locn::in, string::out) is det.
@@ -610,8 +628,16 @@
% Return true iff the given type of RTTI data structure includes
% code addresses.
+:- func rtti_id_would_include_code_addr(rtti_id) = bool.
+
+ % Return true iff the given type of RTTI data structure includes
+ % code addresses.
:- func rtti_name_would_include_code_addr(rtti_name) = bool.
+ % Return true iff the given type of RTTI data structure includes
+ % code addresses.
+:- func tc_rtti_name_would_include_code_addr(tc_rtti_name) = bool.
+
% Return true iff the given type_info's RTTI data structure includes
% code addresses.
:- func type_info_would_incl_code_addr(rtti_type_info) = bool.
@@ -620,15 +646,35 @@
% includes code addresses.
:- func pseudo_type_info_would_incl_code_addr(rtti_pseudo_type_info) = bool.
+ % rtti_id_c_type(RttiId, Type, IsArray):
+ % To declare a variable of the type specified by RttiId,
+ % put Type before the name of the variable; if IsArray is true,
+ % also put "[]" after the name.
+:- pred rtti_id_c_type(rtti_id::in, string::out, bool::out) is det.
+
% rtti_name_c_type(RttiName, Type, IsArray):
% To declare a variable of the type specified by RttiName,
% put Type before the name of the variable; if IsArray is true,
% also put "[]" after the name.
:- pred rtti_name_c_type(rtti_name::in, string::out, bool::out) is det.
+ % tc_rtti_name_c_type(TCRttiName, Type, IsArray):
+ % To declare a variable of the type specified by TCRttiName,
+ % put Type before the name of the variable; if IsArray is true,
+ % also put "[]" after the name.
+:- pred tc_rtti_name_c_type(tc_rtti_name::in, string::out, bool::out)
+ is det.
+
+ % Analogous to rtti_id_c_type.
+:- pred rtti_id_java_type(rtti_id::in, string::out, bool::out) is det.
+
% Analogous to rtti_name_c_type.
:- pred rtti_name_java_type(rtti_name::in, string::out, bool::out) is det.
+ % Analogous to tc_rtti_name_c_type.
+:- pred tc_rtti_name_java_type(tc_rtti_name::in, string::out, bool::out)
+ is det.
+
:- implementation.
:- import_module backend_libs__name_mangle.
@@ -651,17 +697,17 @@
encode_type_ctor_flag(kind_of_du_flag, N) = N + 4.
encode_type_ctor_flag(typeinfo_fake_arity_flag, N) = N + 8.
-rtti_data_to_name(type_ctor_info(TypeCtorData), RttiTypeCtor,
- type_ctor_info) :-
+rtti_data_to_id(type_ctor_info(TypeCtorData),
+ rtti_id(RttiTypeCtor, type_ctor_info)) :-
RttiTypeCtor = tcd_get_rtti_type_ctor(TypeCtorData).
-rtti_data_to_name(type_info(TypeInfo), RttiTypeCtor, type_info(TypeInfo)) :-
+rtti_data_to_id(type_info(TypeInfo),
+ rtti_id(RttiTypeCtor, type_info(TypeInfo))) :-
RttiTypeCtor = ti_get_rtti_type_ctor(TypeInfo).
-rtti_data_to_name(pseudo_type_info(PseudoTypeInfo), RttiTypeCtor,
- pseudo_type_info(PseudoTypeInfo)) :-
+rtti_data_to_id(pseudo_type_info(PseudoTypeInfo),
+ rtti_id(RttiTypeCtor, pseudo_type_info(PseudoTypeInfo))) :-
RttiTypeCtor = pti_get_rtti_type_ctor(PseudoTypeInfo).
-rtti_data_to_name(base_typeclass_info(_, _, _, _), _, _) :-
- % there's no rtti_type_ctor associated with a base_typeclass_info
- error("rtti_data_to_name: base_typeclass_info").
+rtti_data_to_id(base_typeclass_info(Module, ClassId, Instance, _),
+ tc_rtti_id(base_typeclass_info(Module, ClassId, Instance))).
tcd_get_rtti_type_ctor(TypeCtorData) = RttiTypeCtor :-
ModuleName = TypeCtorData ^ tcr_module_name,
@@ -700,9 +746,22 @@
mercury_public_builtin_module(Builtin),
Ctor = rtti_type_ctor(Builtin, "tuple", 0).
+rtti_id_has_array_type(rtti_id(_, RttiName)) =
+ rtti_name_has_array_type(RttiName).
+rtti_id_has_array_type(tc_rtti_id(TCRttiName)) =
+ tc_rtti_name_has_array_type(TCRttiName).
+
rtti_name_has_array_type(RttiName) = IsArray :-
rtti_name_type(RttiName, _, IsArray).
+tc_rtti_name_has_array_type(TCRttiName) = IsArray :-
+ tc_rtti_name_type(TCRttiName, _, IsArray).
+
+rtti_id_is_exported(rtti_id(_, RttiName)) =
+ rtti_name_is_exported(RttiName).
+rtti_id_is_exported(tc_rtti_id(TCRttiName)) =
+ tc_rtti_name_is_exported(TCRttiName).
+
rtti_name_is_exported(exist_locns(_)) = no.
rtti_name_is_exported(exist_info(_)) = no.
rtti_name_is_exported(field_names(_)) = no.
@@ -725,9 +784,10 @@
type_info_is_exported(TypeInfo).
rtti_name_is_exported(pseudo_type_info(PseudoTypeInfo)) =
pseudo_type_info_is_exported(PseudoTypeInfo).
-rtti_name_is_exported(base_typeclass_info(_, _, _)) = yes.
rtti_name_is_exported(type_hashcons_pointer) = no.
+tc_rtti_name_is_exported(base_typeclass_info(_, _, _)) = yes.
+
:- func type_info_is_exported(rtti_type_info) = bool.
type_info_is_exported(plain_arity_zero_type_info(_)) = yes.
@@ -772,7 +832,15 @@
ProcLabel = rtti_proc_label(_, _, _, _, _, _, PredId, ProcId,
_, _, _, _, _, _, _).
-rtti__addr_to_string(RttiTypeCtor, RttiName, Str) :-
+rtti__addr_to_string(rtti_id(RttiTypeCtor, RttiName), Str) :-
+ rtti__name_to_string(RttiTypeCtor, RttiName, Str).
+rtti__addr_to_string(tc_rtti_id(TCRttiName), Str) :-
+ rtti__tc_name_to_string(TCRttiName, Str).
+
+:- pred rtti__name_to_string(rtti_type_ctor::in, rtti_name::in, string::out)
+ is det.
+
+rtti__name_to_string(RttiTypeCtor, RttiName, Str) :-
rtti__mangle_rtti_type_ctor(RttiTypeCtor, ModuleName, TypeName, A_str),
(
RttiName = exist_locns(Ordinal),
@@ -862,21 +930,17 @@
RttiName = pseudo_type_info(PseudoTypeInfo),
Str = rtti__pseudo_type_info_to_string(PseudoTypeInfo)
;
- RttiName = base_typeclass_info(_ModuleName, ClassId,
- InstanceStr),
- ClassId = class_id(ClassSym, ClassArity),
- MangledClassString = sym_name_mangle(ClassSym),
- string__int_to_string(ClassArity, ArityString),
- MangledTypeNames = name_mangle(InstanceStr),
- string__append_list(["base_typeclass_info_",
- MangledClassString, "__arity", ArityString, "__",
- MangledTypeNames], Str)
- ;
RttiName = type_hashcons_pointer,
string__append_list([ModuleName, "__hashcons_ptr_",
TypeName, "_", A_str], Str)
).
+:- pred rtti__tc_name_to_string(tc_rtti_name::in, string::out) is det.
+
+rtti__tc_name_to_string(TCRttiName, Str) :-
+ TCRttiName = base_typeclass_info(_ModuleName, ClassId, InstanceStr),
+ Str = make_base_typeclass_info_name(ClassId, InstanceStr).
+
:- pred rtti__mangle_rtti_type_ctor(rtti_type_ctor::in,
string::out, string::out, string::out) is det.
@@ -901,7 +965,8 @@
rtti__type_info_to_string(TypeInfo) = Str :-
(
TypeInfo = plain_arity_zero_type_info(RttiTypeCtor),
- rtti__addr_to_string(RttiTypeCtor, type_ctor_info, Str)
+ rtti__addr_to_string(rtti_id(RttiTypeCtor, type_ctor_info),
+ Str)
;
TypeInfo = plain_type_info(RttiTypeCtor, Args),
rtti__mangle_rtti_type_ctor(RttiTypeCtor,
@@ -925,7 +990,8 @@
(
PseudoTypeInfo =
plain_arity_zero_pseudo_type_info(RttiTypeCtor),
- rtti__addr_to_string(RttiTypeCtor, type_ctor_info, Str)
+ rtti__addr_to_string(rtti_id(RttiTypeCtor, type_ctor_info),
+ Str)
;
PseudoTypeInfo = plain_pseudo_type_info(RttiTypeCtor, Args),
rtti__mangle_rtti_type_ctor(RttiTypeCtor,
@@ -1129,6 +1195,11 @@
res_addr_is_numeric(null_pointer).
res_addr_is_numeric(small_pointer(_)).
+rtti_id_would_include_code_addr(rtti_id(_, RttiName)) =
+ rtti_name_would_include_code_addr(RttiName).
+rtti_id_would_include_code_addr(tc_rtti_id(TCRttiName)) =
+ tc_rtti_name_would_include_code_addr(TCRttiName).
+
rtti_name_would_include_code_addr(exist_locns(_)) = no.
rtti_name_would_include_code_addr(exist_info(_)) = no.
rtti_name_would_include_code_addr(field_names(_)) = no.
@@ -1148,12 +1219,13 @@
rtti_name_would_include_code_addr(res_name_ordered_table) = no.
rtti_name_would_include_code_addr(type_hashcons_pointer) = no.
rtti_name_would_include_code_addr(type_ctor_info) = yes.
-rtti_name_would_include_code_addr(base_typeclass_info(_, _, _)) = yes.
rtti_name_would_include_code_addr(type_info(TypeInfo)) =
type_info_would_incl_code_addr(TypeInfo).
rtti_name_would_include_code_addr(pseudo_type_info(PseudoTypeInfo)) =
pseudo_type_info_would_incl_code_addr(PseudoTypeInfo).
+tc_rtti_name_would_include_code_addr(base_typeclass_info(_, _, _)) = yes.
+
type_info_would_incl_code_addr(plain_arity_zero_type_info(_)) = yes.
type_info_would_incl_code_addr(plain_type_info(_, _)) = no.
type_info_would_incl_code_addr(var_arity_type_info(_, _)) = no.
@@ -1164,14 +1236,32 @@
pseudo_type_info_would_incl_code_addr(var_arity_pseudo_type_info(_, _)) = no.
pseudo_type_info_would_incl_code_addr(type_var(_)) = no.
+rtti_id_c_type(rtti_id(_, RttiName), CTypeName, IsArray) :-
+ rtti_name_c_type(RttiName, CTypeName, IsArray).
+rtti_id_c_type(tc_rtti_id(TCRttiName), CTypeName, IsArray) :-
+ tc_rtti_name_c_type(TCRttiName, CTypeName, IsArray).
+
rtti_name_c_type(RttiName, CTypeName, IsArray) :-
rtti_name_type(RttiName, GenTypeName, IsArray),
CTypeName = string__append("MR_", GenTypeName).
+tc_rtti_name_c_type(TCRttiName, CTypeName, IsArray) :-
+ tc_rtti_name_type(TCRttiName, GenTypeName, IsArray),
+ CTypeName = string__append("MR_", GenTypeName).
+
+rtti_id_java_type(rtti_id(_, RttiName), JavaTypeName, IsArray) :-
+ rtti_name_java_type(RttiName, JavaTypeName, IsArray).
+rtti_id_java_type(tc_rtti_id(TCRttiName), JavaTypeName, IsArray) :-
+ tc_rtti_name_java_type(TCRttiName, JavaTypeName, IsArray).
+
rtti_name_java_type(RttiName, JavaTypeName, IsArray) :-
rtti_name_type(RttiName, GenTypeName, IsArray),
JavaTypeName = string__append("mercury.runtime.", GenTypeName).
+tc_rtti_name_java_type(TCRttiName, JavaTypeName, IsArray) :-
+ tc_rtti_name_type(TCRttiName, GenTypeName, IsArray),
+ JavaTypeName = string__append("mercury.runtime.", GenTypeName).
+
% rtti_name_type(RttiName, Type, IsArray):
:- pred rtti_name_type(rtti_name::in, string::out, bool::out) is det.
@@ -1193,12 +1283,16 @@
rtti_name_type(res_value_ordered_table, "ReservedAddrTypeLayout", no).
rtti_name_type(res_name_ordered_table, "MaybeResAddrFunctorDesc", yes).
rtti_name_type(type_ctor_info, "TypeCtorInfo_Struct", no).
-rtti_name_type(base_typeclass_info(_,_,_), "BaseTypeclassInfo", yes).
rtti_name_type(type_hashcons_pointer, "TrieNodePtr", no).
rtti_name_type(type_info(TypeInfo), TypeName, no) :-
TypeName = type_info_name_type(TypeInfo).
rtti_name_type(pseudo_type_info(PseudoTypeInfo), TypeName, no) :-
TypeName = pseudo_type_info_name_type(PseudoTypeInfo).
+
+ % tc_rtti_name_type(RttiName, Type, IsArray):
+:- pred tc_rtti_name_type(tc_rtti_name::in, string::out, bool::out) is det.
+
+tc_rtti_name_type(base_typeclass_info(_, _, _), "BaseTypeclassInfo", yes).
:- func type_info_name_type(rtti_type_info) = string.
Index: compiler/rtti_out.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rtti_out.m,v
retrieving revision 1.35
diff -u -b -r1.35 rtti_out.m
--- compiler/rtti_out.m 19 Apr 2003 05:52:03 -0000 1.35
+++ compiler/rtti_out.m 1 May 2003 07:00:34 -0000
@@ -24,9 +24,7 @@
:- interface.
:- import_module backend_libs__rtti.
-:- import_module hlds__hlds_data.
:- import_module ll_backend__llds_out.
-:- import_module parse_tree__prog_data.
:- import_module bool, io.
@@ -62,22 +60,13 @@
:- pred rtti_out__register_rtti_data_if_nec(rtti_data::in,
bool::in, io__state::di, io__state::uo) is det.
- % Output the C name of the rtti_data specified by the given
- % rtti_type_ctor and rtti_name.
-:- pred output_rtti_addr(rtti_type_ctor::in, rtti_name::in,
- io__state::di, io__state::uo) is det.
+ % Output the C name of the rtti_data specified by the given rtti_id.
+:- pred output_rtti_id(rtti_id::in, io__state::di, io__state::uo) is det.
% Output the C storage class, C type, and C name of the rtti_data
- % specified by the given rtti_type_ctor and rtti_name,
- % for use in a declaration or definition.
- % The bool should be `yes' iff it is for a definition.
-:- pred output_rtti_addr_storage_type_name(rtti_type_ctor::in, rtti_name::in,
- bool::in, io__state::di, io__state::uo) is det.
-
- % The same as output_rtti_addr_storage_type_name,
- % but for a base_typeclass_info.
-:- pred output_base_typeclass_info_storage_type_name(module_name::in,
- class_id::in, string::in, bool::in,
+ % specified by the given rtti_id for use in a declaration or
+ % definition. The bool should be `yes' iff it is for a definition.
+:- pred output_rtti_addr_storage_type_name(rtti_id::in, bool::in,
io__state::di, io__state::uo) is det.
:- implementation.
@@ -86,27 +75,29 @@
:- import_module backend_libs__name_mangle.
:- import_module backend_libs__pseudo_type_info.
:- import_module backend_libs__type_ctor_info.
+:- import_module hlds__hlds_data.
:- import_module hlds__error_util.
:- import_module libs__globals.
:- import_module libs__options.
:- import_module ll_backend__code_util.
:- import_module ll_backend__llds.
+:- import_module parse_tree__prog_data.
:- import_module parse_tree__prog_out.
:- import_module int, string, list, assoc_list, map, require, std_util.
%-----------------------------------------------------------------------------%
-output_rtti_data_defn(base_typeclass_info(InstanceModuleName, ClassId,
- InstanceString, BaseTypeClassInfo), DeclSet0, DeclSet) -->
- output_base_typeclass_info_defn(InstanceModuleName, ClassId,
- InstanceString, BaseTypeClassInfo, DeclSet0, DeclSet).
output_rtti_data_defn(type_info(TypeInfo), DeclSet0, DeclSet) -->
output_type_info_defn(TypeInfo, DeclSet0, DeclSet).
output_rtti_data_defn(pseudo_type_info(PseudoTypeInfo), DeclSet0, DeclSet) -->
output_pseudo_type_info_defn(PseudoTypeInfo, DeclSet0, DeclSet).
output_rtti_data_defn(type_ctor_info(TypeCtorData), DeclSet0, DeclSet) -->
output_type_ctor_data_defn(TypeCtorData, DeclSet0, DeclSet).
+output_rtti_data_defn(base_typeclass_info(InstanceModuleName, ClassId,
+ InstanceString, BaseTypeClassInfo), DeclSet0, DeclSet) -->
+ output_base_typeclass_info_defn(InstanceModuleName, ClassId,
+ InstanceString, BaseTypeClassInfo, DeclSet0, DeclSet).
%-----------------------------------------------------------------------------%
@@ -120,8 +111,9 @@
{ CodeAddrs = list__map(make_code_addr, Methods) },
output_code_addrs_decls(CodeAddrs, "", "", 0, _, DeclSet0, DeclSet1),
io__write_string("\n"),
- output_base_typeclass_info_storage_type_name(InstanceModuleName,
- ClassId, InstanceString, yes),
+ { RttiId = tc_rtti_id(base_typeclass_info(InstanceModuleName,
+ ClassId, InstanceString)) },
+ output_rtti_addr_storage_type_name(RttiId, yes),
% XXX It would be nice to avoid generating redundant declarations
% of base_typeclass_infos, but currently we don't.
{ DeclSet1 = DeclSet },
@@ -160,9 +152,8 @@
output_type_info_defn(TypeInfo, DeclSet0, DeclSet) -->
(
- { rtti_data_to_name(type_info(TypeInfo),
- RttiTypeCtor, RttiName) },
- { DataAddr = rtti_addr(RttiTypeCtor, RttiName) },
+ { rtti_data_to_id(type_info(TypeInfo), RttiId) },
+ { DataAddr = rtti_addr(RttiId) },
{ decl_set_is_member(data_addr(DataAddr), DeclSet0) }
->
{ DeclSet = DeclSet0 }
@@ -182,8 +173,8 @@
{ ArgRttiDatas = list__map(type_info_to_rtti_data, Args) },
output_type_ctor_and_arg_defns_and_decls(TypeCtorRttiData,
ArgRttiDatas, DeclSet0, DeclSet1),
- output_generic_rtti_data_defn_start(RttiTypeCtor,
- type_info(TypeInfo), DeclSet1, DeclSet),
+ output_generic_rtti_data_defn_start(
+ rtti_id(RttiTypeCtor, type_info(TypeInfo)), DeclSet1, DeclSet),
io__write_string(" = {\n\t&"),
output_rtti_addr(RttiTypeCtor, type_ctor_info),
io__write_string(",\n{"),
@@ -197,8 +188,8 @@
{ ArgRttiDatas = list__map(type_info_to_rtti_data, Args) },
output_type_ctor_and_arg_defns_and_decls(TypeCtorRttiData,
ArgRttiDatas, DeclSet0, DeclSet1),
- output_generic_rtti_data_defn_start(RttiTypeCtor,
- type_info(TypeInfo), DeclSet1, DeclSet),
+ output_generic_rtti_data_defn_start(
+ rtti_id(RttiTypeCtor, type_info(TypeInfo)), DeclSet1, DeclSet),
io__write_string(" = {\n\t&"),
output_rtti_addr(RttiTypeCtor, type_ctor_info),
io__write_string(",\n\t"),
@@ -217,9 +208,8 @@
->
{ DeclSet = DeclSet0 }
;
- { rtti_data_to_name(pseudo_type_info(PseudoTypeInfo),
- RttiTypeCtor, RttiName) },
- { DataAddr = rtti_addr(RttiTypeCtor, RttiName) },
+ { rtti_data_to_id(pseudo_type_info(PseudoTypeInfo), RttiId) },
+ { DataAddr = rtti_addr(RttiId) },
{ decl_set_is_member(data_addr(DataAddr), DeclSet0) }
->
{ DeclSet = DeclSet0 }
@@ -240,8 +230,9 @@
{ ArgRttiDatas = list__map(maybe_pseudo_type_info_to_rtti_data, Args) },
output_type_ctor_and_arg_defns_and_decls(TypeCtorRttiData,
ArgRttiDatas, DeclSet0, DeclSet1),
- output_generic_rtti_data_defn_start(RttiTypeCtor,
- pseudo_type_info(PseudoTypeInfo), DeclSet1, DeclSet),
+ output_generic_rtti_data_defn_start(
+ rtti_id(RttiTypeCtor, pseudo_type_info(PseudoTypeInfo)),
+ DeclSet1, DeclSet),
io__write_string(" = {\n\t&"),
output_rtti_addr(RttiTypeCtor, type_ctor_info),
io__write_string(",\n{"),
@@ -255,8 +246,9 @@
{ ArgRttiDatas = list__map(maybe_pseudo_type_info_to_rtti_data, Args) },
output_type_ctor_and_arg_defns_and_decls(TypeCtorRttiData,
ArgRttiDatas, DeclSet0, DeclSet1),
- output_generic_rtti_data_defn_start(RttiTypeCtor,
- pseudo_type_info(PseudoTypeInfo), DeclSet1, DeclSet),
+ output_generic_rtti_data_defn_start(
+ rtti_id(RttiTypeCtor, pseudo_type_info(PseudoTypeInfo)),
+ DeclSet1, DeclSet),
io__write_string(" = {\n\t&"),
output_rtti_addr(RttiTypeCtor, type_ctor_info),
io__write_string(",\n\t"),
@@ -302,8 +294,10 @@
{ CompareCodeAddr = make_code_addr(CompareProcLabel) },
{ CodeAddrs = [UnifyCodeAddr, CompareCodeAddr] },
output_code_addrs_decls(CodeAddrs, "", "", 0, _, DeclSet1, DeclSet2),
- output_generic_rtti_data_defn_start(RttiTypeCtor, type_ctor_info,
- DeclSet2, DeclSet), io__write_string(" = {\n\t"),
+ output_generic_rtti_data_defn_start(
+ rtti_id(RttiTypeCtor, type_ctor_info),
+ DeclSet2, DeclSet),
+ io__write_string(" = {\n\t"),
io__write_int(TypeArity),
io__write_string(",\n\t"),
io__write_int(Version),
@@ -440,8 +434,9 @@
output_enum_functor_defn(RttiTypeCtor, EnumFunctor, DeclSet0, DeclSet) -->
{ EnumFunctor = enum_functor(FunctorName, Ordinal) },
- output_generic_rtti_data_defn_start(RttiTypeCtor,
- enum_functor_desc(Ordinal), DeclSet0, DeclSet),
+ output_generic_rtti_data_defn_start(
+ rtti_id(RttiTypeCtor, enum_functor_desc(Ordinal)),
+ DeclSet0, DeclSet),
io__write_string(" = {\n\t"""),
c_util__output_quoted_string(FunctorName),
io__write_string(""",\n\t"),
@@ -457,7 +452,8 @@
{ ArgTypeData = maybe_pseudo_type_info_to_rtti_data(ArgType) },
output_rtti_data_decls(ArgTypeData, "", "", 0, _,
DeclSet1, DeclSet2),
- output_generic_rtti_data_defn_start(RttiTypeCtor, notag_functor_desc,
+ output_generic_rtti_data_defn_start(
+ rtti_id(RttiTypeCtor, notag_functor_desc),
DeclSet2, DeclSet),
io__write_string(" = {\n\t"""),
c_util__output_quoted_string(FunctorName),
@@ -518,8 +514,9 @@
{ MaybeExistInfo = no },
{ DeclSet3 = DeclSet2 }
),
- output_generic_rtti_data_defn_start(RttiTypeCtor,
- du_functor_desc(Ordinal), DeclSet3, DeclSet),
+ output_generic_rtti_data_defn_start(
+ rtti_id(RttiTypeCtor, du_functor_desc(Ordinal)),
+ DeclSet3, DeclSet),
io__write_string(" = {\n\t"""),
c_util__output_quoted_string(FunctorName),
io__write_string(""",\n\t"),
@@ -556,7 +553,7 @@
io__write_string("(MR_PseudoTypeInfo *) "), % cast away const
(
{ ArgInfos = [_ | _] },
- output_addr_of_rtti_addr(RttiTypeCtor, field_types(Ordinal))
+ output_addr_of_rtti_addr( RttiTypeCtor, field_types(Ordinal))
;
{ ArgInfos = [] },
io__write_string("NULL")
@@ -584,8 +581,9 @@
output_res_functor_defn(RttiTypeCtor, ResFunctor, DeclSet0, DeclSet) -->
{ ResFunctor = reserved_functor(FunctorName, Ordinal, Rep) },
- output_generic_rtti_data_defn_start(RttiTypeCtor,
- res_functor_desc(Ordinal), DeclSet0, DeclSet),
+ output_generic_rtti_data_defn_start(
+ rtti_id(RttiTypeCtor, res_functor_desc(Ordinal)),
+ DeclSet0, DeclSet),
io__write_string(" = {\n\t"""),
c_util__output_quoted_string(FunctorName),
io__write_string(""",\n\t"),
@@ -627,7 +625,8 @@
decl_set::in, decl_set::out, io__state::di, io__state::uo) is det.
output_exist_locns_array(RttiTypeCtor, Ordinal, Locns, DeclSet0, DeclSet) -->
- output_generic_rtti_data_defn_start(RttiTypeCtor, exist_locns(Ordinal),
+ output_generic_rtti_data_defn_start(
+ rtti_id(RttiTypeCtor, exist_locns(Ordinal)),
DeclSet0, DeclSet),
(
% ANSI/ISO C doesn't allow empty arrays, so
@@ -648,7 +647,8 @@
{ ExistInfo = exist_info(Plain, InTci, Tci, Locns) },
output_exist_locns_array(RttiTypeCtor, Ordinal, Locns,
DeclSet0, DeclSet1),
- output_generic_rtti_data_defn_start(RttiTypeCtor, exist_info(Ordinal),
+ output_generic_rtti_data_defn_start(
+ rtti_id(RttiTypeCtor, exist_info(Ordinal)),
DeclSet1, DeclSet),
io__write_string(" = {\n\t"),
io__write_int(Plain),
@@ -671,7 +671,8 @@
ArgTypes) },
output_rtti_datas_decls(ArgTypeDatas, "", "", 0, _,
DeclSet1, DeclSet2),
- output_generic_rtti_data_defn_start(RttiTypeCtor, field_types(Ordinal),
+ output_generic_rtti_data_defn_start(
+ rtti_id(RttiTypeCtor, field_types(Ordinal)),
DeclSet2, DeclSet),
io__write_string(" = {\n"),
{ require(list__is_not_empty(ArgTypes),
@@ -686,7 +687,8 @@
io__state::di, io__state::uo) is det.
output_du_arg_names(RttiTypeCtor, Ordinal, MaybeNames, DeclSet0, DeclSet) -->
- output_generic_rtti_data_defn_start(RttiTypeCtor, field_names(Ordinal),
+ output_generic_rtti_data_defn_start(
+ rtti_id(RttiTypeCtor, field_names(Ordinal)),
DeclSet0, DeclSet),
io__write_string(" = {\n"),
{ require(list__is_not_empty(MaybeNames),
@@ -704,8 +706,9 @@
-->
{ Functors = map__values(FunctorMap) },
{ FunctorRttiNames = list__map(enum_functor_rtti_name, Functors) },
- output_generic_rtti_data_defn_start(RttiTypeCtor,
- enum_value_ordered_table, DeclSet0, DeclSet),
+ output_generic_rtti_data_defn_start(
+ rtti_id(RttiTypeCtor, enum_value_ordered_table),
+ DeclSet0, DeclSet),
io__write_string(" = {\n"),
output_addr_of_rtti_addrs(RttiTypeCtor, FunctorRttiNames),
io__write_string("};\n").
@@ -718,8 +721,9 @@
-->
{ Functors = map__values(FunctorMap) },
{ FunctorRttiNames = list__map(enum_functor_rtti_name, Functors) },
- output_generic_rtti_data_defn_start(RttiTypeCtor,
- enum_name_ordered_table, DeclSet0, DeclSet),
+ output_generic_rtti_data_defn_start(
+ rtti_id(RttiTypeCtor, enum_name_ordered_table),
+ DeclSet0, DeclSet),
io__write_string(" = {\n"),
output_addr_of_rtti_addrs(RttiTypeCtor, FunctorRttiNames),
io__write_string("};\n").
@@ -733,8 +737,9 @@
{ list__map(map__values, ArityMaps, FunctorLists) },
{ list__condense(FunctorLists, Functors) },
{ FunctorRttiNames = list__map(du_functor_rtti_name, Functors) },
- output_generic_rtti_data_defn_start(RttiTypeCtor,
- du_name_ordered_table, DeclSet0, DeclSet),
+ output_generic_rtti_data_defn_start(
+ rtti_id(RttiTypeCtor, du_name_ordered_table),
+ DeclSet0, DeclSet),
io__write_string(" = {\n"),
output_addr_of_rtti_addrs(RttiTypeCtor, FunctorRttiNames),
io__write_string("};\n").
@@ -748,8 +753,9 @@
{ SectagTable = sectag_table(_SectagLocn, _NumSharers, SectagMap) },
{ map__values(SectagMap, SectagFunctors) },
{ FunctorNames = list__map(du_functor_rtti_name, SectagFunctors) },
- output_generic_rtti_data_defn_start(RttiTypeCtor,
- du_stag_ordered_table(Ptag), DeclSet0, DeclSet),
+ output_generic_rtti_data_defn_start(
+ rtti_id(RttiTypeCtor, du_stag_ordered_table(Ptag)),
+ DeclSet0, DeclSet),
io__write_string(" = {\n"),
output_addr_of_rtti_addrs(RttiTypeCtor, FunctorNames),
io__write_string("\n};\n").
@@ -762,8 +768,9 @@
{ map__to_assoc_list(PtagMap, PtagList) },
list__foldl2(output_du_stag_ordered_table(RttiTypeCtor), PtagList,
DeclSet0, DeclSet1),
- output_generic_rtti_data_defn_start(RttiTypeCtor,
- du_ptag_ordered_table, DeclSet1, DeclSet),
+ output_generic_rtti_data_defn_start(
+ rtti_id(RttiTypeCtor, du_ptag_ordered_table),
+ DeclSet1, DeclSet),
io__write_string(" = {\n"),
( { PtagList = [1 - _ | _] } ->
% Output a dummy ptag definition for the
@@ -836,8 +843,8 @@
{ require(unify(NumSymbolicResFunctorReps, 0),
"output_res_value_ordered_table: symbolic functors") },
- output_generic_rtti_data_defn_start(RttiTypeCtor,
- res_addr_functors, DeclSet0, DeclSet1),
+ output_generic_rtti_data_defn_start(
+ rtti_id(RttiTypeCtor, res_addr_functors), DeclSet0, DeclSet1),
io__write_string(" = {\n"),
list__foldl(output_res_addr_functors(RttiTypeCtor), ResFunctors),
io__write_string("};\n"),
@@ -845,8 +852,9 @@
output_du_ptag_ordered_table(RttiTypeCtor, DuPtagTable,
DeclSet1, DeclSet2),
- output_generic_rtti_data_defn_start(RttiTypeCtor,
- res_value_ordered_table, DeclSet2, DeclSet),
+ output_generic_rtti_data_defn_start(
+ rtti_id(RttiTypeCtor, res_value_ordered_table),
+ DeclSet2, DeclSet),
io__write_string(" = {\n\t"""),
io__write_int(NumNumericResFunctorReps),
io__write_string(",\n\t"),
@@ -867,8 +875,9 @@
{ map__values(NameArityMap, ArityMaps) },
{ list__map(map__values, ArityMaps, FunctorLists) },
{ list__condense(FunctorLists, Functors) },
- output_generic_rtti_data_defn_start(RttiTypeCtor,
- res_name_ordered_table, DeclSet0, DeclSet),
+ output_generic_rtti_data_defn_start(
+ rtti_id(RttiTypeCtor, res_name_ordered_table),
+ DeclSet0, DeclSet),
io__write_string(" = {\n\t"""),
list__foldl(output_res_name_ordered_table_element(RttiTypeCtor),
Functors),
@@ -928,84 +937,46 @@
% Also rtti_data_to_name/3 does not handle this case.
{ DeclSet = DeclSet0 }
;
- { RttiData = base_typeclass_info(InstanceModuleName, ClassId,
- InstanceStr, _) }
- ->
- % rtti_data_to_name/3 does not handle this case
- output_base_typeclass_info_decl(InstanceModuleName, ClassId,
- InstanceStr, no, DeclSet0, DeclSet)
- ;
- { rtti_data_to_name(RttiData, RttiTypeCtor, RttiName) },
- output_generic_rtti_data_decl(RttiTypeCtor, RttiName,
- DeclSet0, DeclSet)
+ { rtti_data_to_id(RttiData, RttiId) },
+ output_generic_rtti_data_decl(RttiId, DeclSet0, DeclSet)
).
-:- pred output_base_typeclass_info_decl(module_name::in, class_id::in,
- string::in, bool::in, decl_set::in, decl_set::out,
- io__state::di, io__state::uo) is det.
-
-output_base_typeclass_info_decl(InstanceModuleName, ClassId, InstanceStr,
- BeingDefined, DeclSet0, DeclSet) -->
- output_base_typeclass_info_storage_type_name(InstanceModuleName,
- ClassId, InstanceStr, BeingDefined),
- io__write_string(";\n"),
- % XXX It would be nice to avoid generating redundant declarations
- % of base_typeclass_infos, but currently we don't.
- { DeclSet = DeclSet0 }.
-
-output_base_typeclass_info_storage_type_name(InstanceModuleName, ClassId,
- InstanceStr, BeingDefined) -->
- output_rtti_name_storage_type_name(
- output_base_typeclass_info_name(ClassId, InstanceStr),
- base_typeclass_info(InstanceModuleName, ClassId, InstanceStr),
- BeingDefined).
-
%-----------------------------------------------------------------------------%
-:- pred output_generic_rtti_data_decl(rtti_type_ctor::in, rtti_name::in,
- decl_set::in, decl_set::out, io__state::di, io__state::uo) is det.
+:- pred output_generic_rtti_data_decl(rtti_id::in, decl_set::in, decl_set::out,
+ io__state::di, io__state::uo) is det.
-output_generic_rtti_data_decl(RttiTypeCtor, RttiName, DeclSet0, DeclSet) -->
- output_rtti_addr_storage_type_name(RttiTypeCtor, RttiName, no),
+output_generic_rtti_data_decl(RttiId, DeclSet0, DeclSet) -->
+ output_rtti_addr_storage_type_name(RttiId, no),
io__write_string(";\n"),
- { DataAddr = rtti_addr(RttiTypeCtor, RttiName) },
+ { DataAddr = rtti_addr(RttiId) },
{ decl_set_insert(data_addr(DataAddr), DeclSet0, DeclSet) }.
-:- pred output_generic_rtti_data_defn_start(rtti_type_ctor::in, rtti_name::in,
+:- pred output_generic_rtti_data_defn_start(rtti_id::in,
decl_set::in, decl_set::out, io__state::di, io__state::uo) is det.
-output_generic_rtti_data_defn_start(RttiTypeCtor, RttiName, DeclSet0, DeclSet)
- -->
+output_generic_rtti_data_defn_start(RttiId, DeclSet0, DeclSet) -->
io__write_string("\n"),
- output_rtti_addr_storage_type_name(RttiTypeCtor, RttiName, yes),
- { DataAddr = rtti_addr(RttiTypeCtor, RttiName) },
+ output_rtti_addr_storage_type_name(RttiId, yes),
+ { DataAddr = rtti_addr(RttiId) },
{ decl_set_insert(data_addr(DataAddr), DeclSet0, DeclSet) }.
-output_rtti_addr_storage_type_name(RttiTypeCtor, RttiName, BeingDefined) -->
- output_rtti_name_storage_type_name(
- output_rtti_addr(RttiTypeCtor, RttiName),
- RttiName, BeingDefined).
-
-:- pred output_rtti_name_storage_type_name(
- pred(io__state, io__state)::pred(di, uo) is det,
- rtti_name::in, bool::in, io__state::di, io__state::uo) is det.
-
-output_rtti_name_storage_type_name(OutputName, RttiName, BeingDefined) -->
- output_rtti_type_decl(RttiName),
- { rtti_name_linkage(RttiName, Linkage) },
+output_rtti_addr_storage_type_name(RttiId, BeingDefined) -->
+ output_rtti_type_decl(RttiId),
+ { rtti_id_linkage(RttiId, Linkage) },
globals__io_get_globals(Globals),
{ LinkageStr = c_data_linkage_string(Globals, Linkage, yes,
BeingDefined) },
io__write_string(LinkageStr),
- { InclCodeAddr = rtti_name_would_include_code_addr(RttiName) },
+ { InclCodeAddr = rtti_id_would_include_code_addr(RttiId) },
{ c_data_const_string(Globals, InclCodeAddr, ConstStr) },
io__write_string(ConstStr),
- { rtti_name_c_type(RttiName, CType, IsArray) },
+ { rtti_id_c_type(RttiId, CType, IsArray) },
c_util__output_quoted_string(CType),
io__write_string(" "),
- OutputName,
+ output_rtti_id(RttiId),
(
{ IsArray = yes },
io__write_string("[]")
@@ -1017,12 +988,12 @@
% depending on what kind of type_info or pseudo_type_info it is,
% and also on its arity. We need to declare that C type here.
-:- pred output_rtti_type_decl(rtti_name::in, io__state::di, io__state::uo)
+:- pred output_rtti_type_decl(rtti_id::in, io__state::di, io__state::uo)
is det.
-output_rtti_type_decl(RttiName) -->
+output_rtti_type_decl(RttiId) -->
(
- { rtti_type_template_arity(RttiName, Arity) },
+ { rtti_type_template_arity(RttiId, Arity) },
{ Arity > max_always_declared_arity }
->
{ Template =
@@ -1036,9 +1007,10 @@
[]
).
-:- pred rtti_type_template_arity(rtti_name::in, int::out) is semidet.
+:- pred rtti_type_template_arity(rtti_id::in, int::out) is semidet.
-rtti_type_template_arity(RttiName, NumArgTypes) :-
+rtti_type_template_arity(RttiId, NumArgTypes) :-
+ RttiId = rtti_id(_, RttiName),
RttiName = type_info(TypeInfo),
(
TypeInfo = plain_type_info(_, ArgTypes)
@@ -1046,7 +1018,8 @@
TypeInfo = var_arity_type_info(_, ArgTypes)
),
NumArgTypes = list__length(ArgTypes).
-rtti_type_template_arity(RttiName, NumArgTypes) :-
+rtti_type_template_arity(RttiId, NumArgTypes) :-
+ RttiId = rtti_id(_, RttiName),
RttiName = pseudo_type_info(PseudoTypeInfo),
(
PseudoTypeInfo = plain_pseudo_type_info(_, ArgTypes)
@@ -1107,20 +1080,20 @@
{ Data = type_ctor_info(TypeCtorData) }
->
{ RttiTypeCtor = tcd_get_rtti_type_ctor(TypeCtorData) },
+ { RttiId = rtti_id(RttiTypeCtor, type_ctor_info) },
(
{ SplitFiles = yes },
io__write_string("\t{\n\t"),
- output_rtti_addr_storage_type_name(RttiTypeCtor,
- type_ctor_info, no),
+ output_rtti_addr_storage_type_name(RttiId, no),
io__write_string(
";\n\tMR_register_type_ctor_info(\n\t\t&"),
- output_rtti_addr(RttiTypeCtor, type_ctor_info),
+ output_rtti_id(RttiId),
io__write_string(");\n\t}\n")
;
{ SplitFiles = no },
io__write_string(
"\tMR_register_type_ctor_info(\n\t\t&"),
- output_rtti_addr(RttiTypeCtor, type_ctor_info),
+ output_rtti_id(RttiId),
io__write_string(");\n")
)
;
@@ -1133,7 +1106,8 @@
% we don't even have any data structures in the runtime system
% to describe such membership information.
%
- % io__write_string("\tMR_register_base_typeclass_info(\n\t\t&"),
+ % io__write_string(
+ % "\tMR_register_base_typeclass_info(\n\t\t&"),
% output_base_typeclass_info_storage_type_name(
% InstanceModuleName, ClassId, InstanceString, no),
% io__write_string(");\n")
@@ -1142,6 +1116,7 @@
[]
).
+
:- pred output_init_method_pointers(int, list(code_addr), class_id, string,
io__state, io__state).
:- mode output_init_method_pointers(in, in, in, in, di, uo) is det.
@@ -1167,7 +1142,8 @@
FirstIndent, LaterIndent, N0, N, DeclSet0, DeclSet) -->
(
{ MaybeRttiName = yes(RttiName) },
- output_data_addr_decls(rtti_addr(RttiTypeCtor, RttiName),
+ output_data_addr_decls(rtti_addr(
+ rtti_id(RttiTypeCtor, RttiName)),
FirstIndent, LaterIndent, N0, N1, DeclSet0, DeclSet1)
;
{ MaybeRttiName = no },
@@ -1196,7 +1172,7 @@
output_rtti_addrs_decls(_, [], _, _, N, N, DeclSet, DeclSet) --> [].
output_rtti_addrs_decls(RttiTypeCtor, [RttiName | RttiNames],
FirstIndent, LaterIndent, N0, N, DeclSet0, DeclSet) -->
- output_data_addr_decls(rtti_addr(RttiTypeCtor, RttiName),
+ output_data_addr_decls(rtti_addr(rtti_id(RttiTypeCtor, RttiName)),
FirstIndent, LaterIndent, N0, N1, DeclSet0, DeclSet1),
output_rtti_addrs_decls(RttiTypeCtor, RttiNames,
FirstIndent, LaterIndent, N1, N, DeclSet1, DeclSet).
@@ -1214,28 +1190,19 @@
{ DeclSet = DeclSet0 },
{ N = N0 }
;
- { RttiData = base_typeclass_info(InstanceModuleName, ClassId,
- InstanceStr, _) }
- ->
- % rtti_data_to_name/3 does not handle this case,
- % so we need to handle it here
- output_base_typeclass_info_decl(InstanceModuleName, ClassId,
- InstanceStr, no, DeclSet0, DeclSet),
- { N = N0 }
- ;
- { rtti_data_to_name(RttiData, RttiTypeCtor, RttiName) },
- output_rtti_addr_decls(RttiTypeCtor, RttiName,
- FirstIndent, LaterIndent, N0, N, DeclSet0, DeclSet)
+ { rtti_data_to_id(RttiData, RttiId) },
+ output_rtti_addr_decls(RttiId, FirstIndent, LaterIndent,
+ N0, N, DeclSet0, DeclSet)
).
-:- pred output_rtti_addr_decls(rtti_type_ctor::in, rtti_name::in,
- string::in, string::in, int::in, int::out, decl_set::in, decl_set::out,
+:- pred output_rtti_addr_decls(rtti_id::in, string::in, string::in,
+ int::in, int::out, decl_set::in, decl_set::out,
io__state::di, io__state::uo) is det.
-output_rtti_addr_decls(RttiTypeCtor, RttiName, FirstIndent, LaterIndent,
+output_rtti_addr_decls(RttiId, FirstIndent, LaterIndent,
N0, N1, DeclSet0, DeclSet1) -->
- output_data_addr_decls(rtti_addr(RttiTypeCtor, RttiName),
- FirstIndent, LaterIndent, N0, N1, DeclSet0, DeclSet1).
+ output_data_addr_decls(rtti_addr(RttiId), FirstIndent, LaterIndent,
+ N0, N1, DeclSet0, DeclSet1).
:- pred output_addr_of_maybe_rtti_addr(rtti_type_ctor::in,
maybe(rtti_name)::in, io__state::di, io__state::uo) is det.
@@ -1295,44 +1262,46 @@
output_addr_of_rtti_data(RttiData).
output_addr_of_rtti_data(RttiData) -->
- (
- { RttiData = pseudo_type_info(type_var(VarNum)) }
- ->
+ ( { RttiData = pseudo_type_info(type_var(VarNum)) } ->
% rtti_data_to_name/3 does not handle this case
io__write_int(VarNum)
;
- { RttiData = base_typeclass_info(_InstanceModuleName, ClassId,
- InstanceStr, _) }
- ->
- % rtti_data_to_name/3 does not handle this case
- output_base_typeclass_info_name(ClassId, InstanceStr)
- ;
- { rtti_data_to_name(RttiData, RttiTypeCtor, RttiName) },
- output_addr_of_rtti_addr(RttiTypeCtor, RttiName)
+ { rtti_data_to_id(RttiData, RttiId) },
+ output_addr_of_rtti_id(RttiId)
).
-:- pred output_addr_of_rtti_addr(rtti_type_ctor::in, rtti_name::in,
- io__state::di, io__state::uo) is det.
+:- pred output_addr_of_rtti_id(rtti_id::in, io__state::di, io__state::uo)
+ is det.
-output_addr_of_rtti_addr(RttiTypeCtor, RttiName) -->
+output_addr_of_rtti_id(RttiId) -->
%
% If the RttiName is not an array, then
% we need to use `&' to take its address
%
- (
- { rtti_name_has_array_type(RttiName) = yes }
- ->
+ ( { rtti_id_has_array_type(RttiId) = yes } ->
[]
;
io__write_string("&")
),
- output_rtti_addr(RttiTypeCtor, RttiName).
+ output_rtti_id(RttiId).
-output_rtti_addr(RttiTypeCtor, RttiName) -->
+:- pred output_addr_of_rtti_addr(rtti_type_ctor::in, rtti_name::in,
+ io__state::di, io__state::uo) is det.
+
+output_addr_of_rtti_addr(RttiTypeCtor, RttiName) -->
+ output_addr_of_rtti_id(rtti_id(RttiTypeCtor, RttiName)).
+
+output_rtti_id(RttiId) -->
io__write_string(mercury_data_prefix),
- { rtti__addr_to_string(RttiTypeCtor, RttiName, Str) },
+ { rtti__addr_to_string(RttiId, Str) },
io__write_string(Str).
+:- pred output_rtti_addr(rtti_type_ctor::in, rtti_name::in,
+ io__state::di, io__state::uo) is det.
+
+output_rtti_addr(RttiTypeCtor, RttiName) -->
+ output_rtti_id(rtti_id(RttiTypeCtor, RttiName)).
+
%-----------------------------------------------------------------------------%
:- pred output_maybe_quoted_string(maybe(string)::in,
@@ -1402,19 +1371,19 @@
%-----------------------------------------------------------------------------%
-:- pred rtti_name_linkage(rtti_name::in, linkage::out) is det.
+:- pred rtti_id_linkage(rtti_id::in, linkage::out) is det.
-rtti_name_linkage(RttiName, Linkage) :-
+rtti_id_linkage(RttiId, Linkage) :-
(
% ANSI/ISO C doesn't allow forward declarations
% of static data with incomplete types (in this
% case array types without an explicit array
% size), so make the declarations extern.
- yes = rtti_name_has_array_type(RttiName)
+ yes = rtti_id_has_array_type(RttiId)
->
Linkage = extern
;
- Exported = rtti_name_is_exported(RttiName),
+ Exported = rtti_id_is_exported(RttiId),
( Exported = yes, Linkage = extern
; Exported = no, Linkage = static
)
Index: compiler/rtti_to_mlds.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rtti_to_mlds.m,v
retrieving revision 1.38
diff -u -b -r1.38 rtti_to_mlds.m
--- compiler/rtti_to_mlds.m 15 Mar 2003 03:09:09 -0000 1.38
+++ compiler/rtti_to_mlds.m 26 Apr 2003 09:26:15 -0000
@@ -59,7 +59,7 @@
mlds_defn_is_potentially_duplicated(MLDS_Defn) :-
MLDS_Defn = mlds__defn(EntityName, _, _, _),
EntityName = data(DataName),
- DataName = rtti(_, RttiName),
+ DataName = rtti(rtti_id(_, RttiName)),
( RttiName = type_info(_)
; RttiName = pseudo_type_info(_)
).
@@ -74,24 +74,11 @@
% Also rtti_data_to_name/3 does not handle this case.
MLDS_Defns = []
;
- %
- % Generate the name
- %
- (
- RttiData = base_typeclass_info(InstanceModule,
- ClassId, InstanceStr, _)
- ->
- RttiName = base_typeclass_info(InstanceModule,
- ClassId, InstanceStr),
- Name = data(base_typeclass_info(ClassId, InstanceStr))
- ;
- rtti_data_to_name(RttiData, RttiTypeCtor, RttiName),
- Name = data(rtti(RttiTypeCtor, RttiName))
- ),
-
+ rtti_data_to_id(RttiData, RttiId),
+ Name = data(rtti(RttiId)),
gen_init_rtti_data_defn(RttiData, ModuleInfo, Initializer,
ExtraDefns),
- rtti_entity_name_and_init_to_defn(Name, RttiName, Initializer,
+ rtti_entity_name_and_init_to_defn(Name, RttiId, Initializer,
MLDS_Defn),
MLDS_Defns = [MLDS_Defn | ExtraDefns]
).
@@ -100,14 +87,15 @@
mlds__initializer::in, mlds__defn::out) is det.
rtti_name_and_init_to_defn(RttiTypeCtor, RttiName, Initializer, MLDS_Defn) :-
- Name = data(rtti(RttiTypeCtor, RttiName)),
- rtti_entity_name_and_init_to_defn(Name, RttiName, Initializer,
+ RttiId = rtti_id(RttiTypeCtor, RttiName),
+ Name = data(rtti(RttiId)),
+ rtti_entity_name_and_init_to_defn(Name, RttiId, Initializer,
MLDS_Defn).
-:- pred rtti_entity_name_and_init_to_defn(mlds__entity_name::in, rtti_name::in,
+:- pred rtti_entity_name_and_init_to_defn(mlds__entity_name::in, rtti_id::in,
mlds__initializer::in, mlds__defn::out) is det.
-rtti_entity_name_and_init_to_defn(Name, RttiName, Initializer, MLDS_Defn) :-
+rtti_entity_name_and_init_to_defn(Name, RttiId, Initializer, MLDS_Defn) :-
%
% Generate the context
%
@@ -120,7 +108,7 @@
%
% Generate the declaration flags
%
- Exported = rtti_name_is_exported(RttiName),
+ Exported = rtti_id_is_exported(RttiId),
Flags = rtti_data_decl_flags(Exported),
% The GC never needs to trace these definitions,
@@ -132,7 +120,7 @@
% Generate the declaration body,
% i.e. the type and the initializer
%
- MLDS_Type = rtti_type(RttiName),
+ MLDS_Type = rtti_type(RttiId),
DefnBody = mlds__data(MLDS_Type, Initializer, GC_TraceCode),
MLDS_Defn = mlds__defn(Name, MLDS_Context, Flags, DefnBody).
@@ -437,7 +425,7 @@
ArgInfos = [],
ArgTypeDefns = [],
ArgTypeInit = gen_init_null_pointer(
- mlds__rtti_type(field_types(0)))
+ mlds__rtti_type(rtti_id(RttiTypeCtor, field_types(0))))
),
(
ArgNames = [_ | _],
@@ -450,7 +438,7 @@
ArgNames = [],
ArgNameDefns = [],
ArgNameInit = gen_init_null_pointer(
- mlds__rtti_type(field_names(0)))
+ mlds__rtti_type(rtti_id(RttiTypeCtor, field_names(0))))
),
(
MaybeExistInfo = yes(ExistInfo),
@@ -462,7 +450,7 @@
MaybeExistInfo = no,
ExistInfoDefns = [],
ExistInfoInit = gen_init_null_pointer(
- mlds__rtti_type(exist_info(0)))
+ mlds__rtti_type(rtti_id(RttiTypeCtor, exist_info(0))))
),
SubDefns = list__condense([ArgTypeDefns, ArgNameDefns,
ExistInfoDefns]),
@@ -642,7 +630,8 @@
gen_init_int(0),
gen_init_builtin_const("MR_SECTAG_VARIABLE"),
gen_init_null_pointer(
- mlds__rtti_type(du_stag_ordered_table(0)))
+ mlds__rtti_type(rtti_id(RttiTypeCtor,
+ du_stag_ordered_table(0))))
])],
FirstPtag = 1
; PtagList = [0 - _ | _] ->
@@ -841,20 +830,22 @@
RttiData = base_typeclass_info(InstanceModuleName, ClassId,
InstanceString, _)
->
- % rtti_data_to_name/3 does not handle this case
- SrcType = rtti_type(base_typeclass_info(InstanceModuleName,
- ClassId, InstanceString)),
+ SrcType = rtti_type(tc_rtti_id(
+ base_typeclass_info(InstanceModuleName,
+ ClassId, InstanceString))),
MLDS_ModuleName = mercury_module_name_to_mlds(
InstanceModuleName),
- MLDS_DataName = base_typeclass_info(ClassId, InstanceString),
+ MLDS_DataName = rtti(tc_rtti_id(
+ base_typeclass_info(InstanceModuleName,
+ ClassId, InstanceString))),
DataAddr = data_addr(MLDS_ModuleName, MLDS_DataName),
Rval = const(data_addr_const(DataAddr)),
Initializer = init_obj(unop(gen_cast(SrcType, DestType),
Rval))
;
- rtti_data_to_name(RttiData, RttiTypeCtor, RttiName),
- Initializer = gen_init_cast_rtti_name(DestType,
- ModuleName, RttiTypeCtor, RttiName)
+ rtti_data_to_id(RttiData, RttiId),
+ Initializer = gen_init_cast_rtti_id(DestType,
+ ModuleName, RttiId)
).
% currently casts only store the destination type
@@ -866,8 +857,18 @@
:- func gen_init_rtti_data(module_name, rtti_data) = mlds__initializer.
gen_init_rtti_data(ModuleName, RttiData) = Initializer :-
- rtti_data_to_name(RttiData, RttiTypeCtor, RttiName),
- Initializer = gen_init_rtti_name(ModuleName, RttiTypeCtor, RttiName).
+ rtti_data_to_id(RttiData, RttiId),
+ Initializer = gen_init_rtti_id(ModuleName, RttiId).
+
+ % Generate an MLDS initializer comprising just the
+ % the rval for a given rtti_id
+:- func gen_init_rtti_id(module_name, rtti_id) =
+ mlds__initializer.
+
+gen_init_rtti_id(ModuleName, rtti_id(RttiTypeCtor, RttiName)) =
+ gen_init_rtti_name(ModuleName, RttiTypeCtor, RttiName).
+gen_init_rtti_id(ModuleName, tc_rtti_id(TCRttiName)) =
+ gen_init_tc_rtti_name(ModuleName, TCRttiName).
% Generate an MLDS initializer comprising just the
% the rval for a given rtti_name
@@ -877,18 +878,32 @@
gen_init_rtti_name(ModuleName, RttiTypeCtor, RttiName) =
init_obj(gen_rtti_name(ModuleName, RttiTypeCtor, RttiName)).
+ % Generate an MLDS initializer comprising just the
+ % the rval for a given tc_rtti_name
+:- func gen_init_tc_rtti_name(module_name, tc_rtti_name) =
+ mlds__initializer.
+
+gen_init_tc_rtti_name(ModuleName, TCRttiName) =
+ init_obj(gen_tc_rtti_name(ModuleName, TCRttiName)).
+
% Generate the MLDS initializer comprising the rtti_name
% for a given rtti_name, converted to the given type.
-:- func gen_init_cast_rtti_name(mlds__type, module_name, rtti_type_ctor,
- rtti_name) = mlds__initializer.
+:- func gen_init_cast_rtti_id(mlds__type, module_name, rtti_id)
+ = mlds__initializer.
-gen_init_cast_rtti_name(DestType, ModuleName, RttiTypeCtor, RttiName) =
- Initializer :-
- SrcType = rtti_type(RttiName),
+gen_init_cast_rtti_id(DestType, ModuleName, RttiId) = Initializer :-
+ SrcType = rtti_type(RttiId),
Initializer = init_obj(unop(gen_cast(SrcType, DestType),
- gen_rtti_name(ModuleName, RttiTypeCtor, RttiName))).
+ gen_rtti_id(ModuleName, RttiId))).
+
+ % Generate the MLDS rval for an rtti_id.
+:- func gen_rtti_id(module_name, rtti_id) = mlds__rval.
+
+gen_rtti_id(ThisModuleName, rtti_id(RttiTypeCtor, RttiName)) =
+ gen_rtti_name(ThisModuleName, RttiTypeCtor, RttiName).
+gen_rtti_id(ThisModuleName, tc_rtti_id(TCRttiName)) =
+ gen_tc_rtti_name(ThisModuleName, TCRttiName).
- % Generate the MLDS rval for an rtti_name.
:- func gen_rtti_name(module_name, rtti_type_ctor, rtti_name) = mlds__rval.
gen_rtti_name(ThisModuleName, RttiTypeCtor0, RttiName) = Rval :-
@@ -931,7 +946,16 @@
)
),
MLDS_ModuleName = mercury_module_name_to_mlds(ModuleName),
- MLDS_DataName = rtti(RttiTypeCtor, RttiName),
+ MLDS_DataName = rtti(rtti_id(RttiTypeCtor, RttiName)),
+ DataAddr = data_addr(MLDS_ModuleName, MLDS_DataName),
+ Rval = const(data_addr_const(DataAddr)).
+
+:- func gen_tc_rtti_name(module_name, tc_rtti_name) = mlds__rval.
+
+gen_tc_rtti_name(_ThisModuleName, TCRttiName) = Rval :-
+ TCRttiName = base_typeclass_info(InstanceModuleName, _, _),
+ MLDS_ModuleName = mercury_module_name_to_mlds(InstanceModuleName),
+ MLDS_DataName = rtti(tc_rtti_id(TCRttiName)),
DataAddr = data_addr(MLDS_ModuleName, MLDS_DataName),
Rval = const(data_addr_const(DataAddr)).
Index: compiler/stack_layout.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/stack_layout.m,v
retrieving revision 1.79
diff -u -b -r1.79 stack_layout.m
--- compiler/stack_layout.m 30 Apr 2003 18:15:45 -0000 1.79
+++ compiler/stack_layout.m 30 Apr 2003 18:16:30 -0000
@@ -1233,39 +1233,39 @@
stack_layout__represent_live_value_type(succip, Rval, data_ptr) -->
{ RttiTypeCtor = rtti_type_ctor(unqualified(""), "succip", 0) },
- { DataAddr = rtti_addr(RttiTypeCtor, type_ctor_info) },
+ { DataAddr = rtti_addr(rtti_id(RttiTypeCtor, type_ctor_info)) },
{ Rval = const(data_addr_const(DataAddr)) }.
stack_layout__represent_live_value_type(hp, Rval, data_ptr) -->
{ RttiTypeCtor = rtti_type_ctor(unqualified(""), "hp", 0) },
- { DataAddr = rtti_addr(RttiTypeCtor, type_ctor_info) },
+ { DataAddr = rtti_addr(rtti_id(RttiTypeCtor, type_ctor_info)) },
{ Rval = const(data_addr_const(DataAddr)) }.
stack_layout__represent_live_value_type(curfr, Rval, data_ptr) -->
{ RttiTypeCtor = rtti_type_ctor(unqualified(""), "curfr", 0) },
- { DataAddr = rtti_addr(RttiTypeCtor, type_ctor_info) },
+ { DataAddr = rtti_addr(rtti_id(RttiTypeCtor, type_ctor_info)) },
{ Rval = const(data_addr_const(DataAddr)) }.
stack_layout__represent_live_value_type(maxfr, Rval, data_ptr) -->
{ RttiTypeCtor = rtti_type_ctor(unqualified(""), "maxfr", 0) },
- { DataAddr = rtti_addr(RttiTypeCtor, type_ctor_info) },
+ { DataAddr = rtti_addr(rtti_id(RttiTypeCtor, type_ctor_info)) },
{ Rval = const(data_addr_const(DataAddr)) }.
stack_layout__represent_live_value_type(redofr, Rval, data_ptr) -->
{ RttiTypeCtor = rtti_type_ctor(unqualified(""), "redofr", 0) },
- { DataAddr = rtti_addr(RttiTypeCtor, type_ctor_info) },
+ { DataAddr = rtti_addr(rtti_id(RttiTypeCtor, type_ctor_info)) },
{ Rval = const(data_addr_const(DataAddr)) }.
stack_layout__represent_live_value_type(redoip, Rval, data_ptr) -->
{ RttiTypeCtor = rtti_type_ctor(unqualified(""), "redoip", 0) },
- { DataAddr = rtti_addr(RttiTypeCtor, type_ctor_info) },
+ { DataAddr = rtti_addr(rtti_id(RttiTypeCtor, type_ctor_info)) },
{ Rval = const(data_addr_const(DataAddr)) }.
stack_layout__represent_live_value_type(trail_ptr, Rval, data_ptr) -->
{ RttiTypeCtor = rtti_type_ctor(unqualified(""), "trail_ptr", 0) },
- { DataAddr = rtti_addr(RttiTypeCtor, type_ctor_info) },
+ { DataAddr = rtti_addr(rtti_id(RttiTypeCtor, type_ctor_info)) },
{ Rval = const(data_addr_const(DataAddr)) }.
stack_layout__represent_live_value_type(ticket, Rval, data_ptr) -->
{ RttiTypeCtor = rtti_type_ctor(unqualified(""), "ticket", 0) },
- { DataAddr = rtti_addr(RttiTypeCtor, type_ctor_info) },
+ { DataAddr = rtti_addr(rtti_id(RttiTypeCtor, type_ctor_info)) },
{ Rval = const(data_addr_const(DataAddr)) }.
stack_layout__represent_live_value_type(unwanted, Rval, data_ptr) -->
{ RttiTypeCtor = rtti_type_ctor(unqualified(""), "unwanted", 0) },
- { DataAddr = rtti_addr(RttiTypeCtor, type_ctor_info) },
+ { DataAddr = rtti_addr(rtti_id(RttiTypeCtor, type_ctor_info)) },
{ Rval = const(data_addr_const(DataAddr)) }.
stack_layout__represent_live_value_type(var(_, _, Type, _), Rval, LldsType)
-->
Index: compiler/unify_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/unify_gen.m,v
retrieving revision 1.125
diff -u -b -r1.125 unify_gen.m
--- compiler/unify_gen.m 16 Mar 2003 08:01:31 -0000 1.125
+++ compiler/unify_gen.m 26 Apr 2003 01:24:37 -0000
@@ -406,7 +406,7 @@
{ error("unify_gen: type-info constant has args") }
),
{ RttiTypeCtor = rtti_type_ctor(ModuleName, TypeName, TypeArity) },
- { DataAddr = rtti_addr(RttiTypeCtor, type_ctor_info) },
+ { DataAddr = rtti_addr(rtti_id(RttiTypeCtor, type_ctor_info)) },
code_info__assign_const_to_var(Var, const(data_addr_const(DataAddr))).
unify_gen__generate_construction_2(base_typeclass_info_constant(ModuleName,
ClassId, Instance), Var, Args, _Modes, _, _, empty) -->
@@ -415,8 +415,9 @@
;
{ error("unify_gen: typeclass-info constant has args") }
),
- code_info__assign_const_to_var(Var, const(data_addr_const(data_addr(
- ModuleName, base_typeclass_info(ClassId, Instance))))).
+ code_info__assign_const_to_var(Var, const(data_addr_const(
+ rtti_addr(tc_rtti_id(base_typeclass_info(ModuleName, ClassId,
+ Instance)))))).
unify_gen__generate_construction_2(tabling_pointer_constant(PredId, ProcId),
Var, Args, _Modes, _, _, empty) -->
( { Args = [] } ->
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/error
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/lex/tests
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
Index: runtime/mercury_ho_call.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_ho_call.c,v
retrieving revision 1.60
diff -u -b -r1.60 mercury_ho_call.c
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/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
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/mmc_make
cvs diff: Diffing tests/mmc_make/lib
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
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
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