[m-rev.] for review: improvements to bitmap.m [1]
Jonathan Morgan
jonmmorgan at gmail.com
Mon Feb 12 21:51:45 AEDT 2007
I'm reviewing the IL parts of this change, but I'll test it once I've
got the IL backend working again. As the bits I'm reviewing are in
comments, there is no pressing need to change them.
On 2/11/07, Simon Taylor <staylr at gmail.com> wrote:
> For review by Ralph.
>
>
> Estimated hours taken: 80
> Branches: main
>
...
> +/* XXX UNTESTED
> +:- pragma foreign_code("C#", "
> +namespace mercury {
> + namespace bitmap__csharp_code {
> +
> + public class MercuryBitmap {
> + int num_bits;
> + byte[] elements;
> +
> + MercuryBitmap(int numBits) {
> + num_bits = numBits;
> + elements = new byte[numBits / 8 + (((numBits % 8) != 0) ? 1: 0)];
> + }
> + }
> + }
> +}
> +").
> +*/
This doesn't look right. All foreign_code declarations will already
be inside the class mercury.bitmap__csharp_code.mercury_code, so both
namespace declarations should be removed (if you want to have code
outside of this class, then use `pragma foreign_decl' instead, but
this code shouldn't need it).
If you want to access them later you might need public on your
instance declarations (I can't remember how C# handles them by
default).
> +
> +:- 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.
> +/* XXX UNTESTED
> +:- pragma foreign_type("IL", bitmap,
> + "class [mercury]mercury.bitmap__csharp_code.MercuryBitmap")
> + where equality is bitmap_equal, comparison is bitmap_compare.
> +*/
That should be "class
[mercury]mercury.bitmap__csharp_code.mercury_code.MercuryBitmap".
I'm not sure whether inner classes can be accessed in this way. It
would probably be better to use a foreign_decl, as is done in the
various concurrency (thread.*) libraries.
> +:- pred bitmap_equal(bitmap, bitmap).
> +:- mode bitmap_equal(in, in) is semidet.
> +
...
> +/* 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);
> +").
> +*/
This is using a mixture of IL and C# syntax. You should be able to
get away with:
BM = new MercuryBitmap(N);
On a side note, does `will_not_modify_trail' have any meaning for the
IL backend?
Jon
--------------------------------------------------------------------------
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