Files
mercury/tests/hard_coded/test_java_foreign_primitive.exp
Julien Fischer a369cef8af Allow foreign types to be Java primitive types.
Currently we only allow non-primitive Java types to used with foreign_type
pragmas.  This means that for foreign types that map on to Java primitive types
we have to use their boxed form (e.g. java.lang.Long, java.lang.Float etc) in
the foreign_type pragma.  Doing so results in unnecessary boxing and is a
source of errors (e.g. accidently comparing for reference equality instead of
value equality).

This change causes the MLDS->Java code generator to recognise primitive
foreign_types and generate code that works for them directly.   (In effect
their handling is not really different to how the builtin types are handled.)

doc/reference.texi:
     Change the language so Java foreign types are allowed to be a
     primitive Java types.

compiler/mlds_to_java.m:
     Recognise foreign types that are defined as primitive types in Java and
     generate code that avoids the need for (some) boxing of them.

library/array.m:
     Handle arrays of Java bytes, shorts, longs and floats specially.
     (boolean, char, int and double were already handled thus.)

NEWS:
     Announce the above.

tests/hard_coded/Mmakefile:
tests/hard_coded/test_java_foreign_primitive.{m,exp}:
     Test that foreign types work with primitive types in Java.
2016-04-13 16:37:29 +10:00

15 lines
186 B
Plaintext

32
32
32
32
32.0
32.0
-128, -1, 0, 1, 127
-10, 0, 1, 48
-100, -1, 0, 561, 60000
1, 2, 60, 231231231
-100.0, 0.0, 10.0, 561.0
-100.0, 0.0, 10.0, 561.0
true, false, false, true
A, B, C, D