diff options
author | Martin Odersky <odersky@gmail.com> | 2007-02-20 11:23:17 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2007-02-20 11:23:17 +0000 |
commit | fabe192ccb6493f6f0b32c753b72a716a97a5646 (patch) | |
tree | 0c05898ad2293d92e00778a0ef7442745b7f0bcd /src | |
parent | 53c115ff4c8a6cf81659e0ac7bb878b32765107a (diff) | |
download | scala-fabe192ccb6493f6f0b32c753b72a716a97a5646.tar.gz scala-fabe192ccb6493f6f0b32c753b72a716a97a5646.tar.bz2 scala-fabe192ccb6493f6f0b32c753b72a716a97a5646.zip |
fixed slice method
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/TreePrinters.scala | 12 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/Trees.scala | 2 | ||||
-rw-r--r-- | src/library/scala/runtime/BoxedAnyArray.scala | 8 | ||||
-rw-r--r-- | src/library/scala/runtime/BoxedArray.scala | 3 | ||||
-rw-r--r-- | src/library/scala/runtime/BoxedBooleanArray.scala | 7 | ||||
-rw-r--r-- | src/library/scala/runtime/BoxedByteArray.scala | 7 | ||||
-rw-r--r-- | src/library/scala/runtime/BoxedCharArray.scala | 7 | ||||
-rw-r--r-- | src/library/scala/runtime/BoxedDoubleArray.scala | 7 | ||||
-rw-r--r-- | src/library/scala/runtime/BoxedFloatArray.scala | 7 | ||||
-rw-r--r-- | src/library/scala/runtime/BoxedIntArray.scala | 7 | ||||
-rw-r--r-- | src/library/scala/runtime/BoxedLongArray.scala | 7 | ||||
-rw-r--r-- | src/library/scala/runtime/BoxedObjectArray.scala | 7 | ||||
-rw-r--r-- | src/library/scala/runtime/BoxedShortArray.scala | 7 |
13 files changed, 77 insertions, 11 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala index 89fc896003..2f932a2e84 100644 --- a/src/compiler/scala/tools/nsc/ast/TreePrinters.scala +++ b/src/compiler/scala/tools/nsc/ast/TreePrinters.scala @@ -128,13 +128,11 @@ abstract class TreePrinters { printTypeParams(tparams) print(" extends "); printRow(impl.parents, " with ") - if (!impl.body.isEmpty) { - print(" {"); - if (self.name != nme.WILDCARD) { - print(" "); print(self.name); printOpt(": ", self.tpt); print(" => ") - } else if (!self.tpt.isEmpty) { - print(" _ : "); print(self); print(" => ") - } + print(" {"); + if (self.name != nme.WILDCARD) { + print(" "); print(self.name); printOpt(": ", self.tpt); print(" => ") + } else if (!self.tpt.isEmpty) { + print(" _ : "); print(self.tpt); print(" => ") } printColumn(impl.body, "", ";", "}") diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala index ac9a1ab02c..a2085bb50b 100644 --- a/src/compiler/scala/tools/nsc/ast/Trees.scala +++ b/src/compiler/scala/tools/nsc/ast/Trees.scala @@ -298,7 +298,7 @@ trait Trees requires Global { def ValDef(sym: Symbol): ValDef = ValDef(sym, EmptyTree) - object emptyValDef extends ValDef(Modifiers(PRIVATE), nme.WILDCARD, TypeTree(), EmptyTree) + object emptyValDef extends ValDef(Modifiers(PRIVATE), nme.WILDCARD, TypeTree(NoType), EmptyTree) /** Method definition * diff --git a/src/library/scala/runtime/BoxedAnyArray.scala b/src/library/scala/runtime/BoxedAnyArray.scala index 5a1a6b99cc..d979e34523 100644 --- a/src/library/scala/runtime/BoxedAnyArray.scala +++ b/src/library/scala/runtime/BoxedAnyArray.scala @@ -252,4 +252,12 @@ final class BoxedAnyArray(val length: Int) extends BoxedArray { } result } + + final override def slice(start: Int, end: Int): BoxedArray = { + val len = end - start + val result = new BoxedAnyArray(len) + Array.copy(this, start, result, 0, len) + result + } + } diff --git a/src/library/scala/runtime/BoxedArray.scala b/src/library/scala/runtime/BoxedArray.scala index 3ba9433f8a..0036c8f4fe 100644 --- a/src/library/scala/runtime/BoxedArray.scala +++ b/src/library/scala/runtime/BoxedArray.scala @@ -72,9 +72,6 @@ abstract class BoxedArray extends Seq[Any] { // todo: eliminate def subArray(from: Int, end: Int): AnyRef - override def slice(from: Int, end: Int): Seq[Object] = - subArray(from, end).asInstanceOf[Seq[Object]] - final override def map[b](f: Any => b): Array[b] = { val len = length val result = new Array[b](len) diff --git a/src/library/scala/runtime/BoxedBooleanArray.scala b/src/library/scala/runtime/BoxedBooleanArray.scala index 1dbf6bb987..1c434db467 100644 --- a/src/library/scala/runtime/BoxedBooleanArray.scala +++ b/src/library/scala/runtime/BoxedBooleanArray.scala @@ -57,4 +57,11 @@ final class BoxedBooleanArray(val value: Array[Boolean]) extends BoxedArray { } new BoxedBooleanArray(result) } + + final override def slice(start: Int, end: Int): BoxedArray = { + val len = end - start + val result = new Array[Boolean](len) + Array.copy(value, start, result, 0, len) + new BoxedBooleanArray(result) + } } diff --git a/src/library/scala/runtime/BoxedByteArray.scala b/src/library/scala/runtime/BoxedByteArray.scala index 62407d6974..8580acf2a4 100644 --- a/src/library/scala/runtime/BoxedByteArray.scala +++ b/src/library/scala/runtime/BoxedByteArray.scala @@ -57,4 +57,11 @@ final class BoxedByteArray(val value: Array[Byte]) extends BoxedArray { } new BoxedByteArray(result) } + + final override def slice(start: Int, end: Int): BoxedArray = { + val len = end - start + val result = new Array[Byte](len) + Array.copy(value, start, result, 0, len) + new BoxedByteArray(result) + } } diff --git a/src/library/scala/runtime/BoxedCharArray.scala b/src/library/scala/runtime/BoxedCharArray.scala index 1f823853eb..7e93c71c30 100644 --- a/src/library/scala/runtime/BoxedCharArray.scala +++ b/src/library/scala/runtime/BoxedCharArray.scala @@ -58,4 +58,11 @@ final class BoxedCharArray(val value: Array[Char]) extends BoxedArray { } new BoxedCharArray(result) } + + final override def slice(start: Int, end: Int): BoxedArray = { + val len = end - start + val result = new Array[Char](len) + Array.copy(value, start, result, 0, len) + new BoxedCharArray(result) + } } diff --git a/src/library/scala/runtime/BoxedDoubleArray.scala b/src/library/scala/runtime/BoxedDoubleArray.scala index eca804d76c..951828e1cd 100644 --- a/src/library/scala/runtime/BoxedDoubleArray.scala +++ b/src/library/scala/runtime/BoxedDoubleArray.scala @@ -57,4 +57,11 @@ final class BoxedDoubleArray(val value: Array[Double]) extends BoxedArray { } new BoxedDoubleArray(result) } + + final override def slice(start: Int, end: Int): BoxedArray = { + val len = end - start + val result = new Array[Double](len) + Array.copy(value, start, result, 0, len) + new BoxedDoubleArray(result) + } } diff --git a/src/library/scala/runtime/BoxedFloatArray.scala b/src/library/scala/runtime/BoxedFloatArray.scala index 0505a2545d..9e22386370 100644 --- a/src/library/scala/runtime/BoxedFloatArray.scala +++ b/src/library/scala/runtime/BoxedFloatArray.scala @@ -57,4 +57,11 @@ final class BoxedFloatArray(val value: Array[Float]) extends BoxedArray { } new BoxedFloatArray(result) } + + final override def slice(start: Int, end: Int): BoxedArray = { + val len = end - start + val result = new Array[Float](len) + Array.copy(value, start, result, 0, len) + new BoxedFloatArray(result) + } } diff --git a/src/library/scala/runtime/BoxedIntArray.scala b/src/library/scala/runtime/BoxedIntArray.scala index 2519075a3a..633504a98f 100644 --- a/src/library/scala/runtime/BoxedIntArray.scala +++ b/src/library/scala/runtime/BoxedIntArray.scala @@ -57,4 +57,11 @@ final class BoxedIntArray(val value: Array[Int]) extends BoxedArray { } new BoxedIntArray(result) } + + final override def slice(start: Int, end: Int): BoxedArray = { + val len = end - start + val result = new Array[Int](len) + Array.copy(value, start, result, 0, len) + new BoxedIntArray(result) + } } diff --git a/src/library/scala/runtime/BoxedLongArray.scala b/src/library/scala/runtime/BoxedLongArray.scala index f82d1711e1..9d0b7175d5 100644 --- a/src/library/scala/runtime/BoxedLongArray.scala +++ b/src/library/scala/runtime/BoxedLongArray.scala @@ -57,4 +57,11 @@ final class BoxedLongArray(val value: Array[Long]) extends BoxedArray { } new BoxedLongArray(result) } + + final override def slice(start: Int, end: Int): BoxedArray = { + val len = end - start + val result = new Array[Long](len) + Array.copy(value, start, result, 0, len) + new BoxedLongArray(result) + } } diff --git a/src/library/scala/runtime/BoxedObjectArray.scala b/src/library/scala/runtime/BoxedObjectArray.scala index c1596d0949..48b1da7e8a 100644 --- a/src/library/scala/runtime/BoxedObjectArray.scala +++ b/src/library/scala/runtime/BoxedObjectArray.scala @@ -62,4 +62,11 @@ final class BoxedObjectArray(val value: Array[AnyRef]) extends BoxedArray { } new BoxedObjectArray(result) } + + final override def slice(start: Int, end: Int): BoxedArray = { + val len = end - start + val result = create(len) + Array.copy(value, start, result, 0, len) + new BoxedObjectArray(result) + } } diff --git a/src/library/scala/runtime/BoxedShortArray.scala b/src/library/scala/runtime/BoxedShortArray.scala index c3bc7a6125..256bd43727 100644 --- a/src/library/scala/runtime/BoxedShortArray.scala +++ b/src/library/scala/runtime/BoxedShortArray.scala @@ -57,4 +57,11 @@ final class BoxedShortArray(val value: Array[Short]) extends BoxedArray { } new BoxedShortArray(result) } + + final override def slice(start: Int, end: Int): BoxedArray = { + val len = end - start + val result = new Array[Short](len) + Array.copy(value, start, result, 0, len) + new BoxedShortArray(result) + } } |