[m-rev.] diff: fix .rt grade bug

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Feb 12 17:54:49 AEDT 2004


Estimated hours taken: 0.75
Branches: main

Fix some bugs which caused test case failures in *.rt (--reserve-tag)
grades.

runtime/mercury_tags.h:
	Define a new macro MR_GET_ENUM_VALUE, for getting the
	value of a Mercury enumeration constant.
	
runtime/mercury_wrapper.c:
trace/mercury_trace_internal.c:
	When indexing arrays by Mercury enumeration constants,
	call MR_GET_ENUM_VALUE first, in order to strip away the
	reserved tag (if any).

Workspace: /home/ceres/fjh/mercury
Index: runtime/mercury_tags.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_tags.h,v
retrieving revision 1.18
diff -u -d -r1.18 mercury_tags.h
--- runtime/mercury_tags.h	3 Feb 2004 05:40:05 -0000	1.18
+++ runtime/mercury_tags.h	12 Feb 2004 06:49:36 -0000
@@ -300,13 +300,19 @@
 		x = MR_CONVERT_C_ENUM_CONSTANT(MR_PASTE2(x, _val)), \
 		MR_PASTE2(x, _dummy) = MR_PASTE2(x, _val)
 
+	/* This is the inverse of MR_CONVERT_C_ENUM_CONSTANT */
+	#define MR_GET_ENUM_VALUE(x) \
+		MR_body((x), MR_mktag(MR_FIRST_UNRESERVED_RAW_TAG))
 #else
 
 	#define MR_CONVERT_C_ENUM_CONSTANT(x)   (x)
 
 	#define MR_DEFINE_MERCURY_ENUM_CONST(x)	x
 
+	#define MR_GET_ENUM_VALUE(x) (x)
+
 #endif
+
 
 /*
 ** For each enumeration constant defined in the runtime (not in Mercury)
Index: runtime/mercury_wrapper.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_wrapper.c,v
retrieving revision 1.130
diff -u -d -r1.130 mercury_wrapper.c
--- runtime/mercury_wrapper.c	30 Dec 2003 13:17:14 -0000	1.130
+++ runtime/mercury_wrapper.c	12 Feb 2004 06:43:28 -0000
@@ -1557,8 +1557,10 @@
 	MR_TypeCtorInfo type_ctor_info)
 {
 	int	i;
-
-	type_stat->type_ctor_reps[MR_type_ctor_rep(type_ctor_info)]++;
+	MR_TypeCtorRep rep;
+	
+	rep = MR_type_ctor_rep(type_ctor_info);
+	type_stat->type_ctor_reps[MR_GET_ENUM_VALUE(rep)]++;
 
 	for (i = 0; i < type_stat->type_ctor_name_next; i++) {
 		/*
@@ -1587,8 +1589,7 @@
 		type_ctor_info->type_ctor_module_name;
 	type_stat->type_ctor_names[i].type_stat_name =
 		type_ctor_info->type_ctor_name;
-	type_stat->type_ctor_names[i].type_stat_ctor_rep =
-		MR_type_ctor_rep(type_ctor_info);
+	type_stat->type_ctor_names[i].type_stat_ctor_rep = rep;
 	type_stat->type_ctor_names[i].type_stat_count = 1;
 	type_stat->type_ctor_name_next++;
 }
@@ -1628,8 +1629,8 @@
 		fprintf(fp, "%s %s %s %s %ld\n", op,
 			type_stat->type_ctor_names[i].type_stat_module,
 			type_stat->type_ctor_names[i].type_stat_name,
-			MR_ctor_rep_name[type_stat->
-				type_ctor_names[i].type_stat_ctor_rep],
+			MR_ctor_rep_name[MR_GET_ENUM_VALUE(type_stat->
+				type_ctor_names[i].type_stat_ctor_rep)],
 			type_stat->type_ctor_names[i].type_stat_count);
 	}
 }
Index: trace/mercury_trace_internal.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.166
diff -u -d -r1.166 mercury_trace_internal.c
--- trace/mercury_trace_internal.c	26 Jan 2004 21:17:47 -0000	1.166
+++ trace/mercury_trace_internal.c	12 Feb 2004 06:52:10 -0000
@@ -4751,7 +4751,8 @@
 	
 	rep = MR_type_ctor_rep(type_ctor_info);
 	if (print_rep) {
-		fprintf(fp, ": %s\n", MR_ctor_rep_name[rep]);
+		fprintf(fp, ": %s\n",
+			MR_ctor_rep_name[MR_GET_ENUM_VALUE(rep)]);
 	} else {
 		fprintf(fp, "\n");
 	}

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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