[m-dev.] diff: fix warnings in mercury_type_info.c

Fergus Henderson fjh at cs.mu.OZ.AU
Sat Dec 11 01:40:16 AEDT 1999


Estimated hours taken: 1

runtime/mercury_type_info.h:
runtime/mercury_type_info.c:
	Add `const' in various places, and add some casts,
	to avoid gcc compiler warnings.

	Make MR_get_arg_type_info() static, since it is only
	used by mercury_type_info.c.

	Also some trivial layout changes: wrap long lines, fix
	some inconsistent indentation, delete some
	unnecessary blank lines and reformat a few comments.

Workspace: /d-drive/home/hg/public/test_mercury/test_dirs/hg/mercury
Index: runtime/mercury_type_info.c
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/mercury_type_info.c,v
retrieving revision 1.26
diff -u -d -r1.26 mercury_type_info.c
--- runtime/mercury_type_info.c	1999/12/09 04:42:37	1.26
+++ runtime/mercury_type_info.c	1999/12/10 14:30:27
@@ -19,6 +19,13 @@
 
 /*---------------------------------------------------------------------------*/
 
+static Word *
+MR_get_arg_type_info(const Word *term_type_info, 
+	const Word *arg_pseudo_type_info, const Word *data_value, 
+	const Word *functor_descriptor);
+
+/*---------------------------------------------------------------------------*/
+
 	/* type_ctor_layout for `pred' */
 	/* (this is used for all higher-order types) */
 
@@ -155,7 +162,7 @@
 	** instead of on the Mercury heap.
 	*/
 Word * 
-MR_create_type_info(Word *term_type_info, Word *arg_pseudo_type_info)
+MR_create_type_info(const Word *term_type_info, const Word *arg_pseudo_type_info)
 {
 	return MR_create_type_info_maybe_existq(term_type_info, 
 		arg_pseudo_type_info, NULL, NULL);
@@ -171,9 +178,9 @@
 	** well as the functor descriptor for that functor.
 	*/
 Word * 
-MR_create_type_info_maybe_existq(Word *term_type_info, 
-	Word *arg_pseudo_type_info, Word *data_value, 
-	Word *functor_descriptor)
+MR_create_type_info_maybe_existq(const Word *term_type_info, 
+	const Word *arg_pseudo_type_info, const Word *data_value, 
+	const Word *functor_descriptor)
 {
 	int i, arity, extra_args;
 	MR_TypeCtorInfo type_ctor_info;
@@ -201,7 +208,7 @@
 
 	/* no arguments - optimise common case */
 	if ((Word) type_ctor_info == (Word) arg_pseudo_type_info) {
-		return arg_pseudo_type_info;
+		return (Word *) arg_pseudo_type_info;
 	}
 
 	if (MR_TYPE_CTOR_INFO_IS_HO(type_ctor_info)) {
@@ -243,33 +250,33 @@
 		}
 	}
 	if (type_info == NULL) {
-		return arg_pseudo_type_info;
+		return (Word *) arg_pseudo_type_info;
 	} else {
 		return type_info;
 	}
 }
 
