Put all Mercury-generated Java classes into the package `jmercury' and

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.
This commit is contained in:
Peter Wang
2009-06-17 07:48:16 +00:00
parent 018614f3c6
commit 1b648d0ac2
53 changed files with 420 additions and 524 deletions

View File

@@ -6,7 +6,7 @@
// This is a throwable class used for the Java implementation of commits.
//
package mercury.runtime;
package jmercury.runtime;
public class Commit extends java.lang.Error {

View File

@@ -8,7 +8,7 @@
// At the moment it just stores the library version.
//
package mercury.runtime;
package jmercury.runtime;
public class Constants {
public static final java.lang.String MR_VERSION = "@VERSION@";

View File

@@ -4,24 +4,23 @@
// Public License - see the file COPYING.LIB in the Mercury distribution.
//
package mercury.runtime;
package jmercury.runtime;
public class DuExistInfo {
public int exist_typeinfos_plain;
public int exist_typeinfos_in_tci;
public int exist_tcis;
public /* final */ mercury.runtime.DuExistLocn[] exist_typeinfo_locns;
public /* final */ mercury.runtime.TypeClassConstraint[]
exist_constraints;
public /* final */ DuExistLocn[] exist_typeinfo_locns;
public /* final */ TypeClassConstraint[] exist_constraints;
public DuExistInfo()
{
}
public void init(int typeinfos_plain, int typeinfos_in_tci, int tcis,
mercury.runtime.DuExistLocn[] typeinfo_locns,
mercury.runtime.TypeClassConstraint constraints[])
DuExistLocn[] typeinfo_locns,
TypeClassConstraint constraints[])
{
exist_typeinfos_plain = typeinfos_plain;
exist_typeinfos_in_tci = typeinfos_in_tci;

View File

@@ -4,7 +4,7 @@
// Public License - see the file COPYING.LIB in the Mercury distribution.
//
package mercury.runtime;
package jmercury.runtime;
// Corresponds to MR_DuExistLocn in runtime/mercury_type_info.h

View File

@@ -4,22 +4,22 @@
// Public License - see the file COPYING.LIB in the Mercury distribution.
//
package mercury.runtime;
package jmercury.runtime;
public class DuFunctorDesc {
public java.lang.String du_functor_name;
public int du_functor_orig_arity;
public int du_functor_arg_type_contains_var;
public mercury.runtime.Sectag_Locn du_functor_sectag_locn;
public Sectag_Locn du_functor_sectag_locn;
public int du_functor_primary;
public int du_functor_secondary;
public int du_functor_ordinal;
// XXX PseudoTypeInfo's have not been implemented properly
// yet, so this may not be correct.
public /*final*/ mercury.runtime.PseudoTypeInfo[] du_functor_arg_types;
public /*final*/ PseudoTypeInfo[] du_functor_arg_types;
public /*final*/ java.lang.String[] du_functor_arg_names;
public /*final*/ mercury.runtime.DuExistInfo du_functor_exist_info;
public /*final*/ DuExistInfo du_functor_exist_info;
public DuFunctorDesc()
{
@@ -37,15 +37,12 @@ public class DuFunctorDesc {
du_functor_orig_arity = orig_arity;
du_functor_ordinal = ordinal;
du_functor_arg_type_contains_var = arg_type_contains_var;
du_functor_sectag_locn =
new mercury.runtime.Sectag_Locn(sectag_locn);
du_functor_sectag_locn = new Sectag_Locn(sectag_locn);
du_functor_primary = primary;
du_functor_secondary = secondary;
du_functor_ordinal = ordinal;
du_functor_arg_types = (mercury.runtime.PseudoTypeInfo [])
arg_types;
du_functor_arg_types = (PseudoTypeInfo []) arg_types;
du_functor_arg_names = (java.lang.String []) arg_names;
du_functor_exist_info =
(mercury.runtime.DuExistInfo) exist_info;
du_functor_exist_info = (DuExistInfo) exist_info;
}
}

View File

@@ -4,16 +4,15 @@
// Public License - see the file COPYING.LIB in the Mercury distribution.
//
package mercury.runtime;
package jmercury.runtime;
public class DuPtagLayout {
public int sectag_sharers;
public mercury.runtime.Sectag_Locn sectag_locn;
public /* final */ mercury.runtime.DuFunctorDesc[] sectag_alternatives;
public Sectag_Locn sectag_locn;
public /* final */ DuFunctorDesc[] sectag_alternatives;
public DuPtagLayout(int sharers, mercury.runtime.Sectag_Locn locn,
mercury.runtime.DuFunctorDesc[] alts)
public DuPtagLayout(int sharers, Sectag_Locn locn, DuFunctorDesc[] alts)
{
sectag_sharers = sharers;
sectag_locn = locn;
@@ -22,7 +21,7 @@ public class DuPtagLayout {
public DuPtagLayout(int sharers, int locn, DuFunctorDesc[] alts) {
sectag_sharers = sharers;
sectag_locn = new mercury.runtime.Sectag_Locn(locn);
sectag_locn = new Sectag_Locn(locn);
sectag_alternatives = alts;
}
}

View File

@@ -4,7 +4,7 @@
// Public License - see the file COPYING.LIB in the Mercury distribution.
//
package mercury.runtime;
package jmercury.runtime;
public class EnumFunctorDesc {

View File

@@ -4,7 +4,7 @@
// Public License - see the file COPYING.LIB in the Mercury distribution.
//
package mercury.runtime;
package jmercury.runtime;
public class Exception extends java.lang.Error {
// Should be mercury.univ.Univ_0 but we don't want to depend on the

View File

@@ -4,7 +4,7 @@
// Public License - see the file COPYING.LIB in the Mercury distribution.
//
package mercury.runtime;
package jmercury.runtime;
public class ForeignEnumFunctorDesc {

View File

@@ -14,7 +14,7 @@
// level class.
//
package mercury.runtime;
package jmercury.runtime;
public class JavaInternal {
public static java.lang.String progname;

View File

@@ -4,7 +4,7 @@
// Public License - see the file COPYING.LIB in the Mercury distribution.
//
package mercury.runtime;
package jmercury.runtime;
public class MaybeResAddrFunctorDesc {
public java.lang.String maybe_res_name;

View File

@@ -4,7 +4,7 @@
// Public License - see the file COPYING.LIB in the Mercury distribution.
//
package mercury.runtime;
package jmercury.runtime;
public class MaybeResFunctorDesc {
public DuFunctorDesc maybe_res_du;

View File

@@ -7,7 +7,7 @@
// generated by the Java back-end to implement method pointers in Java.
//
package mercury.runtime;
package jmercury.runtime;
public interface MercuryType {
}

View File

@@ -7,7 +7,7 @@
// generated by the Java back-end to implement method pointers in Java.
//
package mercury.runtime;
package jmercury.runtime;
public interface MethodPtr {
public abstract java.lang.Object call___0_0(java.lang.Object[] args);

View File

@@ -3,7 +3,8 @@
# This file may only be copied under the terms of the GNU Library General
# Public License - see the file COPYING.LIB in the Mercury distribution.
#
# This Makefile compiles the shared object for use with mercury.runtime.Native
# This Makefile compiles the shared object for use with
# jmercury.runtime.Native
#
MERCURY_DIR = ../..

View File

@@ -12,7 +12,7 @@
// At the moment the only services provided are those relating to timing.
//
package mercury.runtime;
package jmercury.runtime;
public class Native {
/*
@@ -86,8 +86,7 @@ public class Native {
SHARED_OBJ);
if (match.exists() == false) {
dir = new java.io.File(dir,
mercury.runtime.Constants.
MR_FULLARCH);
Constants.MR_FULLARCH);
match = new java.io.File(dir,
SHARED_OBJ);
}

View File

@@ -4,16 +4,16 @@
// Public License - see the file COPYING.LIB in the Mercury distribution.
//
package mercury.runtime;
package jmercury.runtime;
public class NotagFunctorDesc {
public java.lang.String no_tag_functor_name;
public mercury.runtime.PseudoTypeInfo no_tag_functor_arg_type;
public PseudoTypeInfo no_tag_functor_arg_type;
public java.lang.String no_tag_functor_arg_name;
public NotagFunctorDesc(java.lang.String functor_name,
mercury.runtime.PseudoTypeInfo functor_arg_type,
PseudoTypeInfo functor_arg_type,
java.lang.Object functor_arg_name)
{
no_tag_functor_name = functor_name;

View File

@@ -4,7 +4,7 @@
// Public License - see the file COPYING.LIB in the Mercury distribution.
//
package mercury.runtime;
package jmercury.runtime;
public class PredFunc {

View File

@@ -4,7 +4,7 @@
// Public License - see the file COPYING.LIB in the Mercury distribution.
//
package mercury.runtime;
package jmercury.runtime;
// A PseudoTypeInfo represents a possibly non-ground type.
// There are three possible cases:

View File

@@ -7,7 +7,7 @@
// This corresponds to the C type MR_ReservedAddrFunctorDesc
// in runtime/mercury_type_info.h.
package mercury.runtime;
package jmercury.runtime;
public class ReservedAddrFunctorDesc {
public java.lang.String ra_functor_name;

View File

@@ -4,7 +4,7 @@
// Public License - see the file COPYING.LIB in the Mercury distribution.
//
package mercury.runtime;
package jmercury.runtime;
public class Sectag_Locn {

View File

@@ -4,7 +4,7 @@
// Public License - see the file COPYING.LIB in the Mercury distribution.
//
package mercury.runtime;
package jmercury.runtime;
// This corresponds to the C type MR_TypeClassConstraint
// in runtime/mercury_type_info.h.
@@ -18,7 +18,7 @@ public class TypeClassConstraint {
}
public void init(TypeClassDeclStruct type_class,
// XXX Object[] should be mercury.runtime.PseudoTypeInfo[],
// XXX Object[] should be PseudoTypeInfo[],
// but mlds_to_java.m generates Object[] since
// init_array/1 doesn't give type info
Object[] ptis)

View File

@@ -4,7 +4,7 @@
// Public License - see the file COPYING.LIB in the Mercury distribution.
//
package mercury.runtime;
package jmercury.runtime;
// This corresponds to the C typedef "MR_TypeClassDeclStruct"
// in runtime/mercury_types.h, i.e. the C struct

View File

@@ -4,7 +4,7 @@
// Public License - see the file COPYING.LIB in the Mercury distribution.
//
package mercury.runtime;
package jmercury.runtime;
// This corresponds to the C type MR_TypeClassId
// in runtime/mercury_typeclass_info.h.

View File

@@ -4,7 +4,7 @@
// Public License - see the file COPYING.LIB in the Mercury distribution.
//
package mercury.runtime;
package jmercury.runtime;
// This corresponds to the C type MR_TypeClassMethod
// in runtime/mercury_typeclass_info.h.

View File

@@ -4,26 +4,26 @@
// Public License - see the file COPYING.LIB in the Mercury distribution.
//
package mercury.runtime;
package jmercury.runtime;
// This corresponds to the C type "struct MR_TypeCtorInfo_Struct"
// in runtime/mercury_type_info.h.
public class TypeCtorInfo_Struct extends PseudoTypeInfo {
public int arity;
public int type_ctor_version;
public int type_ctor_num_ptags; // if DU
public mercury.runtime.TypeCtorRep type_ctor_rep;
public mercury.runtime.MethodPtr unify_pred;
public mercury.runtime.MethodPtr compare_pred;
public java.lang.String type_ctor_module_name;
public java.lang.String type_ctor_name;
public mercury.runtime.TypeFunctors type_functors;
public mercury.runtime.TypeLayout type_layout;
public int type_ctor_num_functors;
public /* short */ int type_ctor_flags;
public int[] type_functor_number_map;
public int arity;
public int type_ctor_version;
public int type_ctor_num_ptags; // if DU
public TypeCtorRep type_ctor_rep;
public MethodPtr unify_pred;
public MethodPtr compare_pred;
public java.lang.String type_ctor_module_name;
public java.lang.String type_ctor_name;
public TypeFunctors type_functors;
public TypeLayout type_layout;
public int type_ctor_num_functors;
public /* short */ int type_ctor_flags;
public int[] type_functor_number_map;
public TypeCtorInfo_Struct()
{
@@ -33,9 +33,9 @@ public class TypeCtorInfo_Struct extends PseudoTypeInfo {
int type_arity, int version, int num_ptags, int rep,
Object unify_proc, Object compare_proc,
String module, String name,
// mercury.runtime.TypeFunctors
// TypeFunctors
java.lang.Object name_ordered_functor_descs,
// mercury.runtime.TypeLayout
// TypeLayout
java.lang.Object value_ordered_functor_descs,
int num_functors, int flags,
int[] functor_number_map)
@@ -44,14 +44,12 @@ public class TypeCtorInfo_Struct extends PseudoTypeInfo {
type_ctor_version = version;
type_ctor_num_ptags = num_ptags;
type_ctor_rep = new TypeCtorRep(rep);
unify_pred = (mercury.runtime.MethodPtr) unify_proc;
compare_pred = (mercury.runtime.MethodPtr) compare_proc;
unify_pred = (MethodPtr) unify_proc;
compare_pred = (MethodPtr) compare_proc;
type_ctor_module_name = module;
type_ctor_name = name;
type_functors = (mercury.runtime.TypeFunctors)
name_ordered_functor_descs;
type_layout = (mercury.runtime.TypeLayout)
value_ordered_functor_descs;
type_functors = (TypeFunctors) name_ordered_functor_descs;
type_layout = (TypeLayout) value_ordered_functor_descs;
type_ctor_flags = flags;
type_functor_number_map = functor_number_map;
}

View File

@@ -4,7 +4,7 @@
// Public License - see the file COPYING.LIB in the Mercury distribution.
//
package mercury.runtime;
package jmercury.runtime;
public class TypeCtorRep {

View File

@@ -4,7 +4,7 @@
// Public License - see the file COPYING.LIB in the Mercury distribution.
//
package mercury.runtime;
package jmercury.runtime;
// XXX In the C backend this was a union.
// It might (eventually) be better to have derived classes
@@ -16,17 +16,17 @@ package mercury.runtime;
public class TypeFunctors {
public java.lang.Object functors_init;
// the above field should contain one of the following types:
public mercury.runtime.DuFunctorDesc[] functors_du() {
return (mercury.runtime.DuFunctorDesc[]) functors_init;
public DuFunctorDesc[] functors_du() {
return (DuFunctorDesc[]) functors_init;
}
public mercury.runtime.EnumFunctorDesc[] functors_enum() {
return (mercury.runtime.EnumFunctorDesc[]) functors_init;
public EnumFunctorDesc[] functors_enum() {
return (EnumFunctorDesc[]) functors_init;
}
public mercury.runtime.ForeignEnumFunctorDesc[] functors_foreign_enum() {
return (mercury.runtime.ForeignEnumFunctorDesc[]) functors_init;
public ForeignEnumFunctorDesc[] functors_foreign_enum() {
return (ForeignEnumFunctorDesc[]) functors_init;
}
public mercury.runtime.NotagFunctorDesc functors_notag() {
return (mercury.runtime.NotagFunctorDesc) functors_init;
public NotagFunctorDesc functors_notag() {
return (NotagFunctorDesc) functors_init;
}
public TypeFunctors(java.lang.Object init) {
functors_init = init;

View File

@@ -4,7 +4,7 @@
// Public License - see the file COPYING.LIB in the Mercury distribution.
//
package mercury.runtime;
package jmercury.runtime;
public class TypeInfo_Struct extends PseudoTypeInfo {

View File

@@ -4,7 +4,7 @@
// Public License - see the file COPYING.LIB in the Mercury distribution.
//
package mercury.runtime;
package jmercury.runtime;
public class TypeLayout {
// This should hold a value of one of the types
@@ -16,8 +16,8 @@ public class TypeLayout {
// typedef MR_DuPtagLayout *MR_DuTypeLayout;
// so here we just use DuPtagLayout[]
//
public mercury.runtime.DuPtagLayout[] layout_du() {
return (mercury.runtime.DuPtagLayout[]) layout_init;
public DuPtagLayout[] layout_du() {
return (DuPtagLayout[]) layout_init;
}
//
@@ -25,8 +25,8 @@ public class TypeLayout {
// typedef MR_EnumFunctorDesc **EnumTypeLayout;
// so here we just use EnumFunctorDesc[][]
//
public mercury.runtime.EnumFunctorDesc[] layout_enum() {
return (mercury.runtime.EnumFunctorDesc[]) layout_init;
public EnumFunctorDesc[] layout_enum() {
return (EnumFunctorDesc[]) layout_init;
}
//
@@ -34,16 +34,16 @@ public class TypeLayout {
// typedef MR_NotagFunctorDesc *MR_NotagTypeLayout;
// so here we just us NotagFunctorDesc[]
//
public mercury.runtime.NotagFunctorDesc[] layout_notag() {
return (mercury.runtime.NotagFunctorDesc[]) layout_init;
public NotagFunctorDesc[] layout_notag() {
return (NotagFunctorDesc[]) layout_init;
}
//
// In runtime/mercury_type_info.h:
// typedef MR_PseudoTypeInfo MR_EquivType;
// so here we just use MR_PseudoTypeInfo
//
public mercury.runtime.PseudoTypeInfo layout_equiv() {
return (mercury.runtime.PseudoTypeInfo) layout_init;
public PseudoTypeInfo layout_equiv() {
return (PseudoTypeInfo) layout_init;
}
public TypeLayout(java.lang.Object init) {

View File

@@ -7,7 +7,7 @@
// statement is reached.
//
package mercury.runtime;
package jmercury.runtime;
public class UnreachableDefault extends java.lang.RuntimeException {