[m-dev.] for review: Java runtime system (Part I)

Julien Fischer juliensf at students.cs.mu.oz.au
Thu Feb 22 16:41:38 AEDT 2001


These are the classes from the Java runtime system.  I'll post
another diff shortly with readme's, makefile's and things
related to the standard library.

Julien

---------------------------

Estimated hours taken: 12

Classes used by the Java backend, particularly in the implementation
of RTTI.  

java/Compare.java:
java/DuExistInfo.java:
java/DuExistLocn.java:
java/DuFunctorDesc.java:
java/DuPtagLayout.java:
java/EnumFunctorDesc.java:
java/JavaInternal.java:
java/NotagFunctorDesc.java:
java/ProcAddr.java:
java/PseudoTypeInfo.java:
java/Sectag_Locn.java:
java/TypeCtorInfo_Struct.java
java/TypeCtorRep.java:
java/TypeFunctors.java:
java/TypeLayout.java:
java/Unify.java:
java/UnreachableDefault.java:
	New files.

==============================================================
--- /dev/null	Mon Jul  3 19:10:56 2000
+++ Compare.java	Thu Feb 22 16:18:17 2001
@@ -0,0 +1,17 @@
+//
+// Copyright (C) 2001 The University of Melbourne.
+// 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 interface is implemented by classes that are wrapped around the
+// `compare' special predicate.  Instantitions of those classes are then
+// used as entries in the TypeCtorInfo_Struct's.
+//
+
+package mercury.runtime;
+
+public interface Compare {
+	public abstract mercury.Builtin.comparison_result_0 call(
+			java.lang.Object[] args); 
+}
+
--- /dev/null	Mon Jul  3 19:10:56 2000
+++ DuExistInfo.java	Thu Feb 22 13:12:12 2001
@@ -0,0 +1,16 @@
+//
+// Copyright (C) 2001 The University of Melbourne.
+// 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.
+//
+
+package mercury.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;
+
+}
--- /dev/null	Mon Jul  3 19:10:56 2000
+++ DuExistLocn.java	Thu Feb 22 12:28:58 2001
@@ -0,0 +1,14 @@
+//
+// Copyright (C) 2001 The University of Melbourne.
+// 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.
+//
+
+package mercury.runtime;
+
+public class DuExistLocn {
+	
+	public int exist_arg_num;
+	public int exist_offset_in_tci;
+
+}
--- /dev/null	Mon Jul  3 19:10:56 2000
+++ DuFunctorDesc.java	Thu Feb 22 13:12:50 2001
@@ -0,0 +1,24 @@
+//
+// Copyright (C) 2001 The University of Melbourne.
+// 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.
+//
+
+package mercury.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 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*/ java.lang.String[] du_functor_arg_names;
+	public /*final*/ mercury.runtime.DuExistInfo[] du_functor_exist_info;
+
+}
--- /dev/null	Mon Jul  3 19:10:56 2000
+++ DuPtagLayout.java	Thu Feb 22 13:10:32 2001
@@ -0,0 +1,15 @@
+//
+// Copyright (C) 2001 The University of Melbourne.
+// 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.
+//
+
+package mercury.runtime;
+
+public class DuPtagLayout {
+	
+	public int sectag_sharers;
+	public mercury.runtime.Sectag_Locn sectag_locn;
+	public /* final */ DuFunctorDesc[] sectag_alternatives;
+
+}
--- /dev/null	Mon Jul  3 19:10:56 2000
+++ EnumFunctorDesc.java	Thu Feb 22 15:27:50 2001
@@ -0,0 +1,14 @@
+//
+// Copyright (C) 2001 The University of Melbourne.
+// 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.
+//
+
+package mercury.runtime;
+
+public class EnumFunctorDesc {
+	
+	public java.lang.String enum_functor_name;
+	public int              enum_functor_ordinal;
+
+}
--- /dev/null	Mon Jul  3 19:10:56 2000
+++ JavaInternal.java	Mon Feb 19 13:21:19 2001
@@ -0,0 +1,20 @@
+//
+// Copyright (C) 2001 The University of Melbourne.
+// 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.
+//
+//
+// All modifications to this file will require changes to:
+// compiler/mlds_to_java.m
+// 
+//
+// At the moment this class is just used to store the command line
+//   arguments.   
+//
+
+package mercury.runtime;
+
+public class JavaInternal {
+	public static java.lang.String[] args;
+}
--- /dev/null	Mon Jul  3 19:10:56 2000
+++ NotagFunctorDesc.java	Thu Feb 22 16:05:54 2001
@@ -0,0 +1,15 @@
+//
+// Copyright (C) 2001 The University of Melbourne.
+// 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.
+//
+
+package mercury.runtime;
+
+public class NotagFunctorDesc {
+	
+	public java.lang.String no_tag_functor_name;
+	public mercury.runtime.PseudoTypeInfo no_tag_functor_arg_type;
+	public java.lang.String no_tag_functor_arg_name;
+}
+		
--- /dev/null	Mon Jul  3 19:10:56 2000
+++ ProcAddr.java	Thu Feb 22 16:27:19 2001
@@ -0,0 +1,18 @@
+//
+// Copyright (C) 2001 The University of Melbourne.
+// 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 interface is implemented by classes that have been wrapped around
+// any general predicate. We then use instantiations of those classes as
+// pseudo function pointers (which we don't have in Java).  The original
+// predicate can be called via the `call' method.  This interface should
+// not be used for the `compare' and `unify' special predicates as the
+// `Unify' and `Compare' interfaces perform as similar function for them.
+//
+
+package mercury.runtime;
+
+public interface ProcAddr {
+	public abstract java.lang.Object[] call(java.lang.Object[] Args);
+}
--- /dev/null	Mon Jul  3 19:10:56 2000
+++ PseudoTypeInfo.java	Thu Feb 22 16:07:25 2001
@@ -0,0 +1,13 @@
+//
+// Copyright (C) 2001 The University of Melbourne.
+// 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.
+//
+
+package mercury.runtime;
+
+public abstract class PseudoTypeInfo {
+	// This class is intentionally empty. 
+	// XXX PsuedoTypeInfo's have not been implemented yet.
+	//     They should all extend this class.
+}
--- /dev/null	Mon Jul  3 19:10:56 2000
+++ Sectag_Locn.java	Thu Feb 22 16:08:45 2001
@@ -0,0 +1,23 @@
+//
+// Copyright (C) 2001 The University of Melbourne.
+// 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.
+//
+
+package mercury.runtime;
+
+public class Sectag_Locn {
+	
+	public static final int MR_SECTAG_NONE = 0;
+	public static final int MR_SECTAG_LOCAL = 1;
+	public static final int MR_SECTAG_REMOTE = 2;
+
+	public int value;
+
+	public Sectag_locn(int arg) {
+		this.value = arg
+	}
+}
+
+
+
--- /dev/null	Mon Jul  3 19:10:56 2000
+++ TypeCtorInfo_Struct.java	Thu Feb 22 12:54:07 2001
@@ -0,0 +1,25 @@
+//
+// Copyright (C) 2001 The University of Melbourne.
+// 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.
+//
+
+package mercury.runtime;
+
+public class TypeCtorInfo_Struct {
+    
+	public int                              arity;
+	public mercury.runtime.Unify            unify_pred;
+	public mercury.runtime.Unify            new_unify_pred;
+	public mercury.runtime.Compare          compare_pred;
+	public mercury.runtime.TypeCtorRep      type_ctor_rep;
+	public mercury.runtime.ProcAddr         unused1;    // spare 
+	public mercury.runtime.ProcAddr         unused2;    // spare 
+	public java.lang.String                 type_ctor_module_name;
+	public java.lang.String                 type_ctor_name;
+	public int                              type_ctor_version;
+	public mercury.runtime.TypeFunctors     type_functors;
+	public mercury.runtime.TypeLayout       type_layout;
+	public int 			        type_ctor_num_functors;
+	public int                              type_ctor_num_ptags; // if DU 
+}
--- /dev/null	Mon Jul  3 19:10:56 2000
+++ TypeCtorRep.java	Thu Feb 22 16:09:55 2001
@@ -0,0 +1,56 @@
+//
+// Copyright (C) 2001 The University of Melbourne.
+// 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.
+//
+
+package mercury.runtime;
+
+public class TypeCtorRep {
+	
+	// Constants
+	
+	public static final int MR_TYPECTOR_REP_ENUM = 0;
+	public static final int MR_TYPECTOR_REP_ENUM_USEREQ = 1;
+	public static final int MR_TYPECTOR_REP_DU = 2;
+	public static final int MR_TYPECTOR_REP_DU_USEREQ = 3;
+	public static final int MR_TYPECTOR_REP_NOTAG = 4;
+	public static final int MR_TYPECTOR_REP_NOTAG_USEREQ = 5;
+	public static final int MR_TYPECTOR_REP_EQUIV = 6;
+	public static final int MR_TYPECTOR_REP_EQUIV_VAR = 7;
+	public static final int MR_TYPECTOR_REP_INT = 8;
+	public static final int MR_TYPECTOR_REP_CHAR = 9;
+	public static final int MR_TYPECTOR_REP_FLOAT = 10;
+	public static final int MR_TYPECTOR_REP_STRING = 11;
+	public static final int MR_TYPECTOR_REP_PRED = 12;
+	public static final int MR_TYPECTOR_REP_UNIV = 13;
+	public static final int MR_TYPECTOR_REP_VOID = 14;
+	public static final int MR_TYPECTOR_REP_C_POINTER = 15;
+	public static final int MR_TYPECTOR_REP_TYPEINFO = 16;
+	public static final int MR_TYPECTOR_REP_TYPECLASSINFO = 17;
+	public static final int MR_TYPECTOR_REP_ARRAY = 18;
+	public static final int MR_TYPECTOR_REP_SUCCIP = 19;
+	public static final int MR_TYPECTOR_REP_HP = 20;
+	public static final int MR_TYPECTOR_REP_CURFR = 21;
+	public static final int MR_TYPECTOR_REP_MAXFR = 22;
+	public static final int MR_TYPECTOR_REP_REDOFR = 23;
+	public static final int MR_TYPECTOR_REP_REDOIP = 24;
+	public static final int MR_TYPECTOR_REP_TRAIL_PTR = 25;
+	public static final int MR_TYPECTOR_REP_TICKET = 26;
+	public static final int MR_TYPECTOR_REP_NOTAG_GROUND = 27;
+	public static final int MR_TYPECTOR_REP_NOTAG_GROUND_USEREQ = 28;
+	public static final int MR_TYPECTOR_REP_EQUIV_GROUND = 29;
+	public static final int MR_TYPECTOR_REP_TUPLE = 30;
+	public static final int MR_TYPECTOR_REP_UNKNOWN = 31;
+	
+	// Instance variable for TypeCtorRep objects.
+	
+	public int value;
+
+	// Constructor
+
+	public TypeCtorRep(int arg) {
+		this.value = arg;
+	}
+}
+	
--- /dev/null	Mon Jul  3 19:10:56 2000
+++ TypeFunctors.java	Thu Feb 22 16:11:11 2001
@@ -0,0 +1,21 @@
+//
+// Copyright (C) 2001 The University of Melbourne.
+// 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.
+//
+
+package mercury.runtime;
+
+//   XXX In the C backend this was a union.  
+//   It would (eventually) be better to have derived classes
+//   for each of the unions constructors and make them all extend
+//   this class (rather like we do with the generated code from the 
+//   mercury compiler.  That way we can just use the `instanceof' operator
+//   to work out what each instance is.
+
+public class TypeFunctors {
+	public java.lang.Object functors_init;
+	public mercury.runtime.DuFunctorDesc[] functors_du;
+	public mercury.runtime.EnumFunctorDesc[] functors_enum;
+	public mercury.runtime.NotagFunctorDesc functors_notag;
+}
--- /dev/null	Mon Jul  3 19:10:56 2000
+++ TypeLayout.java	Thu Feb 22 16:12:12 2001
@@ -0,0 +1,35 @@
+//
+// Copyright (C) 2001 The University of Melbourne.
+// 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.
+//
+	
+package mercury.runtime;
+
+public class TypeLayout {
+		//
+		// In runtime/mercury_type_info.h:
+		// typedef MR_DuPtagLayout *MR_DuTypeLayout;
+		// so here we just use DuPtagLayout[]
+		//
+	public mercury.runtime.DuPtagLayout[] layout_du;
+		//
+		// In runtime/mercury_type_info.h:
+		// typedef MR_EnumFunctorDesc **EnumTypeLayout;
+		// so here we just use EnumFunctorDesc[][]
+		//
+	public mercury.runtime.EnumFunctorDesc[] layout_enum;
+		//
+		// In runtime/mercury_type_info.h:
+		// typedef MR_NotagFunctorDesc *MR_NotagTypeLayout;
+		// so here we just us NotagFunctorDesc[]
+		//
+	public mercury.runtime.NotagFunctorDesc[] layout_notag;
+		//
+		// In runtime/mercury_type_info.h:
+		// typedef MR_PseudoTypeInfo MR_EquivType;
+		// so here we just use MR_PseudoTypeInfo
+		//
+	public mercury.runtime.PseudoTypeInfo layout_equiv;
+}
+	
--- /dev/null	Mon Jul  3 19:10:56 2000
+++ Unify.java	Thu Feb 22 16:19:41 2001
@@ -0,0 +1,15 @@
+//
+// Copyright (C) 2001 The University of Melbourne.
+// 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 interface is implemented by classes that are wrapped around the
+// `unify' special predicate.  Instantitions of those classes are then
+// used as entries in the TypeCtorInfo_Struct's.
+//
+
+package mercury.runtime;
+
+public interface Unify {
+	public abstract boolean call(java.lang.Object[] args);
+}
--- /dev/null	Mon Jul  3 19:10:56 2000
+++ UnreachableDefault.java	Thu Feb 22 13:22:06 2001
@@ -0,0 +1,21 @@
+//
+// Copyright (C) 2001 The University of Melbourne.
+// 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 exception signals when an unreachable default case of of a switch
+// statement is reached.
+//
+
+package mercury.runtime;
+
+public class UnreachableDefault extends java.lang.RuntimeException {
+	
+	public UnreachableDefault() {
+		super();
+	}
+
+	public UnreachableDefault(String s) {
+		super(s);
+	}
+}



--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list