cvs diff: more bug fixes for std_util.m

Tyson Richard DOWD trd at students.cs.mu.oz.au
Wed Apr 23 11:52:08 AEST 1997


Hi,

	DJ, could you review this? (anyone else is welcome to have a go).

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

Estimated hours taken: 6 (incl. debugging)

Fix some bugs in semidet C code, and more problems with --split-c-files.

library/std_util.m:
	- Don't use SUCCESS_INDICATOR in C code until the very end, as
	  it may get clobbered by restore_transient_registers() (this is
	  more conservative than we need to be, but should be less
	  error-prone for future modifications).
	- Make create_type_info an extern function, before it was
	  static, which could cause link errors with --split-c-files.
	- Move declarations of other static functions out of C header
	  code, so they will give compile errors in --split-c-files
	  rather than link errors.

Index: std_util.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/library/std_util.m,v
retrieving revision 1.77
diff -u -r1.77 std_util.m
--- std_util.m	1997/04/21 14:46:54	1.77
+++ std_util.m	1997/04/23 01:23:48
@@ -960,6 +960,7 @@
 {
 	int i;
 	ML_Construct_Info info;
+	bool success;
 
 		/* 
 		** Get information for this functor number and
@@ -968,7 +969,7 @@
 	 	** succeed.
 		*/
 	save_transient_registers();
-	SUCCESS_INDICATOR = ML_get_functors_check_range(FunctorNumber,
+	success = ML_get_functors_check_range(FunctorNumber,
 				TypeInfo, &info);
 	restore_transient_registers();
 
@@ -977,7 +978,7 @@
 		** of type_infos for arguments.
 		*/
 
-	if (SUCCESS_INDICATOR) {
+	if (success) {
 		make_aligned_string(FunctorName, (String) (Word) 
 				info.functor_name);
 		Arity = info.arity;
@@ -986,7 +987,7 @@
 				TypeInfo, info.argument_vector);
 		restore_transient_registers();
 	}
-
+	SUCCESS_INDICATOR = success;
 }
 ").
 
@@ -997,13 +998,14 @@
 		term_vector, list_arg_type_info;
 	int i;
 	ML_Construct_Info info;
+	bool success;
 
 		/* 
 		** Check range of FunctorNum, get info for this
 		** functor.
 		*/
 	save_transient_registers();
-	SUCCESS_INDICATOR = 
+	success = 
 		ML_get_functors_check_range(FunctorNumber, TypeInfo, &info) &&
 		ML_typecheck_arguments(TypeInfo, info.arity, ArgList, 
 				info.argument_vector);
@@ -1016,7 +1018,7 @@
 		** the argument vector.
 		** 
 		*/
-	if (SUCCESS_INDICATOR) {
+	if (success) {
 
 		layout_entry = MR_BASE_TYPEINFO_GET_TYPELAYOUT_ENTRY(
 			MR_TYPEINFO_GET_BASE_TYPEINFO((Word *) TypeInfo), 
@@ -1101,6 +1103,7 @@
 	        field(mktag(0), Term, UNIV_OFFSET_FOR_DATA) = (Word) new_data;
 	}
 
+	SUCCESS_INDICATOR = success;
 }
 "). 
 
@@ -1477,6 +1480,13 @@
 
 void mercury_expand(Word* type_info, Word data_word, ML_Expand_Info *info);
 
+Word * create_type_info(Word *term_type_info, 
+	Word *arg_pseudo_type_info);
+
+").
+
+:- pragma(c_code, "
+
 static void mercury_expand_const(Word data_value, Word entry_value,
 	ML_Expand_Info *info);
 static void mercury_expand_enum(Word data_value, Word entry_value, 
@@ -1487,12 +1497,6 @@
 	ML_Expand_Info *info);
 static void mercury_expand_complicated(Word data_value, Word entry_value, 
 	Word * type_info, ML_Expand_Info *info);
-static Word * create_type_info(Word *term_type_info, 
-	Word *arg_pseudo_type_info);
-
-").
-
-:- pragma(c_code, "
 
 /*
 ** Expand the given data using its type_info, find its
@@ -1994,6 +1998,7 @@
 {
 	ML_Expand_Info info;
 	Word arg_pseudo_type_info;
+	bool success;
 
 	info.need_functor = FALSE;
 	info.need_args = TRUE;
@@ -2005,8 +2010,8 @@
 	restore_transient_registers();
 
 		/* Check range */
-	SUCCESS_INDICATOR = (ArgumentIndex > 0 && ArgumentIndex <= info.arity);
-	if (SUCCESS_INDICATOR) {
+	success = (ArgumentIndex > 0 && ArgumentIndex <= info.arity);
+	if (success) {
 
 			/* Allocate enough room for a univ */
 		incr_hp(Argument, 2);
@@ -2029,6 +2034,7 @@
 
 	free(info.type_info_vector);
 
+	SUCCESS_INDICATOR = success;
 
 }").
 
-- 
       Tyson Dowd           #
                            #             Sign on refrigerator:
     trd at cs.mu.oz.au        #           Refrigerate after opening. 
http://www.cs.mu.oz.au/~trd #                  - C. J. Owen.



More information about the developers mailing list