[m-rev.] for prelim review: pragma foreign_import_module on IL backend.

Peter Ross pro at missioncriticalit.com
Fri Dec 6 03:01:19 AEDT 2002


Hi,


Here is the update to the test case that I have used to test the
foreign_import_module change.


Index: tests/hard_coded/foreign_import_module.exp
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/foreign_import_module.exp,v
retrieving revision 1.1
diff -u -r1.1 foreign_import_module.exp
--- tests/hard_coded/foreign_import_module.exp	6 Nov 2001 15:21:26 -0000	1.1
+++ tests/hard_coded/foreign_import_module.exp	5 Dec 2002 15:59:16 -0000
@@ -1 +1,2 @@
 42
+42
Index: tests/hard_coded/foreign_import_module.m
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/foreign_import_module.m,v
retrieving revision 1.2
diff -u -r1.2 foreign_import_module.m
--- tests/hard_coded/foreign_import_module.m	28 Nov 2002 16:33:44 -0000	1.2
+++ tests/hard_coded/foreign_import_module.m	5 Dec 2002 15:59:16 -0000
@@ -13,15 +13,50 @@
 main -->
 	{ bar(41, X) },
 	io__write(X),
-	io__write_char('\n').
+	io__nl,
 
-:- pragma foreign_import_module("C", foreign_import_module_2).
+	{ bar2(41, Y) },
+	io__write(Y),
+	io__nl.
+
+:- pragma foreign_import_module(c, foreign_import_module_2).
+:- pragma foreign_import_module(il, foreign_import_module_2).
+:- pragma foreign_import_module("MC++", foreign_import_module_2).
+:- pragma foreign_import_module(il, std_util).
 
 :- pragma c_code(bar(X::in, Y::out), may_call_mercury,
 "
 	foo(X, &Y);
 ").
-:- pragma foreign_proc("C#", bar(X::in, Y::out),
+:- pragma foreign_proc("MC++", bar(X::in, Y::out),
 		[may_call_mercury, promise_pure], "
-	foreign_import_module_2.mercury_code.foo(X, ref Y);
+	MR_Integer Y1, Y2;
+
+	foreign_import_module_2::mercury_code::foo(X, &Y1);
+	foreign_import_module_2__cpp_code::mercury_code::foo2(X, &Y2);
+
+	if (Y1 == Y2) {
+		Y = Y1;
+	} else {
+		throw new System::Exception(""Y1 != Y2"");
+	}
+").
+
+:- pred bar2(int::in, int::out) is det.
+:- pragma c_code(bar2(X::in, Y::out), may_call_mercury,
+"
+	foo(X, &Y);
+").
+:- pragma foreign_proc("C#", bar2(X::in, Y::out),
+		[may_call_mercury, promise_pure], "
+	int Y1 = 0, Y2 = 0;
+
+	foreign_import_module_2.mercury_code.foo(X, ref Y1);
+	foreign_import_module_2__cpp_code.mercury_code.foo2(X, ref Y2);
+
+	if (Y1 == Y2) {
+		Y = Y1;
+	} else {
+		throw new System.Exception(""Y1 != Y2"");
+	}
 ").
Index: tests/hard_coded/foreign_import_module_2.m
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/foreign_import_module_2.m,v
retrieving revision 1.1
diff -u -r1.1 foreign_import_module_2.m
--- tests/hard_coded/foreign_import_module_2.m	6 Nov 2001 15:21:27 -0000	1.1
+++ tests/hard_coded/foreign_import_module_2.m	5 Dec 2002 15:59:16 -0000
@@ -11,3 +11,10 @@
 :- pragma export(foo(in, out), "foo").
 
 foo(X, X+1).
+
+:- pragma foreign_code("MC++", "
+	static void foo2(MR_Integer X, MR_Ref(MR_Integer) Y)
+	{
+		*Y = X + 1;
+	}
+").

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