[m-rev.] For review: Implement store library procedures for Java

James Goddard goddardjames at yahoo.com
Wed Feb 4 14:18:13 AEDT 2004


Estimated hours taken: 1
Branches: main

Implement some library procedures for Java.

library/store.m:
	Define generic_mutvar as having foreign_type "mercury.stdutil.Mutvar"
	since it has the same properties.

	Implement the following predicates in Java:
		new_mutvar/4
		get_mutvar/4
		set_mutvar/4
		unsafe_new_uninitialized_mutvar/3

Index: store.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/store.m,v
retrieving revision 1.42
diff -u -d -r1.42 store.m
--- store.m	1 Dec 2003 13:17:11 -0000	1.42
+++ store.m	4 Feb 2004 02:43:34 -0000
@@ -326,6 +326,29 @@
 	S = S0;
 ").
 
+:- pragma foreign_type(java, generic_mutvar(T, S), "mercury.std_util.Mutvar").
+
+:- pragma foreign_proc("Java",
+	new_mutvar(Val::in, Mutvar::out, _S0::di, _S::uo),
+	[will_not_call_mercury, promise_pure],
+"
+	Mutvar = new mercury.std_util.Mutvar(Val);
+").
+
+:- pragma foreign_proc("Java",
+	get_mutvar(Mutvar::in, Val::out, _S0::di, _S::uo),
+	[will_not_call_mercury, promise_pure],
+"
+	Val = Mutvar.object;
+").
+
+:- pragma foreign_proc("Java",
+	set_mutvar(Mutvar::in, Val::in, _S0::di, _S::uo),
+	[will_not_call_mercury, promise_pure],
+"
+	Mutvar.object = Val;
+").
+
 copy_mutvar(Mutvar, Copy) -->
 	get_mutvar(Mutvar, Value),
 	new_mutvar(Value, Copy).
@@ -342,6 +365,13 @@
 		MR_PROC_LABEL, ""store:mutvar/2"");
 	MR_define_size_slot(0, Mutvar, 1);
 	S = S0;
+").
+
+:- pragma foreign_proc("Java",
+	unsafe_new_uninitialized_mutvar(Mutvar::out, _S0::di, _S::uo),
+	[will_not_call_mercury, promise_pure],
+"
+	Mutvar = new mercury.std_util.Mutvar(null);
 ").
 
 store__new_cyclic_mutvar(Func, MutVar) -->
--------------------------------------------------------------------------
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