summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschinz <schinz@epfl.ch>2005-01-17 12:47:57 +0000
committerschinz <schinz@epfl.ch>2005-01-17 12:47:57 +0000
commit986b87a3be1febae98c2ff607a64b5cbd61131da (patch)
treec71792231c461d2c7827cded71642270b878a2bb
parent88a2e8af943918bdce075df159e8a1cd0af34397 (diff)
downloadscala-986b87a3be1febae98c2ff607a64b5cbd61131da.tar.gz
scala-986b87a3be1febae98c2ff607a64b5cbd61131da.tar.bz2
scala-986b87a3be1febae98c2ff607a64b5cbd61131da.zip
*** empty log message ***
-rw-r--r--sources/scala/runtime/types/JavaRefArrayType.java60
-rw-r--r--sources/scala/runtime/types/SpecialType.java37
-rw-r--r--sources/scala/runtime/types/TypeAll.java28
-rw-r--r--sources/scala/runtime/types/TypeAllRef.java29
-rw-r--r--sources/scala/runtime/types/TypeAny.java29
-rw-r--r--sources/scala/runtime/types/TypeAnyVal.java29
-rw-r--r--sources/scala/runtime/types/TypeUnit.java31
-rw-r--r--sources/scala/runtime/types/ValueType.java34
8 files changed, 277 insertions, 0 deletions
diff --git a/sources/scala/runtime/types/JavaRefArrayType.java b/sources/scala/runtime/types/JavaRefArrayType.java
new file mode 100644
index 0000000000..b4e80fee6a
--- /dev/null
+++ b/sources/scala/runtime/types/JavaRefArrayType.java
@@ -0,0 +1,60 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2003, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+// $Id$
+
+package scala.runtime.types;
+
+import scala.Type;
+import scala.Array;
+
+/**
+ * Type for Java arrays of references.
+ *
+ * @author Michel Schinz
+ * @version 1.0
+ */
+
+public class JavaRefArrayType extends Type {
+ public final Type elemType;
+
+ public JavaRefArrayType(Type elemType) {
+ this.elemType = elemType;
+ }
+
+ public Array newArray(int size) {
+ throw new Error(); // TODO
+ }
+
+ public Object defaultValue() {
+ return null;
+ }
+
+ public boolean isInstance(Object o) {
+ // TODO plus fin: on doit tenir compte de la version effacée
+ // de elemType.
+ return (o instanceof Object[]);
+ }
+
+ public boolean isSameAs(Type that) {
+ return (that instanceof JavaRefArrayType)
+ && (elemType.isSameAs(((JavaRefArrayType)that).elemType));
+ }
+
+ public boolean isSubType(Type that) {
+ return isSameAs(that);
+ }
+
+ public String toString() {
+ return elemType.toString() + "[]";
+ }
+
+ public int hashCode() {
+ return elemType.hashCode() * 11;
+ }
+}
diff --git a/sources/scala/runtime/types/SpecialType.java b/sources/scala/runtime/types/SpecialType.java
new file mode 100644
index 0000000000..33d6925262
--- /dev/null
+++ b/sources/scala/runtime/types/SpecialType.java
@@ -0,0 +1,37 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2003, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+// $Id$
+
+package scala.runtime.types;
+
+import scala.Type;
+import scala.Array;
+import scala.runtime.RunTime;
+
+/**
+ * Abstract superclass for all "special" types, which are types
+ * existing in Scala but not in Java: Any, AnyVal, All and AllRef.
+ *
+ * @author Michel Schinz
+ * @version 1.0
+ */
+
+abstract public class SpecialType extends Type {
+ public Array newArray(int size) {
+ return RunTime.box_oarray(new Object[size]);
+ }
+
+ public Object defaultValue() {
+ return null;
+ }
+
+ public boolean isSameAs(Type that) {
+ return this == that;
+ }
+}
diff --git a/sources/scala/runtime/types/TypeAll.java b/sources/scala/runtime/types/TypeAll.java
new file mode 100644
index 0000000000..10796e730d
--- /dev/null
+++ b/sources/scala/runtime/types/TypeAll.java
@@ -0,0 +1,28 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2003, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+// $Id$
+
+package scala.runtime.types;
+
+import scala.runtime.RunTime;
+import scala.Type;
+import scala.Array;
+
+public class TypeAll extends SpecialType {
+ public boolean isInstance(Object o) {
+ return false;
+ }
+
+ public boolean isSubType(Type that) {
+ return true;
+ }
+
+ public String toString() { return "scala.All"; }
+ public int hashCode() { return 0xAAAAAAAA; }
+};
diff --git a/sources/scala/runtime/types/TypeAllRef.java b/sources/scala/runtime/types/TypeAllRef.java
new file mode 100644
index 0000000000..92848c1911
--- /dev/null
+++ b/sources/scala/runtime/types/TypeAllRef.java
@@ -0,0 +1,29 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2003, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+// $Id$
+
+package scala.runtime.types;
+
+import scala.runtime.RunTime;
+import scala.Type;
+import scala.Array;
+
+public class TypeAllRef extends SpecialType {
+ public boolean isInstance(Object o) {
+ return false;
+ }
+
+ public boolean isSubType(Type that) {
+ return true;
+ }
+
+ public String toString() { return "scala.All"; }
+
+ public int hashCode() { return 0xDDDDDDDD; }
+};
diff --git a/sources/scala/runtime/types/TypeAny.java b/sources/scala/runtime/types/TypeAny.java
new file mode 100644
index 0000000000..7aa8417c18
--- /dev/null
+++ b/sources/scala/runtime/types/TypeAny.java
@@ -0,0 +1,29 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2003, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+// $Id$
+
+package scala.runtime.types;
+
+import scala.runtime.RunTime;
+import scala.Type;
+import scala.Array;
+
+public class TypeAny extends SpecialType {
+ public boolean isInstance(Object o) {
+ return true;
+ }
+
+ public boolean isSubType(Type that) {
+ return that == this;
+ }
+
+ public String toString() { return "scala.Any"; }
+
+ public int hashCode() { return 0xBBBBBBBB; }
+};
diff --git a/sources/scala/runtime/types/TypeAnyVal.java b/sources/scala/runtime/types/TypeAnyVal.java
new file mode 100644
index 0000000000..b606cc71e3
--- /dev/null
+++ b/sources/scala/runtime/types/TypeAnyVal.java
@@ -0,0 +1,29 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2003, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+// $Id$
+
+package scala.runtime.types;
+
+import scala.runtime.RunTime;
+import scala.Type;
+import scala.Array;
+
+public class TypeAnyVal extends SpecialType {
+ public boolean isInstance(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean isSubType(Type that) {
+ return that == Type.Any || that == this;
+ }
+
+ public String toString() { return "scala.AnyVal"; }
+
+ public int hashCode() { return 0xCCCCCCCC; }
+};
diff --git a/sources/scala/runtime/types/TypeUnit.java b/sources/scala/runtime/types/TypeUnit.java
new file mode 100644
index 0000000000..430de84c59
--- /dev/null
+++ b/sources/scala/runtime/types/TypeUnit.java
@@ -0,0 +1,31 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2003, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+// $Id$
+
+package scala.runtime.types;
+
+import scala.runtime.RunTime;
+import scala.Type;
+import scala.Array;
+import scala.Unit;
+
+public class TypeUnit extends ValueType {
+ private final Unit ZERO = RunTime.box_uvalue();
+ public Array newArray(int size) {
+ return RunTime.box_oarray(new Object[size]);
+ }
+ public Object checkCastability(Object o) {
+ if (! (o == null || o instanceof scala.Unit))
+ throw new ClassCastException(); // TODO error message
+ return o;
+ }
+ public Object defaultValue() { return ZERO; }
+ public String toString() { return "scala.Unit"; }
+ public int hashCode() { return 0x99999999; }
+};
diff --git a/sources/scala/runtime/types/ValueType.java b/sources/scala/runtime/types/ValueType.java
new file mode 100644
index 0000000000..a4dad93f6a
--- /dev/null
+++ b/sources/scala/runtime/types/ValueType.java
@@ -0,0 +1,34 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2003, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+// $Id$
+
+package scala.runtime.types;
+
+import scala.Type;
+
+/**
+ * Abstract superclass for all value types.
+ *
+ * @author Michel Schinz
+ * @version 1.0
+ */
+
+abstract public class ValueType extends Type {
+ public boolean isInstance(Object o) {
+ throw new UnsupportedOperationException();
+ }
+ public boolean isSubType(Type that) {
+ return that == Type.Any
+ || that == Type.AnyVal
+ || that == this;
+ }
+ public boolean isSameAs(Type that) {
+ return this == that;
+ }
+}