[m-dev.] for review: make base_typeclass_info self-describing

David Glen JEFFERY dgj at hydra.cs.mu.oz.au
Wed Jan 12 18:29:16 AEDT 2000


This one's for zs too.

===================================================================

Estimated hours taken: 0.25

Include the number of typeclass methods in the base_typeclass_info
structure, making the structure self-describing. This information
is not used at the moment, but may be useful.

compiler/base_typeclass_info.m:
	Add the new information.
compiler/polymorphism.m:
	Update the documentation.
runtime/mercury_type_info.h:
	Update and add macros for the new structure.

===================================================================
Index: compiler/base_typeclass_info.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/base_typeclass_info.m,v
retrieving revision 1.16
diff -u -t -r1.16 base_typeclass_info.m
--- compiler/base_typeclass_info.m	1999/12/09 17:17:43	1.16
+++ compiler/base_typeclass_info.m	2000/01/12 06:06:13
@@ -131,7 +131,10 @@
                 PredAddrArgs),
         base_typeclass_info__gen_superclass_count(ClassId, ModuleInfo,
                         SuperClassCount, ClassArity),
-        Rvals = [ ArityArg, SuperClassCount, ClassArity | PredAddrArgs ].
+        list__length(PredAddrArgs, NumMethods),
+        NumMethodsArg = yes(const(int_const(NumMethods))),
+        Rvals = [ ArityArg, SuperClassCount, ClassArity, NumMethods 
+                        | PredAddrArgs ].
 
 :- pred base_typeclass_info__construct_pred_addrs(list(pred_proc_id),
         module_info, list(maybe(rval))).
Index: compiler/polymorphism.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/polymorphism.m,v
retrieving revision 1.179
diff -u -t -r1.179 polymorphism.m
--- compiler/polymorphism.m	2000/01/10 05:55:37	1.179
+++ compiler/polymorphism.m	2000/01/12 07:23:47
@@ -174,9 +174,10 @@
 %                 * the number of constraints on the typeclass decl. (`m')
 %                 * the number of parameters (type variables) from 
 %                        the typeclass decl. (`n')
-%                 * pointer to first method
+%                 * the number of constraints on the typeclass decl. (`p')
+%                 * pointer to method #1
 %                   ...
-%                 * pointer to last method
+%                 * pointer to method #p
 %
 %               The typeclass_info contains:
 %                 * a pointer to the base typeclass info
Index: runtime/mercury_type_info.h
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/mercury_type_info.h,v
retrieving revision 1.35
diff -u -t -r1.35 mercury_type_info.h
--- runtime/mercury_type_info.h	2000/01/11 00:10:16	1.35
+++ runtime/mercury_type_info.h	2000/01/12 06:08:41
@@ -742,8 +742,10 @@
         ((Integer)(*(Word **)(tci))[1])
 #define MR_typeclass_info_num_type_infos(tci) \
         ((Integer)(*(Word **)(tci))[2])
+#define MR_typeclass_info_num_methods(tci) \
+        ((Integer)(*(Word **)(tci))[3])
 #define MR_typeclass_info_class_method(tci, n) \
-        ((Code *)(*(Word **)tci)[(n+2)])
+        ((Code *)(*(Word **)tci)[(n+3)])
 #define MR_typeclass_info_arg_typeclass_info(tci, n) \
         (((Word *)(tci))[(n)])
 


dgj
-- 
David Jeffery (dgj at cs.mu.oz.au) | If your thesis is utterly vacuous
PhD student,                    | Use first-order predicate calculus.
Dept. of Comp. Sci. & Soft. Eng.|     With sufficient formality
The University of Melbourne     |     The sheerist banality
Australia                       | Will be hailed by the critics: "Miraculous!"
                                |     -- Anon.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list