[m-rev.] for review: implemented int library predicates for Java

James Goddard goddardjames at yahoo.com
Thu Dec 11 18:31:47 AEDT 2003


Estimated hours taken: 0.5
Branches: main

Implemented some library functions for the int library in java.

library/int.m:
	Implemented the following predicates in java:

		int__to_float/2
		int__max_int/1
		int__min_int/1
		int__bits_per_int/1

Index: int.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/int.m,v
retrieving revision 1.95
diff -u -d -r1.95 int.m
--- int.m	9 Dec 2003 06:48:10 -0000	1.95
+++ int.m	11 Dec 2003 07:21:32 -0000
@@ -519,6 +519,12 @@
 "
 	FloatVal = (double) IntVal;
 ").
+:- pragma foreign_proc("Java",
+	int__to_float(IntVal::in, FloatVal::out),
+	[will_not_call_mercury, promise_pure],
+"
+	FloatVal = (double) IntVal;
+").
 
 %-----------------------------------------------------------------------------%
 
@@ -600,6 +606,28 @@
 "
 	// we are using int32 in the compiler.
 	// XXX would be better to avoid hard-coding this here.
+	Bits = 32;
+").
+
+:- pragma foreign_proc("Java",
+	int__max_int(Max::out),
+	[will_not_call_mercury, promise_pure, thread_safe],
+"
+	Max = java.lang.Integer.MAX_VALUE;
+").
+
+:- pragma foreign_proc("Java",
+	int__min_int(Min::out),
+	[will_not_call_mercury, promise_pure, thread_safe],
+"
+	Min = java.lang.Integer.MIN_VALUE;
+").
+
+:- pragma foreign_proc("Java",
+        int__bits_per_int(Bits::out),
+	        [will_not_call_mercury, promise_pure, thread_safe],
+"
+	// Java ints are 32 bits.
 	Bits = 32;
 ").
 
--------------------------------------------------------------------------
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