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

James Goddard goddardjames at yahoo.com
Mon Feb 9 18:46:00 AEDT 2004


> That looks fine, except that (as we discussed) this
> Java code isn't doing the same dynamic type checking
> that the C code does, and so there should be some XXX
> comments about that in the appropriate places,
> namely arg_ref/5 and new_arg_ref/5.

I've added those comments, as well as removing the operator overloading
for those functions where it might be considered ambiguous (Ref vs Object).

Here's the relative diff:

--------------------------------------------------------------------------
diff -u store.m store.m
--- store.m	9 Feb 2004 05:54:05 -0000
+++ store.m	9 Feb 2004 07:39:34 -0000
@@ -397,10 +397,6 @@
 			object	= init;
 			field	= null;
 		}
-		public Ref(mercury.store.Ref ref, int num) {
-			object	= ref.getValue();
-			setField(num);
-		}
 		public Ref(java.lang.Object init, int num) {
 			object	= init;
 			setField(num);
@@ -454,9 +450,6 @@
 		}
 
 		// Update the value of the reference.
-		public void setValue(mercury.store.Ref ref) {
-			setValue(ref.getValue());
-		}
 		public void setValue(java.lang.Object value) {
 			try {
 				field.set(object, value);
@@ -571,7 +564,13 @@
 	arg_ref(Ref::in, ArgNum::in, ArgRef::out, _S0::di, _S::uo),
 	[will_not_call_mercury, promise_pure],
 "
-	ArgRef = new mercury.store.Ref(Ref, ArgNum);
+	/*
+	** XXX Some dynamic type-checking should be done here to check that
+	**     the type of the specified Arg matches the type supplied by the
+	**     caller.  This will require RTTI.
+	*/
+
+	ArgRef = new mercury.store.Ref(Ref.getValue(), ArgNum);
 ").
 
 :- pragma foreign_proc("C", 
@@ -626,6 +625,12 @@
 	new_arg_ref(Val::di, ArgNum::in, ArgRef::out, _S0::di, _S::uo),
 	[will_not_call_mercury, promise_pure],
 "
+	/*
+	** XXX Some dynamic type-checking should be done here to check that
+	**     the type of the specified Arg matches the type supplied by the
+	**     caller.  This will require RTTI.
+	*/
+
 	ArgRef = new mercury.store.Ref(Val, ArgNum);
 ").
 
@@ -641,7 +646,7 @@
 	set_ref(Ref::in, ValRef::in, _S0::di, _S::uo),
 	[will_not_call_mercury, promise_pure],
 "
-	Ref.setValue(ValRef);
+	Ref.setValue(ValRef.getValue());
 ").
 
 :- pragma foreign_proc("C",	
@@ -689,7 +694,7 @@
 	unsafe_arg_ref(Ref::in, Arg::in, ArgRef::out, _S0::di, _S::uo),
 	[will_not_call_mercury, promise_pure],
 "
-	ArgRef = new mercury.store.Ref(Ref, Arg);
+	ArgRef = new mercury.store.Ref(Ref.getValue(), Arg);
 ").
 
 :- pragma foreign_proc("C",
--------------------------------------------------------------------------
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