summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormihaylov <mihaylov@epfl.ch>2006-11-06 14:33:04 +0000
committermihaylov <mihaylov@epfl.ch>2006-11-06 14:33:04 +0000
commit69583d89bc25089f4068f21576c512e9358f098d (patch)
tree2931780ec4e16d885f5cd90195de0e82c23a77d0
parent8b5680aa83ae211d4a1a1be026ae66d5312580e7 (diff)
downloadscala-69583d89bc25089f4068f21576c512e9358f098d.tar.gz
scala-69583d89bc25089f4068f21576c512e9358f098d.tar.bz2
scala-69583d89bc25089f4068f21576c512e9358f098d.zip
Use platform-independent boxing/unboxing in Box...
Use platform-independent boxing/unboxing in Boxed*Array
-rw-r--r--src/library/scala/runtime/BoxedAnyArray.scala56
-rw-r--r--src/library/scala/runtime/BoxedBooleanArray.scala5
-rw-r--r--src/library/scala/runtime/BoxedByteArray.scala5
-rw-r--r--src/library/scala/runtime/BoxedCharArray.scala5
-rw-r--r--src/library/scala/runtime/BoxedDoubleArray.scala5
-rw-r--r--src/library/scala/runtime/BoxedFloatArray.scala5
-rw-r--r--src/library/scala/runtime/BoxedIntArray.scala5
-rw-r--r--src/library/scala/runtime/BoxedLongArray.scala5
-rw-r--r--src/library/scala/runtime/BoxedShortArray.scala5
-rw-r--r--src/library/scala/runtime/ScalaRunTime.scala8
10 files changed, 40 insertions, 64 deletions
diff --git a/src/library/scala/runtime/BoxedAnyArray.scala b/src/library/scala/runtime/BoxedAnyArray.scala
index 303f25def8..558c01dead 100644
--- a/src/library/scala/runtime/BoxedAnyArray.scala
+++ b/src/library/scala/runtime/BoxedAnyArray.scala
@@ -31,21 +31,21 @@ final class BoxedAnyArray(val length: Int) extends BoxedArray {
if (unboxed == null)
boxed(index);
else if (elemClass eq ScalaRunTime.IntTYPE)
- BoxedInt.box(unboxed.asInstanceOf[Array[Int]](index))
+ Int.box(unboxed.asInstanceOf[Array[Int]](index))
else if (elemClass eq ScalaRunTime.DoubleTYPE)
- BoxedDouble.box(unboxed.asInstanceOf[Array[Double]](index))
+ Double.box(unboxed.asInstanceOf[Array[Double]](index))
else if (elemClass eq ScalaRunTime.FloatTYPE)
- BoxedFloat.box(unboxed.asInstanceOf[Array[Float]](index))
+ Float.box(unboxed.asInstanceOf[Array[Float]](index))
else if (elemClass eq ScalaRunTime.LongTYPE)
- BoxedLong.box(unboxed.asInstanceOf[Array[Long]](index))
+ Long.box(unboxed.asInstanceOf[Array[Long]](index))
else if (elemClass eq ScalaRunTime.CharTYPE)
- BoxedChar.box(unboxed.asInstanceOf[Array[Char]](index))
+ Char.box(unboxed.asInstanceOf[Array[Char]](index))
else if (elemClass eq ScalaRunTime.ByteTYPE)
- BoxedByte.box(unboxed.asInstanceOf[Array[Byte]](index))
+ Byte.box(unboxed.asInstanceOf[Array[Byte]](index))
else if (elemClass eq ScalaRunTime.ShortTYPE)
- BoxedShort.box(unboxed.asInstanceOf[Array[Short]](index))
+ Short.box(unboxed.asInstanceOf[Array[Short]](index))
else if (elemClass eq ScalaRunTime.BooleanTYPE)
- BoxedBoolean.box(unboxed.asInstanceOf[Array[Boolean]](index))
+ Boolean.box(unboxed.asInstanceOf[Array[Boolean]](index))
else
unboxed.asInstanceOf[Array[AnyRef]](index)
}
@@ -54,21 +54,21 @@ final class BoxedAnyArray(val length: Int) extends BoxedArray {
if (unboxed == null)
boxed(index) = elem
else if (elemClass eq ScalaRunTime.IntTYPE)
- unboxed.asInstanceOf[Array[Int]](index) = elem.asInstanceOf[BoxedNumber].intValue()
+ unboxed.asInstanceOf[Array[Int]](index) = Int.unbox(elem)
else if (elemClass eq ScalaRunTime.DoubleTYPE)
- unboxed.asInstanceOf[Array[Double]](index) = elem.asInstanceOf[BoxedNumber].doubleValue()
+ unboxed.asInstanceOf[Array[Double]](index) = Double.unbox(elem)
else if (elemClass eq ScalaRunTime.FloatTYPE)
- unboxed.asInstanceOf[Array[Float]](index) = elem.asInstanceOf[BoxedNumber].floatValue()
+ unboxed.asInstanceOf[Array[Float]](index) = Float.unbox(elem)
else if (elemClass eq ScalaRunTime.LongTYPE)
- unboxed.asInstanceOf[Array[Long]](index) = elem.asInstanceOf[BoxedNumber].longValue()
+ unboxed.asInstanceOf[Array[Long]](index) = Long.unbox(elem)
else if (elemClass eq ScalaRunTime.CharTYPE)
- unboxed.asInstanceOf[Array[Char]](index) = elem.asInstanceOf[BoxedNumber].charValue()
+ unboxed.asInstanceOf[Array[Char]](index) = Char.unbox(elem)
else if (elemClass eq ScalaRunTime.ByteTYPE)
- unboxed.asInstanceOf[Array[Byte]](index) = elem.asInstanceOf[BoxedNumber].byteValue()
+ unboxed.asInstanceOf[Array[Byte]](index) = Byte.unbox(elem)
else if (elemClass eq ScalaRunTime.ShortTYPE)
- unboxed.asInstanceOf[Array[Short]](index) = elem.asInstanceOf[BoxedNumber].shortValue()
+ unboxed.asInstanceOf[Array[Short]](index) = Short.unbox(elem)
else if (elemClass eq ScalaRunTime.BooleanTYPE)
- unboxed.asInstanceOf[Array[Boolean]](index) = elem.asInstanceOf[BoxedBoolean].value
+ unboxed.asInstanceOf[Array[Boolean]](index) = Boolean.unbox(elem)
else
unboxed.asInstanceOf[Array[AnyRef]](index) = elem
}
@@ -91,8 +91,7 @@ final class BoxedAnyArray(val length: Int) extends BoxedArray {
val newvalue = new Array[Int](length)
var i = 0
while (i < length) {
- val x = boxed(i).asInstanceOf[BoxedNumber]
- if (x ne null) newvalue(i) = x.intValue();
+ newvalue(i) = Int.unbox(boxed(i))
i = i + 1
}
unboxed = newvalue
@@ -100,8 +99,7 @@ final class BoxedAnyArray(val length: Int) extends BoxedArray {
val newvalue = new Array[Double](length)
var i = 0
while (i < length) {
- val x = boxed(i).asInstanceOf[BoxedNumber];
- if (x ne null) newvalue(i) = x.doubleValue();
+ newvalue(i) = Double.unbox(boxed(i))
i = i + 1
}
unboxed = newvalue;
@@ -109,8 +107,7 @@ final class BoxedAnyArray(val length: Int) extends BoxedArray {
val newvalue = new Array[Float](length)
var i = 0
while (i < length) {
- val x = boxed(i).asInstanceOf[BoxedNumber];
- if (x ne null) newvalue(i) = x.floatValue();
+ newvalue(i) = Float.unbox(boxed(i))
i = i + 1
}
unboxed = newvalue;
@@ -118,8 +115,7 @@ final class BoxedAnyArray(val length: Int) extends BoxedArray {
val newvalue = new Array[Long](length)
var i = 0
while (i < length) {
- val x = boxed(i).asInstanceOf[BoxedNumber]
- if (x ne null) newvalue(i) = x.longValue();
+ newvalue(i) = Long.unbox(boxed(i))
i = i + 1
}
unboxed = newvalue;
@@ -127,8 +123,7 @@ final class BoxedAnyArray(val length: Int) extends BoxedArray {
val newvalue = new Array[Char](length)
var i = 0
while (i < length) {
- val x = boxed(i).asInstanceOf[BoxedNumber]
- if (x ne null) newvalue(i) = x.charValue();
+ newvalue(i) = Char.unbox(boxed(i))
i = i + 1
}
unboxed = newvalue
@@ -136,8 +131,7 @@ final class BoxedAnyArray(val length: Int) extends BoxedArray {
val newvalue = new Array[Byte](length)
var i = 0
while (i < length) {
- val x = boxed(i).asInstanceOf[BoxedNumber]
- if (x ne null) newvalue(i) = x.byteValue();
+ newvalue(i) = Byte.unbox(boxed(i))
i = i + 1
}
unboxed = newvalue;
@@ -145,8 +139,7 @@ final class BoxedAnyArray(val length: Int) extends BoxedArray {
val newvalue = new Array[Short](length)
var i = 0
while (i < length) {
- val x = boxed(i).asInstanceOf[BoxedNumber]
- if (x ne null) newvalue(i) = x.shortValue();
+ newvalue(i) = Short.unbox(boxed(i))
i = i + 1
}
unboxed = newvalue;
@@ -154,8 +147,7 @@ final class BoxedAnyArray(val length: Int) extends BoxedArray {
val newvalue = new Array[Boolean](length)
var i = 0
while (i < length) {
- val x = boxed(i).asInstanceOf[BoxedBoolean];
- if (x ne null) newvalue(i) = x.value;
+ newvalue(i) = Boolean.unbox(boxed(i))
i = i + 1
}
unboxed = newvalue;
diff --git a/src/library/scala/runtime/BoxedBooleanArray.scala b/src/library/scala/runtime/BoxedBooleanArray.scala
index ccf3b79461..85393f94b1 100644
--- a/src/library/scala/runtime/BoxedBooleanArray.scala
+++ b/src/library/scala/runtime/BoxedBooleanArray.scala
@@ -19,10 +19,10 @@ final class BoxedBooleanArray(val value: Array[Boolean]) extends BoxedArray {
def length: Int = value.length
- def apply(index: Int): AnyRef = BoxedBoolean.box(value(index))
+ def apply(index: Int): AnyRef = Boolean.box(value(index))
def update(index: Int, elem: AnyRef): Unit = {
- value(index) = elem.asInstanceOf[BoxedBoolean].value
+ value(index) = Boolean.unbox(elem)
}
def unbox(elemTag: String): AnyRef = value
@@ -58,4 +58,3 @@ final class BoxedBooleanArray(val value: Array[Boolean]) extends BoxedArray {
result
}
}
-
diff --git a/src/library/scala/runtime/BoxedByteArray.scala b/src/library/scala/runtime/BoxedByteArray.scala
index 16792d6de8..0fb36007ae 100644
--- a/src/library/scala/runtime/BoxedByteArray.scala
+++ b/src/library/scala/runtime/BoxedByteArray.scala
@@ -19,10 +19,10 @@ final class BoxedByteArray(val value: Array[Byte]) extends BoxedArray {
def length: Int = value.length
- def apply(index: Int): AnyRef = BoxedByte.box(value(index))
+ def apply(index: Int): AnyRef = Byte.box(value(index))
def update(index: Int, elem: AnyRef): Unit = {
- value(index) = elem.asInstanceOf[BoxedNumber].byteValue()
+ value(index) = Byte.unbox(elem)
}
def unbox(elemTag: String): AnyRef = value
@@ -58,4 +58,3 @@ final class BoxedByteArray(val value: Array[Byte]) extends BoxedArray {
result
}
}
-
diff --git a/src/library/scala/runtime/BoxedCharArray.scala b/src/library/scala/runtime/BoxedCharArray.scala
index 928d3f67cc..87bc56391d 100644
--- a/src/library/scala/runtime/BoxedCharArray.scala
+++ b/src/library/scala/runtime/BoxedCharArray.scala
@@ -19,10 +19,10 @@ final class BoxedCharArray(val value: Array[Char]) extends BoxedArray {
def length: Int = value.length;
- def apply(index: Int): AnyRef = BoxedChar.box(value(index));
+ def apply(index: Int): AnyRef = Char.box(value(index));
def update(index: Int, elem: AnyRef): Unit = {
- value(index) = elem.asInstanceOf[BoxedNumber].charValue()
+ value(index) = Char.unbox(elem)
}
def unbox(elemTag: String): AnyRef = value;
@@ -59,4 +59,3 @@ final class BoxedCharArray(val value: Array[Char]) extends BoxedArray {
result
}
}
-
diff --git a/src/library/scala/runtime/BoxedDoubleArray.scala b/src/library/scala/runtime/BoxedDoubleArray.scala
index 55bcfbe520..4744c56774 100644
--- a/src/library/scala/runtime/BoxedDoubleArray.scala
+++ b/src/library/scala/runtime/BoxedDoubleArray.scala
@@ -19,10 +19,10 @@ final class BoxedDoubleArray(val value: Array[Double]) extends BoxedArray {
def length: Int = value.length
- def apply(index: Int): AnyRef = BoxedDouble.box(value(index))
+ def apply(index: Int): AnyRef = Double.box(value(index))
def update(index: Int, elem: AnyRef): Unit = {
- value(index) = elem.asInstanceOf[BoxedNumber].doubleValue()
+ value(index) = Double.unbox(elem)
}
def unbox(elemTag: String): AnyRef = value
@@ -58,4 +58,3 @@ final class BoxedDoubleArray(val value: Array[Double]) extends BoxedArray {
result
}
}
-
diff --git a/src/library/scala/runtime/BoxedFloatArray.scala b/src/library/scala/runtime/BoxedFloatArray.scala
index a722991e9d..a80643951a 100644
--- a/src/library/scala/runtime/BoxedFloatArray.scala
+++ b/src/library/scala/runtime/BoxedFloatArray.scala
@@ -19,10 +19,10 @@ final class BoxedFloatArray(val value: Array[Float]) extends BoxedArray {
def length: Int = value.length
- def apply(index: Int): AnyRef = BoxedFloat.box(value(index))
+ def apply(index: Int): AnyRef = Float.box(value(index))
def update(index: Int, elem: AnyRef): Unit = {
- value(index) = elem.asInstanceOf[BoxedNumber].floatValue()
+ value(index) = Float.unbox(elem)
}
def unbox(elemTag: String): AnyRef = value
@@ -58,4 +58,3 @@ final class BoxedFloatArray(val value: Array[Float]) extends BoxedArray {
result
}
}
-
diff --git a/src/library/scala/runtime/BoxedIntArray.scala b/src/library/scala/runtime/BoxedIntArray.scala
index ad8db390d6..d3c02b2627 100644
--- a/src/library/scala/runtime/BoxedIntArray.scala
+++ b/src/library/scala/runtime/BoxedIntArray.scala
@@ -19,10 +19,10 @@ final class BoxedIntArray(val value: Array[Int]) extends BoxedArray {
def length: Int = value.length
- def apply(index: Int): AnyRef = BoxedInt.box(value(index))
+ def apply(index: Int): AnyRef = Int.box(value(index))
def update(index: Int, elem: AnyRef): Unit = {
- value(index) = elem.asInstanceOf[BoxedNumber].intValue()
+ value(index) = Int.unbox(elem)
}
def unbox(elemTag: String): AnyRef = value
@@ -58,4 +58,3 @@ final class BoxedIntArray(val value: Array[Int]) extends BoxedArray {
result
}
}
-
diff --git a/src/library/scala/runtime/BoxedLongArray.scala b/src/library/scala/runtime/BoxedLongArray.scala
index 6592cc2408..7a2a70758a 100644
--- a/src/library/scala/runtime/BoxedLongArray.scala
+++ b/src/library/scala/runtime/BoxedLongArray.scala
@@ -19,10 +19,10 @@ final class BoxedLongArray(val value: Array[Long]) extends BoxedArray {
def length: Int = value.length
- def apply(index: Int): AnyRef = BoxedLong.box(value(index))
+ def apply(index: Int): AnyRef = Long.box(value(index))
def update(index: Int, elem: AnyRef): Unit = {
- value(index) = elem.asInstanceOf[BoxedNumber].longValue()
+ value(index) = Long.unbox(elem)
}
def unbox(elemTag: String): AnyRef = value
@@ -58,4 +58,3 @@ final class BoxedLongArray(val value: Array[Long]) extends BoxedArray {
result
}
}
-
diff --git a/src/library/scala/runtime/BoxedShortArray.scala b/src/library/scala/runtime/BoxedShortArray.scala
index f1b37ca5b0..6adea4029b 100644
--- a/src/library/scala/runtime/BoxedShortArray.scala
+++ b/src/library/scala/runtime/BoxedShortArray.scala
@@ -19,10 +19,10 @@ final class BoxedShortArray(val value: Array[Short]) extends BoxedArray {
def length: Int = value.length
- def apply(index: Int): AnyRef = BoxedShort.box(value(index))
+ def apply(index: Int): AnyRef = Short.box(value(index))
def update(index: Int, elem: AnyRef): Unit = {
- value(index) = elem.asInstanceOf[BoxedNumber].shortValue()
+ value(index) = Short.unbox(elem)
}
def unbox(elemTag: String): AnyRef = value
@@ -58,4 +58,3 @@ final class BoxedShortArray(val value: Array[Short]) extends BoxedArray {
result
}
}
-
diff --git a/src/library/scala/runtime/ScalaRunTime.scala b/src/library/scala/runtime/ScalaRunTime.scala
index f32db05a23..f20f6106fa 100644
--- a/src/library/scala/runtime/ScalaRunTime.scala
+++ b/src/library/scala/runtime/ScalaRunTime.scala
@@ -152,14 +152,6 @@ object ScalaRunTime {
def Seq[a](xs: a*): Seq[a] = null; // interpreted specially by new backend.
- def booleanValue(x: BoxedBoolean): Boolean = if (x eq null) false else x.booleanValue();
- def byteValue (x: BoxedNumber ): Byte = if (x eq null) 0 else x.byteValue();
- def shortValue (x: BoxedNumber ): Short = if (x eq null) 0 else x.shortValue();
- def charValue (x: BoxedNumber ): Char = if (x eq null) 0 else x.charValue();
- def intValue (x: BoxedNumber ): Int = if (x eq null) 0 else x.intValue();
- def longValue (x: BoxedNumber ): Long = if (x eq null) 0L else x.longValue();
- def floatValue (x: BoxedNumber ): Float = if (x eq null) 0.0F else x.floatValue();
- def doubleValue (x: BoxedNumber ): Double = if (x eq null) 0.0D else x.doubleValue();
def arrayValue (x: BoxedArray, elemTag: String): AnyRef =
if (x eq null) null else x.unbox(elemTag);
def arrayValue (x: BoxedArray, elemClass: Class): AnyRef =