[m-rev.] diff: almost last step in MC++ to C# transition

Peter Ross pro at missioncriticalit.com
Sat Nov 15 03:05:30 AEDT 2003


Hi,

Fergus have you got any ideas about the best approach to replace
MR_DEFINE_BUILTIN_TYPE_CTOR_INFO in C#?  Feel free to implement them, if
you do ;).

My first instinct is to go the approach mentioned by pjm and factor out
all this code into one place, and then automatically generate it for
each of the relevant backends.

Once that is done the standard library will then be written totally in C#.

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


Estimated hours taken: 3
Branches: main

Convert the last of the code in the library from MC++ to C#.
However the RTTI datastructures for the builtin types are still defined
in MC++, for the moment.

compiler/mlds_to_il.m:
	Change the mangling so that for the names that need mangling
	that aren't RTTI types we look for them in the C# module.
	
library/builtin.m:
library/private_builtin.m:
library/type_desc.m:
	Convert all the code from MC++ to C#, and mark that the
	MR_DEFINE_BUILTIN_TYPE_CTOR_INFO macros need to be rewritten in
	Mercury.


Index: compiler/mlds_to_il.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_il.m,v
retrieving revision 1.133
diff -u -r1.133 mlds_to_il.m
--- compiler/mlds_to_il.m	24 Oct 2003 11:31:52 -0000	1.133
+++ compiler/mlds_to_il.m	14 Nov 2003 15:57:59 -0000
@@ -3274,7 +3274,7 @@
 	% either a compiler-generated static,
 	% or possibly a handwritten RTTI reference or a
 	% reference to some hand-written code in the
-	% modulename__cpp_code class.
+	% modulename__csharp_code.mercury_code class.
 
 :- func make_static_fieldref(il_data_rep, mlds__var, mlds__type)
 	 = fieldref.
@@ -3345,7 +3345,7 @@
 :- mode mangle_dataname_module(in, in, out) is det.
 
 mangle_dataname_module(no, ModuleName0, ModuleName) :-
