From 42123a6366d3877070b2f40160337fc6ffd4a27e Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 22 Nov 2009 16:07:46 +0000 Subject: Removed all traces of Boxed*Array. New starr. --- lib/scala-compiler.jar.desired.sha1 | 2 +- lib/scala-library-src.jar.desired.sha1 | 2 +- lib/scala-library.jar.desired.sha1 | 2 +- src/compiler/scala/tools/nsc/Global.scala | 4 - .../scala/tools/nsc/symtab/Definitions.scala | 7 - src/compiler/scala/tools/nsc/symtab/StdNames.scala | 2 - .../scala/tools/nsc/transform/Erasure.scala | 11 - src/library/scala/Array.scala | 4 - src/library/scala/runtime/BoxedAnyArray.scala | 224 --------------------- src/library/scala/runtime/BoxedArray.scala | 165 --------------- src/library/scala/runtime/BoxedBooleanArray.scala | 28 --- src/library/scala/runtime/BoxedByteArray.scala | 28 --- src/library/scala/runtime/BoxedCharArray.scala | 28 --- src/library/scala/runtime/BoxedDoubleArray.scala | 28 --- src/library/scala/runtime/BoxedFloatArray.scala | 28 --- src/library/scala/runtime/BoxedIntArray.scala | 28 --- src/library/scala/runtime/BoxedLongArray.scala | 28 --- src/library/scala/runtime/BoxedObjectArray.scala | 40 ---- src/library/scala/runtime/BoxedShortArray.scala | 28 --- src/library/scala/runtime/BoxedUnitArray.scala | 28 --- src/library/scala/runtime/ScalaRunTime.scala | 37 +--- 21 files changed, 4 insertions(+), 748 deletions(-) delete mode 100644 src/library/scala/runtime/BoxedAnyArray.scala delete mode 100644 src/library/scala/runtime/BoxedArray.scala delete mode 100644 src/library/scala/runtime/BoxedBooleanArray.scala delete mode 100644 src/library/scala/runtime/BoxedByteArray.scala delete mode 100644 src/library/scala/runtime/BoxedCharArray.scala delete mode 100644 src/library/scala/runtime/BoxedDoubleArray.scala delete mode 100644 src/library/scala/runtime/BoxedFloatArray.scala delete mode 100644 src/library/scala/runtime/BoxedIntArray.scala delete mode 100644 src/library/scala/runtime/BoxedLongArray.scala delete mode 100644 src/library/scala/runtime/BoxedObjectArray.scala delete mode 100644 src/library/scala/runtime/BoxedShortArray.scala delete mode 100644 src/library/scala/runtime/BoxedUnitArray.scala diff --git a/lib/scala-compiler.jar.desired.sha1 b/lib/scala-compiler.jar.desired.sha1 index 2b2a67b22a..2e408e7b30 100644 --- a/lib/scala-compiler.jar.desired.sha1 +++ b/lib/scala-compiler.jar.desired.sha1 @@ -1 +1 @@ -4186f137b40693ccded4286cf2f0ab86b447caff ?scala-compiler.jar +ffd0a45a376f604415980cf8891d780edc327c8f ?scala-compiler.jar diff --git a/lib/scala-library-src.jar.desired.sha1 b/lib/scala-library-src.jar.desired.sha1 index 044afcee1c..639779719e 100644 --- a/lib/scala-library-src.jar.desired.sha1 +++ b/lib/scala-library-src.jar.desired.sha1 @@ -1 +1 @@ -05ba03d2b01076b6b45b82fd324be7193b571616 ?scala-library-src.jar +4b4cf49e7d50ec49a0a5c1762f7213c41b8149e2 ?scala-library-src.jar diff --git a/lib/scala-library.jar.desired.sha1 b/lib/scala-library.jar.desired.sha1 index d6cdbc58e7..d130f5a43f 100644 --- a/lib/scala-library.jar.desired.sha1 +++ b/lib/scala-library.jar.desired.sha1 @@ -1 +1 @@ -a0b0c7cd53700e6034fa7db3f38e60575aedf021 ?scala-library.jar +a3dc8a4cf67a2fd2096cd42ab5ee34ea7a45c0d4 ?scala-library.jar diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 09d900ce78..a933c13c39 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -375,10 +375,6 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable val runsRightAfter = None } with TailCalls - // object checkDefined extends { - // val global: Global.this.type = Global.this - // } with CheckDefined - // phaseName = "explicitouter" object explicitOuter extends { val global: Global.this.type = Global.this diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala index aa4234fbfb..c32a6fffd8 100644 --- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala +++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala @@ -149,8 +149,6 @@ trait Definitions { lazy val ScalaRunTimeModule: Symbol = getModule("scala.runtime.ScalaRunTime") lazy val SymbolModule: Symbol = getModule("scala.Symbol") def SeqFactory = getMember(ScalaRunTimeModule, nme.Seq) - def checkDefinedMethod = getMember(ScalaRunTimeModule, "checkDefined") - def isArrayMethod = getMember(ScalaRunTimeModule, "isArray") def arrayApplyMethod = getMember(ScalaRunTimeModule, "array_apply") def arrayUpdateMethod = getMember(ScalaRunTimeModule, "array_update") def arrayLengthMethod = getMember(ScalaRunTimeModule, "array_length") @@ -400,9 +398,6 @@ trait Definitions { // boxed classes lazy val ObjectRefClass = getClass("scala.runtime.ObjectRef") lazy val BoxesRunTimeClass = getModule("scala.runtime.BoxesRunTime") - lazy val BoxedArrayClass = getClass("scala.runtime.BoxedArray") - lazy val BoxedAnyArrayClass = getClass("scala.runtime.BoxedAnyArray") - lazy val BoxedObjectArrayClass = getClass("scala.runtime.BoxedObjectArray") lazy val BoxedNumberClass = getClass(sn.BoxedNumber) lazy val BoxedCharacterClass = getClass(sn.BoxedCharacter) lazy val BoxedBooleanClass = getClass(sn.BoxedBoolean) @@ -570,7 +565,6 @@ trait Definitions { val boxedModule = new HashMap[Symbol, Symbol] val unboxMethod = new HashMap[Symbol, Symbol] // Type -> Method val boxMethod = new HashMap[Symbol, Symbol] // Type -> Method - val boxedArrayClass = new HashMap[Symbol, Symbol] def isUnbox(m: Symbol) = (m.name == nme.unbox) && cond(m.tpe) { case MethodType(_, restpe) => cond(unboxMethod get restpe.typeSymbol) { @@ -595,7 +589,6 @@ trait Definitions { val clazz = newClass(ScalaPackageClass, name, anyvalparam) setFlag (ABSTRACT | FINAL) boxedClass(clazz) = getClass(boxedName) boxedModule(clazz) = getModule(boxedName) - boxedArrayClass(clazz) = getClass("scala.runtime.Boxed" + name + "Array") refClass(clazz) = getClass("scala.runtime." + name + "Ref") abbrvTag(clazz) = tag if (width > 0) numericWidth(clazz) = width diff --git a/src/compiler/scala/tools/nsc/symtab/StdNames.scala b/src/compiler/scala/tools/nsc/symtab/StdNames.scala index 3c5b866ba8..990d6dc463 100644 --- a/src/compiler/scala/tools/nsc/symtab/StdNames.scala +++ b/src/compiler/scala/tools/nsc/symtab/StdNames.scala @@ -268,8 +268,6 @@ trait StdNames { val assume_ = newTermName("assume") val asInstanceOf_ = newTermName("asInstanceOf") val box = newTermName("box") - val boxArray = newTermName("boxArray") - val forceBoxedArray = newTermName("forceBoxedArray") val canEqual_ = newTermName("canEqual") val checkInitialized = newTermName("checkInitialized") val classOf = newTermName("classOf") diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 290abd0995..b4e2aefd58 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -425,17 +425,6 @@ abstract class Erasure extends AddInterfaces with typechecker.Analyzer with ast. }) } - /** generate ScalaRuntime.boxArray(tree) - * !!! todo: optimize this in case the runtime type is known - */ - private def boxArray(tree: Tree): Tree = tree match { - case LabelDef(name, params, rhs) => - val rhs1 = boxArray(rhs) - treeCopy.LabelDef(tree, name, params, rhs1) setType rhs1.tpe - case _ => - typedPos(tree.pos) { gen.mkRuntimeCall(nme.boxArray, List(tree)) } - } - /** Unbox tree of boxed type to expected type pt. * * @param tree the given tree diff --git a/src/library/scala/Array.scala b/src/library/scala/Array.scala index a323dccffc..acd3d17059 100644 --- a/src/library/scala/Array.scala +++ b/src/library/scala/Array.scala @@ -42,10 +42,6 @@ class FallbackArrayBuilding { * @version 1.0 */ object Array extends FallbackArrayBuilding { - - import runtime.BoxedArray; - import scala.runtime.ScalaRunTime.boxArray; - implicit def canBuildFrom[T](implicit m: ClassManifest[T]): CanBuildFrom[Array[_], T, Array[T]] = new CanBuildFrom[Array[_], T, Array[T]] { def apply(from: Array[_]) = ArrayBuilder.make[T]()(m) diff --git a/src/library/scala/runtime/BoxedAnyArray.scala b/src/library/scala/runtime/BoxedAnyArray.scala deleted file mode 100644 index e0f6bd5be2..0000000000 --- a/src/library/scala/runtime/BoxedAnyArray.scala +++ /dev/null @@ -1,224 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -// $Id$ - - -package scala.runtime -import scala.reflect.ClassManifest -import compat.Platform - -/** - * Arrays created by new Array[T](length) where T - * is a type variable. - * - * @author Martin Odersky - */ -@serializable -final class BoxedAnyArray[A](val length: Int) extends BoxedArray[A] { - - def elemManifest: ClassManifest[A] = null - - private var boxed = new Array[AnyRef](length) -// private val hash = boxed.hashCode() - private var unboxed: AnyRef = null - private var elemClass: Class[_] = null - - def apply(index: Int): A = synchronized { - if (unboxed eq null) - boxed(index) - else if (elemClass eq classOf[Int]) - Int.box(unboxed.asInstanceOf[Array[Int]](index)) - else if (elemClass eq classOf[Double]) - Double.box(unboxed.asInstanceOf[Array[Double]](index)) - else if (elemClass eq classOf[Float]) - Float.box(unboxed.asInstanceOf[Array[Float]](index)) - else if (elemClass eq classOf[Long]) - Long.box(unboxed.asInstanceOf[Array[Long]](index)) - else if (elemClass eq classOf[Char]) - Char.box(unboxed.asInstanceOf[Array[Char]](index)) - else if (elemClass eq classOf[Byte]) - Byte.box(unboxed.asInstanceOf[Array[Byte]](index)) - else if (elemClass eq classOf[Short]) - Short.box(unboxed.asInstanceOf[Array[Short]](index)) - else if (elemClass eq classOf[Boolean]) - Boolean.box(unboxed.asInstanceOf[Array[Boolean]](index)) - else - unboxed.asInstanceOf[Array[AnyRef]](index) - }.asInstanceOf[A] - - def update(index: Int, _elem: A): Unit = synchronized { - val elem = _elem.asInstanceOf[AnyRef] - if (unboxed eq null) - boxed(index) = elem - else if (elemClass eq classOf[Int]) - unboxed.asInstanceOf[Array[Int]](index) = Int.unbox(elem) - else if (elemClass eq classOf[Double]) - unboxed.asInstanceOf[Array[Double]](index) = Double.unbox(elem) - else if (elemClass eq classOf[Float]) - unboxed.asInstanceOf[Array[Float]](index) = Float.unbox(elem) - else if (elemClass eq classOf[Long]) - unboxed.asInstanceOf[Array[Long]](index) = Long.unbox(elem) - else if (elemClass eq classOf[Char]) - unboxed.asInstanceOf[Array[Char]](index) = Char.unbox(elem) - else if (elemClass eq classOf[Byte]) - unboxed.asInstanceOf[Array[Byte]](index) = Byte.unbox(elem) - else if (elemClass eq classOf[Short]) - unboxed.asInstanceOf[Array[Short]](index) = Short.unbox(elem) - else if (elemClass eq classOf[Boolean]) - unboxed.asInstanceOf[Array[Boolean]](index) = Boolean.unbox(elem) - else - unboxed.asInstanceOf[Array[AnyRef]](index) = elem - } - - def unbox(elemClass: Class[_]): AnyRef = synchronized { - if (unboxed eq null) { - this.elemClass = elemClass; - if (elemClass eq classOf[Int]) { - val newvalue = new Array[Int](length) - var i = 0 - while (i < length) { - newvalue(i) = Int.unbox(boxed(i)) - i += 1 - } - unboxed = newvalue - } else if (elemClass eq classOf[Double]) { - val newvalue = new Array[Double](length) - var i = 0 - while (i < length) { - newvalue(i) = Double.unbox(boxed(i)) - i += 1 - } - unboxed = newvalue; - } else if (elemClass eq classOf[Float]) { - val newvalue = new Array[Float](length) - var i = 0 - while (i < length) { - newvalue(i) = Float.unbox(boxed(i)) - i += 1 - } - unboxed = newvalue; - } else if (elemClass eq classOf[Long]) { - val newvalue = new Array[Long](length) - var i = 0 - while (i < length) { - newvalue(i) = Long.unbox(boxed(i)) - i += 1 - } - unboxed = newvalue; - } else if (elemClass eq classOf[Char]) { - val newvalue = new Array[Char](length) - var i = 0 - while (i < length) { - newvalue(i) = Char.unbox(boxed(i)) - i += 1 - } - unboxed = newvalue - } else if (elemClass eq classOf[Byte]) { - val newvalue = new Array[Byte](length) - var i = 0 - while (i < length) { - newvalue(i) = Byte.unbox(boxed(i)) - i += 1 - } - unboxed = newvalue; - } else if (elemClass eq classOf[Short]) { - val newvalue = new Array[Short](length) - var i = 0 - while (i < length) { - newvalue(i) = Short.unbox(boxed(i)) - i += 1 - } - unboxed = newvalue; - } else if (elemClass eq classOf[Boolean]) { - val newvalue = new Array[Boolean](length) - var i = 0 - while (i < length) { - newvalue(i) = Boolean.unbox(boxed(i)) - i += 1 - } - unboxed = newvalue; - } else if (elemClass == classOf[AnyRef]) { - unboxed = boxed - } else { - unboxed = Platform.createArray(elemClass, length) - if (elemClass.isArray) { - var i = 0 - while (i < length) { - boxed(i) match { - case ba: BoxedArray[_] => boxed(i) = ba.unbox(elemClass.getComponentType()) - case _ => - } - i += 1 - } - } - Platform.arraycopy(boxed, 0, unboxed, 0, length) - } - boxed = null - } - unboxed - } - - def value: AnyRef = { - if (unboxed eq null) throw new NotDefinedError("BoxedAnyArray.value") - unboxed - } - - private def adapt(other: AnyRef): AnyRef = - if (this.unboxed eq null) - other match { - case that: BoxedAnyArray[_] => - if (that.unboxed eq null) { - that.boxed - } else { - if (ScalaRunTime.isValueClass(that.elemClass)) unbox(that.elemClass); - that.unboxed - } - case that: BoxedArray[_] => - adapt(that.value) - case that: Array[Int] => - unbox(classOf[Int]); that - case that: Array[Double] => - unbox(classOf[Double]); that - case that: Array[Float] => - unbox(classOf[Float]); that - case that: Array[Long] => - unbox(classOf[Long]); that - case that: Array[Char] => - unbox(classOf[Char]); that - case that: Array[Short] => - unbox(classOf[Short]); that - case that: Array[Byte] => - unbox(classOf[Byte]); that - case that: Array[Boolean] => - unbox(classOf[Boolean]); that - case _ => - other - } - else - other match { - case that: BoxedAnyArray[_] => - if (that.unboxed ne null) that.unboxed - else if (ScalaRunTime.isValueClass(this.elemClass)) that.unbox(this.elemClass) - else that.boxed - case that: BoxedArray[_] => - adapt(that.value) - case _ => - other - } - - override def copyFrom(src: AnyRef, from: Int, to: Int, len: Int) { - val src1 = adapt(src) - Array.copy(src1, from, if (unboxed ne null) unboxed else boxed, to, len) - } - - override def copyTo(from: Int, dest: AnyRef, to: Int, len: Int) { - var dest1 = adapt(dest) - Array.copy(if (unboxed ne null) unboxed else boxed, from, dest1, to, len) - } -} diff --git a/src/library/scala/runtime/BoxedArray.scala b/src/library/scala/runtime/BoxedArray.scala deleted file mode 100644 index 0a8659ffe6..0000000000 --- a/src/library/scala/runtime/BoxedArray.scala +++ /dev/null @@ -1,165 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -// $Id$ - - -package scala.runtime - -import scala.reflect.ClassManifest -import collection.mutable._ -import collection.Seq - -/** - *