-Word *
-MR_get_arg_type_info(Word *term_type_info, 
-	Word *arg_pseudo_type_info, Word *data_value, 
-	Word *functor_descriptor)
+static Word *
+MR_get_arg_type_info(const Word *term_type_info, 
+	const Word *arg_pseudo_type_info, const Word *data_value, 
+	const Word *functor_descriptor)
 {
 	Word *arg_type_info;
-
 	int num_univ_type_infos;
 
 	num_univ_type_infos =
 		MR_TYPEINFO_GET_TYPE_CTOR_INFO(term_type_info)->arity;
 
 	if ((Word) arg_pseudo_type_info <= num_univ_type_infos) {
-
-		/* This is a universally quantified type variable */
-
+		/*
+		** This is a universally quantified type variable
+		*/
 		arg_type_info = (Word *) 
 			term_type_info[(Word) arg_pseudo_type_info];
 	} else {
-
-		/* This is an existentially quantified type variable */
+		/*
+		** This is an existentially quantified type variable
+		*/
 
 		Word type_info_locn;
 
@@ -280,7 +287,6 @@
 				- num_univ_type_infos - 1];
 
 		if (MR_TYPE_INFO_LOCN_IS_INDIRECT(type_info_locn)) {
-
 			/*
 			** This is indirect; the type-info
 			** is inside a typeclass-info 
@@ -289,19 +295,25 @@
 			int typeinfo_number;
 			int arg_number;
 
-			typeinfo_number = MR_TYPE_INFO_LOCN_INDIRECT_GET_TYPEINFO_NUMBER(type_info_locn);
+			typeinfo_number =
+				MR_TYPE_INFO_LOCN_INDIRECT_GET_TYPEINFO_NUMBER(
+					type_info_locn);
 
-			arg_number = MR_TYPE_INFO_LOCN_INDIRECT_GET_ARG_NUMBER(type_info_locn);
+			arg_number = MR_TYPE_INFO_LOCN_INDIRECT_GET_ARG_NUMBER(
+					type_info_locn);
 
-			arg_type_info = 
-				MR_typeclass_info_type_info(
-					data_value[arg_number],
-					typeinfo_number);
+			arg_type_info = (Word *) MR_typeclass_info_type_info(
+				data_value[arg_number], typeinfo_number);
 		} else {
-			/* This is direct */
+			/*
+			** This is direct
+			*/
 
-			arg_type_info = 
-				(Word *) data_value[MR_TYPE_INFO_LOCN_DIRECT_GET_TYPEINFO_NUMBER(type_info_locn)];
+			int typeinfo_number =
+				MR_TYPE_INFO_LOCN_DIRECT_GET_TYPEINFO_NUMBER(
+					type_info_locn);
+
+			arg_type_info = (Word *) data_value[typeinfo_number];
 		}
 	}
 
@@ -525,8 +537,8 @@
 	*/
 Word *
 MR_make_type_info_maybe_existq(const Word *term_type_info, 
-	const Word *arg_pseudo_type_info, Word *data_value, 
-	Word *functor_descriptor, MR_MemoryList *allocated) 
+	const Word *arg_pseudo_type_info, const Word *data_value, 
+	const Word *functor_descriptor, MR_MemoryList *allocated) 
 {
 	int i, arity, extra_args;
 	MR_TypeCtorInfo type_ctor_info;
@@ -558,10 +570,10 @@
 
 	if (MR_TYPE_CTOR_INFO_IS_HO(type_ctor_info)) {
 		arity = MR_TYPEINFO_GET_HIGHER_ARITY(arg_pseudo_type_info);
-			extra_args = 2;
+		extra_args = 2;
 	} else {
 		arity = MR_TYPE_CTOR_INFO_GET_TYPE_ARITY(type_ctor_info);
-			extra_args = 1;
+		extra_args = 1;
 	}
 
 	/*
Index: runtime/mercury_type_info.h
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/mercury_type_info.h,v
retrieving revision 1.31
diff -u -d -r1.31 mercury_type_info.h
--- runtime/mercury_type_info.h	1999/12/09 04:42:39	1.31
+++ runtime/mercury_type_info.h	1999/12/10 14:28:48
@@ -797,9 +797,9 @@
 
 /*---------------------------------------------------------------------------*/
 
-Word * MR_create_type_info(Word *, Word *);
-Word * MR_create_type_info_maybe_existq(Word *, Word *, Word *, Word *);
-Word * MR_get_arg_type_info(Word *, Word *, Word *, Word *);
+Word * MR_create_type_info(const Word *, const Word *);
+Word * MR_create_type_info_maybe_existq(const Word *, const Word *,
+		const Word *, const Word *);
 int MR_compare_type_info(Word, Word);
 Word MR_collapse_equivalences(Word);
 
@@ -818,8 +818,8 @@
 Word * MR_make_type_info(const Word *term_type_info, 
 	const Word *arg_pseudo_type_info, MR_MemoryList *allocated);
 Word * MR_make_type_info_maybe_existq(const Word *term_type_info, 
-	const Word *arg_pseudo_type_info, Word *data_value, 
-	Word *functor_descriptor, MR_MemoryList *allocated) ;
+	const Word *arg_pseudo_type_info, const Word *data_value, 
+	const Word *functor_descriptor, MR_MemoryList *allocated) ;
 void MR_deallocate(MR_MemoryList allocated_memory_cells);
 
 /*---------------------------------------------------------------------------*/

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