[m-rev.] for review: add uint->uintN conversions

Zoltan Somogyi zoltan.somogyi at runbox.com
Wed Jun 30 22:02:12 AEST 2021


2021-06-30 21:38 GMT+10:00 "Julien Fischer" <jfischer at opturion.com>:
>> > NEWS:
>>     Announce the new predicates and functions.
> 
> The test suite should be extended to cover these new operations.

OK. Seeing that there seems to be no test case in tests/hard_coded
into which tests of these functions would fit, the thing to do would seem
to be to create from_uint_uintN.m on the basis of from_int_uintN.
However, there is no from_int_uint64.m. Is this intentional, or
an oversight?

>> +:- func cast_from_uint(int) = uint64.
> 
> The argument type is incorrect there; it should be uint *not* int.

Fixed.

>> > @@ -464,8 +477,6 @@ det_from_int(I) = U64 :-
>>          error($pred, "cannot convert int to uint64")
>>      ).
> 
> ...
> 
>> +
>> +:- pragma foreign_proc("Java",
>> +    cast_from_uint(U::in) = (U64::out),
>> +    [will_not_call_mercury, promise_pure, thread_safe],
>> +"
>> +    U64 = U;
>> +").
> 
> That should be:
> 
>       U64 = (long) U & 0xffffffffL;
> 
> (Consider what happens when U is max_uint in the Java grade.)

Thanks for catching that.

Zoltan.


More information about the reviews mailing list