[m-rev.] diff: fix foreign type unify/compare

Simon Taylor stayl at cs.mu.OZ.AU
Mon Feb 17 00:25:14 AEDT 2003


Estimated hours taken: 0.1
Branches: main

runtime/mercury_unify_compare_body.h:
	Implement user-defined unification and comparison for foreign
	types. Without this change tests/hard_coded/user_compare fails
	in debugging grades.

Index: mercury_unify_compare_body.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_unify_compare_body.h,v
retrieving revision 1.29
diff -u -u -r1.29 mercury_unify_compare_body.h
--- mercury_unify_compare_body.h	11 Feb 2003 06:31:49 -0000	1.29
+++ mercury_unify_compare_body.h	15 Feb 2003 07:08:56 -0000
@@ -36,12 +36,12 @@
 ** because they implement the same task.
 **
 ** We need separate C functions for unifications and comparison because
-** with --no-special-preds, a type with user-defined equality has an
-** a non-NULL unify_pred field in its type_ctor_info but a NULL compare_pred
-** field. While in principle unification is a special case of comparison,
-** we cannot implement unifications by comparisons for such types:
-** they support unifications but not comparisons. Since we cannot do it
-** for such types, it is simplest not to do it for any types.
+** with --no-special-preds, a type with user-defined equality (but not
+** comparison) has a non-NULL unify_pred field in its type_ctor_info but a
+** NULL compare_pred field. While in principle unification is a special case
+** of comparison, we cannot implement unifications by comparisons for such
+** types: they support unifications but not comparisons. Since we cannot do
+** it for such types, it is simplest not to do it for any types.
 */
 #ifdef  select_compare_code
   #if defined(MR_DEEP_PROFILING) && defined(entry_point_is_mercury)
@@ -144,6 +144,12 @@
   #endif
 
   #ifdef include_compare_rep_code
+        case MR_TYPECTOR_REP_FOREIGN:
+            MR_fatal_error("sorry, not implemented: "
+                "compare_representation for foreign types");
+  #endif
+
+  #ifdef include_compare_rep_code
         case MR_TYPECTOR_REP_DU_USEREQ:
             /* fall through */
   #endif
@@ -384,6 +390,7 @@
         case MR_TYPECTOR_REP_NOTAG_USEREQ:
         case MR_TYPECTOR_REP_NOTAG_GROUND_USEREQ:
         case MR_TYPECTOR_REP_ARRAY:
+        case MR_TYPECTOR_REP_FOREIGN:
 
             /*
             ** We call the type-specific compare routine as
@@ -670,9 +677,6 @@
 
         case MR_TYPECTOR_REP_BASETYPECLASSINFO:
             MR_fatal_error(attempt_msg "base_typeclass_infos");
-
-        case MR_TYPECTOR_REP_FOREIGN:
-            MR_fatal_error(attempt_msg "terms of a foreign type");
 
         case MR_TYPECTOR_REP_REFERENCE:
 #ifdef  select_compare_code
--------------------------------------------------------------------------
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