[m-rev.] For review: Implement the bitmap module for the IL backend

Jonathan Morgan jonmmorgan at gmail.com
Sat Jun 16 22:27:13 AEST 2007


Note that, as with previous changes, this change only ensures that the
module compiles.  There are strange problems with the loading of the
class that have meant that I have been unable to test it, but the
implementation looks correct.

Jon

================================================================
Estimated hours taken: 0.75
Branches: main

Implemented the bitmap module for the IL backend (previously the relevant
foreign type and methods were there, but were commented out).

library/bitmap.m:
	Made the `MercuryBitmap' type an inner class, and altered the
	foreign type declaration accordingly.
	Marked the default equality and comparison predicates as terminating.
	Uncommented all commented out C# foreign procedures.

Index: library/bitmap.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/bitmap.m,v
retrieving revision 1.21
diff -u -u -r1.21 bitmap.m
--- library/bitmap.m	7 Jun 2007 07:11:42 -0000	1.21
+++ library/bitmap.m	16 Jun 2007 12:07:35 -0000
@@ -1537,35 +1537,29 @@
 }
 ").

-/* XXX UNTESTED
-:- pragma foreign_decl("C#", "
-namespace mercury {
-  namespace bitmap__csharp_code {
-
-    public class MercuryBitmap {
-        public int num_bits;
-        public byte[] elements;
-
-        public MercuryBitmap(int numBits) {
-            num_bits = numBits;
-            elements = new byte[numBits / 8 + (((numBits % 8) != 0) ? 1: 0)];
-        }
+:- pragma foreign_code("C#", "
+public class MercuryBitmap {
+    public int num_bits;
+    public byte[] elements;
+
+    public MercuryBitmap(int numBits) {
+        num_bits = numBits;
+        elements = new byte[numBits / 8 + (((numBits % 8) != 0) ? 1: 0)];
     }
-  }
 }
 ").
-*/

 :- pragma foreign_type("C", bitmap, "MR_BitmapPtr")
     where equality is bitmap_equal, comparison is bitmap_compare.
 :- pragma foreign_type("Java", bitmap, "mercury.bitmap.MercuryBitmap")
     where equality is bitmap_equal, comparison is bitmap_compare.
 :- pragma foreign_type("IL", bitmap,
-    "class [mercury]mercury.bitmap__csharp_code.MercuryBitmap")
+    "class [mercury]mercury.bitmap__csharp_code.mercury_code.MercuryBitmap")
     where equality is bitmap_equal, comparison is bitmap_compare.
 :- pragma foreign_type("Erlang", bitmap, "")
     where equality is bitmap_equal, comparison is bitmap_compare.

+:- pragma terminates(bitmap_equal/2).
 :- pred bitmap_equal(bitmap, bitmap).
 :- mode bitmap_equal(in, in) is semidet.

@@ -1591,6 +1585,7 @@
         true
     ).

+:- pragma terminates(bitmap_compare/3).
 :- pred bitmap_compare(comparison_result, bitmap, bitmap).
 :- mode bitmap_compare(uo, in, in) is det.

@@ -1661,14 +1656,12 @@
     NumBits = BM.num_bits;
 ").

-/* XXX UNTESTED
 :- pragma foreign_proc("C#",
     num_bits(BM::in) = (NumBits::out),
     [will_not_call_mercury, promise_pure, thread_safe, will_not_modify_trail],
 "
     NumBits = BM.num_bits;
 ").
-*/

 %-----------------------------------------------------------------------------%

@@ -1690,7 +1683,6 @@
     BM = BM0;
     BM.num_bits = NumBits;
 ").
-/* XXX UNTESTED
 :- pragma foreign_proc("C#",
     'num_bits :='(BM0::bitmap_di, NumBits::in) = (BM::bitmap_uo),
     [will_not_call_mercury, promise_pure, thread_safe, will_not_modify_trail],
@@ -1698,7 +1690,6 @@
     BM = BM0;
     BM.num_bits = NumBits;
 ").
-*/

 %-----------------------------------------------------------------------------%

@@ -1724,14 +1715,12 @@
     Byte = ((int) BM.elements[N]) & 0xff;
 ").

-/* XXX UNTESTED
 :- pragma foreign_proc("C#",
     unsafe_byte(N::in, BM::in) = (Byte::out),
     [will_not_call_mercury, promise_pure, thread_safe, will_not_modify_trail],
 "
     Byte = BM.elements[N];
 ").
-*/

 %-----------------------------------------------------------------------------%

@@ -1761,7 +1750,6 @@
     BM.elements[N] = (byte) Byte;
 ").

-/* XXX UNTESTED
 :- pragma foreign_proc("C#",
     'unsafe_byte :='(N::in, BM0::bitmap_di, Byte::in) = (BM::bitmap_uo),
     [will_not_call_mercury, promise_pure, thread_safe, will_not_modify_trail],
@@ -1769,7 +1757,6 @@
     BM = BM0;
     BM.elements[N] = (byte) Byte;
 ").
-*/

 %-----------------------------------------------------------------------------%

@@ -1790,14 +1777,12 @@
     BM = new mercury.bitmap.MercuryBitmap(N);
 ").

-/* XXX UNTESTED
 :- pragma foreign_proc("C#",
     allocate_bitmap(N::in) = (BM::bitmap_uo),
     [will_not_call_mercury, promise_pure, thread_safe, will_not_modify_trail],
 "
-    BM = new [mercury]mercury.bitmap__csharp_code.MercuryBitmap(N);
+    BM = new MercuryBitmap(N);
 ").
-*/

 :- func resize_bitmap(bitmap, num_bits) = bitmap.
 :- mode resize_bitmap(bitmap_di, in) = bitmap_uo is det.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list