Branches: main
Make Java classes corresponding to Mercury types automatically serialisable.
java/runtime/MercuryType.java:
Make MercuryType extend java.io.Serializable.
compiler/mlds_to_java.m:
java/runtime/MercuryEnum.java:
Add a MercuryEnum interface which is implemented by classes
corresponding to Mercury enumerations. Previously enumerations
didn't implement MercuryType.
compiler/ml_type_gen.m:
Make enumeration classes implement MercuryType and MercuryEnum.
library/builtin.m:
Make builtin.copy check for MercuryEnum instead of relying on
enumeration classes not to implement MercuryType. This is not
strictly necessary but avoids copying instances of enumeration
classes.
Branches: main
Put all Mercury-generated Java classes into the package `jmercury' and
runtime classes into `jmercury.runtime'. The Mercury module hierarchy is
not reflected in the package name. We name sub-module classes using
their fully-qualified module names with `__' between components, e.g.
`bit_buffer.read' produces `class bit_buffer__read'.
As all generated Java code is in the same package we don't need to package
qualify identifiers, and we don't need the hack to avoid clashing package
and class names. It also makes it easier to write Java foreign code because
generated Java class names are easier to predict from Mercury module names.
The package names are not `mercury' and `mercury.runtime' because on
case-insensitive file systems we may end up with a `mercury' directory
that could be confused with the `Mercury' directory.
compiler/java_names.m:
Delete code related to mangling package names.
Remove the extra `mercury' prefix added to standard library module
names, as it is redundant with `jmercury'.
Change runtime package name.
compiler/mlds_to_java.m:
Make generated code follow the new packaging scheme.
Don't automatically import all runtime classes. It doesn't seem
necessary.
Update for new packaging scheme.
compiler/file_names.m:
Fix Java file paths for the new packaging scheme.
compiler/module_cmds.m:
compiler/rtti.m:
library/array.m:
library/backjump.m:
library/benchmarking.m:
library/bitmap.m:
library/builtin.m:
library/exception.m:
library/io.m:
library/library.m:
library/mutvar.m:
library/private_builtin.m:
library/rtti_implementation.m:
library/store.m:
library/string.m:
library/time.m:
library/type_desc.m:
java/runtime/*.java:
Rename package names.
Delete unnecessary package qualification.
compiler/mlds.m:
Add some XXXs to be fixed later.
library/Mmakefile:
Update for new packaging scheme.
Let mmake --use-mmc-make work in this directory.
Branches: main
Fix two problems implementation of arrays for Java backend:
- array.from_list([1, 2, 3]) didn't work because it would create an Integer[]
array, but the code generated by the Mercury compiler would try to assign
it to a int[] variable. Fix this by special casing the primitive types to
create arrays with the expected types.
- We used the class of a representative element to determine the type of
an array to create. Enumeration types only have the one class
corresponding to the Mercury type, so the class of the representative
element is correct.
However, general d.u. types have subclasses for each functor, so the class
of a representative element could correspond to a functor. This meant that
arrays could only hold more elements with the same functor. What is needed
is actually the super class, corresponding to a Mercury type.
The solution adopted here is to make Java classes corresponding to Mercury
types implement an interface called `MercuryType'. Then we can tell
whether the class or the superclass of the representative element is the
one needed.
java/runtime/MercuryType.java:
Add the new interface.
compiler/ml_type_gen.m:
When the target language is Java, make d.u. parent types implement
the `MercuryType' interface.
compiler/mlds_to_java.m:
Make the `MercuryType' interface special so it is printed without an
arity suffix.
library/array.m:
Fix the problems with creating/resizing ararys.