summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2005-06-24 15:58:53 +0000
committerMartin Odersky <odersky@gmail.com>2005-06-24 15:58:53 +0000
commit85d13f716bc000622242691ebb96fa0e0502fe8c (patch)
treeeea0c3aab87c6944ba905a9ecf0fb387832f4b03
parent799955690251681664755a022c4d8f608a0a0f3a (diff)
downloadscala-85d13f716bc000622242691ebb96fa0e0502fe8c.tar.gz
scala-85d13f716bc000622242691ebb96fa0e0502fe8c.tar.bz2
scala-85d13f716bc000622242691ebb96fa0e0502fe8c.zip
*** empty log message ***
-rwxr-xr-xsources/scala/runtime/BoxedAnyArray.scala148
-rwxr-xr-xsources/scala/runtime/BoxedArray.scala37
-rwxr-xr-xsources/scala/runtime/BoxedBoolean.java38
-rwxr-xr-xsources/scala/runtime/BoxedBooleanArray.scala29
-rwxr-xr-xsources/scala/runtime/BoxedByte.java50
-rwxr-xr-xsources/scala/runtime/BoxedByteArray.scala29
-rwxr-xr-xsources/scala/runtime/BoxedChar.java51
-rwxr-xr-xsources/scala/runtime/BoxedCharArray.scala29
-rwxr-xr-xsources/scala/runtime/BoxedDouble.java42
-rwxr-xr-xsources/scala/runtime/BoxedDoubleArray.scala29
-rwxr-xr-xsources/scala/runtime/BoxedFloat.java41
-rwxr-xr-xsources/scala/runtime/BoxedFloatArray.scala29
-rwxr-xr-xsources/scala/runtime/BoxedInt.java51
-rwxr-xr-xsources/scala/runtime/BoxedIntArray.scala29
-rwxr-xr-xsources/scala/runtime/BoxedLong.java42
-rwxr-xr-xsources/scala/runtime/BoxedLongArray.scala29
-rwxr-xr-xsources/scala/runtime/BoxedNumber.java21
-rwxr-xr-xsources/scala/runtime/BoxedObjectArray.scala27
-rwxr-xr-xsources/scala/runtime/BoxedShort.java51
-rwxr-xr-xsources/scala/runtime/BoxedShortArray.scala29
-rwxr-xr-xsources/scala/runtime/BoxedUnit.java29
21 files changed, 860 insertions, 0 deletions
diff --git a/sources/scala/runtime/BoxedAnyArray.scala b/sources/scala/runtime/BoxedAnyArray.scala
new file mode 100755
index 0000000000..5b7ff7528d
--- /dev/null
+++ b/sources/scala/runtime/BoxedAnyArray.scala
@@ -0,0 +1,148 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+package scala.runtime;
+
+/** Arrays created by new Array[T](length) where T is a type variable
+ */
+final class BoxedAnyArray(val length: Int) extends BoxedArray {
+
+ private var boxed = new Array[Object](length);
+ private val hash = boxed.hashCode();
+ private var unboxed: Object = null;
+ private var elemClass: Class = null;
+
+ def apply(index: Int): Object = synchronized {
+ if (unboxed == null)
+ boxed(index);
+ else if (elemClass == java.lang.Integer.TYPE)
+ BoxedInt.box(unboxed.asInstanceOf[Array[Int]](index))
+ else if (elemClass == java.lang.Double.TYPE)
+ BoxedDouble.box(unboxed.asInstanceOf[Array[Double]](index))
+ else if (elemClass == java.lang.Float.TYPE)
+ BoxedFloat.box(unboxed.asInstanceOf[Array[Float]](index))
+ else if (elemClass == java.lang.Long.TYPE)
+ BoxedLong.box(unboxed.asInstanceOf[Array[Long]](index))
+ else if (elemClass == java.lang.Character.TYPE)
+ BoxedChar.box(unboxed.asInstanceOf[Array[Char]](index))
+ else if (elemClass == java.lang.Byte.TYPE)
+ BoxedByte.box(unboxed.asInstanceOf[Array[Byte]](index))
+ else if (elemClass == java.lang.Short.TYPE)
+ BoxedShort.box(unboxed.asInstanceOf[Array[Short]](index))
+ else if (elemClass == java.lang.Boolean.TYPE)
+ BoxedBoolean.box(unboxed.asInstanceOf[Array[Boolean]](index))
+ else
+ unboxed.asInstanceOf[Array[Object]](index)
+ }
+
+ def update(index: Int, elem: Object): Unit = synchronized {
+ if (unboxed == null)
+ boxed(index) = elem;
+ else if (elemClass == java.lang.Integer.TYPE)
+ unboxed.asInstanceOf[Array[Int]](index) = elem.asInstanceOf[BoxedNumber].intValue()
+ else if (elemClass == java.lang.Double.TYPE)
+ unboxed.asInstanceOf[Array[Double]](index) = elem.asInstanceOf[BoxedNumber].doubleValue()
+ else if (elemClass == java.lang.Float.TYPE)
+ unboxed.asInstanceOf[Array[Float]](index) = elem.asInstanceOf[BoxedNumber].floatValue()
+ else if (elemClass == java.lang.Long.TYPE)
+ unboxed.asInstanceOf[Array[Long]](index) = elem.asInstanceOf[BoxedNumber].longValue()
+ else if (elemClass == java.lang.Character.TYPE)
+ unboxed.asInstanceOf[Array[Char]](index) = elem.asInstanceOf[BoxedNumber].charValue()
+ else if (elemClass == java.lang.Byte.TYPE)
+ unboxed.asInstanceOf[Array[Byte]](index) = elem.asInstanceOf[BoxedNumber].byteValue()
+ else if (elemClass == java.lang.Short.TYPE)
+ unboxed.asInstanceOf[Array[Short]](index) = elem.asInstanceOf[BoxedNumber].shortValue()
+ else if (elemClass == java.lang.Boolean.TYPE)
+ unboxed.asInstanceOf[Array[Boolean]](index) = elem.asInstanceOf[BoxedBoolean].value
+ else
+ unboxed.asInstanceOf[Array[Object]](index) = elem
+ }
+
+ def unbox(elemClass: Class): Object = synchronized {
+ if (unboxed == null) {
+ this.elemClass = elemClass;
+ if (elemClass == java.lang.Integer.TYPE) {
+ val newvalue = new Array[Int](length);
+ var i = 0;
+ while (i < length) {
+ newvalue(i) = boxed(i).asInstanceOf[BoxedNumber].intValue();
+ i = i + 1
+ }
+ unboxed = newvalue;
+ } else if (elemClass == java.lang.Double.TYPE) {
+ val newvalue = new Array[Double](length);
+ var i = 0;
+ while (i < length) {
+ newvalue(i) = boxed(i).asInstanceOf[BoxedNumber].doubleValue();
+ i = i + 1
+ }
+ unboxed = newvalue;
+ } else if (elemClass == java.lang.Float.TYPE) {
+ val newvalue = new Array[Float](length);
+ var i = 0;
+ while (i < length) {
+ newvalue(i) = boxed(i).asInstanceOf[BoxedNumber].floatValue();
+ i = i + 1
+ }
+ unboxed = newvalue;
+ } else if (elemClass == java.lang.Long.TYPE) {
+ val newvalue = new Array[Long](length);
+ var i = 0;
+ while (i < length) {
+ newvalue(i) = boxed(i).asInstanceOf[BoxedNumber].longValue();
+ i = i + 1
+ }
+ unboxed = newvalue;
+ } else if (elemClass == java.lang.Character.TYPE) {
+ val newvalue = new Array[Char](length);
+ var i = 0;
+ while (i < length) {
+ newvalue(i) = boxed(i).asInstanceOf[BoxedNumber].charValue();
+ i = i + 1
+ }
+ unboxed = newvalue;
+ } else if (elemClass == java.lang.Byte.TYPE) {
+ val newvalue = new Array[Byte](length);
+ var i = 0;
+ while (i < length) {
+ newvalue(i) = boxed(i).asInstanceOf[BoxedNumber].byteValue();
+ i = i + 1
+ }
+ unboxed = newvalue;
+ } else if (elemClass == java.lang.Short.TYPE) {
+ val newvalue = new Array[Short](length);
+ var i = 0;
+ while (i < length) {
+ newvalue(i) = boxed(i).asInstanceOf[BoxedNumber].shortValue();
+ i = i + 1
+ }
+ unboxed = newvalue;
+ } else if (elemClass == java.lang.Boolean.TYPE) {
+ val newvalue = new Array[Boolean](length);
+ var i = 0;
+ while (i < length) {
+ newvalue(i) = boxed(i).asInstanceOf[BoxedBoolean].value;
+ i = i + 1
+ }
+ unboxed = newvalue;
+ } else if (elemClass == boxed.getClass().getComponentType()) {
+ unboxed = boxed;
+ } else {
+ unboxed = java.lang.reflect.Array.newInstance(elemClass, length);
+ System.arraycopy(boxed, 0, unboxed, 0, length);
+ }
+ boxed = null
+ }
+ unboxed
+ }
+
+ override def equals(other: Any): Boolean =
+ other.isInstanceOf[BoxedAnyArray] && (this eq (other.asInstanceOf[BoxedAnyArray])) ||
+ (if (unboxed == null) boxed == other else unboxed == other);
+
+ override def hashCode(): Int = hash;
+}
diff --git a/sources/scala/runtime/BoxedArray.scala b/sources/scala/runtime/BoxedArray.scala
new file mode 100755
index 0000000000..d3376e9a15
--- /dev/null
+++ b/sources/scala/runtime/BoxedArray.scala
@@ -0,0 +1,37 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+package scala.runtime;
+
+/** A class representing Array[T]
+ */
+abstract class BoxedArray() extends PartialFunction[Int, Object] with Seq[Object] {
+ def length: Int;
+ def apply(index: Int): Object;
+ def update(index: Int, elem: Object): Unit;
+ def unbox(elemClass: Class): Object;
+
+ override def isDefinedAt(x: Int): Boolean = 0 <= x && x < length;
+
+ override def toString(): String = {
+ val buf = new StringBuffer();
+ buf.append("Array(");
+ val len = length;
+ var i = 0;
+ while (i < len) { buf.append(apply(i)); i = i + 1 }
+ buf.append(")");
+ buf.toString()
+ }
+
+ def elements = new Iterator[Object] {
+ var index = 0;
+ def hasNext: Boolean = index < length;
+ def next: Object = { val i = index; index = i + 1; apply(i) }
+ }
+}
+
+
diff --git a/sources/scala/runtime/BoxedBoolean.java b/sources/scala/runtime/BoxedBoolean.java
new file mode 100755
index 0000000000..9f0ed53f30
--- /dev/null
+++ b/sources/scala/runtime/BoxedBoolean.java
@@ -0,0 +1,38 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+package scala.runtime;
+
+public final class BoxedBoolean {
+
+ private final static BoxedBoolean TRUE = new BoxedBoolean(true);
+ private final static BoxedBoolean FALSE = new BoxedBoolean(false);
+
+ public static BoxedBoolean box(boolean value) {
+ return (value ? TRUE : FALSE);
+ }
+
+ public final boolean value;
+
+ private BoxedBoolean(boolean value) { this.value = value; }
+
+ public final boolean booleanValue() { return value; }
+
+ public boolean equals(java.lang.Object other) {
+ return other instanceof BoxedBoolean && value == ((BoxedBoolean) other).value;
+ }
+
+ public int hashCode() {
+ return value ? 1 : 0;
+ }
+
+ public String toString() {
+ return String.valueOf(value);
+ }
+}
+
+
diff --git a/sources/scala/runtime/BoxedBooleanArray.scala b/sources/scala/runtime/BoxedBooleanArray.scala
new file mode 100755
index 0000000000..c4804ce6ac
--- /dev/null
+++ b/sources/scala/runtime/BoxedBooleanArray.scala
@@ -0,0 +1,29 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+package scala.runtime;
+
+final class BoxedBooleanArray(val value: Array[Boolean]) extends BoxedArray {
+
+ def length: Int = value.length;
+
+ def apply(index: Int): Object = BoxedBoolean.box(value(index));
+
+ def update(index: Int, elem: Object): Unit = {
+ value(index) = elem.asInstanceOf[BoxedBoolean].value
+ }
+
+ def unbox(elemClass: Class): Object = value;
+
+ override def equals(other: Any) =
+ value == other ||
+ other.isInstanceOf[BoxedBooleanArray] && value == other.asInstanceOf[BoxedBooleanArray].value;
+
+ override def hashCode(): Int = value.hashCode();
+}
+
+
diff --git a/sources/scala/runtime/BoxedByte.java b/sources/scala/runtime/BoxedByte.java
new file mode 100755
index 0000000000..adbba56d30
--- /dev/null
+++ b/sources/scala/runtime/BoxedByte.java
@@ -0,0 +1,50 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+package scala.runtime;
+
+public final class BoxedByte extends BoxedNumber {
+
+ private static final int MinHashed = -128;
+ private static final int MaxHashed = 127;
+ private static BoxedByte[] canonical = new BoxedByte[MaxHashed - MinHashed + 1];
+
+ static {
+ for (int i = MinHashed; i <= MaxHashed; i++)
+ canonical[i - MinHashed] = new BoxedByte((byte)i);
+ }
+
+ public static BoxedByte box(byte value) {
+ return canonical[value - MinHashed];
+ }
+
+ public final byte value;
+
+ private BoxedByte(byte value) { this.value = value; }
+
+ public byte byteValue() { return (byte)value; }
+ public short shortValue() { return (short)value; }
+ public char charValue() { return (char)value; }
+ public int intValue() { return (int)value; }
+ public long longValue() { return (long)value; }
+ public float floatValue() { return (float)value; }
+ public double doubleValue() { return (double)value; }
+
+ public boolean equals(java.lang.Object other) {
+ return other instanceof BoxedNumber && value == ((BoxedNumber) other).byteValue();
+ }
+
+ public int hashCode() {
+ return value;
+ }
+
+ public String toString() {
+ return String.valueOf(value);
+ }
+}
+
+
diff --git a/sources/scala/runtime/BoxedByteArray.scala b/sources/scala/runtime/BoxedByteArray.scala
new file mode 100755
index 0000000000..ea96c7600d
--- /dev/null
+++ b/sources/scala/runtime/BoxedByteArray.scala
@@ -0,0 +1,29 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+package scala.runtime;
+
+final class BoxedByteArray(val value: Array[Byte]) extends BoxedArray {
+
+ def length: Int = value.length;
+
+ def apply(index: Int): Object = BoxedByte.box(value(index));
+
+ def update(index: Int, elem: Object): Unit = {
+ value(index) = elem.asInstanceOf[BoxedNumber].byteValue()
+ }
+
+ def unbox(elemClass: Class): Object = value;
+
+ override def equals(other: Any) =
+ value == other ||
+ other.isInstanceOf[BoxedByteArray] && value == other.asInstanceOf[BoxedByteArray].value;
+
+ override def hashCode(): Int = value.hashCode();
+}
+
+
diff --git a/sources/scala/runtime/BoxedChar.java b/sources/scala/runtime/BoxedChar.java
new file mode 100755
index 0000000000..b38f06fa32
--- /dev/null
+++ b/sources/scala/runtime/BoxedChar.java
@@ -0,0 +1,51 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+package scala.runtime;
+
+public class BoxedChar extends BoxedNumber {
+
+ private static final int MinHashed = 0;
+ private static final int MaxHashed = 255;
+ private static BoxedChar[] canonical = new BoxedChar[MaxHashed - MinHashed + 1];
+
+ static {
+ for (int i = MinHashed; i <= MaxHashed; i++)
+ canonical[i - MinHashed] = new BoxedChar((char)i);
+ }
+
+ public static BoxedChar box(char value) {
+ if (MinHashed <= value && value <= MaxHashed) return canonical[value - MinHashed];
+ else return new BoxedChar(value);
+ }
+
+ public final char value;
+
+ private BoxedChar(char value) { this.value = value; }
+
+ public byte byteValue() { return (byte)value; }
+ public short shortValue() { return (short)value; }
+ public char charValue() { return (char)value; }
+ public int intValue() { return (int)value; }
+ public long longValue() { return (long)value; }
+ public float floatValue() { return (float)value; }
+ public double doubleValue() { return (double)value; }
+
+ public boolean equals(java.lang.Object other) {
+ return other instanceof BoxedNumber && value == ((BoxedNumber) other).charValue();
+ }
+
+ public int hashCode() {
+ return value;
+ }
+
+ public String toString() {
+ return String.valueOf(value);
+ }
+}
+
+
diff --git a/sources/scala/runtime/BoxedCharArray.scala b/sources/scala/runtime/BoxedCharArray.scala
new file mode 100755
index 0000000000..c91efbd38e
--- /dev/null
+++ b/sources/scala/runtime/BoxedCharArray.scala
@@ -0,0 +1,29 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+package scala.runtime;
+
+final class BoxedCharArray(val value: Array[Char]) extends BoxedArray {
+
+ def length: Int = value.length;
+
+ def apply(index: Int): Object = BoxedChar.box(value(index));
+
+ def update(index: Int, elem: Object): Unit = {
+ value(index) = elem.asInstanceOf[BoxedNumber].charValue()
+ }
+
+ def unbox(elemClass: Class): Object = value;
+
+ override def equals(other: Any) =
+ value == other ||
+ other.isInstanceOf[BoxedCharArray] && value == other.asInstanceOf[BoxedCharArray].value;
+
+ override def hashCode(): Int = value.hashCode();
+}
+
+
diff --git a/sources/scala/runtime/BoxedDouble.java b/sources/scala/runtime/BoxedDouble.java
new file mode 100755
index 0000000000..23abdb4485
--- /dev/null
+++ b/sources/scala/runtime/BoxedDouble.java
@@ -0,0 +1,42 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+package scala.runtime;
+
+public class BoxedDouble extends BoxedNumber {
+
+ public static BoxedDouble box(double value) {
+ return new BoxedDouble(value);
+ }
+
+ public final double value;
+
+ private BoxedDouble(double value) { this.value = value; }
+
+ public final byte byteValue() { return (byte)value; }
+ public final short shortValue() { return (short)value; }
+ public final char charValue() { return (char)value; }
+ public final int intValue() { return (int)value; }
+ public final long longValue() { return (long)value; }
+ public final float floatValue() { return (float)value; }
+ public final double doubleValue() { return (double)value; }
+
+ public boolean equals(java.lang.Object other) {
+ return other instanceof BoxedNumber && value == ((BoxedNumber) other).doubleValue();
+ }
+
+ public int hashCode() {
+ long bits = java.lang.Double.doubleToLongBits(value);
+ return (int)(bits ^ (bits >>> 32));
+ }
+
+ public String toString() {
+ return String.valueOf(value);
+ }
+}
+
+
diff --git a/sources/scala/runtime/BoxedDoubleArray.scala b/sources/scala/runtime/BoxedDoubleArray.scala
new file mode 100755
index 0000000000..e93a47c42d
--- /dev/null
+++ b/sources/scala/runtime/BoxedDoubleArray.scala
@@ -0,0 +1,29 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+package scala.runtime;
+
+final class BoxedDoubleArray(val value: Array[Double]) extends BoxedArray {
+
+ def length: Int = value.length;
+
+ def apply(index: Int): Object = BoxedDouble.box(value(index));
+
+ def update(index: Int, elem: Object): Unit = {
+ value(index) = elem.asInstanceOf[BoxedNumber].doubleValue()
+ }
+
+ def unbox(elemClass: Class): Object = value;
+
+ override def equals(other: Any) =
+ value == other ||
+ other.isInstanceOf[BoxedDoubleArray] && value == other.asInstanceOf[BoxedDoubleArray].value;
+
+ override def hashCode(): Int = value.hashCode();
+}
+
+
diff --git a/sources/scala/runtime/BoxedFloat.java b/sources/scala/runtime/BoxedFloat.java
new file mode 100755
index 0000000000..48ec9f8626
--- /dev/null
+++ b/sources/scala/runtime/BoxedFloat.java
@@ -0,0 +1,41 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+package scala.runtime;
+
+public class BoxedFloat extends BoxedNumber {
+
+ public static BoxedFloat box(float value) {
+ return new BoxedFloat(value);
+ }
+
+ public final float value;
+
+ private BoxedFloat(float value) { this.value = value; }
+
+ public final byte byteValue() { return (byte)value; }
+ public final short shortValue() { return (short)value; }
+ public final char charValue() { return (char)value; }
+ public final int intValue() { return (int)value; }
+ public final long longValue() { return (long)value; }
+ public final float floatValue() { return (float)value; }
+ public final double doubleValue() { return (double)value; }
+
+ public boolean equals(java.lang.Object other) {
+ return other instanceof BoxedNumber && value == ((BoxedNumber) other).floatValue();
+ }
+
+ public int hashCode() {
+ return java.lang.Float.floatToIntBits(value);
+ }
+
+ public String toString() {
+ return String.valueOf(value);
+ }
+}
+
+
diff --git a/sources/scala/runtime/BoxedFloatArray.scala b/sources/scala/runtime/BoxedFloatArray.scala
new file mode 100755
index 0000000000..2ca4f2e54d
--- /dev/null
+++ b/sources/scala/runtime/BoxedFloatArray.scala
@@ -0,0 +1,29 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+package scala.runtime;
+
+final class BoxedFloatArray(val value: Array[Float]) extends BoxedArray {
+
+ def length: Int = value.length;
+
+ def apply(index: Int): Object = BoxedFloat.box(value(index));
+
+ def update(index: Int, elem: Object): Unit = {
+ value(index) = elem.asInstanceOf[BoxedNumber].floatValue()
+ }
+
+ def unbox(elemClass: Class): Object = value;
+
+ override def equals(other: Any) =
+ value == other ||
+ other.isInstanceOf[BoxedFloatArray] && value == other.asInstanceOf[BoxedFloatArray].value;
+
+ override def hashCode(): Int = value.hashCode();
+}
+
+
diff --git a/sources/scala/runtime/BoxedInt.java b/sources/scala/runtime/BoxedInt.java
new file mode 100755
index 0000000000..ba7116d3a1
--- /dev/null
+++ b/sources/scala/runtime/BoxedInt.java
@@ -0,0 +1,51 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+package scala.runtime;
+
+public final class BoxedInt extends BoxedNumber {
+
+ private static final int MinHashed = -128;
+ private static final int MaxHashed = 1024;
+ private static BoxedInt[] canonical = new BoxedInt[MaxHashed - MinHashed + 1];
+
+ static {
+ for (int i = MinHashed; i <= MaxHashed; i++)
+ canonical[i - MinHashed] = new BoxedInt(i);
+ }
+
+ public static BoxedInt box(int value) {
+ if (MinHashed <= value && value <= MaxHashed) return canonical[value - MinHashed];
+ else return new BoxedInt(value);
+ }
+
+ public final int value;
+
+ private BoxedInt(int value) { this.value = value; }
+
+ public byte byteValue() { return (byte)value; }
+ public short shortValue() { return (short)value; }
+ public char charValue() { return (char)value; }
+ public int intValue() { return (int)value; }
+ public long longValue() { return (long)value; }
+ public float floatValue() { return (float)value; }
+ public double doubleValue() { return (double)value; }
+
+ public boolean equals(java.lang.Object other) {
+ return other instanceof BoxedNumber && value == ((BoxedNumber) other).intValue();
+ }
+
+ public int hashCode() {
+ return value;
+ }
+
+ public String toString() {
+ return String.valueOf(value);
+ }
+}
+
+
diff --git a/sources/scala/runtime/BoxedIntArray.scala b/sources/scala/runtime/BoxedIntArray.scala
new file mode 100755
index 0000000000..bf46e33846
--- /dev/null
+++ b/sources/scala/runtime/BoxedIntArray.scala
@@ -0,0 +1,29 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+package scala.runtime;
+
+final class BoxedIntArray(val value: Array[Int]) extends BoxedArray {
+
+ def length: Int = value.length;
+
+ def apply(index: Int): Object = BoxedInt.box(value(index));
+
+ def update(index: Int, elem: Object): Unit = {
+ value(index) = elem.asInstanceOf[BoxedNumber].intValue()
+ }
+
+ def unbox(elemClass: Class): Object = value;
+
+ override def equals(other: Any) =
+ value == other ||
+ other.isInstanceOf[BoxedIntArray] && value == other.asInstanceOf[BoxedIntArray].value;
+
+ override def hashCode(): Int = value.hashCode();
+}
+
+
diff --git a/sources/scala/runtime/BoxedLong.java b/sources/scala/runtime/BoxedLong.java
new file mode 100755
index 0000000000..203cb5dfad
--- /dev/null
+++ b/sources/scala/runtime/BoxedLong.java
@@ -0,0 +1,42 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+package scala.runtime;
+
+public class BoxedLong extends BoxedNumber {
+
+ public static BoxedLong box(long value) {
+ return new BoxedLong(value);
+ }
+
+ public final long value;
+
+ private BoxedLong(long value) { this.value = value; }
+
+ public final byte byteValue() { return (byte)value; }
+ public final short shortValue() { return (short)value; }
+ public final char charValue() { return (char)value; }
+ public final int intValue() { return (int)value; }
+ public final long longValue() { return (long)value; }
+ public final float floatValue() { return (float)value; }
+ public final double doubleValue() { return (double)value; }
+
+ public boolean equals(java.lang.Object other) {
+ return other instanceof BoxedNumber && value == ((BoxedNumber) other).longValue();
+ }
+
+ public int hashCode() {
+ long bits = value;
+ return (int)(bits ^ (bits >>> 32));
+ }
+
+ public String toString() {
+ return String.valueOf(value);
+ }
+}
+
+
diff --git a/sources/scala/runtime/BoxedLongArray.scala b/sources/scala/runtime/BoxedLongArray.scala
new file mode 100755
index 0000000000..23506a4783
--- /dev/null
+++ b/sources/scala/runtime/BoxedLongArray.scala
@@ -0,0 +1,29 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+package scala.runtime;
+
+final class BoxedLongArray(val value: Array[Long]) extends BoxedArray {
+
+ def length: Int = value.length;
+
+ def apply(index: Int): Object = BoxedLong.box(value(index));
+
+ def update(index: Int, elem: Object): Unit = {
+ value(index) = elem.asInstanceOf[BoxedNumber].longValue()
+ }
+
+ def unbox(elemClass: Class): Object = value;
+
+ override def equals(other: Any) =
+ value == other ||
+ other.isInstanceOf[BoxedLongArray] && value == other.asInstanceOf[BoxedLongArray].value;
+
+ override def hashCode(): Int = value.hashCode();
+}
+
+
diff --git a/sources/scala/runtime/BoxedNumber.java b/sources/scala/runtime/BoxedNumber.java
new file mode 100755
index 0000000000..471d52516d
--- /dev/null
+++ b/sources/scala/runtime/BoxedNumber.java
@@ -0,0 +1,21 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+// $OldId: RunTime.java,v 1.13 2002/11/19 12:01:40 paltherr Exp $
+// $Id$
+package scala.runtime;
+
+public abstract class BoxedNumber {
+ public abstract byte byteValue();
+ public abstract short shortValue();
+ public abstract char charValue();
+ public abstract int intValue();
+ public abstract long longValue();
+ public abstract float floatValue();
+ public abstract double doubleValue();
+}
diff --git a/sources/scala/runtime/BoxedObjectArray.scala b/sources/scala/runtime/BoxedObjectArray.scala
new file mode 100755
index 0000000000..747888afaf
--- /dev/null
+++ b/sources/scala/runtime/BoxedObjectArray.scala
@@ -0,0 +1,27 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+package scala.runtime;
+
+final class BoxedObjectArray(val value: Array[Object]) extends BoxedArray {
+
+ def length: Int = value.length;
+
+ def apply(index: Int): Object = value(index);
+
+ def update(index: Int, elem: Object): Unit = { value(index) = elem }
+
+ def unbox(elemClass: Class): Object = value;
+
+ override def equals(other: Any): Boolean =
+ value == other ||
+ other.isInstanceOf[BoxedObjectArray] && value == other.asInstanceOf[BoxedObjectArray].value;
+
+ override def hashCode(): Int = value.hashCode();
+}
+
+
diff --git a/sources/scala/runtime/BoxedShort.java b/sources/scala/runtime/BoxedShort.java
new file mode 100755
index 0000000000..367a82550d
--- /dev/null
+++ b/sources/scala/runtime/BoxedShort.java
@@ -0,0 +1,51 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+package scala.runtime;
+
+public final class BoxedShort extends BoxedNumber {
+
+ private static final int MinHashed = -128;
+ private static final int MaxHashed = 127;
+ private static BoxedShort[] canonical = new BoxedShort[MaxHashed - MinHashed + 1];
+
+ static {
+ for (int i = MinHashed; i <= MaxHashed; i++)
+ canonical[i - MinHashed] = new BoxedShort((short)i);
+ }
+
+ public static BoxedShort box(short value) {
+ if (MinHashed <= value && value <= MaxHashed) return canonical[value - MinHashed];
+ else return new BoxedShort(value);
+ }
+
+ public final short value;
+
+ private BoxedShort(short value) { this.value = value; }
+
+ public byte byteValue() { return (byte)value; }
+ public short shortValue() { return (short)value; }
+ public char charValue() { return (char)value; }
+ public int intValue() { return (int)value; }
+ public long longValue() { return (long)value; }
+ public float floatValue() { return (float)value; }
+ public double doubleValue() { return (double)value; }
+
+ public boolean equals(java.lang.Object other) {
+ return other instanceof BoxedNumber && value == ((BoxedNumber) other).shortValue();
+ }
+
+ public int hashCode() {
+ return value;
+ }
+
+ public String toString() {
+ return String.valueOf(value);
+ }
+}
+
+
diff --git a/sources/scala/runtime/BoxedShortArray.scala b/sources/scala/runtime/BoxedShortArray.scala
new file mode 100755
index 0000000000..464b238ed3
--- /dev/null
+++ b/sources/scala/runtime/BoxedShortArray.scala
@@ -0,0 +1,29 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+package scala.runtime;
+
+final class BoxedShortArray(val value: Array[Short]) extends BoxedArray {
+
+ def length: Int = value.length;
+
+ def apply(index: Int): Object = BoxedShort.box(value(index));
+
+ def update(index: Int, elem: Object): Unit = {
+ value(index) = elem.asInstanceOf[BoxedNumber].shortValue()
+ }
+
+ def unbox(elemClass: Class): Object = value;
+
+ override def equals(other: Any) =
+ value == other ||
+ other.isInstanceOf[BoxedShortArray] && value == other.asInstanceOf[BoxedShortArray].value;
+
+ override def hashCode(): Int = value.hashCode();
+}
+
+
diff --git a/sources/scala/runtime/BoxedUnit.java b/sources/scala/runtime/BoxedUnit.java
new file mode 100755
index 0000000000..ea9ccd9640
--- /dev/null
+++ b/sources/scala/runtime/BoxedUnit.java
@@ -0,0 +1,29 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2002, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+package scala.runtime;
+
+public final class BoxedUnit {
+
+ public final static BoxedUnit UNIT = new BoxedUnit();
+
+ private BoxedUnit() { }
+
+ public boolean equals(java.lang.Object other) {
+ return this == other;
+ }
+
+ public int hashCode() {
+ return 0;
+ }
+
+ public String toString() {
+ return "()";
+ }
+}
+
+