diff: don't uses spaces in mangled typeclass names

David Glen JEFFERY dgj at cs.mu.OZ.AU
Wed Aug 5 10:13:54 AEST 1998


Hi,

Can you please review this, Zoltan?

----------------------------------------------------------------------------


Estimated hours taken: 1

compiler/check_typeclas.m:
	Make the mangled name we choose for introduced instance method preds
	a little nicer: remove all spaces and colons, replacing them with
	underscores. This makes the names that end up in the C code much nicer
	since they don't need to use character codes.
compiler/hlds_out.m:
	Check for the new form of mangled name.


cvs diff: Diffing .
Index: check_typeclass.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/check_typeclass.m,v
retrieving revision 1.14
diff -u -t -r1.14 check_typeclass.m
--- check_typeclass.m	1998/08/04 06:44:11	1.14
+++ check_typeclass.m	1998/08/04 23:34:45
@@ -507,23 +507,25 @@
         sym_name).
 :- mode make_introduced_pred_name(in, in, in, in, out) is det.
 
-make_introduced_pred_name(ClassId, MethodName, _PredArity, 
+make_introduced_pred_name(ClassId, MethodName, PredArity, 
                 InstanceTypes, PredName) :-
         ClassId = class_id(ClassName, _ClassArity),
-        prog_out__sym_name_to_string(ClassName, ClassNameString),
-        prog_out__sym_name_to_string(MethodName, MethodNameString),
+        prog_out__sym_name_to_string(ClassName, "__", ClassNameString),
+        prog_out__sym_name_to_string(MethodName, "__", MethodNameString),
                 % Perhaps we should include the pred arity in this mangled
                 % string?
-        % string__int_to_string(PredArity, PredArityString),
+        string__int_to_string(PredArity, PredArityString),
         base_typeclass_info__make_instance_string(InstanceTypes, 
                 InstanceString),
         string__append_list(
-                ["Introduced predicate for ",
+                ["Introduced_pred_for_",
                 ClassNameString,
-                "(",
+                "_",
                 InstanceString,
-                ") method ",
-                MethodNameString
+                "____",
+                MethodNameString,
+                "_",
+                PredArityString
                 ], 
                 PredNameString),
         PredName = unqualified(PredNameString).
Index: hlds_out.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/hlds_out.m,v
retrieving revision 1.198
diff -u -t -r1.198 hlds_out.m
--- hlds_out.m	1998/08/04 06:44:13	1.198
+++ hlds_out.m	1998/08/04 08:55:45
@@ -262,7 +262,7 @@
                 ;
                         { error("special_pred_get_type failed!") }
                 )
-        ; { string__prefix(Name, "Introduced predicate for ") } ->
+        ; { string__prefix(Name, "Introduced_pred_for_") } ->
                 io__write_string("type class method implementation")
         ;
                 hlds_out__write_pred_or_func(PredOrFunc),

----------------------------------------------------------------------------


love and cuddles,
dgj
-- 
David Jeffery (dgj at cs.mu.oz.au) |  Marge: Did you just call everyone "chicken"?
PhD student,                    |  Homer: Noooo.  I swear on this Bible!
Department of Computer Science  |  Marge: That's not a Bible; that's a book of
University of Melbourne         |         carpet samples!
Australia                       |  Homer: Ooooh... Fuzzy.



More information about the developers mailing list