A class representing Array[T]

- * - * @author Martin Odersky, Stephane Micheloud - * @version 1.0 - */ -abstract class BoxedArray[A] extends IndexedSeq[A] with IndexedSeqLike[A, BoxedArray[A]] with Boxed { self => - - val ex = new Error("trying to create a BoxedArray") - ex.printStackTrace() - throw ex - - /** The manifest of the element type */ - def elemManifest: ClassManifest[A] - - /** The length of the array */ - def length: Int - - /** The element at given index */ - def apply(index: Int): A - - /** Update element at given index */ - def update(index: Int, elem: A): Unit - - /** Creates new builder for this collection ==> move to subclasses - */ - override protected[this] def newBuilder: Builder[A, BoxedArray[A]] = - genericBuilder[A] - - // !!! todo: remove - override def genericBuilder[B]: Builder[B, BoxedArray[B]] = new ArrayBuffer[B].mapResult { - _.toArray(null).asInstanceOf[BoxedArray[B]] - } - - /** Convert to Java array. - * @param elemTag Either one of the tags ".N" where N is the name of a primitive type - * (@see ScalaRunTime), or a full class name. - */ - def unbox(elemClass: Class[_]): AnyRef - - /** The underlying array value - */ - def value: AnyRef - - def copyFrom(src: AnyRef, from: Int, to: Int, len: Int): Unit = - Array.copy(src, from, value, to, len) - - def copyTo(from: Int, dest: AnyRef, to: Int, len: Int): Unit = { - Array.copy(value, from, dest, to, len) - } - - override def toArray[B >: A](implicit m: ClassManifest[B]): Array[B] = { - if ((elemManifest ne null) && (elemManifest.erasure eq m.erasure)) this.asInstanceOf[Array[B]] - else super.toArray[B] - } - -/* - override def equals(other: Any) = - (value eq other) || - - other.isInstanceOf[BoxedArray[_]] && (value == other.asInstanceOf[BoxedArray[_]].value) - - override def hashCode(): Int = value.hashCode() -*/ - /** Fills the given array xs with the elements of - * this sequence starting at position start. - * - * @param xs the array to fill. - * @param start starting index. - * @pre the array must be large enough to hold all elements. - */ - override def copyToArray[B](xs: Array[B], start: Int, len: Int): Unit = - copyTo(0, xs, start, len) - - /** Creates a possible nested IndexedSeq which consists of all the elements - * of this array. If the elements are arrays themselves, the `deep' transformation - * is applied recursively to them. The stringPrefix of the IndexedSeq is - * "Array", hence the IndexedSeq prints like an array with all its - * elements shown, and the same recursively for any subarrays. - * - * Example: Array(Array(1, 2), Array(3, 4)).deep.toString - * prints: Array(Array(1, 2), Array(3, 4)) - */ - def deep: collection.IndexedSeq[Any] = new collection.IndexedSeq[Any] { - def length = self.length - def apply(idx: Int): Any = self.apply(idx) match { - case elem: AnyRef if ScalaRunTime.isArray(elem) => ScalaRunTime.boxArray(elem).deep - case elem => elem - } - override def stringPrefix = "Array" - } - - @deprecated("use deep.toString instead") - final def deepToString() = deepMkString(stringPrefix + "(", ", ", ")") - - @deprecated("use deep.mkString instead") - final def deepMkString(start: String, sep: String, end: String): String = { - def _deepToString(x: Any) = x match { - case a: AnyRef if ScalaRunTime.isArray(a) => - ScalaRunTime.boxArray(a).deepMkString(start, sep, end) - case _ => - ScalaRunTime.stringOf(x) - } - val buf = new StringBuilder() - buf.append(start) - val iter = this.iterator - if (iter.hasNext) buf.append(_deepToString(iter.next)) - while (iter.hasNext) { - buf.append(sep); buf.append(_deepToString(iter.next)) - } - buf.append(end) - buf.toString - } - - @deprecated("use deep.mkString instead") - final def deepMkString(sep: String): String = this.deepMkString("", sep, "") - - @deprecated("use array1.deep.equals(array2.deep) instead") - final def deepEquals(that: Any): Boolean = { - def _deepEquals(x1: Any, x2: Any) = (x1, x2) match { - case (a1: BoxedArray[_], a2: BoxedArray[_]) => - _sameElements(a1, a2) - case (a1: AnyRef, a2: AnyRef) - if ScalaRunTime.isArray(a1) && ScalaRunTime.isArray(a2) => - _sameElements(ScalaRunTime.boxArray(a1), ScalaRunTime.boxArray(a2)) - case _ => - x1.equals(x2) - } - def _sameElements(a1: BoxedArray[_], a2: BoxedArray[_]): Boolean = { - val it1 = a1.iterator - val it2 = a2.iterator - var res = true - while (res && it1.hasNext && it2.hasNext) - res = _deepEquals(it1.next, it2.next) - !it1.hasNext && !it2.hasNext && res - } - that match { - case a: BoxedArray[_] => - _sameElements(this, a) - case a: AnyRef if ScalaRunTime.isArray(a) => - _sameElements(this, ScalaRunTime.boxArray(a)) - case _ => - false - } - } - - override final def stringPrefix: String = "Array" -} diff --git a/src/library/scala/runtime/BoxedBooleanArray.scala b/src/library/scala/runtime/BoxedBooleanArray.scala deleted file mode 100644 index ff781004d4..0000000000 --- a/src/library/scala/runtime/BoxedBooleanArray.scala +++ /dev/null @@ -1,28 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -// $Id$ - - -package scala.runtime -import scala.reflect.ClassManifest - -@serializable -final class BoxedBooleanArray(val value: Array[Boolean]) extends BoxedArray[Boolean] { - - def elemManifest = ClassManifest.Boolean - - def length: Int = value.length - - def apply(index: Int): Boolean = value(index) - - def update(index: Int, elem: Boolean) { - value(index) = elem - } - def unbox(elemClass: Class[_]): AnyRef = value -} diff --git a/src/library/scala/runtime/BoxedByteArray.scala b/src/library/scala/runtime/BoxedByteArray.scala deleted file mode 100644 index 9f81dc2a86..0000000000 --- a/src/library/scala/runtime/BoxedByteArray.scala +++ /dev/null @@ -1,28 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -// $Id$ - - -package scala.runtime -import scala.reflect.ClassManifest - -@serializable -final class BoxedByteArray(val value: Array[Byte]) extends BoxedArray[Byte] { - - def elemManifest = ClassManifest.Byte - - def length: Int = value.length - - def apply(index: Int): Byte = value(index) - - def update(index: Int, elem: Byte) { - value(index) = elem - } - def unbox(elemClass: Class[_]): AnyRef = value -} diff --git a/src/library/scala/runtime/BoxedCharArray.scala b/src/library/scala/runtime/BoxedCharArray.scala deleted file mode 100644 index 8924ed52f5..0000000000 --- a/src/library/scala/runtime/BoxedCharArray.scala +++ /dev/null @@ -1,28 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -// $Id$ - - -package scala.runtime -import scala.reflect.ClassManifest - -@serializable -final class BoxedCharArray(val value: Array[Char]) extends BoxedArray[Char] { - - def elemManifest = ClassManifest.Char - - def length: Int = value.length - - def apply(index: Int): Char = value(index) - - def update(index: Int, elem: Char) { - value(index) = elem - } - def unbox(elemClass: Class[_]): AnyRef = value -} diff --git a/src/library/scala/runtime/BoxedDoubleArray.scala b/src/library/scala/runtime/BoxedDoubleArray.scala deleted file mode 100644 index 2a9a657915..0000000000 --- a/src/library/scala/runtime/BoxedDoubleArray.scala +++ /dev/null @@ -1,28 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -// $Id$ - - -package scala.runtime -import scala.reflect.ClassManifest - -@serializable -final class BoxedDoubleArray(val value: Array[Double]) extends BoxedArray[Double] { - - def elemManifest = ClassManifest.Double - - def length: Int = value.length - - def apply(index: Int): Double = value(index) - - def update(index: Int, elem: Double) { - value(index) = elem - } - def unbox(elemClass: Class[_]): AnyRef = value -} diff --git a/src/library/scala/runtime/BoxedFloatArray.scala b/src/library/scala/runtime/BoxedFloatArray.scala deleted file mode 100644 index 038356150e..0000000000 --- a/src/library/scala/runtime/BoxedFloatArray.scala +++ /dev/null @@ -1,28 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -// $Id$ - - -package scala.runtime -import scala.reflect.ClassManifest - -@serializable -final class BoxedFloatArray(val value: Array[Float]) extends BoxedArray[Float] { - - def elemManifest = ClassManifest.Float - - def length: Int = value.length - - def apply(index: Int): Float = value(index) - - def update(index: Int, elem: Float) { - value(index) = elem - } - def unbox(elemClass: Class[_]): AnyRef = value -} diff --git a/src/library/scala/runtime/BoxedIntArray.scala b/src/library/scala/runtime/BoxedIntArray.scala deleted file mode 100644 index fac3b24b77..0000000000 --- a/src/library/scala/runtime/BoxedIntArray.scala +++ /dev/null @@ -1,28 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -// $Id$ - - -package scala.runtime -import scala.reflect.ClassManifest - -@serializable -final class BoxedIntArray(val value: Array[Int]) extends BoxedArray[Int] { - - def elemManifest = ClassManifest.Int - - def length: Int = value.length - - def apply(index: Int): Int = value(index) - - def update(index: Int, elem: Int) { - value(index) = elem - } - def unbox(elemClass: Class[_]): AnyRef = value -} diff --git a/src/library/scala/runtime/BoxedLongArray.scala b/src/library/scala/runtime/BoxedLongArray.scala deleted file mode 100644 index cbf9d68498..0000000000 --- a/src/library/scala/runtime/BoxedLongArray.scala +++ /dev/null @@ -1,28 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -// $Id$ - - -package scala.runtime -import scala.reflect.ClassManifest - -@serializable -final class BoxedLongArray(val value: Array[Long]) extends BoxedArray[Long] { - - def elemManifest = ClassManifest.Long - - def length: Int = value.length - - def apply(index: Int): Long = value(index) - - def update(index: Int, elem: Long) { - value(index) = elem - } - def unbox(elemClass: Class[_]): AnyRef = value -} diff --git a/src/library/scala/runtime/BoxedObjectArray.scala b/src/library/scala/runtime/BoxedObjectArray.scala deleted file mode 100644 index 47ad9a3b48..0000000000 --- a/src/library/scala/runtime/BoxedObjectArray.scala +++ /dev/null @@ -1,40 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -// $Id$ - - -package scala.runtime -import scala.reflect.ClassManifest - -@serializable -final class BoxedObjectArray[A <: AnyRef](val value: Array[AnyRef], val elemManifest: ClassManifest[A]) extends BoxedArray[A] { - -// @deprecated("creating array w/o manifest") - def this(value: Array[AnyRef]) = this(value, null) // !!! todo: remove - - def length: Int = value.length - - def apply(index: Int): A = value(index).asInstanceOf[A] - - def update(index: Int, elem: A) { - value(index) = elem - } - - def unbox(elemClass: Class[_]): AnyRef = value - -/* - override def equals(other: Any): Boolean = - (value eq other.asInstanceOf[AnyRef]) || - other.isInstanceOf[BoxedObjectArray[_]] && (value eq other.asInstanceOf[BoxedObjectArray[_]].value) - - override def hashCode(): Int = (value.asInstanceOf[AnyRef]).hashCode() -*/ - -} - diff --git a/src/library/scala/runtime/BoxedShortArray.scala b/src/library/scala/runtime/BoxedShortArray.scala deleted file mode 100644 index 4da6b0c1c9..0000000000 --- a/src/library/scala/runtime/BoxedShortArray.scala +++ /dev/null @@ -1,28 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -// $Id$ - - -package scala.runtime -import scala.reflect.ClassManifest - -@serializable -final class BoxedShortArray(val value: Array[Short]) extends BoxedArray[Short] { - - def elemManifest = ClassManifest.Short - - def length: Int = value.length - - def apply(index: Int): Short = value(index) - - def update(index: Int, elem: Short) { - value(index) = elem - } - def unbox(elemClass: Class[_]): AnyRef = value -} diff --git a/src/library/scala/runtime/BoxedUnitArray.scala b/src/library/scala/runtime/BoxedUnitArray.scala deleted file mode 100644 index 351237c4b2..0000000000 --- a/src/library/scala/runtime/BoxedUnitArray.scala +++ /dev/null @@ -1,28 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2002-2009, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -// $Id$ - - -package scala.runtime -import scala.reflect.ClassManifest - -@serializable -final class BoxedUnitArray(val value: Array[Unit]) extends BoxedArray[Unit] { - - def elemManifest = ClassManifest.Unit - - def length: Int = value.length - - def apply(index: Int): Unit = value(index) - - def update(index: Int, elem: Unit) { - value(index) = elem - } - def unbox(elemClass: Class[_]): AnyRef = value -} diff --git a/src/library/scala/runtime/ScalaRunTime.scala b/src/library/scala/runtime/ScalaRunTime.scala index c25e042957..79c97af3d7 100644 --- a/src/library/scala/runtime/ScalaRunTime.scala +++ b/src/library/scala/runtime/ScalaRunTime.scala @@ -19,10 +19,7 @@ import scala.collection.immutable.{List, Stream, Nil, ::} /* The object ScalaRunTime provides ... */ object ScalaRunTime { - - def isArray(x: AnyRef): Boolean = // !!! remove once newarrays - x != null && (x.getClass.isArray || x.isInstanceOf[BoxedArray[_]]) - + def isArray(x: AnyRef): Boolean = isArray(x, 1) def isArray(x: Any, atLevel: Int): Boolean = x != null && isArrayClass(x.asInstanceOf[AnyRef].getClass, atLevel) @@ -31,10 +28,6 @@ object ScalaRunTime { def isValueClass(clazz: Class[_]) = clazz.isPrimitive() - // todo: remove? - def forceBoxedArray[A <: Any](xs: Seq[A]): Array[A] = - throw new Error(" not implemented: forceBoxedArray") - /** Retrieve generic array element */ def array_apply(xs: AnyRef, idx: Int): Any = java.lang.reflect.Array.get(xs, idx) @@ -157,36 +150,8 @@ object ScalaRunTime { false } - //def checkDefined[T >: Null](x: T): T = - // if (x == null) throw new UndefinedException else x - def Seq[a](xs: a*): Seq[a] = null // interpreted specially by new backend. - def arrayValue[A](x: BoxedArray[A], elemClass: Class[_]): AnyRef = - if (x eq null) null else x.unbox(elemClass) - - /** Temporary method to go to new array representation - * !!! can be reomved once bootstrap is complete !!! - */ - def unboxedArray[A](x: AnyRef): AnyRef = x match { - case ba: BoxedArray[_] => ba.value - case _ => x - } - - def boxArray(value: AnyRef): BoxedArray[_] = value match { - case x: Array[AnyRef] => new BoxedObjectArray(x, ClassManifest.classType(x.getClass.getComponentType)) - case x: Array[Int] => new BoxedIntArray(x) - case x: Array[Double] => new BoxedDoubleArray(x) - case x: Array[Long] => new BoxedLongArray(x) - case x: Array[Float] => new BoxedFloatArray(x) - case x: Array[Char] => new BoxedCharArray(x) - case x: Array[Byte] => new BoxedByteArray(x) - case x: Array[Short] => new BoxedShortArray(x) - case x: Array[Boolean] => new BoxedBooleanArray(x) - case x: BoxedArray[_] => x - case null => null - } - /** Given any Scala value, convert it to a String. * * The primary motivation for this method is to provide a means for -- cgit v1.2.3