[m-rev.] diff: fix get_typeinfo_from_term for high level data

Peter Ross pro at missioncriticalit.com
Wed Nov 27 01:41:09 AEDT 2002


Hi,


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


Estimated hours taken: 2
Branches: main

library/rtti_implementation.m:
	Adapt get_typeinfo_from_term so that it works for high level
	data as well.


Index: library/rtti_implementation.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/rtti_implementation.m,v
retrieving revision 1.22
diff -u -r1.22 rtti_implementation.m
--- library/rtti_implementation.m	24 Oct 2002 17:11:45 -0000	1.22
+++ library/rtti_implementation.m	26 Nov 2002 14:39:58 -0000
@@ -1321,7 +1321,13 @@
 :- pragma foreign_proc("C#",
 	get_typeinfo_from_term(Term::in, Index::in) = (TypeInfo::out),
 		[promise_pure], "
-	TypeInfo = (object[]) ((object[]) Term)[Index];
+	try {
+		TypeInfo = (object[]) ((object[]) Term)[Index];
+	} catch (System.InvalidCastException) {
+		// try high level data
+		TypeInfo = (object[])
+			Term.GetType().GetFields()[Index].GetValue(Term);
+	}
 ").
 
 :- func typeclass_info_type_info(type_info, int) = type_info.

--------------------------------------------------------------------------
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