-	mangle_foreign_code_module(ModuleName0, managed_cplusplus, ModuleName).
+	mangle_foreign_code_module(ModuleName0, csharp, ModuleName).
 
 mangle_dataname_module(yes(DataName), ModuleName0, ModuleName) :-
 	(
Index: library/builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/builtin.m,v
retrieving revision 1.94
diff -u -r1.94 builtin.m
--- library/builtin.m	14 Nov 2003 12:39:42 -0000	1.94
+++ library/builtin.m	14 Nov 2003 15:58:01 -0000
@@ -457,38 +457,31 @@
 call_rtti_generic_compare(Res, X, Y) :-
 	rtti_implementation__generic_compare(Res, X, Y).
 
-:- pragma foreign_decl("MC++", "
-#using ""builtin__csharp_code.dll""
-").
-:- pragma foreign_code("MC++", "
+:- pragma foreign_code("C#", "
 
-static void compare_3(MR_TypeInfo TypeInfo_for_T,
-		MR_Ref(MR_ComparisonResult) Res, 
-		MR_Box X, MR_Box Y) 
+public static void compare_3(object[] TypeInfo_for_T,
+		ref object[] Res, object X, object Y) 
 {
-	mercury::builtin::mercury_code::call_rtti_generic_compare_3(
-			TypeInfo_for_T, Res, X, Y);
+	mercury.builtin.mercury_code.call_rtti_generic_compare_3(
+			TypeInfo_for_T, ref Res, X, Y);
 }
 
-static void compare_3_m1(MR_TypeInfo TypeInfo_for_T,
-		MR_Ref(MR_ComparisonResult) Res, 
-		MR_Box X, MR_Box Y) 
+public static void compare_3_m1(object[] TypeInfo_for_T,
+		ref object[] Res, object X, object Y) 
 {
-	compare_3(TypeInfo_for_T, Res, X, Y);
+	compare_3(TypeInfo_for_T, ref Res, X, Y);
 }
 
-static void compare_3_m2(MR_TypeInfo TypeInfo_for_T,
-		MR_Ref(MR_ComparisonResult) Res, 
-		MR_Box X, MR_Box Y) 
+public static void compare_3_m2(object[] TypeInfo_for_T,
+		ref object[] Res, object X, object Y) 
 {
-	compare_3(TypeInfo_for_T, Res, X, Y);
+	compare_3(TypeInfo_for_T, ref Res, X, Y);
 }
 
-static void compare_3_m3(MR_TypeInfo TypeInfo_for_T,
-		MR_Ref(MR_ComparisonResult) Res, 
-		MR_Box X, MR_Box Y) 
+public static void compare_3_m3(object[] TypeInfo_for_T,
+		ref object[] Res, object X, object Y) 
 {
-	compare_3(TypeInfo_for_T, Res, X, Y);
+	compare_3(TypeInfo_for_T, ref Res, X, Y);
 }
 ").
 
@@ -547,18 +540,18 @@
 
 ").
 
-:- pragma foreign_code("MC++", "
+:- pragma foreign_code("C#", "
 
-static MR_bool unify_2_p(MR_TypeInfo ti, MR_Box X, MR_Box Y) 
+public static bool unify_2_p(object[] ti, object X, object Y) 
 {
-	return mercury::builtin::mercury_code::call_rtti_generic_unify_2_p(
+	return mercury.builtin.mercury_code.call_rtti_generic_unify_2_p(
 			ti, X, Y);
 }
 
 ").
 
 :- pragma foreign_code("MC++", "
-	
+
 MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(builtin, int, 0, MR_TYPECTOR_REP_INT) 
 MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(builtin, character, 0, MR_TYPECTOR_REP_CHAR) 
 MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(builtin, string, 0, MR_TYPECTOR_REP_STRING) 
@@ -570,155 +563,215 @@
 MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(builtin, pred, 0, MR_TYPECTOR_REP_PRED) 
 MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(builtin, tuple, 0, MR_TYPECTOR_REP_TUPLE) 
 
-static MR_bool
-__Unify____int_0_0(MR_Integer x, MR_Integer y)
+").
+:- pragma foreign_code("C#", "
+	
+/* XXX these macros need to be defined in C#
+// MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(builtin, int, 0, MR_TYPECTOR_REP_INT) 
+public static object[] __type_ctor_info_int_0;
+public static object[] builtin__type_ctor_info_int_0;
+
+// MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(builtin, character, 0, MR_TYPECTOR_REP_CHAR) 
+public static object[] __type_ctor_info_character_0;
+public static object[] builtin__type_ctor_info_character_0;
+
+// MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(builtin, string, 0, MR_TYPECTOR_REP_STRING) 
+public static object[] __type_ctor_info_string_0;
+public static object[] builtin__type_ctor_info_string_0;
+
+// MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(builtin, c_pointer, 0,
+// 						MR_TYPECTOR_REP_C_POINTER) 
+public static object[] __type_ctor_info_c_pointer_0;
+public static object[] builtin__type_ctor_info_c_pointer_0;
+
+// MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(builtin, void, 0, MR_TYPECTOR_REP_VOID) 
+public static object[] __type_ctor_info_void_0;
+public static object[] builtin__type_ctor_info_void_0;
+
+// MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(builtin, float, 0, MR_TYPECTOR_REP_FLOAT) 
+public static object[] __type_ctor_info_float_0;
+public static object[] builtin__type_ctor_info_float_0;
+
+// MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(builtin, func, 0, MR_TYPECTOR_REP_FUNC) 
+public static object[] __type_ctor_info_func_0;
+public static object[] builtin__type_ctor_info_func_0;
+
+// MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(builtin, pred, 0, MR_TYPECTOR_REP_PRED) 
+public static object[] __type_ctor_info_pred_0;
+public static object[] builtin__type_ctor_info_pred_0;
+
+// MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(builtin, tuple, 0, MR_TYPECTOR_REP_TUPLE) 
+public static object[] __type_ctor_info_tuple_0;
+public static object[] builtin__type_ctor_info_tuple_0;
+*/
+
+public static bool
+__Unify____int_0_0(int x, int y)
 {
 	return x == y;
 }
 
-static MR_bool
-__Unify____string_0_0(MR_String x, MR_String y)
+public static bool
+__Unify____string_0_0(string x, string y)
 {
-	return System::String::Equals(x, y);
+	return System.String.Equals(x, y);
 }
 
-static MR_bool
-__Unify____character_0_0(MR_Char x, MR_Char y)
+public static bool
+__Unify____character_0_0(char x, char y)
 {
 	return x == y;
 }
 
-static MR_bool
-__Unify____float_0_0(MR_Float x, MR_Float y)
+public static bool
+__Unify____float_0_0(double x, double y)
 {
 	return x == y;
 }
 
-static MR_bool
-__Unify____void_0_0(MR_Word x, MR_Word y)
+public static bool
+__Unify____void_0_0(object[] x, object[] y)
 {
-	mercury::runtime::Errors::fatal_error(
-		S""called unify for type `void'"");
-	return 0;
+	mercury.runtime.Errors.fatal_error(
+		""called unify for type `void'"");
+	return false;
 }
 
-static MR_bool
-__Unify____c_pointer_0_0(MR_Word x, MR_Word y)
+public static bool
+__Unify____c_pointer_0_0(object[] x, object[] y)
 {
-	mercury::runtime::Errors::fatal_error(
-		S""called unify for type `c_pointer'"");
-	return 0;
+	mercury.runtime.Errors.fatal_error(
+		""called unify for type `c_pointer'"");
+	return false;
 }
 
-static MR_bool
-__Unify____func_0_0(MR_Word x, MR_Word y)
+public static bool
+__Unify____func_0_0(object[] x, object[] y)
 {
-	mercury::runtime::Errors::fatal_error(
-		S""called unify for `func' type"");
-	return 0;
+	mercury.runtime.Errors.fatal_error(
+		""called unify for `func' type"");
+	return false;
 }
 
-static MR_bool
-__Unify____pred_0_0(MR_Word x, MR_Word y)
+public static bool
+__Unify____pred_0_0(object[] x, object[] y)
 {
-	mercury::runtime::Errors::fatal_error(
-		S""called unify for `pred' type"");
-	return 0;
+	mercury.runtime.Errors.fatal_error(
+		""called unify for `pred' type"");
+	return false;
 }
 
-static MR_bool
-__Unify____tuple_0_0(MR_Word x, MR_Word y)
+public static bool
+__Unify____tuple_0_0(object[] x, object[] y)
 {
-	mercury::runtime::Errors::fatal_error(
-		S""called unify for `tuple' type"");
-	return 0;
+	mercury.runtime.Errors.fatal_error(
+		""called unify for `tuple' type"");
+	return false;
 }
 
-static void
-__Compare____int_0_0(
-	MR_Word_Ref result, MR_Integer x, MR_Integer y)
+public static void
+__Compare____int_0_0(ref object[] result, int x, int y)
 {
-		MR_COMPARE_LESS);
-	MR_newenum(*result, r);
+	int r;
+	if (x > y) {
+		r = 2;
+	} else if (x == y) {
+		r = 0;
+	} else {
+		r = 1;
+	}
+	result = mercury.runtime.LowLevelData.make_enum(r);
 }
 
-static void
-__Compare____float_0_0(
-	MR_Word_Ref result, MR_Float x, MR_Float y)
+public static void
+__Compare____float_0_0(ref object[] result, double x, double y)
 {
-		(mercury::runtime::Errors::fatal_error(
-			S""incomparable floats in compare/3""),
-			MR_COMPARE_EQUAL)); 
-	MR_newenum(*result, r);
+	int r;
+	if (x > y) {
+		r = 2;
+	} else if (x == y) {
+		r = 0;
+	} else if (x < y) {
+		r = 1;
+	} else {
+		mercury.runtime.Errors.fatal_error(
+			""incomparable floats in compare/3"");
+		r = -1;
+	}
+	result = mercury.runtime.LowLevelData.make_enum(r);
 }
 
 
-static void
-__Compare____string_0_0(MR_Word_Ref result,
-	MR_String x, MR_String y)
+public static void
+__Compare____string_0_0(ref object[] result, string x, string y)
 {
-	int res = System::String::Compare(x, y);
-		MR_COMPARE_LESS);
-	MR_newenum(*result, r);
+	int r;
+	int res = System.String.Compare(x, y);
+	if (res > 0) {
+		r = 2;
+	} else if (res == 0) {
+		r = 0;
+	} else {
+		r = 1;
+	}
+	result = mercury.runtime.LowLevelData.make_enum(r);
 }
 
-static void
+public static void
 __Compare____character_0_0(
-	MR_Word_Ref result, MR_Char x, MR_Char y)
+	ref object[] result, char x, char y)
 {
-		MR_COMPARE_LESS);
-	MR_newenum(*result, r);
+	int r;
+	if (x > y) {
+		r = 2;
+	} else if (x == y) {
+		r = 0;
+	} else {
+		r = 1;
+	}
+	result = mercury.runtime.LowLevelData.make_enum(r);
 }
 
-static void
-__Compare____void_0_0(MR_Word_Ref result,
-	MR_Word x, MR_Word y)
+public static void
+__Compare____void_0_0(ref object[] result,
+	object[] x, object[] y)
 {
-	mercury::runtime::Errors::fatal_error(
-		S""called compare/3 for type `void'"");
+	mercury.runtime.Errors.fatal_error(
+		""called compare/3 for type `void'"");
 }
 
-static void
+public static void
 __Compare____c_pointer_0_0(
-	MR_Word_Ref result, MR_Word x, MR_Word y)
+	ref object[] result, object[] x, object[] y)
 {
-	mercury::runtime::Errors::fatal_error(
-		S""called compare/3 for type `c_pointer'"");
+	mercury.runtime.Errors.fatal_error(
+		""called compare/3 for type `c_pointer'"");
 }
 
-static void
-__Compare____func_0_0(MR_Word_Ref result,
-	MR_Word x, MR_Word y)
+public static void
+__Compare____func_0_0(ref object[] result,
+	object[] x, object[] y)
 {
-	mercury::runtime::Errors::fatal_error(
-		S""called compare/3 for `func' type"");
+	mercury.runtime.Errors.fatal_error(
+		""called compare/3 for `func' type"");
 }
 
-static void
-__Compare____pred_0_0(MR_Word_Ref result,
-	MR_Word x, MR_Word y)
+public static void
+__Compare____pred_0_0(ref object[] result,
+	object[] x, object[] y)
 {
-	mercury::runtime::Errors::fatal_error(
-		S""called compare/3 for `pred' type"");
+	mercury.runtime.Errors.fatal_error(
+		""called compare/3 for `pred' type"");
 }
 
-static void
-__Compare____tuple_0_0(MR_Word_Ref result,
-	MR_Word x, MR_Word y)
+public static void
+__Compare____tuple_0_0(ref object[] result,
+	object[] x, object[] y)
 {
-	mercury::runtime::Errors::fatal_error(
-		S""called compare/3 for `pred' type"");
+	mercury.runtime.Errors.fatal_error(
+		""called compare/3 for `pred' type"");
 }
 
 /*
@@ -726,76 +779,72 @@
 ** These are just wrappers which call the unboxed version.
 */
 
-static MR_bool
-do_unify__int_0_0(MR_Box x, MR_Box y)
+public static bool
+do_unify__int_0_0(object x, object y)
 {
-	return mercury::builtin__cpp_code::mercury_code::__Unify____int_0_0(
-		System::Convert::ToInt32(x), 
-		System::Convert::ToInt32(y)); 
+	return __Unify____int_0_0(
+		System.Convert.ToInt32(x), 
+		System.Convert.ToInt32(y)); 
 }
 
-static MR_bool
-do_unify__string_0_0(MR_Box x, MR_Box y)
+public static bool
+do_unify__string_0_0(object x, object y)
 {
-	return mercury::builtin__cpp_code::mercury_code::__Unify____string_0_0(
-		dynamic_cast<MR_String>(x), 
-		dynamic_cast<MR_String>(y));
+	return __Unify____string_0_0((string) x, (string) y);
 }
 
-static MR_bool
-do_unify__float_0_0(MR_Box x, MR_Box y)
+public static bool
+do_unify__float_0_0(object x, object y)
 {
-	return mercury::builtin__cpp_code::mercury_code::__Unify____float_0_0(
-		System::Convert::ToDouble(x), 
-		System::Convert::ToDouble(y)); 
+	return __Unify____float_0_0(
+		System.Convert.ToDouble(x), 
+		System.Convert.ToDouble(y)); 
 }
 
-static MR_bool
-do_unify__character_0_0(MR_Box x, MR_Box y)
+public static bool
+do_unify__character_0_0(object x, object y)
 {
-	return mercury::builtin__cpp_code::mercury_code::__Unify____character_0_0(
-		System::Convert::ToChar(x), 
-		System::Convert::ToChar(y)); 
+	return __Unify____character_0_0(
+		System.Convert.ToChar(x), 
+		System.Convert.ToChar(y)); 
 }
 
-static MR_bool
-do_unify__void_0_0(MR_Box x, MR_Box y)
+public static bool
+do_unify__void_0_0(object x, object y)
 {
-	mercury::runtime::Errors::fatal_error(
-		S""called unify for type `void'"");
-	return 0;
+	mercury.runtime.Errors.fatal_error(
+		""called unify for type `void'"");
+	return false;
 }
 
-static MR_bool
-do_unify__c_pointer_0_0(MR_Box x, MR_Box y)
+public static bool
+do_unify__c_pointer_0_0(object x, object y)
 {
-	return mercury::builtin__cpp_code::mercury_code::__Unify____c_pointer_0_0(
-		dynamic_cast<MR_Word>(x), 
-		dynamic_cast<MR_Word>(y)); 
+	return __Unify____c_pointer_0_0((object[]) x, (object[]) y); 
 }
 
-static MR_bool
-do_unify__func_0_0(MR_Box x, MR_Box y)
+public static bool
+do_unify__func_0_0(object x, object y)
 {
-	mercury::runtime::Errors::fatal_error(
-		S""called unify for `func' type"");
-	return 0;
+	mercury.runtime.Errors.fatal_error(
+		""called unify for `func' type"");
+	return false;
 }
 
-static MR_bool
-do_unify__pred_0_0(MR_Box x, MR_Box y)
+public static bool
+do_unify__pred_0_0(object x, object y)
 {
-	mercury::runtime::Errors::fatal_error(
-		S""called unify for `pred' type"");
-	return 0;
+	mercury.runtime.Errors.fatal_error(
+		""called unify for `pred' type"");
+	return false;
 }
 
-static MR_bool
-do_unify__tuple_0_0(MR_Box x, MR_Box y)
+public static bool
+do_unify__tuple_0_0(object x, object y)
 {
-	mercury::runtime::Errors::fatal_error(
-		S""called unify for `tuple' type"");
-	return 0;
+	mercury.runtime.Errors.fatal_error(
+		""called unify for `tuple' type"");
+	return false;
 }
 
 /*
@@ -803,76 +852,70 @@
 ** These are just wrappers which call the unboxed version.
 */
 
-static void
-do_compare__int_0_0(MR_Word_Ref result, MR_Box x, MR_Box y)
+public static void
+do_compare__int_0_0(ref object[] result, object x, object y)
 {
-	mercury::builtin__cpp_code::mercury_code::__Compare____int_0_0(result,
-		System::Convert::ToInt32(x), 
-		System::Convert::ToInt32(y)); 
+	__Compare____int_0_0(ref result,
+		System.Convert.ToInt32(x), 
+		System.Convert.ToInt32(y)); 
 }
 
-static void
-do_compare__string_0_0(MR_Word_Ref result, MR_Box x, MR_Box y)
+public static void
+do_compare__string_0_0(ref object[] result, object x, object y)
 {
-	mercury::builtin__cpp_code::mercury_code::__Compare____string_0_0(result,
-		dynamic_cast<MR_String>(x),
-		dynamic_cast<MR_String>(y));
+	__Compare____string_0_0(ref result, (string) x, (string) y);
 }
 
-static void
-do_compare__float_0_0(MR_Word_Ref result, MR_Box x, MR_Box y)
+public static void
+do_compare__float_0_0(ref object[] result, object x, object y)
 {
-	mercury::builtin__cpp_code::mercury_code::__Compare____float_0_0(result,
-		System::Convert::ToDouble(x), 
-		System::Convert::ToDouble(y)); 
+	__Compare____float_0_0(ref result,
+		System.Convert.ToDouble(x), 
+		System.Convert.ToDouble(y)); 
 }
 
-static void
+public static void
 do_compare__character_0_0(
-	MR_Word_Ref result, MR_Box x, MR_Box y)
+	ref object[] result, object x, object y)
 {
-	mercury::builtin__cpp_code::mercury_code::__Compare____character_0_0(
-		result, 
-		System::Convert::ToChar(x), 
-		System::Convert::ToChar(y)); 
+	__Compare____character_0_0(ref result, 
+		System.Convert.ToChar(x), 
+		System.Convert.ToChar(y)); 
 }
 
-static void
-do_compare__void_0_0(MR_Word_Ref result, MR_Box x, MR_Box y)
+public static void
+do_compare__void_0_0(ref object[] result, object x, object y)
 {
-	mercury::runtime::Errors::fatal_error(
-		S""called compare/3 for type `void'"");
+	mercury.runtime.Errors.fatal_error(
+		""called compare/3 for type `void'"");
 }
 
-static void
+public static void
 do_compare__c_pointer_0_0(
-	MR_Word_Ref result, MR_Box x, MR_Box y)
+	ref object[] result, object x, object y)
 {
-	mercury::builtin__cpp_code::mercury_code::__Compare____c_pointer_0_0(
-		result, 
-		dynamic_cast<MR_Word>(x),
-		dynamic_cast<MR_Word>(y));
+	__Compare____c_pointer_0_0(ref result, (object[]) x, (object[]) y);
 }
 
-static void
-do_compare__func_0_0(MR_Word_Ref result, MR_Box x, MR_Box y)
+public static void
+do_compare__func_0_0(ref object[] result, object x, object y)
 {
-	mercury::runtime::Errors::fatal_error(
-		S""called compare/3 for func type"");
+	mercury.runtime.Errors.fatal_error(
+		""called compare/3 for func type"");
 }
 
-static void
-do_compare__pred_0_0(MR_Word_Ref result, MR_Box x, MR_Box y)
+public static void
+do_compare__pred_0_0(ref object[] result, object x, object y)
 {
-	mercury::runtime::Errors::fatal_error(
-		S""called compare/3 for pred type"");
+	mercury.runtime.Errors.fatal_error(
+		""called compare/3 for pred type"");
 }
 
-static void
-do_compare__tuple_0_0(MR_Word_Ref result, MR_Box x, MR_Box y)
+public static void
+do_compare__tuple_0_0(ref object[] result, object x, object y)
 {
-	mercury::runtime::Errors::fatal_error(
-		S""called compare/3 for tuple type"");
+	mercury.runtime.Errors.fatal_error(
+		""called compare/3 for tuple type"");
 }
 
 ").
Index: library/private_builtin.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/private_builtin.m,v
retrieving revision 1.128
diff -u -r1.128 private_builtin.m
--- library/private_builtin.m	13 Nov 2003 15:08:12 -0000	1.128
+++ library/private_builtin.m	14 Nov 2003 15:58:01 -0000
@@ -105,6 +105,16 @@
 :- implementation.
 :- import_module require, string, std_util, int, float, char, string, list.
 
+:- pragma foreign_code("C#", "
+
+// The dummy_var is used to represent io__states and other Mercury
+// parameters that are not really passed around.  Occasionally a dummy variable
+// will be used by the code generator as an lval, so we use
+// private_builtin:dummy_var as that lval.
+
+public static object[] dummy_var;
+
+").
 :- pragma foreign_code("MC++", "
 
 // The dummy_var is used to represent io__states and other Mercury
@@ -343,39 +353,38 @@
 
 	% The definitions for type_ctor_info/1 and type_info/1.
 
-:- pragma foreign_code("MC++", "
+:- pragma foreign_code("C#", "
 
-static MR_TypeInfo MR_typeclass_info_type_info(
-	MR_TypeClassInfo tcinfo, int index)
+public static object[] MR_typeclass_info_type_info(object[] tcinfo, int index)
 {
-	MR_Word tmp;
+	object[] tmp;
 	int t1;
 
-	tmp = dynamic_cast<MR_Word> (tcinfo[0]);
-	t1 = System::Convert::ToInt32(tmp[0]) + index;
-	return dynamic_cast<MR_TypeInfo> (tcinfo[t1]);
+	tmp = (object[]) tcinfo[0];
+	t1 = System.Convert.ToInt32(tmp[0]) + index;
+	return (object[]) tcinfo[t1];
 }
-static MR_TypeInfo MR_typeclass_info_unconstrained_type_info(
-	MR_TypeClassInfo tcinfo, int index) 
+public static object[] MR_typeclass_info_unconstrained_type_info(
+	object[] tcinfo, int index) 
 {
-	return dynamic_cast<MR_Word> (tcinfo[index]);
+	return (object[]) tcinfo[index];
 }
 
-static MR_TypeClassInfo MR_typeclass_info_superclass_info(
-	MR_TypeClassInfo tcinfo, int index)
+public static object[] MR_typeclass_info_superclass_info(
+	object[] tcinfo, int index)
 {
-	MR_Word tmp;
+	object[] tmp;
 	int t1;
 
-	tmp = dynamic_cast<MR_Word> (tcinfo[0]);
-	t1 = System::Convert::ToInt32(tmp[0]) + index;
-	return dynamic_cast<MR_Word> (tcinfo[t1]);
+	tmp = (object[]) tcinfo[0];
+	t1 = System.Convert.ToInt32(tmp[0]) + index;
+	return (object[]) tcinfo[t1];
 }
 
-static MR_TypeClassInfo MR_typeclass_info_arg_typeclass_info(
-	MR_TypeClassInfo tcinfo, int index) 
+public static object[] MR_typeclass_info_arg_typeclass_info(
+	object[] tcinfo, int index) 
 {
-	return dynamic_cast<MR_Word> (tcinfo[index]);
+	return (object[]) tcinfo[index];
 }
 
 ").
@@ -390,204 +399,206 @@
 	MR_TYPECTOR_REP_BASETYPECLASSINFO) 
 MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(private_builtin, typeclass_info, 1,
 	MR_TYPECTOR_REP_TYPECLASSINFO) 
+").
+:- pragma foreign_code("C#", "
+
+/* XXX these macros need to be defined in C#
+// MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(private_builtin, type_ctor_info, 1,
+//	MR_TYPECTOR_REP_TYPECTORINFO) 
+public static object[] __type_ctor_info_type_ctor_info_1;
+public static object[] private_builtin__type_ctor_info_type_ctor_info_1;
+
+// MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(private_builtin, type_info, 1,
+//	MR_TYPECTOR_REP_TYPEINFO) 
+public static object[] __type_ctor_info_type_info_1;
+public static object[] private_builtin__type_ctor_info_type_info_1;
+
+// MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(private_builtin, base_typeclass_info, 1,
+//	MR_TYPECTOR_REP_BASETYPECLASSINFO) 
+public static object[] __type_ctor_info_base_typeclass_info_1;
+public static object[] private_builtin__type_ctor_info_base_typeclass_info_1;
+
+// MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(private_builtin, typeclass_info, 1,
+//	MR_TYPECTOR_REP_TYPECLASSINFO) 
+public static object[] __type_ctor_info_typeclass_info_1;
+public static object[] private_builtin__type_ctor_info_typeclass_info_1;
+*/
 
 	// XXX These static constants are duplicated both here and in
 	// mercury_dotnet.cs.in.
 
 	// This is because other library modules reference them
-	// from MC++ code (so they depend on the versions in the runtime to
+	// from .NET code (so they depend on the versions in the runtime to
 	// make the dependencies simple) whereas the compiler generates
 	// references to the ones here. 
 
 	// See runtime/mercury_dotnet.cs.in for discussion of why we aren't
 	// using enums or const static ints here.
 
-static int MR_TYPECTOR_REP_ENUM 		= MR_TYPECTOR_REP_ENUM_val;
-static int MR_TYPECTOR_REP_ENUM_USEREQ 		= MR_TYPECTOR_REP_ENUM_USEREQ_val;
-static int MR_TYPECTOR_REP_DU			= MR_TYPECTOR_REP_DU_val;
-static int MR_TYPECTOR_REP_DU_USEREQ		= 3;
-static int MR_TYPECTOR_REP_NOTAG		= 4;
-static int MR_TYPECTOR_REP_NOTAG_USEREQ		= 5;
-static int MR_TYPECTOR_REP_EQUIV		= 6;
-static int MR_TYPECTOR_REP_FUNC			= 7;
-static int MR_TYPECTOR_REP_INT		    	= 8;
-static int MR_TYPECTOR_REP_CHAR		    	= 9;
-static int MR_TYPECTOR_REP_FLOAT		=10;
-static int MR_TYPECTOR_REP_STRING		=11;
-static int MR_TYPECTOR_REP_PRED		    	=12;
-static int MR_TYPECTOR_REP_SUBGOAL	    	=13;
-static int MR_TYPECTOR_REP_VOID		    	=14;
-static int MR_TYPECTOR_REP_C_POINTER		=15;
-static int MR_TYPECTOR_REP_TYPEINFO		=16;
-static int MR_TYPECTOR_REP_TYPECLASSINFO	=17;
-static int MR_TYPECTOR_REP_ARRAY		=18;
-static int MR_TYPECTOR_REP_SUCCIP		=19;
-static int MR_TYPECTOR_REP_HP			=20;
-static int MR_TYPECTOR_REP_CURFR		=21;
-static int MR_TYPECTOR_REP_MAXFR		=22;
-static int MR_TYPECTOR_REP_REDOFR		=23;
-static int MR_TYPECTOR_REP_REDOIP		=24;
-static int MR_TYPECTOR_REP_TRAIL_PTR		=25;
-static int MR_TYPECTOR_REP_TICKET		=26;
-static int MR_TYPECTOR_REP_NOTAG_GROUND		=27;
-static int MR_TYPECTOR_REP_NOTAG_GROUND_USEREQ	=28;
-static int MR_TYPECTOR_REP_EQUIV_GROUND		=29;
-static int MR_TYPECTOR_REP_TUPLE		=30;
-static int MR_TYPECTOR_REP_RESERVED_ADDR	=31;
-static int MR_TYPECTOR_REP_RESERVED_ADDR_USEREQ	=32;
-static int MR_TYPECTOR_REP_TYPECTORINFO		=33;
-static int MR_TYPECTOR_REP_BASETYPECLASSINFO	=34;
-static int MR_TYPECTOR_REP_TYPEDESC		=35;
-static int MR_TYPECTOR_REP_TYPECTORDESC		=36;
-static int MR_TYPECTOR_REP_FOREIGN		=37;
-static int MR_TYPECTOR_REP_REFERENCE		=38;
-static int MR_TYPECTOR_REP_STABLE_C_POINTER	=39;
-static int MR_TYPECTOR_REP_UNKNOWN		=40;
-
-static int MR_SECTAG_NONE				= 0;
-static int MR_SECTAG_LOCAL				= 1;
-static int MR_SECTAG_REMOTE				= 2;
-static int MR_SECTAG_VARIABLE				= 3;
+public static int MR_TYPECTOR_REP_ENUM 			= 0;
+public static int MR_TYPECTOR_REP_ENUM_USEREQ 		= 1;
+public static int MR_TYPECTOR_REP_DU			= 2;
+public static int MR_TYPECTOR_REP_DU_USEREQ		= 3;
+public static int MR_TYPECTOR_REP_NOTAG			= 4;
+public static int MR_TYPECTOR_REP_NOTAG_USEREQ		= 5;
+public static int MR_TYPECTOR_REP_EQUIV			= 6;
+public static int MR_TYPECTOR_REP_FUNC			= 7;
+public static int MR_TYPECTOR_REP_INT		    	= 8;
+public static int MR_TYPECTOR_REP_CHAR		    	= 9;
+public static int MR_TYPECTOR_REP_FLOAT			=10;
+public static int MR_TYPECTOR_REP_STRING		=11;
+public static int MR_TYPECTOR_REP_PRED		    	=12;
+public static int MR_TYPECTOR_REP_SUBGOAL	    	=13;
+public static int MR_TYPECTOR_REP_VOID		    	=14;
+public static int MR_TYPECTOR_REP_C_POINTER		=15;
+public static int MR_TYPECTOR_REP_TYPEINFO		=16;
+public static int MR_TYPECTOR_REP_TYPECLASSINFO		=17;
+public static int MR_TYPECTOR_REP_ARRAY			=18;
+public static int MR_TYPECTOR_REP_SUCCIP		=19;
+public static int MR_TYPECTOR_REP_HP			=20;
+public static int MR_TYPECTOR_REP_CURFR			=21;
+public static int MR_TYPECTOR_REP_MAXFR			=22;
+public static int MR_TYPECTOR_REP_REDOFR		=23;
+public static int MR_TYPECTOR_REP_REDOIP		=24;
+public static int MR_TYPECTOR_REP_TRAIL_PTR		=25;
+public static int MR_TYPECTOR_REP_TICKET		=26;
+public static int MR_TYPECTOR_REP_NOTAG_GROUND		=27;
+public static int MR_TYPECTOR_REP_NOTAG_GROUND_USEREQ	=28;
+public static int MR_TYPECTOR_REP_EQUIV_GROUND		=29;
+public static int MR_TYPECTOR_REP_TUPLE			=30;
+public static int MR_TYPECTOR_REP_RESERVED_ADDR		=31;
+public static int MR_TYPECTOR_REP_RESERVED_ADDR_USEREQ	=32;
+public static int MR_TYPECTOR_REP_TYPECTORINFO		=33;
+public static int MR_TYPECTOR_REP_BASETYPECLASSINFO	=34;
+public static int MR_TYPECTOR_REP_TYPEDESC		=35;
+public static int MR_TYPECTOR_REP_TYPECTORDESC		=36;
+public static int MR_TYPECTOR_REP_FOREIGN		=37;
+public static int MR_TYPECTOR_REP_REFERENCE		=38;
+public static int MR_TYPECTOR_REP_STABLE_C_POINTER	=39;
+public static int MR_TYPECTOR_REP_UNKNOWN		=40;
+
+public static int MR_SECTAG_NONE				= 0;
+public static int MR_SECTAG_LOCAL				= 1;
+public static int MR_SECTAG_REMOTE				= 2;
+public static int MR_SECTAG_VARIABLE				= 3;
 
-static MR_bool
+public static bool
 __Unify____type_info_1_0(
-	MR_Word type_info, MR_Word x, MR_Word y)
+	object[] type_info, object[] x, object[] y)
 {
-	mercury::runtime::Errors::SORRY(S""unify for type_info"");
-	return 0;
+	mercury.runtime.Errors.SORRY(""unify for type_info"");
+	return false;
 }
 
-static MR_bool
+public static bool
 __Unify____typeclass_info_1_0(
-	MR_Word type_info, MR_Word x, MR_Word y)
+	object[] type_info, object[] x, object[] y)
 {
-	mercury::runtime::Errors::SORRY(S""unify for typeclass_info"");
-	return 0;
+	mercury.runtime.Errors.SORRY(""unify for typeclass_info"");
+	return false;
 }
 
-static MR_bool
+public static bool
 __Unify____base_typeclass_info_1_0(
-	MR_Word type_info, MR_Word x, MR_Word y)
+	object[] type_info, object[] x, object[] y)
 {
-	mercury::runtime::Errors::SORRY(S""unify for base_typeclass_info"");
-	return 0;
+	mercury.runtime.Errors.SORRY(""unify for base_typeclass_info"");
+	return false;
 }
 
-static MR_bool
+public static bool
 __Unify____type_ctor_info_1_0(
-	MR_Word type_info, MR_Word x, MR_Word y)
+	object[] type_info, object[] x, object[] y)
 {
-	mercury::runtime::Errors::SORRY(S""unify for type_ctor_info"");
-	return 0;
+	mercury.runtime.Errors.SORRY(""unify for type_ctor_info"");
+	return false;
 }
 
-static void
+public static void
 __Compare____type_ctor_info_1_0(
-	MR_Word type_info, MR_Word_Ref result, MR_Word x, MR_Word y)
+	object[] type_info, ref object[] result, object[] x, object[] y)
 {
-	mercury::runtime::Errors::SORRY(S""compare for type_ctor_info"");
+	mercury.runtime.Errors.SORRY(""compare for type_ctor_info"");
 }
 
-static void
+public static void
 __Compare____type_info_1_0(
-	MR_Word type_info, MR_Word_Ref result, MR_Word x, MR_Word y)
+	object[] type_info, ref object[] result, object[] x, object[] y)
 {
-	mercury::runtime::Errors::SORRY(S""compare for type_info"");
+	mercury.runtime.Errors.SORRY(""compare for type_info"");
 }
 
-static void
+public static void
 __Compare____typeclass_info_1_0(
-	MR_Word type_info, MR_Word_Ref result, MR_Word x, MR_Word y)
+	object[] type_info, ref object[] result, object[] x, object[] y)
 {
-	mercury::runtime::Errors::SORRY(S""compare for typeclass_info"");
+	mercury.runtime.Errors.SORRY(""compare for typeclass_info"");
 }
 
-static void
+public static void
 __Compare____base_typeclass_info_1_0(
-	MR_Word type_info, MR_Word_Ref result, MR_Word x, MR_Word y)
+	object[] type_info, ref object[] result, object[] x, object[] y)
 {
-	mercury::runtime::Errors::SORRY(S""compare for base_typeclass_info"");
+	mercury.runtime.Errors.SORRY(""compare for base_typeclass_info"");
 }
 
-static MR_bool
-do_unify__type_ctor_info_1_0(
-	MR_Word type_info, MR_Box x, MR_Box y)
+public static bool
+do_unify__type_ctor_info_1_0(object[] type_info, object x, object y)
 {
-	return mercury::private_builtin__cpp_code::mercury_code::__Unify____type_ctor_info_1_0(
-		type_info, 
-		dynamic_cast<MR_Word>(x),
-		dynamic_cast<MR_Word>(y));
+	return __Unify____type_ctor_info_1_0(type_info, 
+		(object[]) x, (object[]) y);
 }
 
-static MR_bool
-do_unify__type_info_1_0(
-	MR_Word type_info, MR_Box x, MR_Box y)
+public static bool
+do_unify__type_info_1_0(object[] type_info, object x, object y)
 {
-	return mercury::private_builtin__cpp_code::mercury_code::__Unify____type_info_1_0(
-		type_info,
-		dynamic_cast<MR_Word>(x),
-		dynamic_cast<MR_Word>(y));
+	return __Unify____type_info_1_0(type_info, (object[]) x, (object[]) y);
 }
 
-static MR_bool
-do_unify__typeclass_info_1_0(
-	MR_Word type_info, MR_Box x, MR_Box y)
+public static bool
+do_unify__typeclass_info_1_0(object[] type_info, object x, object y)
 {
-	return mercury::private_builtin__cpp_code::mercury_code::__Unify____typeclass_info_1_0(
-		type_info, 
-		dynamic_cast<MR_Word>(x),
-		dynamic_cast<MR_Word>(y));
+	return __Unify____typeclass_info_1_0(type_info, 
+		(object[]) x, (object[]) y);
 }
 
-static MR_bool
-do_unify__base_typeclass_info_1_0(
-	MR_Word type_info, MR_Box x, MR_Box y)
+public static bool
+do_unify__base_typeclass_info_1_0(object[] type_info, object x, object y)
 {
-	return
-	mercury::private_builtin__cpp_code::mercury_code::__Unify____base_typeclass_info_1_0(
-		type_info,
-		dynamic_cast<MR_Word>(x),
-		dynamic_cast<MR_Word>(y));
+	return __Unify____base_typeclass_info_1_0(type_info,
+		(object[]) x, (object[]) y);
 }
 
-static void
+public static void
 do_compare__type_ctor_info_1_0(
-	MR_Word type_info, MR_Word_Ref result, MR_Box x, MR_Box y)
+	object[] type_info, ref object[] result, object x, object y)
 {
-	mercury::private_builtin__cpp_code::mercury_code::__Compare____type_ctor_info_1_0(
-		type_info, result, 
-		dynamic_cast<MR_Word>(x),
-		dynamic_cast<MR_Word>(y));
+	__Compare____type_ctor_info_1_0(
+		type_info, ref result, (object[]) x, (object[]) y);
 }
 
-static void
+public static void
 do_compare__type_info_1_0(
-	MR_Word type_info, MR_Word_Ref result, MR_Box x, MR_Box y)
+	object[] type_info, ref object[] result, object x, object y)
 {
-	mercury::private_builtin__cpp_code::mercury_code::__Compare____type_info_1_0(
-		type_info, result,
-		dynamic_cast<MR_Word>(x),
-		dynamic_cast<MR_Word>(y));
+	__Compare____type_info_1_0(type_info, ref result,
+		(object[]) x, (object[]) y);
 }
 
-static void
+public static void
 do_compare__typeclass_info_1_0(
-	MR_Word type_info, MR_Word_Ref result, MR_Box x, MR_Box y)
+	object[] type_info, ref object[] result, object x, object y)
 {
-	mercury::private_builtin__cpp_code::mercury_code::__Compare____typeclass_info_1_0(
-		type_info, result,
-		dynamic_cast<MR_Word>(x),
-		dynamic_cast<MR_Word>(y));
+	__Compare____typeclass_info_1_0(type_info, ref result,
+		(object[]) x, (object[]) y);
 }
 
-static void
+public static void
 do_compare__base_typeclass_info_1_0(
-	MR_Word type_info, MR_Word_Ref result, MR_Box x, MR_Box y)
+	object[] type_info, ref object[] result, object x, object y)
 {
-	mercury::private_builtin__cpp_code::mercury_code::__Compare____base_typeclass_info_1_0(
-		type_info, result,
-		dynamic_cast<MR_Word>(x),
-		dynamic_cast<MR_Word>(y));
+	__Compare____base_typeclass_info_1_0(type_info, ref result,
+		(object[]) x, (object[]) y);
 }
 
 ").
@@ -627,7 +638,7 @@
 		MR_typeclass_info_arg_typeclass_info(TypeClassInfo0, Index);
 ").
 
-:- pragma foreign_proc("MC++",
+:- pragma foreign_proc("C#",
 	type_info_from_typeclass_info(TypeClassInfo::in, Index::in,
 		TypeInfo::out),
 		[will_not_call_mercury, promise_pure, thread_safe],
@@ -635,7 +646,7 @@
 	TypeInfo = MR_typeclass_info_type_info(TypeClassInfo, Index);
 ").
 
-:- pragma foreign_proc("MC++",
+:- pragma foreign_proc("C#",
 	unconstrained_type_info_from_typeclass_info(TypeClassInfo::in,
 		Index::in, TypeInfo::out),
 		[will_not_call_mercury, promise_pure, thread_safe],
@@ -644,7 +655,7 @@
 			Index);
 ").
 
-:- pragma foreign_proc("MC++",
+:- pragma foreign_proc("C#",
 	superclass_from_typeclass_info(TypeClassInfo0::in, Index::in,
 		TypeClassInfo::out),
 		[will_not_call_mercury, promise_pure, thread_safe],
@@ -653,7 +664,7 @@
 		MR_typeclass_info_superclass_info(TypeClassInfo0, Index);
 ").
 
-:- pragma foreign_proc("MC++",
+:- pragma foreign_proc("C#",
 	instance_constraint_from_typeclass_info(TypeClassInfo0::in,
 		Index::in, TypeClassInfo::out),
 		[will_not_call_mercury, promise_pure, thread_safe],
@@ -1024,67 +1035,82 @@
 	
 MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(private_builtin, heap_pointer, 0,
 	MR_TYPECTOR_REP_HP) 
+MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(private_builtin, ref, 1,
+	MR_TYPECTOR_REP_REFERENCE) 
+").
+:- pragma foreign_code("C#", "
+	
+/* XXX these macros need to be defined in C#
+// MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(private_builtin, heap_pointer, 0,
+//	MR_TYPECTOR_REP_HP) 
+*/
+public static object[] __type_ctor_info_heap_pointer_0;
+public static object[] private_builtin__type_ctor_info_heap_pointer_0;
 
-static MR_bool
-__Unify__private_builtin__heap_pointer_0_0(MR_Word x, MR_Word y)
+public static bool
+__Unify__private_builtin__heap_pointer_0_0(object[] x, object[] y)
 {
-	mercury::runtime::Errors::fatal_error(
-		S""called unify for type `private_builtin:heap_pointer'"");
-	return 0;
+	mercury.runtime.Errors.fatal_error(
+		""called unify for type `private_builtin:heap_pointer'"");
+	return false;
 }
 
-static void
+public static void
 __Compare__private_builtin__heap_pointer_0_0(
-	MR_Word_Ref result, MR_Word x, MR_Word y)
+	ref object[] result, object[] x, object[] y)
 {
-	mercury::runtime::Errors::fatal_error(
+	mercury.runtime.Errors.fatal_error(
 		""called compare/3 for type `private_builtin:heap_pointer'"");
 }
 
-static MR_bool
-do_unify__heap_pointer_0_0(MR_Box x, MR_Box y)
+public static bool
+do_unify__heap_pointer_0_0(object x, object y)
 {
-	mercury::runtime::Errors::fatal_error(
+	mercury.runtime.Errors.fatal_error(
 		""called unify for type `private_builtin:heap_pointer'"");
-	return 0;
+	return false;
 }
 
-static void
+public static void
 do_compare__heap_pointer_0_0(
-	MR_Word_Ref result, MR_Box x, MR_Box y)
+	ref object[] result, object x, object y)
 {
-	mercury::runtime::Errors::fatal_error(
+	mercury.runtime.Errors.fatal_error(
 		""called compare/3 for type `private_builtin:heap_pointer'"");
 }
 
-MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(private_builtin, ref, 1,
-	MR_TYPECTOR_REP_REFERENCE) 
+/* XXX these macros need to be defined in C#
+// MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(private_builtin, ref, 1,
+//	MR_TYPECTOR_REP_REFERENCE) 
+public static object[] __type_ctor_info_ref_1;
+public static object[] private_builtin__type_ctor_info_ref_1;
+*/
 
-static MR_bool
-__Unify__private_builtin__ref_1_0(MR_Word type_info, MR_Word x, MR_Word y)
+public static bool
+__Unify__private_builtin__ref_1_0(object[] type_info, object[] x, object[] y)
 {
 	return x == y;
 }
 
-static MR_bool
-do_unify__ref_1_0(MR_Word type_info, MR_Box x, MR_Box y)
+public static bool
+do_unify__ref_1_0(object[] type_info, object x, object y)
 {
 	return x == y;
 }
 
-static void
+public static void
 __Compare__private_builtin__ref_1_0(
-	MR_Word type_info, MR_Word_Ref result, MR_Word x, MR_Word y)
+	object[] type_info, ref object[] result, object[] x, object[] y)
 {
-	mercury::runtime::Errors::fatal_error(
+	mercury.runtime.Errors.fatal_error(
 		""called compare/3 for type `private_builtin.ref'"");
 }
 
-static void
+public static void
 do_compare__ref_1_0(
-	MR_Word type_info, MR_Word_Ref result, MR_Box x, MR_Box y)
+	object[] type_info, ref object[] result, object x, object y)
 {
-	mercury::runtime::Errors::fatal_error(
+	mercury.runtime.Errors.fatal_error(
 		""called compare/3 for type `private_builtin.ref'"");
 }
 
Index: library/type_desc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/type_desc.m,v
retrieving revision 1.20
diff -u -r1.20 type_desc.m
--- library/type_desc.m	14 May 2003 14:38:48 -0000	1.20
+++ library/type_desc.m	14 Nov 2003 15:58:01 -0000
@@ -175,114 +175,118 @@
 MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(type_desc, type_desc, 0, 
 	MR_TYPECTOR_REP_TYPEDESC)
 
-static int MR_compare_type_info(MR_TypeInfo_0 t1, MR_TypeInfo_0 t2) {
-	MR_ComparisonResult res;
+").
+:- pragma foreign_code("C#", "
 
-	mercury::type_desc::mercury_code::ML_call_rtti_compare_type_infos(
-		&res, t1, t2);
+/* XXX These macros need to be defined in C#
+// MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(type_desc, type_ctor_desc, 0, 
+//	MR_TYPECTOR_REP_TYPECTORDESC)
+public static object[] __type_ctor_info_type_ctor_desc_0;
+public static object[] type_desc__type_ctor_info_type_ctor_desc_0;
+
+// MR_DEFINE_BUILTIN_TYPE_CTOR_INFO(type_desc, type_desc, 0, 
+//	MR_TYPECTOR_REP_TYPEDESC)
+public static object[] __type_ctor_info_type_desc_0;
+public static object[] type_desc__type_ctor_info_type_desc_0;
+*/
+
+
+public static int MR_compare_type_info(object[] t1, object[] t2) {
+	object[] res = null;
+
+	mercury.type_desc.mercury_code.ML_call_rtti_compare_type_infos(
+		ref res, t1, t2);
 /*
 #ifdef MR_HIGHLEVEL_DATA
-	return res->data_tag;
+	return res-> data_tag;
 #else
 */
-	return System::Convert::ToInt32(res[0]);
+	return System.Convert.ToInt32(res[0]);
 // #endif
 }
 
-static void
+public static void
 __Compare____type_ctor_desc_0_0(
-	MR_ComparisonResult *result, MR_TypeInfo_0 x, MR_TypeInfo_0 y)
+	ref object[] result, object[] x, object[] y)
 {
-	mercury::runtime::Errors::SORRY(
-		S""foreign code for comparing type_ctor_descs"");
+	mercury.runtime.Errors.SORRY(
+		""foreign code for comparing type_ctor_descs"");
 }
 
-static MR_bool
-__Unify____type_ctor_desc_0_0(MR_TypeInfo_0 x, MR_TypeInfo_0 y)
+public static bool
+__Unify____type_ctor_desc_0_0(object[] x, object[] y)
 {
-	mercury::runtime::Errors::SORRY(
-		S""foreign code for unifying type_ctor_descs"");
-	return 0;
+	mercury.runtime.Errors.SORRY(
+		""foreign code for unifying type_ctor_descs"");
+	return false;
 }
 
-static void
+public static void
 special___Compare___type_ctor_desc_0_0(
-	MR_ComparisonResult *result, MR_TypeInfo_0 x, MR_TypeInfo_0 y)
+	ref object[] result, object[] x, object[] y)
 {
-	mercury::runtime::Errors::SORRY(
-		S""foreign code for comparing type_ctor_descs"");
+	mercury.runtime.Errors.SORRY(
+		""foreign code for comparing type_ctor_descs"");
 }
 
-static MR_bool
-special___Unify___type_ctor_desc_0_0(MR_TypeInfo_0 x, MR_TypeInfo_0 y)
+public static bool
+special___Unify___type_ctor_desc_0_0(object[] x, object[] y)
 {
-	mercury::runtime::Errors::SORRY(
-		S""foreign code for unifying type_ctor_descs"");
-	return 0;
+	mercury.runtime.Errors.SORRY(
+		""foreign code for unifying type_ctor_descs"");
+	return false;
 }
 
-static MR_bool
-do_unify__type_ctor_desc_0_0(MR_Box x, MR_Box y)
+public static bool
+do_unify__type_ctor_desc_0_0(object x, object y)
 {
-	return mercury::type_desc__cpp_code::mercury_code::__Unify____type_ctor_desc_0_0(
-		dynamic_cast<MR_TypeInfo_0>(x),
-		dynamic_cast<MR_TypeInfo_0>(y));
+	return __Unify____type_ctor_desc_0_0((object[]) x, (object[]) y);
 }
 
-static void
-do_compare__type_ctor_desc_0_0(
-	MR_ComparisonResult *result, MR_Box x, MR_Box y)
+public static void
+do_compare__type_ctor_desc_0_0(ref object[] result, object x, object y)
 {
-	mercury::type_desc__cpp_code::mercury_code::__Compare____type_ctor_desc_0_0(
-		result,
-		dynamic_cast<MR_TypeInfo_0>(x),
-		dynamic_cast<MR_TypeInfo_0>(y));
+	__Compare____type_ctor_desc_0_0(ref result, (object[]) x, (object[]) y);
 }
 
-static void
-__Compare____type_desc_0_0(
-	MR_ComparisonResult *result, MR_TypeInfo_0 x, MR_TypeInfo_0 y)
+public static void
+__Compare____type_desc_0_0(ref object[] result, object[] x, object[] y)
 {
-	mercury::type_desc::mercury_code::ML_call_rtti_compare_type_infos(
-		result, x, y);
+	mercury.type_desc.mercury_code.ML_call_rtti_compare_type_infos(
+		ref result, x, y);
 }
 
-static MR_bool
-__Unify____type_desc_0_0(MR_TypeInfo_0 x, MR_TypeInfo_0 y)
+public static bool
+__Unify____type_desc_0_0(object[] x, object[] y)
 {
-	return (MR_compare_type_info(x, y) == MR_COMPARE_EQUAL);
+	return (MR_compare_type_info(x, y) == 0);
 }
 
-static void
+public static void
 special___Compare___type_desc_0_0(
-	MR_ComparisonResult *result, MR_TypeInfo_0 x, MR_TypeInfo_0 y)
+	ref object[] result, object[] x, object[] y)
 {
-	mercury::type_desc::mercury_code::ML_call_rtti_compare_type_infos(
-		result, x, y);
+	mercury.type_desc.mercury_code.ML_call_rtti_compare_type_infos(
+		ref result, x, y);
 }
 
-static MR_bool
-special___Unify___type_desc_0_0(MR_TypeInfo_0 x, MR_TypeInfo_0 y)
+public static bool
+special___Unify___type_desc_0_0(object[] x, object[] y)
 {
-	return (MR_compare_type_info(x, y) == MR_COMPARE_EQUAL);
+	return (MR_compare_type_info(x, y) == 0);
 }
 
-static MR_bool
-do_unify__type_desc_0_0(MR_Box x, MR_Box y)
+public static bool
+do_unify__type_desc_0_0(object x, object y)
 {
-	return mercury::type_desc__cpp_code::mercury_code::__Unify____type_desc_0_0(
-		dynamic_cast<MR_TypeInfo_0>(x),
-		dynamic_cast<MR_TypeInfo_0>(y));
+	return __Unify____type_desc_0_0((object[]) x, (object[]) y);
 }
 
-static void
+public static void
 do_compare__type_desc_0_0(
-	MR_ComparisonResult *result, MR_Box x, MR_Box y)
+	ref object[] result, object x, object y)
 {
-	mercury::type_desc__cpp_code::mercury_code::__Compare____type_desc_0_0(
-		result,
-		dynamic_cast<MR_TypeInfo_0>(x),
-		dynamic_cast<MR_TypeInfo_0>(y));
+	__Compare____type_desc_0_0(ref result, (object[]) x, (object[]) y);
 }
 
 ").


-- 
Peter Ross		
Software Engineer                                (Work)   +32 2 757 10 15
Mission Critical                                 (Mobile) +32 485 482 559
--------------------------------------------------------------------------
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