diff options
author | Martin Odersky <odersky@gmail.com> | 2009-12-21 17:30:23 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2009-12-21 17:30:23 +0000 |
commit | a326f40dbf25e50976d17a3a90bdd2dc5e37a87e (patch) | |
tree | ed48bea23d173cf7d751dd4f6089401e4f7e298d /src/library | |
parent | 21e3410dd162f2b78a2507c254c9d516291c3444 (diff) | |
download | scala-a326f40dbf25e50976d17a3a90bdd2dc5e37a87e.tar.gz scala-a326f40dbf25e50976d17a3a90bdd2dc5e37a87e.tar.bz2 scala-a326f40dbf25e50976d17a3a90bdd2dc5e37a87e.zip |
(1) Added some classes to allow arbitrary patch...
(1) Added some classes to allow arbitrary patches to source buffers.
(These are not yet complete so do not need a review yet I think.
(2) Avoided reflexive array operations in ScalaRunTime. review by
(community.
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/runtime/ScalaRunTime.scala | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/src/library/scala/runtime/ScalaRunTime.scala b/src/library/scala/runtime/ScalaRunTime.scala index f6c4cf79dc..ecc81c074e 100644 --- a/src/library/scala/runtime/ScalaRunTime.scala +++ b/src/library/scala/runtime/ScalaRunTime.scala @@ -30,13 +30,49 @@ object ScalaRunTime { def isValueClass(clazz: Class[_]) = clazz.isPrimitive() /** Retrieve generic array element */ - def array_apply(xs: AnyRef, idx: Int): Any = java.lang.reflect.Array.get(xs, idx) + def array_apply(xs: AnyRef, idx: Int): Any = xs match { + case x: Array[AnyRef] => x(idx).asInstanceOf[Any] + case x: Array[Int] => x(idx).asInstanceOf[Any] + case x: Array[Double] => x(idx).asInstanceOf[Any] + case x: Array[Long] => x(idx).asInstanceOf[Any] + case x: Array[Float] => x(idx).asInstanceOf[Any] + case x: Array[Char] => x(idx).asInstanceOf[Any] + case x: Array[Byte] => x(idx).asInstanceOf[Any] + case x: Array[Short] => x(idx).asInstanceOf[Any] + case x: Array[Boolean] => x(idx).asInstanceOf[Any] + case x: Array[Unit] => x(idx).asInstanceOf[Any] + case null => throw new NullPointerException + } /** update generic array element */ - def array_update(xs: AnyRef, idx: Int, value: Any): Unit = java.lang.reflect.Array.set(xs, idx, value) + def array_update(xs: AnyRef, idx: Int, value: Any): Unit = xs match { + case x: Array[AnyRef] => x(idx) = value.asInstanceOf[AnyRef] + case x: Array[Int] => x(idx) = value.asInstanceOf[Int] + case x: Array[Double] => x(idx) = value.asInstanceOf[Double] + case x: Array[Long] => x(idx) = value.asInstanceOf[Long] + case x: Array[Float] => x(idx) = value.asInstanceOf[Float] + case x: Array[Char] => x(idx) = value.asInstanceOf[Char] + case x: Array[Byte] => x(idx) = value.asInstanceOf[Byte] + case x: Array[Short] => x(idx) = value.asInstanceOf[Short] + case x: Array[Boolean] => x(idx) = value.asInstanceOf[Boolean] + case x: Array[Unit] => x(idx) = value.asInstanceOf[Unit] + case null => throw new NullPointerException + } /** Get generic array length */ - def array_length(xs: AnyRef): Int = java.lang.reflect.Array.getLength(xs) + def array_length(xs: AnyRef): Int = xs match { + case x: Array[AnyRef] => x.length + case x: Array[Int] => x.length + case x: Array[Double] => x.length + case x: Array[Long] => x.length + case x: Array[Float] => x.length + case x: Array[Char] => x.length + case x: Array[Byte] => x.length + case x: Array[Short] => x.length + case x: Array[Boolean] => x.length + case x: Array[Unit] => x.length + case null => throw new NullPointerException + } /** Convert a numeric value array to an object array. * Needed to deal with vararg arguments of primtive types that are passed |