summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/build/genprod.scala8
-rw-r--r--src/cldc-library/scala/Predef.scala22
-rw-r--r--src/cldc-library/scala/StringBuilder.scala426
-rw-r--r--src/cldc-library/scala/compat/StringBuilder.scala69
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala5
-rw-r--r--src/dotnet-library/scala/Predef.scala2
-rw-r--r--src/dotnet-library/scala/StringBuilder.scala439
-rw-r--r--src/dotnet-library/scala/compat/Math.scala54
-rw-r--r--src/dotnet-library/scala/compat/StringBuilder.scala73
-rw-r--r--src/dotnet-library/scala/runtime/RichInt.scala8
-rw-r--r--src/dotnet-library/scala/runtime/RichString.scala4
-rw-r--r--src/library/scala/CollectionProxy.scala3
-rw-r--r--src/library/scala/Iterable.scala3
-rw-r--r--src/library/scala/IterableProxy.scala3
-rw-r--r--src/library/scala/Predef.scala20
-rw-r--r--src/library/scala/RandomAccessSeq.scala48
-rw-r--r--src/library/scala/StringBuilder.scala476
-rw-r--r--src/library/scala/Tuple1.scala6
-rw-r--r--src/library/scala/Tuple10.scala8
-rw-r--r--src/library/scala/Tuple11.scala8
-rw-r--r--src/library/scala/Tuple12.scala8
-rw-r--r--src/library/scala/Tuple13.scala8
-rw-r--r--src/library/scala/Tuple14.scala8
-rw-r--r--src/library/scala/Tuple15.scala8
-rw-r--r--src/library/scala/Tuple16.scala8
-rw-r--r--src/library/scala/Tuple17.scala8
-rw-r--r--src/library/scala/Tuple18.scala8
-rw-r--r--src/library/scala/Tuple19.scala8
-rw-r--r--src/library/scala/Tuple2.scala6
-rw-r--r--src/library/scala/Tuple20.scala8
-rw-r--r--src/library/scala/Tuple21.scala8
-rw-r--r--src/library/scala/Tuple22.scala8
-rw-r--r--src/library/scala/Tuple3.scala6
-rw-r--r--src/library/scala/Tuple4.scala6
-rw-r--r--src/library/scala/Tuple5.scala6
-rw-r--r--src/library/scala/Tuple6.scala6
-rw-r--r--src/library/scala/Tuple7.scala6
-rw-r--r--src/library/scala/Tuple8.scala6
-rw-r--r--src/library/scala/Tuple9.scala6
-rw-r--r--src/library/scala/compat/StringBuilder.scala73
-rw-r--r--src/library/scala/io/Position.scala3
-rw-r--r--src/library/scala/runtime/BoxedArray.scala3
-rw-r--r--src/library/scala/throws.scala6
-rw-r--r--src/library/scala/util/automata/DetWordAutom.scala3
-rw-r--r--src/library/scala/util/automata/NondetWordAutom.scala5
-rw-r--r--src/library/scala/xml/Elem.scala4
-rw-r--r--src/library/scala/xml/NodeSeq.scala4
-rw-r--r--src/library/scala/xml/TextBuffer.scala4
-rw-r--r--src/library/scala/xml/dtd/Decl.scala38
-rw-r--r--src/library/scala/xml/dtd/ExternalID.scala15
-rw-r--r--src/library/scala/xml/dtd/Scanner.scala4
-rw-r--r--src/library/scala/xml/dtd/ValidationException.scala35
-rw-r--r--src/library/scala/xml/parsing/MarkupParser.scala14
-rw-r--r--test/files/jvm5/stringbuilder.scala85
54 files changed, 1636 insertions, 481 deletions
diff --git a/src/build/genprod.scala b/src/build/genprod.scala
index cd18bee7b7..0fd71ab95d 100644
--- a/src/build/genprod.scala
+++ b/src/build/genprod.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -238,7 +238,7 @@ object TupleFile {
<file name={tupleFilename(i)}>
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -255,7 +255,7 @@ case class {tupleClassname(i)}{__typeArgs__}({ __fields__ })
extends {productClassname(i)}{__typeArgRefs__} {{
override def toString() = {{
- val sb = new compat.StringBuilder
+ val sb = new StringBuilder
{ if ({i} == 1)
"sb.append('(').append(_" + {i} + ").append(\",)\")"
else {
@@ -284,7 +284,7 @@ object ProductFile {
<file name={productFilename(i)}>
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/cldc-library/scala/Predef.scala b/src/cldc-library/scala/Predef.scala
index 4e2ced1c61..385541a71a 100644
--- a/src/cldc-library/scala/Predef.scala
+++ b/src/cldc-library/scala/Predef.scala
@@ -39,7 +39,6 @@ object Predef {
@deprecated type Character = java.lang.Character
type String = java.lang.String
- type StringBuilder = compat.StringBuilder
type Class[T] = java.lang.Class[T]
type Runnable = java.lang.Runnable
@@ -47,16 +46,17 @@ object Predef {
type Exception = java.lang.Exception
type Error = java.lang.Error
- type AssertionError = java.lang.Error
- type RuntimeException = java.lang.RuntimeException
- type NullPointerException = java.lang.NullPointerException
- type ClassCastException = java.lang.ClassCastException
- type IndexOutOfBoundsException = java.lang.IndexOutOfBoundsException
- type ArrayIndexOutOfBoundsException = java.lang.ArrayIndexOutOfBoundsException
- type UnsupportedOperationException = RuntimeException //java.lang.UnsupportedOperationException
- type IllegalArgumentException = java.lang.IllegalArgumentException
- type NoSuchElementException = java.util.NoSuchElementException
- type NumberFormatException = java.lang.NumberFormatException
+ type AssertionError = java.lang.Error
+ type RuntimeException = java.lang.RuntimeException
+ type NullPointerException = java.lang.NullPointerException
+ type ClassCastException = java.lang.ClassCastException
+ type IndexOutOfBoundsException = java.lang.IndexOutOfBoundsException
+ type ArrayIndexOutOfBoundsException = java.lang.ArrayIndexOutOfBoundsException
+ type StringIndexOutOfBoundsException = java.lang.StringIndexOutOfBoundsException
+ type UnsupportedOperationException = RuntimeException //java.lang.UnsupportedOperationException
+ type IllegalArgumentException = java.lang.IllegalArgumentException
+ type NoSuchElementException = java.util.NoSuchElementException
+ type NumberFormatException = java.lang.NumberFormatException
// miscelleaneous -----------------------------------------------------
diff --git a/src/cldc-library/scala/StringBuilder.scala b/src/cldc-library/scala/StringBuilder.scala
new file mode 100644
index 0000000000..a2d4de6b22
--- /dev/null
+++ b/src/cldc-library/scala/StringBuilder.scala
@@ -0,0 +1,426 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2006-2008, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+// $Id: $
+
+
+package scala
+
+import Predef._
+
+/** <p>
+ * A mutable sequence of characters. This class provides an API compatible
+ * with <code>java.lang.StringBuilder</code>, but with no guarantee of
+ * synchronization.
+ * </p>
+ *
+ * @author Stephane Micheloud
+ * @version 1.0
+ */
+@throws(classOf[NullPointerException])
+final class StringBuilder(initCapacity: Int, private val initValue: String) extends (Int => Char) with Proxy {
+ if (initCapacity < 0) throw new IllegalArgumentException
+ if (initValue eq null) throw new NullPointerException
+
+ /** The value is used for character storage. */
+ private var value = new Array[Char](initCapacity + initValue.length)
+
+ /** The count is the number of characters used. */
+ private var count: Int = 0
+
+ def this() = this(16, "")
+
+ def this(capacity: Int) = this(capacity, "")
+
+ @throws(classOf[NullPointerException])
+ def this(str: String) = this(16, str)
+
+ append(initValue)
+
+ def self = this
+
+ def toArray: Array[Char] = value
+
+ def length: Int = count
+
+ def length_=(n: Int) { setLength(n) }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def setLength(n: Int) {
+ if (n < 0)
+ throw new StringIndexOutOfBoundsException(n)
+ if (n > value.length) expandCapacity(n)
+ if (count < n)
+ while (count < n) {
+ value(count) = '\0'; count += 1
+ }
+ else
+ count = n
+ }
+
+ def capacity: Int = value.length
+
+ def capacity_=(n: Int) { ensureCapacity(n) }
+
+ def ensureCapacity(n: Int) {
+ if (n > value.length) expandCapacity(n)
+ }
+
+ private def expandCapacity(n: Int) {
+ val newCapacity = (value.length + 1) * 2
+ value = StringBuilder.copyOf(
+ value,
+ if (newCapacity < 0) Math.MAX_INT else if (n > newCapacity) n else newCapacity
+ )
+ }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def charAt(index: Int): Char = {
+ if (index < 0 || index >= count)
+ throw new StringIndexOutOfBoundsException(index)
+ value(index)
+ }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def apply(i: Int): Char = charAt(i)
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def deleteCharAt(index: Int): StringBuilder = {
+ if (index < 0 || index >= count)
+ throw new StringIndexOutOfBoundsException(index)
+ compat.Platform.arraycopy(value, index + 1, value, index, count - index - 1)
+ count -= 1
+ this
+ }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def setCharAt(index: Int, c: Char) {
+ if (index < 0 || index >= count)
+ throw new StringIndexOutOfBoundsException(index)
+ value(index) = c
+ }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def update(i: Int, c: Char) { setCharAt(i, c) }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def substring(start: Int): String = substring(start, count)
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def substring(start: Int, end: Int): String = {
+ if (start < 0)
+ throw new StringIndexOutOfBoundsException(start)
+ if (end > count)
+ throw new StringIndexOutOfBoundsException(end)
+ if (start > end)
+ throw new StringIndexOutOfBoundsException(end - start)
+ new String(value, start, end - start)
+ }
+
+ def append(x: Any): StringBuilder =
+ append(String.valueOf(x))
+
+ /** Appends the specified string to this character sequence.
+ *
+ * @param s
+ * @return
+ */
+ def append(s: String): StringBuilder = {
+ val str = if (s == null) "null" else s
+ val len = str.length
+ if (len > 0) {
+ val newCount = count + len
+ if (newCount > value.length) expandCapacity(newCount)
+ compat.Platform.arraycopy(str.toArray: Array[Char], 0, value, count, len)
+ count = newCount
+ }
+ this
+ }
+
+ /** Appends the specified string builder to this sequence.
+ *
+ * @param sb
+ * @return
+ */
+ def append(sb: StringBuilder): StringBuilder =
+ if (sb == null)
+ append("null")
+ else {
+ val len = sb.length
+ val newCount = count + len
+ if (newCount > value.length) expandCapacity(newCount)
+ compat.Platform.arraycopy(sb.toArray, 0, value, count, len)
+ count = newCount
+ this
+ }
+
+ def append(x: Array[Char]): StringBuilder =
+ append(x, 0, x.length)
+
+ def append(x: Array[Char], offset: Int, len: Int): StringBuilder = {
+ val newCount = count + len
+ if (newCount > value.length) expandCapacity(newCount)
+ compat.Platform.arraycopy(x, offset, value, count, len)
+ count = newCount
+ this
+ }
+
+ def append(x: Boolean): StringBuilder = {
+ if (x) {
+ val newCount = count + 4
+ if (newCount > value.length) expandCapacity(newCount)
+ value(count) = 't'; count += 1
+ value(count) = 'r'; count += 1
+ value(count) = 'u'; count += 1
+ value(count) = 'e'; count += 1
+ } else {
+ val newCount = count + 5
+ if (newCount > value.length) expandCapacity(newCount)
+ value(count) = 'f'; count += 1
+ value(count) = 'a'; count += 1
+ value(count) = 'l'; count += 1
+ value(count) = 's'; count += 1
+ value(count) = 'e'; count += 1
+ }
+ this
+ }
+
+ def append(x: Char): StringBuilder = {
+ val newCount = count + 1
+ if (newCount > value.length) expandCapacity(newCount)
+ value(count) = x; count += 1
+ this
+ }
+
+ def append(x: Int): StringBuilder =
+ append(String.valueOf(x))
+
+ def append(x: Long): StringBuilder =
+ append(String.valueOf(x))
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def delete(start: Int, end: Int): StringBuilder = {
+ if (start < 0 || start > end)
+ throw new StringIndexOutOfBoundsException(start)
+ val end0 = if (end > count) count else end
+ val len = end0 - start
+ if (len > 0) {
+ compat.Platform.arraycopy(value, start + len, value, start, count - end0)
+ count -= len
+ }
+ this
+ }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def replace(start: Int, end: Int, str: String) {
+ if (start < 0 || start > count || start > end)
+ throw new StringIndexOutOfBoundsException(start)
+
+ val end0 = if (end > count) count else end
+ val len = str.length()
+ val newCount = count + len - (end0 - start)
+ if (newCount > value.length) expandCapacity(newCount)
+
+ compat.Platform.arraycopy(value, end, value, start + len, count - end)
+ compat.Platform.arraycopy(str.toArray, 0, value, start, len)
+ count = newCount
+ this
+ }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def insert(index: Int, str: Array[Char], offset: Int, len: Int): StringBuilder = {
+ if (index < 0 || index > count)
+ throw new StringIndexOutOfBoundsException(index)
+ if (offset < 0 || len < 0 || offset > str.length - len)
+ throw new StringIndexOutOfBoundsException(
+ "offset " + offset + ", len " + len +
+ ", str.length " + str.length)
+ val newCount = count + len
+ if (newCount > value.length) expandCapacity(newCount)
+ compat.Platform.arraycopy(value, index, value, index + len, count - index)
+ compat.Platform.arraycopy(str, offset, value, index, len)
+ count = newCount
+ this
+ }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def insert(at: Int, x: Any): StringBuilder =
+ insert(at, String.valueOf(x))
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def insert(at: Int, x: String): StringBuilder = {
+ if (at < 0 || at > count)
+ throw new StringIndexOutOfBoundsException(at)
+ val str = if (x == null) "null" else x
+ val len = str.length
+ val newCount = count + len
+ if (newCount > value.length) expandCapacity(newCount)
+ compat.Platform.arraycopy(value, at, value, at + len, count - at)
+ compat.Platform.arraycopy(str.toArray: Array[Char], 0, value, at, len)
+ count = newCount
+ this
+ }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def insert(at: Int, x: Array[Char]): StringBuilder = {
+ if (at < 0 || at > count)
+ throw new StringIndexOutOfBoundsException(at)
+ val len = x.length
+ val newCount = count + len
+ if (newCount > value.length) expandCapacity(newCount)
+ compat.Platform.arraycopy(value, at, value, at + len, count - at)
+ compat.Platform.arraycopy(x, 0, value, at, len)
+ count = newCount
+ this
+ }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def insert(at: Int, x: Boolean): StringBuilder =
+ insert(at, String.valueOf(x))
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def insert(at: Int, x: Char): StringBuilder = {
+ if (at < 0 || at > count)
+ throw new StringIndexOutOfBoundsException(at)
+ val newCount = count + 1
+ if (newCount > value.length) expandCapacity(newCount)
+ compat.Platform.arraycopy(value, at, value, at + 1, count - at)
+ value(at) = x
+ count = newCount
+ this
+ }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def insert(at: Int, x: Int): StringBuilder =
+ insert(at, String.valueOf(x))
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def insert(at: Int, x: Long): StringBuilder =
+ insert(at, String.valueOf(x))
+
+ @throws(classOf[NullPointerException])
+ def indexOf(str: String): Int = indexOf(str, 0)
+
+ @throws(classOf[NullPointerException])
+ def indexOf(str: String, fromIndex: Int): Int =
+ StringBuilder.indexOf(value, 0, count, str.toArray, 0, str.length(), fromIndex)
+
+ @throws(classOf[NullPointerException])
+ def lastIndexOf(str: String): Int = lastIndexOf(str, count)
+
+ @throws(classOf[NullPointerException])
+ def lastIndexOf(str: String, fromIndex: Int): Int =
+ StringBuilder.lastIndexOf(value, 0, count, str.toArray, 0, str.length(), fromIndex)
+
+ def reverse(): StringBuilder = {
+ val n = count - 1
+ var j = (n-1) >> 1
+ while (j >= 0) {
+ val temp = value(j)
+ val temp2 = value(n - j)
+ value(j) = temp2
+ value(n - j) = temp
+ j -= 1
+ }
+ this
+ }
+
+ override def toString(): String = new String(value, 0, count)
+
+}
+
+
+object StringBuilder {
+
+ // method <code>java.util.Arrays.copyOf</code> exists since 1.6
+ private def copyOf(src: Array[Char], newLength: Int): Array[Char] = {
+ val dest = new Array[Char](newLength)
+ val (start, end) =
+ if (src.length < newLength) (src.length, newLength)
+ else (newLength, src.length)
+ compat.Platform.arraycopy(src, 0, dest, 0, start)
+ // For any indices that are valid in the copy but not the original,
+ // the copy will contain '\\u000'.
+ for (i <- start until end) dest(i) = '\0'
+ dest
+ }
+
+ private def indexOf(source: Array[Char], sourceOffset: Int, sourceCount: Int,
+ target: Array[Char], targetOffset: Int, targetCount: Int,
+ fromIndex: Int): Int =
+ if (fromIndex >= sourceCount)
+ if (targetCount == 0) sourceCount else -1
+ else {
+ val inx = if (fromIndex < 0) 0 else fromIndex
+ if (targetCount == 0)
+ inx
+ else {
+ val first = target(targetOffset)
+ val max = sourceOffset + (sourceCount - targetCount)
+
+ var i = sourceOffset + inx
+ while (i <= max) {
+ /* Look for first character. */
+ if (source(i) != first) {
+ i += 1
+ while (i <= max && source(i) != first) i += 1
+ }
+ /* Found first character, now look at the rest of v2 */
+ if (i <= max) {
+ var j = i + 1
+ val end = j + targetCount - 1
+ var k = targetOffset + 1
+ while (j < end && source(j) == target(k)) {
+ j += 1
+ k += 1
+ }
+ if (j == end) {
+ /* Found whole string. */
+ return i - sourceOffset
+ }
+ } // if
+ i += 1
+ } // while
+ -1
+ }
+ }
+
+ private def lastIndexOf(source: Array[Char], sourceOffset: Int, sourceCount: Int,
+ target: Array[Char], targetOffset: Int, targetCount: Int,
+ fromIndex: Int): Int = {
+ val rightIndex = sourceCount - targetCount
+ if (fromIndex < 0) return -1
+ val inx = if (fromIndex > rightIndex) rightIndex else fromIndex
+ // Empty string always matches
+ if (targetCount == 0) return inx
+
+ val strLastIndex = targetOffset + targetCount - 1
+ val strLastChar = target(strLastIndex)
+ val min = sourceOffset + targetCount - 1
+ var i = min + fromIndex
+
+ while (true) {
+ while (i >= min && source(i) != strLastChar) i -= 1
+ if (i < min) return -1
+ var j = i - 1
+ val start = j - (targetCount - 1)
+ var k = strLastIndex - 1
+ var outerWhile = false
+ while (j > start && !outerWhile) {
+ if (source(j) != target(k)) {
+ j -= 1
+ k -= 1
+ i -= 1
+ outerWhile = true
+ }
+ }
+ if (!outerWhile) return start - sourceOffset + 1
+ }
+ -1
+ }
+}
diff --git a/src/cldc-library/scala/compat/StringBuilder.scala b/src/cldc-library/scala/compat/StringBuilder.scala
deleted file mode 100644
index e3416ac497..0000000000
--- a/src/cldc-library/scala/compat/StringBuilder.scala
+++ /dev/null
@@ -1,69 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala.compat
-
-
-import java.lang.{String, StringBuffer}
-
-
-/** Consult the documentation of <code>java.lang.StringBuffer</code> for more
- * details (see http://java.sun.com/javame/reference/apis/jsr030/).
- */
-final class StringBuilder(val self: StringBuffer) extends (Int => Char) with Proxy {
-
- def this() = this(new StringBuffer())
- def this(n: Int) = this(new StringBuffer(n))
- def this(s: String) = this(new StringBuffer(s))
-
- def length: Int = self.length()
- def length_=(n: Int) { self.setLength(n) }
- def setLength(n: Int) { self.setLength(n) }
-
- def capacity: Int = self.capacity
- def capacity_=(n: Int) { self.ensureCapacity(n) }
- def ensureCapacity(n: Int) { self.ensureCapacity(n) }
-
- def charAt(i: Int): Char = self.charAt(i)
- def apply(i: Int): Char = self.charAt(i)
- def deleteCharAt(index: Int) = self.deleteCharAt(index)
-
- def setCharAt(index: Int, c: Char) { self.setCharAt(index, c) }
- def update(i: Int, c: Char) { self.setCharAt(i, c)}
-
- def substring(i: Int): String = self.toString.substring(i)
- def substring(i: Int, j: Int): String = self.toString.substring(i, j)
-
- def append(x: Any): StringBuilder = { self.append(x); this }
- def append(x: Boolean): StringBuilder = { self.append(x); this }
- def append(x: Byte): StringBuilder = { self.append(x); this }
- def append(x: Short): StringBuilder = { self.append(x); this }
- def append(x: Char): StringBuilder = { self.append(x); this }
- def append(x: Int): StringBuilder = { self.append(x); this }
- def append(x: Long): StringBuilder = { self.append(x); this }
- def append(x: String): StringBuilder = { self.append(x); this }
- def append(x: Array[Char]): StringBuilder = { self.append(x); this }
- def append(x: Array[Char], start: Int, length: Int): StringBuilder =
- { self.append(x, start, length); this }
-
- def insert(at: Int, x: Any): StringBuilder = { self.insert(at, x); this }
- def insert(at: Int, x: Boolean): StringBuilder = { self.insert(at, x); this }
- def insert(at: Int, x: Byte): StringBuilder = { self.insert(at, x); this }
- def insert(at: Int, x: Short): StringBuilder = { self.insert(at, x); this }
- def insert(at: Int, x: Char): StringBuilder = { self.insert(at, x); this }
- def insert(at: Int, x: Int): StringBuilder = { self.insert(at, x); this }
- def insert(at: Int, x: Long): StringBuilder = { self.insert(at, x); this }
- def insert(at: Int, x: String): StringBuilder = { self.insert(at, x); this }
- def insert(at: Int, x: Array[Char]): StringBuilder = { self.insert(at, x); this }
- def insert(at: Int, x: Array[Char], start: Int, length: Int): StringBuilder =
- { self.insert(at, x.slice(start, length)); this }
-
-}
diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala
index 9bb4e99924..fcd50a5421 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/Liveness.scala
@@ -7,7 +7,6 @@
package scala.tools.nsc.backend.icode.analysis
-import compat.StringBuilder
import scala.collection.mutable.{HashMap, Map}
import scala.collection.immutable.{Set, ListSet}
@@ -105,8 +104,8 @@ abstract class Liveness {
}
i match {
- case LOAD_LOCAL(l) => in = in + l
- case STORE_LOCAL(l) => in = in - l
+ case LOAD_LOCAL(l) => in += l
+ case STORE_LOCAL(l) => in -= l
case _ =>
()
}
diff --git a/src/dotnet-library/scala/Predef.scala b/src/dotnet-library/scala/Predef.scala
index fe3e048a88..dc45fe2bec 100644
--- a/src/dotnet-library/scala/Predef.scala
+++ b/src/dotnet-library/scala/Predef.scala
@@ -36,7 +36,6 @@ object Predef {
type unit = scala.Unit
type String = System.String
- type StringBuilder = compat.StringBuilder
type Class[T] = System.Type
type Runnable = scala.runtime.Runnable
@@ -49,6 +48,7 @@ object Predef {
type ClassCastException = System.InvalidCastException
type IndexOutOfBoundsException = System.IndexOutOfRangeException
type ArrayIndexOutOfBoundsException = System.IndexOutOfRangeException
+ type StringIndexOutOfBoundsException = System.IndexOutOfRangeException
type UnsupportedOperationException = System.InvalidOperationException
type IllegalArgumentException = System.ArgumentException
type NoSuchElementException = System.InvalidOperationException
diff --git a/src/dotnet-library/scala/StringBuilder.scala b/src/dotnet-library/scala/StringBuilder.scala
new file mode 100644
index 0000000000..683f0afa70
--- /dev/null
+++ b/src/dotnet-library/scala/StringBuilder.scala
@@ -0,0 +1,439 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2006-2008, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+// $Id: $
+
+
+package scala
+
+import Predef._
+
+/** <p>
+ * A mutable sequence of characters. This class provides an API compatible
+ * with <code>java.lang.StringBuilder</code>, but with no guarantee of
+ * synchronization.
+ * </p>
+ *
+ * @author Stephane Micheloud
+ */
+@throws(classOf[NullPointerException])
+final class StringBuilder(initCapacity: Int, private val initValue: String) extends (Int => Char) with Proxy {
+ if (initCapacity < 0) throw new IllegalArgumentException
+ if (initValue eq null) throw new NullPointerException
+
+ /** The value is used for character storage. */
+ private var value = new Array[Char](initCapacity + initValue.length)
+
+ /** The count is the number of characters used. */
+ private var count: Int = 0
+
+ def this() = this(16, "")
+
+ def this(capacity: Int) = this(capacity, "")
+
+ @throws(classOf[NullPointerException])
+ def this(str: String) = this(16, str)
+
+ append(initValue)
+
+ def self = this
+
+ def toArray: Array[Char] = value
+
+ def length: Int = count
+
+ def length_=(n: Int) { setLength(n) }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def setLength(n: Int) {
+ if (n < 0)
+ throw new StringIndexOutOfBoundsException//(n)
+ if (n > value.length) expandCapacity(n)
+ if (count < n)
+ while (count < n) {
+ value(count) = '\0'; count += 1
+ }
+ else
+ count = n
+ }
+
+ def capacity: Int = value.length
+
+ def capacity_=(n: Int) { ensureCapacity(n) }
+
+ def ensureCapacity(n: Int) {
+ if (n > value.length) expandCapacity(n)
+ }
+
+ private def expandCapacity(n: Int) {
+ val newCapacity = (value.length + 1) * 2
+ value = StringBuilder.copyOf(
+ value,
+ if (newCapacity < 0) Math.MAX_INT else if (n > newCapacity) n else newCapacity
+ )
+ }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def charAt(index: Int): Char = {
+ if (index < 0 || index >= count)
+ throw new StringIndexOutOfBoundsException//(index)
+ value(index)
+ }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def apply(i: Int): Char = charAt(i)
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def deleteCharAt(index: Int): StringBuilder = {
+ if (index < 0 || index >= count)
+ throw new StringIndexOutOfBoundsException//(index)
+ compat.Platform.arraycopy(value, index + 1, value, index, count - index - 1)
+ count -= 1
+ this
+ }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def setCharAt(index: Int, c: Char) {
+ if (index < 0 || index >= count)
+ throw new StringIndexOutOfBoundsException//(index)
+ value(index) = c
+ }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def update(i: Int, c: Char) { setCharAt(i, c) }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def substring(start: Int): String = substring(start, count)
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def substring(start: Int, end: Int): String = {
+ if (start < 0)
+ throw new StringIndexOutOfBoundsException//(start)
+ if (end > count)
+ throw new StringIndexOutOfBoundsException//(end)
+ if (start > end)
+ throw new StringIndexOutOfBoundsException//(end - start)
+ new String(value, start, end - start)
+ }
+
+ def append(x: Any): StringBuilder =
+ append(System.Convert.ToString(x))
+
+ /** Appends the specified string to this character sequence.
+ *
+ * @param s
+ * @return
+ */
+ def append(s: String): StringBuilder = {
+ val str = if (s == null) "null" else s
+ val len = str.length
+ if (len > 0) {
+ val newCount = count + len
+ if (newCount > value.length) expandCapacity(newCount)
+ compat.Platform.arraycopy(str.toArray: Array[Char], 0, value, count, len)
+ count = newCount
+ }
+ this
+ }
+
+ /** Appends the specified string builder to this sequence.
+ *
+ * @param sb
+ * @return
+ */
+ def append(sb: StringBuilder): StringBuilder =
+ if (sb == null)
+ append("null")
+ else {
+ val len = sb.length
+ val newCount = count + len
+ if (newCount > value.length) expandCapacity(newCount)
+ compat.Platform.arraycopy(sb.toArray, 0, value, count, len)
+ count = newCount
+ this
+ }
+
+ def append(x: Array[Char]): StringBuilder =
+ append(x, 0, x.length)
+
+ def append(x: Array[Char], offset: Int, len: Int): StringBuilder = {
+ val newCount = count + len
+ if (newCount > value.length) expandCapacity(newCount)
+ compat.Platform.arraycopy(x, offset, value, count, len)
+ count = newCount
+ this
+ }
+
+ def append(x: Boolean): StringBuilder = {
+ if (x) {
+ val newCount = count + 4
+ if (newCount > value.length) expandCapacity(newCount)
+ value(count) = 't'; count += 1
+ value(count) = 'r'; count += 1
+ value(count) = 'u'; count += 1
+ value(count) = 'e'; count += 1
+ } else {
+ val newCount = count + 5
+ if (newCount > value.length) expandCapacity(newCount)
+ value(count) = 'f'; count += 1
+ value(count) = 'a'; count += 1
+ value(count) = 'l'; count += 1
+ value(count) = 's'; count += 1
+ value(count) = 'e'; count += 1
+ }
+ this
+ }
+
+ def append(x: Char): StringBuilder = {
+ val newCount = count + 1
+ if (newCount > value.length) expandCapacity(newCount)
+ value(count) = x; count += 1
+ this
+ }
+
+ def append(x: Int): StringBuilder =
+ append(System.Convert.ToString(x))
+
+ def append(x: Long): StringBuilder =
+ append(System.Convert.ToString(x))
+
+ def append(x: Float): StringBuilder =
+ append(System.Convert.ToString(x))
+
+ def append(x: Double): StringBuilder =
+ append(System.Convert.ToString(x))
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def delete(start: Int, end: Int): StringBuilder = {
+ if (start < 0 || start > end)
+ throw new StringIndexOutOfBoundsException//(start)
+ val end0 = if (end > count) count else end
+ val len = end0 - start
+ if (len > 0) {
+ compat.Platform.arraycopy(value, start + len, value, start, count - end0)
+ count -= len
+ }
+ this
+ }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def replace(start: Int, end: Int, str: String) {
+ if (start < 0 || start > count || start > end)
+ throw new StringIndexOutOfBoundsException//(start)
+
+ val end0 = if (end > count) count else end
+ val len = str.length()
+ val newCount = count + len - (end0 - start)
+ if (newCount > value.length) expandCapacity(newCount)
+
+ compat.Platform.arraycopy(value, end, value, start + len, count - end)
+ compat.Platform.arraycopy(str.toArray, 0, value, start, len)
+ count = newCount
+ this
+ }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def insert(index: Int, str: Array[Char], offset: Int, len: Int): StringBuilder = {
+ if (index < 0 || index > count)
+ throw new StringIndexOutOfBoundsException//(index)
+ if (offset < 0 || len < 0 || offset > str.length - len)
+ throw new StringIndexOutOfBoundsException/*(
+ "offset " + offset + ", len " + len +
+ ", str.length " + str.length)*/
+ val newCount = count + len
+ if (newCount > value.length) expandCapacity(newCount)
+ compat.Platform.arraycopy(value, index, value, index + len, count - index)
+ compat.Platform.arraycopy(str, offset, value, index, len)
+ count = newCount
+ this
+ }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def insert(at: Int, x: Any): StringBuilder =
+ insert(at, System.Convert.ToString(x))
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def insert(at: Int, x: String): StringBuilder = {
+ if (at < 0 || at > count)
+ throw new StringIndexOutOfBoundsException//(at)
+ val str = if (x == null) "null" else x
+ val len = str.length
+ val newCount = count + len
+ if (newCount > value.length) expandCapacity(newCount)
+ compat.Platform.arraycopy(value, at, value, at + len, count - at)
+ compat.Platform.arraycopy(str.toArray: Array[Char], 0, value, at, len)
+ count = newCount
+ this
+ }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def insert(at: Int, x: Array[Char]): StringBuilder = {
+ if (at < 0 || at > count)
+ throw new StringIndexOutOfBoundsException//(at)
+ val len = x.length
+ val newCount = count + len
+ if (newCount > value.length) expandCapacity(newCount)
+ compat.Platform.arraycopy(value, at, value, at + len, count - at)
+ compat.Platform.arraycopy(x, 0, value, at, len)
+ count = newCount
+ this
+ }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def insert(at: Int, x: Boolean): StringBuilder =
+ insert(at, System.Convert.ToString(x))
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def insert(at: Int, x: Char): StringBuilder = {
+ if (at < 0 || at > count)
+ throw new StringIndexOutOfBoundsException//(at)
+ val newCount = count + 1
+ if (newCount > value.length) expandCapacity(newCount)
+ compat.Platform.arraycopy(value, at, value, at + 1, count - at)
+ value(at) = x
+ count = newCount
+ this
+ }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def insert(at: Int, x: Int): StringBuilder =
+ insert(at, System.Convert.ToString(x))
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def insert(at: Int, x: Long): StringBuilder =
+ insert(at, System.Convert.ToString(x))
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def insert(at: Int, x: Float): StringBuilder =
+ insert(at, System.Convert.ToString(x))
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def insert(at: Int, x: Double): StringBuilder =
+ insert(at, System.Convert.ToString(x))
+
+ @throws(classOf[NullPointerException])
+ def indexOf(str: String): Int = indexOf(str, 0)
+
+ @throws(classOf[NullPointerException])
+ def indexOf(str: String, fromIndex: Int): Int =
+ StringBuilder.indexOf(value, 0, count, str.toArray, 0, str.length(), fromIndex)
+
+ @throws(classOf[NullPointerException])
+ def lastIndexOf(str: String): Int = lastIndexOf(str, count)
+
+ @throws(classOf[NullPointerException])
+ def lastIndexOf(str: String, fromIndex: Int): Int =
+ StringBuilder.lastIndexOf(value, 0, count, str.toArray, 0, str.length(), fromIndex)
+
+ def reverse(): StringBuilder = {
+ val n = count - 1
+ var j = (n-1) >> 1
+ while (j >= 0) {
+ val temp = value(j)
+ val temp2 = value(n - j)
+ value(j) = temp2
+ value(n - j) = temp
+ j -= 1
+ }
+ this
+ }
+
+ override def toString(): String = new String(value, 0, count)
+
+}
+
+
+object StringBuilder {
+
+ // method <code>java.util.Arrays.copyOf</code> exists since 1.6
+ private def copyOf(src: Array[Char], newLength: Int): Array[Char] = {
+ val dest = new Array[Char](newLength)
+ val (start, end) =
+ if (src.length < newLength) (src.length, newLength)
+ else (newLength, src.length)
+ compat.Platform.arraycopy(src, 0, dest, 0, start)
+ // For any indices that are valid in the copy but not the original,
+ // the copy will contain '\\u000'.
+ for (i <- start until end) dest(i) = '\0'
+ dest
+ }
+
+ private def indexOf(source: Array[Char], sourceOffset: Int, sourceCount: Int,
+ target: Array[Char], targetOffset: Int, targetCount: Int,
+ fromIndex: Int): Int =
+ if (fromIndex >= sourceCount)
+ if (targetCount == 0) sourceCount else -1
+ else {
+ val inx = if (fromIndex < 0) 0 else fromIndex
+ if (targetCount == 0)
+ inx
+ else {
+ val first = target(targetOffset)
+ val max = sourceOffset + (sourceCount - targetCount)
+
+ var i = sourceOffset + inx
+ while (i <= max) {
+ /* Look for first character. */
+ if (source(i) != first) {
+ i += 1
+ while (i <= max && source(i) != first) i += 1
+ }
+ /* Found first character, now look at the rest of v2 */
+ if (i <= max) {
+ var j = i + 1
+ val end = j + targetCount - 1
+ var k = targetOffset + 1
+ while (j < end && source(j) == target(k)) {
+ j += 1
+ k += 1
+ }
+ if (j == end) {
+ /* Found whole string. */
+ return i - sourceOffset
+ }
+ } // if
+ i += 1
+ } // while
+ -1
+ }
+ }
+
+ private def lastIndexOf(source: Array[Char], sourceOffset: Int, sourceCount: Int,
+ target: Array[Char], targetOffset: Int, targetCount: Int,
+ fromIndex: Int): Int = {
+ val rightIndex = sourceCount - targetCount
+ if (fromIndex < 0) return -1
+ val inx = if (fromIndex > rightIndex) rightIndex else fromIndex
+ // Empty string always matches
+ if (targetCount == 0) return inx
+
+ val strLastIndex = targetOffset + targetCount - 1
+ val strLastChar = target(strLastIndex)
+ val min = sourceOffset + targetCount - 1
+ var i = min + fromIndex
+
+ while (true) {
+ while (i >= min && source(i) != strLastChar) i -= 1
+ if (i < min) return -1
+ var j = i - 1
+ val start = j - (targetCount - 1)
+ var k = strLastIndex - 1
+ var outerWhile = false
+ while (j > start && !outerWhile) {
+ if (source(j) != target(k)) {
+ j -= 1
+ k -= 1
+ i -= 1
+ outerWhile = true
+ }
+ }
+ if (!outerWhile) return start - sourceOffset + 1
+ }
+ -1
+ }
+}
diff --git a/src/dotnet-library/scala/compat/Math.scala b/src/dotnet-library/scala/compat/Math.scala
deleted file mode 100644
index d59f3bdd15..0000000000
--- a/src/dotnet-library/scala/compat/Math.scala
+++ /dev/null
@@ -1,54 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala.compat
-
-/**
- * This class will be removed soon. Use <code>scala.Math</code> instead.
- */
-@deprecated
-object Math {
- val MIN_BYTE = System.Byte.MinValue
- val MAX_BYTE = System.Byte.MaxValue
- val MIN_SHORT = System.Int16.MinValue
- val MAX_SHORT = System.Int16.MaxValue
- val MIN_CHAR = System.Char.MinValue
- val MAX_CHAR = System.Char.MaxValue
- val MIN_INT = System.Int32.MinValue
- val MAX_INT = System.Int32.MaxValue
- val MIN_LONG = System.Int64.MinValue
- val MAX_LONG = System.Int64.MaxValue
-
- val MIN_FLOAT = System.Single.MinValue
- val EPS_FLOAT = System.Single.Epsilon
- val MAX_FLOAT = System.Single.MinValue
- //val NaN_FLOAT = System.Single.NaN
- //val NEG_INF_FLOAT = System.Double.NegativeInfinity
- //val POS_INF_FLOAT = System.Double.PositiveInfinity
-
- val MIN_DOUBLE = System.Double.MinValue
- val EPS_DOUBLE = System.Double.Epsilon
- val MAX_DOUBLE = System.Double.MaxValue
- //val NaN_DOUBLE = System.Double.NaN
- //val NEG_INF_DOUBLE = System.Double.NegativeInfinity
- //val POS_INF_DOUBLE = System.Double.PositiveInfinity
-
- def E: Double = System.Math.E
- def PI: Double = System.Math.PI
-
- def min(x: Int, y: Int): Int = System.Math.Min(x, y)
- def max(x: Int, y: Int): Int = System.Math.Max(x, y)
-
- def ceil (x: Double): Double = System.Math.Ceiling(x)
- def floor(x: Double): Double = System.Math.Floor(x)
- def log (x: Double): Double = System.Math.Log(x)
- def sqrt (x: Double): Double = System.Math.Sqrt(x)
-}
diff --git a/src/dotnet-library/scala/compat/StringBuilder.scala b/src/dotnet-library/scala/compat/StringBuilder.scala
deleted file mode 100644
index 2ce9ad178f..0000000000
--- a/src/dotnet-library/scala/compat/StringBuilder.scala
+++ /dev/null
@@ -1,73 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala.compat
-
-
-import System.Text.{StringBuilder => StringBuffer}
-
-
-/** Consult the documentation of <code>java.lang.StringBuffer</code>
- * for more details.
- */
-final class StringBuilder(val self: StringBuffer) extends (Int => Char) with Proxy {
-
- def this() = this(new StringBuffer())
- def this(n: Int) = this(new StringBuffer(n))
- def this(s: String) = this(new StringBuffer(s))
-
- def length: Int = self.Length
- def length_=(n: Int) { self.Length = n }
- def setLength(n: Int) { self.Length = n }
-
- def capacity: Int = self.Capacity
- def capacity_=(n: Int) { self.Capacity = n }
- def ensureCapacity(n: Int) { self.Capacity = n }
-
- def charAt(i: Int): Char = self(i)
- def apply(i: Int): Char = self(i)
- def deleteCharAt(index: Int) = self.Remove(index, 1)
-
- def setCharAt(i: Int, c: Char) { self(i) = c }
- def update(i: Int, c: Char) { self(i) = c }
-
- def substring(i: Int): String = self.ToString(i, length)
- def substring(i: Int, j: Int): String = self.ToString(i, j)
-
- def append(x: Any): StringBuilder = { self.Append(x); this }
- def append(x: Boolean): StringBuilder = { self.Append(x); this }
-// def append(x: Byte): StringBuilder = { self.Append(x); this }
- def append(x: Short): StringBuilder = { self.Append(x); this }
- def append(x: Char): StringBuilder = { self.Append(x); this }
- def append(x: Int): StringBuilder = { self.Append(x); this }
- def append(x: Long): StringBuilder = { self.Append(x); this }
- def append(x: Float): StringBuilder = { self.Append(x); this }
- def append(x: Double): StringBuilder = { self.Append(x); this }
- def append(x: String): StringBuilder = { self.Append(x); this }
- def append(x: Array[Char]): StringBuilder = { self.Append(x); this }
- def append(x: Array[Char], start: Int, length: Int): StringBuilder =
- { self.Append(x, start, length); this }
-
- def insert(at: Int, x: Any): StringBuilder = { self.Insert(at, x); this }
- def insert(at: Int, x: Boolean): StringBuilder = { self.Insert(at, x); this }
-// def insert(at: Int, x: Byte): StringBuilder = { self.Insert(at, x); this }
- def insert(at: Int, x: Short): StringBuilder = { self.Insert(at, x); this }
- def insert(at: Int, x: Char): StringBuilder = { self.Insert(at, x); this }
- def insert(at: Int, x: Int): StringBuilder = { self.Insert(at, x); this }
- def insert(at: Int, x: Long): StringBuilder = { self.Insert(at, x); this }
- def insert(at: Int, x: Float): StringBuilder = { self.Insert(at, x); this }
- def insert(at: Int, x: Double): StringBuilder = { self.Insert(at, x); this }
- def insert(at: Int, x: String): StringBuilder = { self.Insert(at, x); this }
- def insert(at: Int, x: Array[Char]): StringBuilder = { self.Insert(at, x); this }
- def insert(at: Int, x: Array[Char], start: Int, length: Int): StringBuilder =
- { self.Insert(at, x, start, length); this }
-
-}
diff --git a/src/dotnet-library/scala/runtime/RichInt.scala b/src/dotnet-library/scala/runtime/RichInt.scala
index 368a886df9..fc5080f9b3 100644
--- a/src/dotnet-library/scala/runtime/RichInt.scala
+++ b/src/dotnet-library/scala/runtime/RichInt.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -21,13 +21,13 @@ final class RichInt(start: Int) extends Proxy with Ordered[Int] {
def compare(that: Int): Int = if (start < that) -1 else if (start > that) 1 else 0
/** See <code>Iterator.range</code>. */
- def until(end: Int): Range = Iterator.range(start, end)
+ def until(end: Int): Range = new Range(start, end, 1)
/** See <code>Iterator.range</code>. */
- def until(end: Int, step: Int): Range = Iterator.range(start, end, step)
+ def until(end: Int, step: Int): Range = new Range(start, end, step)
/** like <code>until</code>, but includes the last index */
- def to(end: Int) = until(end + 1)
+ def to(end: Int) = new Range.Inclusive(start, end, 1)
def min(that: Int): Int = if (start < that) start else that
def max(that: Int): Int = if (start > that) start else that
diff --git a/src/dotnet-library/scala/runtime/RichString.scala b/src/dotnet-library/scala/runtime/RichString.scala
index 2a71306686..150edc000e 100644
--- a/src/dotnet-library/scala/runtime/RichString.scala
+++ b/src/dotnet-library/scala/runtime/RichString.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -141,7 +141,7 @@ final class RichString(val self: String) extends Proxy with RandomAccessSeq[Char
* </blockquote>
*/
def stripMargin(marginChar: Char): String = {
- val buf = new scala.compat.StringBuilder()
+ val buf = new StringBuilder()
for (line <- linesWithSeparators) {
val len = line.length
var index = 0
diff --git a/src/library/scala/CollectionProxy.scala b/src/library/scala/CollectionProxy.scala
index c64d329ff7..e9c9999557 100644
--- a/src/library/scala/CollectionProxy.scala
+++ b/src/library/scala/CollectionProxy.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2003-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -12,7 +12,6 @@
package scala
import scala.collection.mutable.Buffer
-import scala.compat.StringBuilder
/** This class implements a proxy for iterable objects. It forwards
diff --git a/src/library/scala/Iterable.scala b/src/library/scala/Iterable.scala
index 0e6fb3a277..a3fd4ca6d4 100644
--- a/src/library/scala/Iterable.scala
+++ b/src/library/scala/Iterable.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2003-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -14,7 +14,6 @@ package scala
import Predef._
import collection.mutable.{Buffer,ArrayBuffer}
-import compat.StringBuilder
/** Various utilities for instances of <a href="Iterable.html">Iterable</a>.
*
diff --git a/src/library/scala/IterableProxy.scala b/src/library/scala/IterableProxy.scala
index a66b110f24..f20c3d25ca 100644
--- a/src/library/scala/IterableProxy.scala
+++ b/src/library/scala/IterableProxy.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2003-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -12,7 +12,6 @@
package scala
import scala.collection.mutable.Buffer
-import scala.compat.StringBuilder
/** This class implements a proxy for iterable objects. It forwards
diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala
index 60042b1862..5950a999fe 100644
--- a/src/library/scala/Predef.scala
+++ b/src/library/scala/Predef.scala
@@ -41,7 +41,6 @@ object Predef {
@deprecated type Character = java.lang.Character
type String = java.lang.String
- type StringBuilder = compat.StringBuilder
type Class[T] = java.lang.Class[T]
type Runnable = java.lang.Runnable
@@ -49,15 +48,16 @@ object Predef {
type Exception = java.lang.Exception
type Error = java.lang.Error
- type RuntimeException = java.lang.RuntimeException
- type NullPointerException = java.lang.NullPointerException
- type ClassCastException = java.lang.ClassCastException
- type IndexOutOfBoundsException = java.lang.IndexOutOfBoundsException
- type ArrayIndexOutOfBoundsException = java.lang.ArrayIndexOutOfBoundsException
- type UnsupportedOperationException = java.lang.UnsupportedOperationException
- type IllegalArgumentException = java.lang.IllegalArgumentException
- type NoSuchElementException = java.util.NoSuchElementException
- type NumberFormatException = java.lang.NumberFormatException
+ type RuntimeException = java.lang.RuntimeException
+ type NullPointerException = java.lang.NullPointerException
+ type ClassCastException = java.lang.ClassCastException
+ type IndexOutOfBoundsException = java.lang.IndexOutOfBoundsException
+ type ArrayIndexOutOfBoundsException = java.lang.ArrayIndexOutOfBoundsException
+ type StringIndexOutOfBoundsException = java.lang.StringIndexOutOfBoundsException
+ type UnsupportedOperationException = java.lang.UnsupportedOperationException
+ type IllegalArgumentException = java.lang.IllegalArgumentException
+ type NoSuchElementException = java.util.NoSuchElementException
+ type NumberFormatException = java.lang.NumberFormatException
// miscelleaneous -----------------------------------------------------
diff --git a/src/library/scala/RandomAccessSeq.scala b/src/library/scala/RandomAccessSeq.scala
index 3290315218..5cd80718ac 100644
--- a/src/library/scala/RandomAccessSeq.scala
+++ b/src/library/scala/RandomAccessSeq.scala
@@ -1,3 +1,13 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2006-2008, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+// $Id: $
+
package scala
object RandomAccessSeq {
@@ -82,17 +92,17 @@ object RandomAccessSeq {
}
override def drop( from: Int): MutableProjection[A] = slice(from, length)
override def take(until: Int): MutableProjection[A] = slice(0, until)
- override def slice(from0 : Int, until0 : Int) : MutableProjection[A] = new MutableSlice[A] {
+ override def slice(from0: Int, until0: Int) : MutableProjection[A] = new MutableSlice[A] {
def from = from0
def until = until0
def underlying = Mutable.this
}
override def reverse : MutableProjection[A] = new MutableProjection[A] {
- def update(idx : Int, what : A) : Unit = Mutable.this.update(length - idx - 1, what)
+ def update(idx: Int, what: A) { Mutable.this.update(length - idx - 1, what) }
def length = Mutable.this.length
- def apply(idx : Int) = Mutable.this.apply(length - idx - 1)
+ def apply(idx: Int) = Mutable.this.apply(length - idx - 1)
override def stringPrefix = Mutable.this.stringPrefix + "R"
- override def reverse : MutableProjection[A] = Mutable.this.projection
+ override def reverse: MutableProjection[A] = Mutable.this.projection
}
}
trait MutableProjection[A] extends Projection[A] with Mutable[A] {
@@ -133,7 +143,7 @@ trait RandomAccessSeq[+A] extends Seq[A] {
def next = {
if (!hasNext) throw new Predef.NoSuchElementException
val ret = RandomAccessSeq.this.apply(idx)
- idx = idx + 1
+ idx += 1
ret
}
}
@@ -154,7 +164,7 @@ trait RandomAccessSeq[+A] extends Seq[A] {
/** insert segment <code>patch</code> into this sequence at <code>from</code>
* replacing <code>replaced</code> elements. The result is a projection.
*/
- def patch[B >: A](from0 : Int, patch0 : RandomAccessSeq[B], replaced0 : Int) : RandomAccessSeq.Projection[B] = new RandomAccessSeq.Patch[B] {
+ def patch[B >: A](from0: Int, patch0: RandomAccessSeq[B], replaced0: Int): RandomAccessSeq.Projection[B] = new RandomAccessSeq.Patch[B] {
override def original = RandomAccessSeq.this
override def from = from0
override def patch = patch0
@@ -162,26 +172,26 @@ trait RandomAccessSeq[+A] extends Seq[A] {
override def stringPrefix = RandomAccessSeq.this.stringPrefix + "P"
}
- override def ++[B >: A](that : Iterable[B]) : RandomAccessSeq[B] = that match {
- case that : RandomAccessSeq[b] =>
- val ret = new Array[B](length + that.length)
- copyToArray(ret, 0)
- (that : RandomAccessSeq[B]).copyToArray(ret, length)
- ret
- case that =>
- val buf = new scala.collection.mutable.ArrayBuffer[B]
- this copyToBuffer buf
- that copyToBuffer buf
- buf.readOnly
+ override def ++[B >: A](that: Iterable[B]): RandomAccessSeq[B] = that match {
+ case that: RandomAccessSeq[b] =>
+ val ret = new Array[B](length + that.length)
+ copyToArray(ret, 0)
+ (that : RandomAccessSeq[B]).copyToArray(ret, length)
+ ret
+ case that =>
+ val buf = new scala.collection.mutable.ArrayBuffer[B]
+ this copyToBuffer buf
+ that copyToBuffer buf
+ buf.readOnly
}
override def toStream : Stream[A] = new Stream.Definite[A] {
override def isEmpty = RandomAccessSeq.this.isEmpty
override def head = RandomAccessSeq.this.apply(0)
override def tail = RandomAccessSeq.this.drop(1).toStream
- protected def addDefinedElems(buf: compat.StringBuilder, prefix: String): compat.StringBuilder = {
+ protected def addDefinedElems(buf: StringBuilder, prefix: String): StringBuilder = {
var prefix0 = prefix
- var buf0 =buf
+ var buf0 = buf
elements.foreach{e =>
buf0 = buf0.append(prefix0).append(e)
prefix0 = ", "
diff --git a/src/library/scala/StringBuilder.scala b/src/library/scala/StringBuilder.scala
new file mode 100644
index 0000000000..026bcb18ab
--- /dev/null
+++ b/src/library/scala/StringBuilder.scala
@@ -0,0 +1,476 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2006-2008, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+// $Id: $
+
+
+package scala
+
+import Predef._
+
+/** <p>
+ * A mutable sequence of characters. This class provides an API compatible
+ * with <code>java.lang.StringBuilder</code>, but with no guarantee of
+ * synchronization.
+ * </p>
+ *
+ * @author Stephane Micheloud
+ */
+@SerialVersionUID(0 - 8525408645367278351L)
+@throws(classOf[NullPointerException])
+final class StringBuilder(initCapacity: Int, private val initValue: String)
+extends (Int => Char) with Proxy {
+ if (initCapacity < 0) throw new IllegalArgumentException
+ if (initValue eq null) throw new NullPointerException
+
+ /** The value is used for character storage. */
+ private var value = new Array[Char](initCapacity + initValue.length)
+
+ /** The count is the number of characters used. */
+ private var count: Int = 0
+
+ def this() = this(16, "")
+
+ def this(capacity: Int) = this(capacity, "")
+
+ @throws(classOf[NullPointerException])
+ def this(str: String) = this(16, str)
+
+ append(initValue)
+
+ def self = this
+
+ def toArray: Array[Char] = value
+
+ def length: Int = count
+
+ def length_=(n: Int) { setLength(n) }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def setLength(n: Int) {
+ if (n < 0)
+ throw new StringIndexOutOfBoundsException(n)
+ if (n > value.length) expandCapacity(n)
+ if (count < n)
+ while (count < n) {
+ value(count) = '\0'; count += 1
+ }
+ else
+ count = n
+ }
+
+ def capacity: Int = value.length
+
+ def capacity_=(n: Int) { ensureCapacity(n) }
+
+ def ensureCapacity(n: Int) {
+ if (n > value.length) expandCapacity(n)
+ }
+
+ private def expandCapacity(n: Int) {
+ val newCapacity = (value.length + 1) * 2
+ value = StringBuilder.copyOf(
+ value,
+ if (newCapacity < 0) Math.MAX_INT else if (n > newCapacity) n else newCapacity
+ )
+ }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def charAt(index: Int): Char = {
+ if (index < 0 || index >= count)
+ throw new StringIndexOutOfBoundsException(index)
+ value(index)
+ }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def apply(i: Int): Char = charAt(i)
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def deleteCharAt(index: Int): StringBuilder = {
+ if (index < 0 || index >= count)
+ throw new StringIndexOutOfBoundsException(index)
+ compat.Platform.arraycopy(value, index + 1, value, index, count - index - 1)
+ count -= 1
+ this
+ }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def setCharAt(index: Int, c: Char) {
+ if (index < 0 || index >= count)
+ throw new StringIndexOutOfBoundsException(index)
+ value(index) = c
+ }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def update(i: Int, c: Char) { setCharAt(i, c) }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def substring(start: Int): String = substring(start, count)
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def substring(start: Int, end: Int): String = {
+ if (start < 0)
+ throw new StringIndexOutOfBoundsException(start)
+ if (end > count)
+ throw new StringIndexOutOfBoundsException(end)
+ if (start > end)
+ throw new StringIndexOutOfBoundsException(end - start)
+ new String(value, start, end - start)
+ }
+
+ def append(x: Any): StringBuilder =
+ append(String.valueOf(x))
+
+ /** Appends the specified string to this character sequence.
+ *
+ * @param s
+ * @return
+ */
+ def append(s: String): StringBuilder = {
+ val str = if (s == null) "null" else s
+ val len = str.length
+ if (len > 0) {
+ val newCount = count + len
+ if (newCount > value.length) expandCapacity(newCount)
+ compat.Platform.arraycopy(str.toArray: Array[Char], 0, value, count, len)
+ count = newCount
+ }
+ this
+ }
+
+ /** Appends the specified string builder to this sequence.
+ *
+ * @param sb
+ * @return
+ */
+ def append(sb: StringBuilder): StringBuilder =
+ if (sb == null)
+ append("null")
+ else {
+ val len = sb.length
+ val newCount = count + len
+ if (newCount > value.length) expandCapacity(newCount)
+ compat.Platform.arraycopy(sb.toArray, 0, value, count, len)
+ count = newCount
+ this
+ }
+
+ def append(x: Array[Char]): StringBuilder =
+ append(x, 0, x.length)
+
+ def append(x: Array[Char], offset: Int, len: Int): StringBuilder = {
+ val newCount = count + len
+ if (newCount > value.length) expandCapacity(newCount)
+ compat.Platform.arraycopy(x, offset, value, count, len)
+ count = newCount
+ this
+ }
+
+ def append(x: Boolean): StringBuilder = {
+ if (x) {
+ val newCount = count + 4
+ if (newCount > value.length) expandCapacity(newCount)
+ value(count) = 't'; count += 1
+ value(count) = 'r'; count += 1
+ value(count) = 'u'; count += 1
+ value(count) = 'e'; count += 1
+ } else {
+ val newCount = count + 5
+ if (newCount > value.length) expandCapacity(newCount)
+ value(count) = 'f'; count += 1
+ value(count) = 'a'; count += 1
+ value(count) = 'l'; count += 1
+ value(count) = 's'; count += 1
+ value(count) = 'e'; count += 1
+ }
+ this
+ }
+
+ def append(x: Char): StringBuilder = {
+ val newCount = count + 1
+ if (newCount > value.length) expandCapacity(newCount)
+ value(count) = x; count += 1
+ this
+ }
+
+ def append(x: Int): StringBuilder =
+ append(String.valueOf(x))
+
+ def append(x: Long): StringBuilder =
+ append(String.valueOf(x))
+
+ def append(x: Float): StringBuilder =
+ append(String.valueOf(x))
+
+ def append(x: Double): StringBuilder =
+ append(String.valueOf(x))
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def delete(start: Int, end: Int): StringBuilder = {
+ if (start < 0 || start > end)
+ throw new StringIndexOutOfBoundsException(start)
+ val end0 = if (end > count) count else end
+ val len = end0 - start
+ if (len > 0) {
+ compat.Platform.arraycopy(value, start + len, value, start, count - end0)
+ count -= len
+ }
+ this
+ }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def replace(start: Int, end: Int, str: String) {
+ if (start < 0 || start > count || start > end)
+ throw new StringIndexOutOfBoundsException(start)
+
+ val end0 = if (end > count) count else end
+ val len = str.length()
+ val newCount = count + len - (end0 - start)
+ if (newCount > value.length) expandCapacity(newCount)
+
+ compat.Platform.arraycopy(value, end, value, start + len, count - end)
+ compat.Platform.arraycopy(str.toArray, 0, value, start, len)
+ count = newCount
+ this
+ }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def insert(index: Int, str: Array[Char], offset: Int, len: Int): StringBuilder = {
+ if (index < 0 || index > count)
+ throw new StringIndexOutOfBoundsException(index)
+ if (offset < 0 || len < 0 || offset > str.length - len)
+ throw new StringIndexOutOfBoundsException(
+ "offset " + offset + ", len " + len +
+ ", str.length " + str.length)
+ val newCount = count + len
+ if (newCount > value.length) expandCapacity(newCount)
+ compat.Platform.arraycopy(value, index, value, index + len, count - index)
+ compat.Platform.arraycopy(str, offset, value, index, len)
+ count = newCount
+ this
+ }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def insert(at: Int, x: Any): StringBuilder =
+ insert(at, String.valueOf(x))
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def insert(at: Int, x: String): StringBuilder = {
+ if (at < 0 || at > count)
+ throw new StringIndexOutOfBoundsException(at)
+ val str = if (x == null) "null" else x
+ val len = str.length
+ val newCount = count + len
+ if (newCount > value.length) expandCapacity(newCount)
+ compat.Platform.arraycopy(value, at, value, at + len, count - at)
+ compat.Platform.arraycopy(str.toArray: Array[Char], 0, value, at, len)
+ count = newCount
+ this
+ }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def insert(at: Int, x: Array[Char]): StringBuilder = {
+ if (at < 0 || at > count)
+ throw new StringIndexOutOfBoundsException(at)
+ val len = x.length
+ val newCount = count + len
+ if (newCount > value.length) expandCapacity(newCount)
+ compat.Platform.arraycopy(value, at, value, at + len, count - at)
+ compat.Platform.arraycopy(x, 0, value, at, len)
+ count = newCount
+ this
+ }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def insert(at: Int, x: Boolean): StringBuilder =
+ insert(at, String.valueOf(x))
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def insert(at: Int, x: Char): StringBuilder = {
+ if (at < 0 || at > count)
+ throw new StringIndexOutOfBoundsException(at)
+ val newCount = count + 1
+ if (newCount > value.length) expandCapacity(newCount)
+ compat.Platform.arraycopy(value, at, value, at + 1, count - at)
+ value(at) = x
+ count = newCount
+ this
+ }
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def insert(at: Int, x: Int): StringBuilder =
+ insert(at, String.valueOf(x))
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def insert(at: Int, x: Long): StringBuilder =
+ insert(at, String.valueOf(x))
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def insert(at: Int, x: Float): StringBuilder =
+ insert(at, String.valueOf(x))
+
+ @throws(classOf[StringIndexOutOfBoundsException])
+ def insert(at: Int, x: Double): StringBuilder =
+ insert(at, String.valueOf(x))
+
+ @throws(classOf[NullPointerException])
+ def indexOf(str: String): Int = indexOf(str, 0)
+
+ @throws(classOf[NullPointerException])
+ def indexOf(str: String, fromIndex: Int): Int =
+ StringBuilder.indexOf(value, 0, count, str.toArray, 0, str.length(), fromIndex)
+
+ @throws(classOf[NullPointerException])
+ def lastIndexOf(str: String): Int = lastIndexOf(str, count)
+
+ @throws(classOf[NullPointerException])
+ def lastIndexOf(str: String, fromIndex: Int): Int =
+ StringBuilder.lastIndexOf(value, 0, count, str.toArray, 0, str.length(), fromIndex)
+
+ def reverse(): StringBuilder = {
+ var hasSurrogate = false
+ val n = count - 1
+ var j = (n-1) >> 1
+ while (j >= 0) {
+ val temp = value(j)
+ val temp2 = value(n - j)
+ if (!hasSurrogate)
+ hasSurrogate =
+ (temp >= Character.MIN_SURROGATE && temp <= Character.MAX_SURROGATE) ||
+ (temp2 >= Character.MIN_SURROGATE && temp2 <= Character.MAX_SURROGATE)
+ value(j) = temp2
+ value(n - j) = temp
+ j -= 1
+ }
+ if (hasSurrogate) {
+ // Reverse back all valid surrogate pairs
+ var i = 0
+ while (i < count - 1) {
+ val c2 = value(i)
+ if (Character.isLowSurrogate(c2)) {
+ val c1 = value(i + 1)
+ if (Character.isHighSurrogate(c1)) {
+ value(i) = c1; i += 1
+ value(i) = c2
+ }
+ }
+ i += 1
+ }
+ }
+ this
+ }
+
+ override def toString(): String = new String(value, 0, count)
+
+ @throws(classOf[java.io.IOException])
+ private def writeObject(s: java.io.ObjectOutputStream) {
+ s.defaultWriteObject()
+ s.writeInt(count)
+ s.writeObject(value)
+ }
+
+ @throws(classOf[java.io.IOException])
+ @throws(classOf[ClassNotFoundException])
+ private def readObject(s: java.io.ObjectInputStream ) {
+ s.defaultReadObject()
+ count = s.readInt()
+ value = s.readObject().asInstanceOf[Array[Char]]
+ }
+
+}
+
+
+object StringBuilder {
+
+ // method <code>java.util.Arrays.copyOf</code> exists since 1.6
+ private def copyOf(src: Array[Char], newLength: Int): Array[Char] = {
+ val dest = new Array[Char](newLength)
+ val (start, end) =
+ if (src.length < newLength) (src.length, newLength)
+ else (newLength, src.length)
+ compat.Platform.arraycopy(src, 0, dest, 0, start)
+ // For any indices that are valid in the copy but not the original,
+ // the copy will contain '\\u000'.
+ for (i <- start until end) dest(i) = '\0'
+ dest
+ }
+
+ private def indexOf(source: Array[Char], sourceOffset: Int, sourceCount: Int,
+ target: Array[Char], targetOffset: Int, targetCount: Int,
+ fromIndex: Int): Int =
+ if (fromIndex >= sourceCount)
+ if (targetCount == 0) sourceCount else -1
+ else {
+ val inx = if (fromIndex < 0) 0 else fromIndex
+ if (targetCount == 0)
+ inx
+ else {
+ val first = target(targetOffset)
+ val max = sourceOffset + (sourceCount - targetCount)
+
+ var i = sourceOffset + inx
+ while (i <= max) {
+ /* Look for first character. */
+ if (source(i) != first) {
+ i += 1
+ while (i <= max && source(i) != first) i += 1
+ }
+ /* Found first character, now look at the rest of v2 */
+ if (i <= max) {
+ var j = i + 1
+ val end = j + targetCount - 1
+ var k = targetOffset + 1
+ while (j < end && source(j) == target(k)) {
+ j += 1
+ k += 1
+ }
+ if (j == end) {
+ /* Found whole string. */
+ return i - sourceOffset
+ }
+ } // if
+ i += 1
+ } // while
+ -1
+ }
+ }
+
+ private def lastIndexOf(source: Array[Char], sourceOffset: Int, sourceCount: Int,
+ target: Array[Char], targetOffset: Int, targetCount: Int,
+ fromIndex: Int): Int = {
+ val rightIndex = sourceCount - targetCount
+ if (fromIndex < 0) return -1
+ val inx = if (fromIndex > rightIndex) rightIndex else fromIndex
+ // Empty string always matches
+ if (targetCount == 0) return inx
+
+ val strLastIndex = targetOffset + targetCount - 1
+ val strLastChar = target(strLastIndex)
+ val min = sourceOffset + targetCount - 1
+ var i = min + fromIndex
+
+ while (true) {
+ while (i >= min && source(i) != strLastChar) i -= 1
+ if (i < min) return -1
+ var j = i - 1
+ val start = j - (targetCount - 1)
+ var k = strLastIndex - 1
+ var outerWhile = false
+ while (j > start && !outerWhile) {
+ if (source(j) != target(k)) {
+ j -= 1
+ k -= 1
+ i -= 1
+ outerWhile = true
+ }
+ }
+ if (!outerWhile) return start - sourceOffset + 1
+ }
+ -1
+ }
+}
diff --git a/src/library/scala/Tuple1.scala b/src/library/scala/Tuple1.scala
index 45e9b0c9fb..f03691131c 100644
--- a/src/library/scala/Tuple1.scala
+++ b/src/library/scala/Tuple1.scala
@@ -1,7 +1,7 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -9,7 +9,7 @@
// $Id$
-// generated by genprod on Thu Apr 19 18:52:00 CEST 2007
+// generated by genprod on Tue Feb 05 21:30:06 CET 2008
package scala
@@ -18,7 +18,7 @@ case class Tuple1[+T1](_1:T1)
extends Product1[T1] {
override def toString() = {
- val sb = new compat.StringBuilder
+ val sb = new StringBuilder
sb.append('(').append(_1).append(",)")
sb.toString
}
diff --git a/src/library/scala/Tuple10.scala b/src/library/scala/Tuple10.scala
index 7339146214..fc7e7d53ad 100644
--- a/src/library/scala/Tuple10.scala
+++ b/src/library/scala/Tuple10.scala
@@ -1,15 +1,15 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
-// $Id: genprod.scala 10751 2007-04-19 15:45:58Z michelou $
+// $Id: genprod.scala 10753 2007-04-19 17:01:17Z michelou $
-// generated by genprod on Thu Apr 19 18:52:00 CEST 2007
+// generated by genprod on Tue Feb 05 21:30:06 CET 2008
package scala
@@ -18,7 +18,7 @@ case class Tuple10[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10](_1:T1, _2:
extends Product10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10] {
override def toString() = {
- val sb = new compat.StringBuilder
+ val sb = new StringBuilder
sb.append('(').append(_1).append(',').append(_2).append(',').append(_3).append(',').append(_4).append(',').append(_5).append(',').append(_6).append(',').append(_7).append(',').append(_8).append(',').append(_9).append(',').append(_10).append(')')
sb.toString
}
diff --git a/src/library/scala/Tuple11.scala b/src/library/scala/Tuple11.scala
index b6e929111b..751369512f 100644
--- a/src/library/scala/Tuple11.scala
+++ b/src/library/scala/Tuple11.scala
@@ -1,15 +1,15 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
-// $Id: genprod.scala 10751 2007-04-19 15:45:58Z michelou $
+// $Id: genprod.scala 10753 2007-04-19 17:01:17Z michelou $
-// generated by genprod on Thu Apr 19 18:52:00 CEST 2007
+// generated by genprod on Tue Feb 05 21:30:06 CET 2008
package scala
@@ -18,7 +18,7 @@ case class Tuple11[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11](_1:T
extends Product11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11] {
override def toString() = {
- val sb = new compat.StringBuilder
+ val sb = new StringBuilder
sb.append('(').append(_1).append(',').append(_2).append(',').append(_3).append(',').append(_4).append(',').append(_5).append(',').append(_6).append(',').append(_7).append(',').append(_8).append(',').append(_9).append(',').append(_10).append(',').append(_11).append(')')
sb.toString
}
diff --git a/src/library/scala/Tuple12.scala b/src/library/scala/Tuple12.scala
index 9e84ae4577..1f3c4e9a38 100644
--- a/src/library/scala/Tuple12.scala
+++ b/src/library/scala/Tuple12.scala
@@ -1,15 +1,15 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
-// $Id: genprod.scala 10751 2007-04-19 15:45:58Z michelou $
+// $Id: genprod.scala 10753 2007-04-19 17:01:17Z michelou $
-// generated by genprod on Thu Apr 19 18:52:00 CEST 2007
+// generated by genprod on Tue Feb 05 21:30:06 CET 2008
package scala
@@ -18,7 +18,7 @@ case class Tuple12[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12
extends Product12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12] {
override def toString() = {
- val sb = new compat.StringBuilder
+ val sb = new StringBuilder
sb.append('(').append(_1).append(',').append(_2).append(',').append(_3).append(',').append(_4).append(',').append(_5).append(',').append(_6).append(',').append(_7).append(',').append(_8).append(',').append(_9).append(',').append(_10).append(',').append(_11).append(',').append(_12).append(')')
sb.toString
}
diff --git a/src/library/scala/Tuple13.scala b/src/library/scala/Tuple13.scala
index 4a09e1432d..5232833f43 100644
--- a/src/library/scala/Tuple13.scala
+++ b/src/library/scala/Tuple13.scala
@@ -1,15 +1,15 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
-// $Id: genprod.scala 10751 2007-04-19 15:45:58Z michelou $
+// $Id: genprod.scala 10753 2007-04-19 17:01:17Z michelou $
-// generated by genprod on Thu Apr 19 18:52:00 CEST 2007
+// generated by genprod on Tue Feb 05 21:30:06 CET 2008
package scala
@@ -18,7 +18,7 @@ case class Tuple13[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12
extends Product13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13] {
override def toString() = {
- val sb = new compat.StringBuilder
+ val sb = new StringBuilder
sb.append('(').append(_1).append(',').append(_2).append(',').append(_3).append(',').append(_4).append(',').append(_5).append(',').append(_6).append(',').append(_7).append(',').append(_8).append(',').append(_9).append(',').append(_10).append(',').append(_11).append(',').append(_12).append(',').append(_13).append(')')
sb.toString
}
diff --git a/src/library/scala/Tuple14.scala b/src/library/scala/Tuple14.scala
index 3c84d00aeb..bc968c0970 100644
--- a/src/library/scala/Tuple14.scala
+++ b/src/library/scala/Tuple14.scala
@@ -1,15 +1,15 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
-// $Id: genprod.scala 10751 2007-04-19 15:45:58Z michelou $
+// $Id: genprod.scala 10753 2007-04-19 17:01:17Z michelou $
-// generated by genprod on Thu Apr 19 18:52:00 CEST 2007
+// generated by genprod on Tue Feb 05 21:30:06 CET 2008
package scala
@@ -18,7 +18,7 @@ case class Tuple14[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12
extends Product14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14] {
override def toString() = {
- val sb = new compat.StringBuilder
+ val sb = new StringBuilder
sb.append('(').append(_1).append(',').append(_2).append(',').append(_3).append(',').append(_4).append(',').append(_5).append(',').append(_6).append(',').append(_7).append(',').append(_8).append(',').append(_9).append(',').append(_10).append(',').append(_11).append(',').append(_12).append(',').append(_13).append(',').append(_14).append(')')
sb.toString
}
diff --git a/src/library/scala/Tuple15.scala b/src/library/scala/Tuple15.scala
index b03c831c0a..be72228061 100644
--- a/src/library/scala/Tuple15.scala
+++ b/src/library/scala/Tuple15.scala
@@ -1,15 +1,15 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
-// $Id: genprod.scala 10751 2007-04-19 15:45:58Z michelou $
+// $Id: genprod.scala 10753 2007-04-19 17:01:17Z michelou $
-// generated by genprod on Thu Apr 19 18:52:00 CEST 2007
+// generated by genprod on Tue Feb 05 21:30:06 CET 2008
package scala
@@ -18,7 +18,7 @@ case class Tuple15[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12
extends Product15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15] {
override def toString() = {
- val sb = new compat.StringBuilder
+ val sb = new StringBuilder
sb.append('(').append(_1).append(',').append(_2).append(',').append(_3).append(',').append(_4).append(',').append(_5).append(',').append(_6).append(',').append(_7).append(',').append(_8).append(',').append(_9).append(',').append(_10).append(',').append(_11).append(',').append(_12).append(',').append(_13).append(',').append(_14).append(',').append(_15).append(')')
sb.toString
}
diff --git a/src/library/scala/Tuple16.scala b/src/library/scala/Tuple16.scala
index 05443967de..c65776afaa 100644
--- a/src/library/scala/Tuple16.scala
+++ b/src/library/scala/Tuple16.scala
@@ -1,15 +1,15 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
-// $Id: genprod.scala 10751 2007-04-19 15:45:58Z michelou $
+// $Id: genprod.scala 10753 2007-04-19 17:01:17Z michelou $
-// generated by genprod on Thu Apr 19 18:52:00 CEST 2007
+// generated by genprod on Tue Feb 05 21:30:06 CET 2008
package scala
@@ -18,7 +18,7 @@ case class Tuple16[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12
extends Product16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16] {
override def toString() = {
- val sb = new compat.StringBuilder
+ val sb = new StringBuilder
sb.append('(').append(_1).append(',').append(_2).append(',').append(_3).append(',').append(_4).append(',').append(_5).append(',').append(_6).append(',').append(_7).append(',').append(_8).append(',').append(_9).append(',').append(_10).append(',').append(_11).append(',').append(_12).append(',').append(_13).append(',').append(_14).append(',').append(_15).append(',').append(_16).append(')')
sb.toString
}
diff --git a/src/library/scala/Tuple17.scala b/src/library/scala/Tuple17.scala
index 7d3e6b9862..4584de6878 100644
--- a/src/library/scala/Tuple17.scala
+++ b/src/library/scala/Tuple17.scala
@@ -1,15 +1,15 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
-// $Id: genprod.scala 10751 2007-04-19 15:45:58Z michelou $
+// $Id: genprod.scala 10753 2007-04-19 17:01:17Z michelou $
-// generated by genprod on Thu Apr 19 18:52:00 CEST 2007
+// generated by genprod on Tue Feb 05 21:30:06 CET 2008
package scala
@@ -18,7 +18,7 @@ case class Tuple17[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12
extends Product17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17] {
override def toString() = {
- val sb = new compat.StringBuilder
+ val sb = new StringBuilder
sb.append('(').append(_1).append(',').append(_2).append(',').append(_3).append(',').append(_4).append(',').append(_5).append(',').append(_6).append(',').append(_7).append(',').append(_8).append(',').append(_9).append(',').append(_10).append(',').append(_11).append(',').append(_12).append(',').append(_13).append(',').append(_14).append(',').append(_15).append(',').append(_16).append(',').append(_17).append(')')
sb.toString
}
diff --git a/src/library/scala/Tuple18.scala b/src/library/scala/Tuple18.scala
index 07e14ec9ed..84507f8c3b 100644
--- a/src/library/scala/Tuple18.scala
+++ b/src/library/scala/Tuple18.scala
@@ -1,15 +1,15 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
-// $Id: genprod.scala 10751 2007-04-19 15:45:58Z michelou $
+// $Id: genprod.scala 10753 2007-04-19 17:01:17Z michelou $
-// generated by genprod on Thu Apr 19 18:52:00 CEST 2007
+// generated by genprod on Tue Feb 05 21:30:06 CET 2008
package scala
@@ -18,7 +18,7 @@ case class Tuple18[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12
extends Product18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18] {
override def toString() = {
- val sb = new compat.StringBuilder
+ val sb = new StringBuilder
sb.append('(').append(_1).append(',').append(_2).append(',').append(_3).append(',').append(_4).append(',').append(_5).append(',').append(_6).append(',').append(_7).append(',').append(_8).append(',').append(_9).append(',').append(_10).append(',').append(_11).append(',').append(_12).append(',').append(_13).append(',').append(_14).append(',').append(_15).append(',').append(_16).append(',').append(_17).append(',').append(_18).append(')')
sb.toString
}
diff --git a/src/library/scala/Tuple19.scala b/src/library/scala/Tuple19.scala
index e32fb0e238..e37b9dcffa 100644
--- a/src/library/scala/Tuple19.scala
+++ b/src/library/scala/Tuple19.scala
@@ -1,15 +1,15 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
-// $Id: genprod.scala 10751 2007-04-19 15:45:58Z michelou $
+// $Id: genprod.scala 10753 2007-04-19 17:01:17Z michelou $
-// generated by genprod on Thu Apr 19 18:52:00 CEST 2007
+// generated by genprod on Tue Feb 05 21:30:06 CET 2008
package scala
@@ -18,7 +18,7 @@ case class Tuple19[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12
extends Product19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19] {
override def toString() = {
- val sb = new compat.StringBuilder
+ val sb = new StringBuilder
sb.append('(').append(_1).append(',').append(_2).append(',').append(_3).append(',').append(_4).append(',').append(_5).append(',').append(_6).append(',').append(_7).append(',').append(_8).append(',').append(_9).append(',').append(_10).append(',').append(_11).append(',').append(_12).append(',').append(_13).append(',').append(_14).append(',').append(_15).append(',').append(_16).append(',').append(_17).append(',').append(_18).append(',').append(_19).append(')')
sb.toString
}
diff --git a/src/library/scala/Tuple2.scala b/src/library/scala/Tuple2.scala
index 5bb12088d9..57a36e02f6 100644
--- a/src/library/scala/Tuple2.scala
+++ b/src/library/scala/Tuple2.scala
@@ -1,7 +1,7 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -9,7 +9,7 @@
// $Id$
-// generated by genprod on Thu Apr 19 18:52:00 CEST 2007
+// generated by genprod on Tue Feb 05 21:30:06 CET 2008
package scala
@@ -18,7 +18,7 @@ case class Tuple2[+T1, +T2](_1:T1, _2:T2)
extends Product2[T1, T2] {
override def toString() = {
- val sb = new compat.StringBuilder
+ val sb = new StringBuilder
sb.append('(').append(_1).append(',').append(_2).append(')')
sb.toString
}
diff --git a/src/library/scala/Tuple20.scala b/src/library/scala/Tuple20.scala
index 0ff6e91324..a366f06dd2 100644
--- a/src/library/scala/Tuple20.scala
+++ b/src/library/scala/Tuple20.scala
@@ -1,15 +1,15 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
-// $Id: genprod.scala 10751 2007-04-19 15:45:58Z michelou $
+// $Id: genprod.scala 10753 2007-04-19 17:01:17Z michelou $
-// generated by genprod on Thu Apr 19 18:52:00 CEST 2007
+// generated by genprod on Tue Feb 05 21:30:06 CET 2008
package scala
@@ -18,7 +18,7 @@ case class Tuple20[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12
extends Product20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20] {
override def toString() = {
- val sb = new compat.StringBuilder
+ val sb = new StringBuilder
sb.append('(').append(_1).append(',').append(_2).append(',').append(_3).append(',').append(_4).append(',').append(_5).append(',').append(_6).append(',').append(_7).append(',').append(_8).append(',').append(_9).append(',').append(_10).append(',').append(_11).append(',').append(_12).append(',').append(_13).append(',').append(_14).append(',').append(_15).append(',').append(_16).append(',').append(_17).append(',').append(_18).append(',').append(_19).append(',').append(_20).append(')')
sb.toString
}
diff --git a/src/library/scala/Tuple21.scala b/src/library/scala/Tuple21.scala
index f714dfe89a..67734a28e7 100644
--- a/src/library/scala/Tuple21.scala
+++ b/src/library/scala/Tuple21.scala
@@ -1,15 +1,15 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
-// $Id: genprod.scala 10751 2007-04-19 15:45:58Z michelou $
+// $Id: genprod.scala 10753 2007-04-19 17:01:17Z michelou $
-// generated by genprod on Thu Apr 19 18:52:00 CEST 2007
+// generated by genprod on Tue Feb 05 21:30:06 CET 2008
package scala
@@ -18,7 +18,7 @@ case class Tuple21[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12
extends Product21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21] {
override def toString() = {
- val sb = new compat.StringBuilder
+ val sb = new StringBuilder
sb.append('(').append(_1).append(',').append(_2).append(',').append(_3).append(',').append(_4).append(',').append(_5).append(',').append(_6).append(',').append(_7).append(',').append(_8).append(',').append(_9).append(',').append(_10).append(',').append(_11).append(',').append(_12).append(',').append(_13).append(',').append(_14).append(',').append(_15).append(',').append(_16).append(',').append(_17).append(',').append(_18).append(',').append(_19).append(',').append(_20).append(',').append(_21).append(')')
sb.toString
}
diff --git a/src/library/scala/Tuple22.scala b/src/library/scala/Tuple22.scala
index e6df5a4a1b..d15b03fa86 100644
--- a/src/library/scala/Tuple22.scala
+++ b/src/library/scala/Tuple22.scala
@@ -1,15 +1,15 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
-// $Id: genprod.scala 10751 2007-04-19 15:45:58Z michelou $
+// $Id: genprod.scala 10753 2007-04-19 17:01:17Z michelou $
-// generated by genprod on Thu Apr 19 18:52:00 CEST 2007
+// generated by genprod on Tue Feb 05 21:30:06 CET 2008
package scala
@@ -18,7 +18,7 @@ case class Tuple22[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12
extends Product22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22] {
override def toString() = {
- val sb = new compat.StringBuilder
+ val sb = new StringBuilder
sb.append('(').append(_1).append(',').append(_2).append(',').append(_3).append(',').append(_4).append(',').append(_5).append(',').append(_6).append(',').append(_7).append(',').append(_8).append(',').append(_9).append(',').append(_10).append(',').append(_11).append(',').append(_12).append(',').append(_13).append(',').append(_14).append(',').append(_15).append(',').append(_16).append(',').append(_17).append(',').append(_18).append(',').append(_19).append(',').append(_20).append(',').append(_21).append(',').append(_22).append(')')
sb.toString
}
diff --git a/src/library/scala/Tuple3.scala b/src/library/scala/Tuple3.scala
index d0ce443c5d..f1828f7e52 100644
--- a/src/library/scala/Tuple3.scala
+++ b/src/library/scala/Tuple3.scala
@@ -1,7 +1,7 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -9,7 +9,7 @@
// $Id$
-// generated by genprod on Thu Apr 19 18:52:00 CEST 2007
+// generated by genprod on Tue Feb 05 21:30:06 CET 2008
package scala
@@ -18,7 +18,7 @@ case class Tuple3[+T1, +T2, +T3](_1:T1, _2:T2, _3:T3)
extends Product3[T1, T2, T3] {
override def toString() = {
- val sb = new compat.StringBuilder
+ val sb = new StringBuilder
sb.append('(').append(_1).append(',').append(_2).append(',').append(_3).append(')')
sb.toString
}
diff --git a/src/library/scala/Tuple4.scala b/src/library/scala/Tuple4.scala
index a87fe7a0e5..f93051d1a6 100644
--- a/src/library/scala/Tuple4.scala
+++ b/src/library/scala/Tuple4.scala
@@ -1,7 +1,7 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -9,7 +9,7 @@
// $Id$
-// generated by genprod on Thu Apr 19 18:52:00 CEST 2007
+// generated by genprod on Tue Feb 05 21:30:06 CET 2008
package scala
@@ -18,7 +18,7 @@ case class Tuple4[+T1, +T2, +T3, +T4](_1:T1, _2:T2, _3:T3, _4:T4)
extends Product4[T1, T2, T3, T4] {
override def toString() = {
- val sb = new compat.StringBuilder
+ val sb = new StringBuilder
sb.append('(').append(_1).append(',').append(_2).append(',').append(_3).append(',').append(_4).append(')')
sb.toString
}
diff --git a/src/library/scala/Tuple5.scala b/src/library/scala/Tuple5.scala
index 22f52da3e9..4537980e57 100644
--- a/src/library/scala/Tuple5.scala
+++ b/src/library/scala/Tuple5.scala
@@ -1,7 +1,7 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -9,7 +9,7 @@
// $Id$
-// generated by genprod on Thu Apr 19 18:52:00 CEST 2007
+// generated by genprod on Tue Feb 05 21:30:06 CET 2008
package scala
@@ -18,7 +18,7 @@ case class Tuple5[+T1, +T2, +T3, +T4, +T5](_1:T1, _2:T2, _3:T3, _4:T4, _5:T5)
extends Product5[T1, T2, T3, T4, T5] {
override def toString() = {
- val sb = new compat.StringBuilder
+ val sb = new StringBuilder
sb.append('(').append(_1).append(',').append(_2).append(',').append(_3).append(',').append(_4).append(',').append(_5).append(')')
sb.toString
}
diff --git a/src/library/scala/Tuple6.scala b/src/library/scala/Tuple6.scala
index 0b73e4d675..6ab36c7fc8 100644
--- a/src/library/scala/Tuple6.scala
+++ b/src/library/scala/Tuple6.scala
@@ -1,7 +1,7 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -9,7 +9,7 @@
// $Id$
-// generated by genprod on Thu Apr 19 18:52:00 CEST 2007
+// generated by genprod on Tue Feb 05 21:30:06 CET 2008
package scala
@@ -18,7 +18,7 @@ case class Tuple6[+T1, +T2, +T3, +T4, +T5, +T6](_1:T1, _2:T2, _3:T3, _4:T4, _5:T
extends Product6[T1, T2, T3, T4, T5, T6] {
override def toString() = {
- val sb = new compat.StringBuilder
+ val sb = new StringBuilder
sb.append('(').append(_1).append(',').append(_2).append(',').append(_3).append(',').append(_4).append(',').append(_5).append(',').append(_6).append(')')
sb.toString
}
diff --git a/src/library/scala/Tuple7.scala b/src/library/scala/Tuple7.scala
index 638a22c9f7..427c46998f 100644
--- a/src/library/scala/Tuple7.scala
+++ b/src/library/scala/Tuple7.scala
@@ -1,7 +1,7 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -9,7 +9,7 @@
// $Id$
-// generated by genprod on Thu Apr 19 18:52:00 CEST 2007
+// generated by genprod on Tue Feb 05 21:30:06 CET 2008
package scala
@@ -18,7 +18,7 @@ case class Tuple7[+T1, +T2, +T3, +T4, +T5, +T6, +T7](_1:T1, _2:T2, _3:T3, _4:T4,
extends Product7[T1, T2, T3, T4, T5, T6, T7] {
override def toString() = {
- val sb = new compat.StringBuilder
+ val sb = new StringBuilder
sb.append('(').append(_1).append(',').append(_2).append(',').append(_3).append(',').append(_4).append(',').append(_5).append(',').append(_6).append(',').append(_7).append(')')
sb.toString
}
diff --git a/src/library/scala/Tuple8.scala b/src/library/scala/Tuple8.scala
index 74c2f26a09..6caddb40d4 100644
--- a/src/library/scala/Tuple8.scala
+++ b/src/library/scala/Tuple8.scala
@@ -1,7 +1,7 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -9,7 +9,7 @@
// $Id$
-// generated by genprod on Thu Apr 19 18:52:00 CEST 2007
+// generated by genprod on Tue Feb 05 21:30:06 CET 2008
package scala
@@ -18,7 +18,7 @@ case class Tuple8[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8](_1:T1, _2:T2, _3:T3, _
extends Product8[T1, T2, T3, T4, T5, T6, T7, T8] {
override def toString() = {
- val sb = new compat.StringBuilder
+ val sb = new StringBuilder
sb.append('(').append(_1).append(',').append(_2).append(',').append(_3).append(',').append(_4).append(',').append(_5).append(',').append(_6).append(',').append(_7).append(',').append(_8).append(')')
sb.toString
}
diff --git a/src/library/scala/Tuple9.scala b/src/library/scala/Tuple9.scala
index 77dc32f8e6..bf340c7e5c 100644
--- a/src/library/scala/Tuple9.scala
+++ b/src/library/scala/Tuple9.scala
@@ -1,7 +1,7 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -9,7 +9,7 @@
// $Id$
-// generated by genprod on Thu Apr 19 18:52:00 CEST 2007
+// generated by genprod on Tue Feb 05 21:30:06 CET 2008
package scala
@@ -18,7 +18,7 @@ case class Tuple9[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9](_1:T1, _2:T2, _3:
extends Product9[T1, T2, T3, T4, T5, T6, T7, T8, T9] {
override def toString() = {
- val sb = new compat.StringBuilder
+ val sb = new StringBuilder
sb.append('(').append(_1).append(',').append(_2).append(',').append(_3).append(',').append(_4).append(',').append(_5).append(',').append(_6).append(',').append(_7).append(',').append(_8).append(',').append(_9).append(')')
sb.toString
}
diff --git a/src/library/scala/compat/StringBuilder.scala b/src/library/scala/compat/StringBuilder.scala
deleted file mode 100644
index abedc99041..0000000000
--- a/src/library/scala/compat/StringBuilder.scala
+++ /dev/null
@@ -1,73 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala.compat
-
-
-import java.lang.{String, StringBuffer}
-
-
-/** Consult the documentation of <code>java.lang.StringBuffer</code> for more
- * details (see http://java.sun.com/javase/6/docs/api/).
- */
-final class StringBuilder(val self: StringBuffer) extends (Int => Char) with Proxy {
-
- def this() = this(new StringBuffer())
- def this(n: Int) = this(new StringBuffer(n))
- def this(s: String) = this(new StringBuffer(s))
-
- def length: Int = self.length()
- def length_=(n: Int) { self.setLength(n) }
- def setLength(n: Int) { self.setLength(n) }
-
- def capacity: Int = self.capacity
- def capacity_=(n: Int) { self.ensureCapacity(n) }
- def ensureCapacity(n: Int) { self.ensureCapacity(n) }
-
- def charAt(i: Int): Char = self.charAt(i)
- def apply(i: Int): Char = self.charAt(i)
- def deleteCharAt(index: Int) = self.deleteCharAt(index)
-
- def setCharAt(index: Int, c: Char) { self.setCharAt(index, c) }
- def update(i: Int, c: Char) { self.setCharAt(i, c)}
-
- def substring(i: Int): String = self.substring(i)
- def substring(i: Int, j: Int): String = self.substring(i, j)
-
- def append(x: Any): StringBuilder = { self.append(x); this }
- def append(x: Boolean): StringBuilder = { self.append(x); this }
- def append(x: Byte): StringBuilder = { self.append(x); this }
- def append(x: Short): StringBuilder = { self.append(x); this }
- def append(x: Char): StringBuilder = { self.append(x); this }
- def append(x: Int): StringBuilder = { self.append(x); this }
- def append(x: Long): StringBuilder = { self.append(x); this }
- def append(x: Float): StringBuilder = { self.append(x); this }
- def append(x: Double): StringBuilder = { self.append(x); this }
- def append(x: String): StringBuilder = { self.append(x); this }
- def append(x: Array[Char]): StringBuilder = { self.append(x); this }
- def append(x: Array[Char], start: Int, length: Int): StringBuilder =
- { self.append(x, start, length); this }
-
- def insert(at: Int, x: Any): StringBuilder = { self.insert(at, x); this }
- def insert(at: Int, x: Boolean): StringBuilder = { self.insert(at, x); this }
- def insert(at: Int, x: Byte): StringBuilder = { self.insert(at, x); this }
- def insert(at: Int, x: Short): StringBuilder = { self.insert(at, x); this }
- def insert(at: Int, x: Char): StringBuilder = { self.insert(at, x); this }
- def insert(at: Int, x: Int): StringBuilder = { self.insert(at, x); this }
- def insert(at: Int, x: Long): StringBuilder = { self.insert(at, x); this }
- def insert(at: Int, x: Float): StringBuilder = { self.insert(at, x); this }
- def insert(at: Int, x: Double): StringBuilder = { self.insert(at, x); this }
- def insert(at: Int, x: String): StringBuilder = { self.insert(at, x); this }
- def insert(at: Int, x: Array[Char]): StringBuilder = { self.insert(at, x); this }
- def insert(at: Int, x: Array[Char], start: Int, length: Int): StringBuilder =
- { self.insert(at, x, start, length); this }
-
-}
diff --git a/src/library/scala/io/Position.scala b/src/library/scala/io/Position.scala
index 228e4f5547..e56ffdb470 100644
--- a/src/library/scala/io/Position.scala
+++ b/src/library/scala/io/Position.scala
@@ -11,9 +11,6 @@
package scala.io
-
-import compat.StringBuilder
-
/** <p>
* The object <code>Position</code> provides convenience methods to encode
* line and column number in one single integer. The encode line (column)
diff --git a/src/library/scala/runtime/BoxedArray.scala b/src/library/scala/runtime/BoxedArray.scala
index 8975aac106..d0555e8e62 100644
--- a/src/library/scala/runtime/BoxedArray.scala
+++ b/src/library/scala/runtime/BoxedArray.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -14,7 +14,6 @@ package scala.runtime
import Predef._
import collection.mutable.ArrayBuffer
-import compat.StringBuilder
/**
* <p>A class representing <code>Array[T]</code></p>
diff --git a/src/library/scala/throws.scala b/src/library/scala/throws.scala
index 96b095b3fd..463a01b3f9 100644
--- a/src/library/scala/throws.scala
+++ b/src/library/scala/throws.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -11,6 +11,8 @@
package scala
+import Predef._
+
/** <p>
* Annotation for specifying the exceptions thrown by a method.
* For example:
@@ -25,4 +27,4 @@ package scala
* @author Nikolay Mihaylov
* @version 1.0, 19/05/2006
*/
-class throws(clazz: java.lang.Class[_]) extends Annotation
+class throws(clazz: Class[_]) extends Annotation
diff --git a/src/library/scala/util/automata/DetWordAutom.scala b/src/library/scala/util/automata/DetWordAutom.scala
index fd267a6648..77bbaefc91 100644
--- a/src/library/scala/util/automata/DetWordAutom.scala
+++ b/src/library/scala/util/automata/DetWordAutom.scala
@@ -56,8 +56,7 @@ abstract class DetWordAutom[T <: AnyRef] {
}
override def toString() = {
- val sb = new compat.StringBuilder()
- sb.append("[DetWordAutom nstates=")
+ val sb = new StringBuilder("[DetWordAutom nstates=")
sb.append(nstates)
sb.append(" finals=")
var map = new scala.collection.immutable.ListMap[Int,Int]
diff --git a/src/library/scala/util/automata/NondetWordAutom.scala b/src/library/scala/util/automata/NondetWordAutom.scala
index 3aa9febf6e..65790f9910 100644
--- a/src/library/scala/util/automata/NondetWordAutom.scala
+++ b/src/library/scala/util/automata/NondetWordAutom.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2003-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -86,8 +86,7 @@ abstract class NondetWordAutom[T <: AnyRef] {
}
override def toString = {
- val sb = new compat.StringBuilder()
- sb.append("[NondetWordAutom nstates=")
+ val sb = new StringBuilder("[NondetWordAutom nstates=")
sb.append(nstates)
sb.append(" finals=")
var map = new scala.collection.immutable.ListMap[Int,Int]
diff --git a/src/library/scala/xml/Elem.scala b/src/library/scala/xml/Elem.scala
index 36f2b56a80..a5f07fd78a 100644
--- a/src/library/scala/xml/Elem.scala
+++ b/src/library/scala/xml/Elem.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -69,7 +69,7 @@ object Elem {
* <code>n</code>.
*/
override def text = {
- val sb = new compat.StringBuilder()
+ val sb = new StringBuilder()
val it = child.elements
while (it.hasNext)
sb.append(it.next.text)
diff --git a/src/library/scala/xml/NodeSeq.scala b/src/library/scala/xml/NodeSeq.scala
index 17ba1e6301..f5262a8ea3 100644
--- a/src/library/scala/xml/NodeSeq.scala
+++ b/src/library/scala/xml/NodeSeq.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2003-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -168,7 +168,7 @@ abstract class NodeSeq extends Seq[Node] {
*/
def text: String = {
- val sb = new compat.StringBuilder()
+ val sb = new StringBuilder()
val it = elements
while (it.hasNext) {
sb.append(it.next.text)
diff --git a/src/library/scala/xml/TextBuffer.scala b/src/library/scala/xml/TextBuffer.scala
index 32383aea53..f31f38e8a6 100644
--- a/src/library/scala/xml/TextBuffer.scala
+++ b/src/library/scala/xml/TextBuffer.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2003-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -23,7 +23,7 @@ object TextBuffer {
*/
class TextBuffer {
- val sb = new compat.StringBuilder()
+ val sb = new StringBuilder()
var ws = true
def appendSpace = if(!ws) { ws = true; sb.append(' ') } else {}
diff --git a/src/library/scala/xml/dtd/Decl.scala b/src/library/scala/xml/dtd/Decl.scala
index 3aec3b1c70..bdae3922fa 100644
--- a/src/library/scala/xml/dtd/Decl.scala
+++ b/src/library/scala/xml/dtd/Decl.scala
@@ -1,7 +1,7 @@
/* __ *\
** ________ ___ / / ___ Scala API **
- ** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL **
- ** __\ \/ /__/ __ |/ /__/ __ | **
+ ** / __/ __// _ | / / / _ | (c) 2003-2008, LAMP/EPFL **
+ ** __\ \/ /__/ __ |/ /__/ __ | http://www.scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
@@ -9,15 +9,13 @@
// $Id$
-package scala.xml.dtd;
+package scala.xml.dtd
-import compat.StringBuilder
-
abstract class Decl;
abstract class MarkupDecl extends Decl {
- def toString(sb: StringBuilder): StringBuilder;
+ def toString(sb: StringBuilder): StringBuilder
}
/** an element declaration
@@ -53,7 +51,7 @@ case class AttListDecl(name: String, attrs:List[AttrDecl]) extends MarkupDecl wi
* versions might provide a way to access the attribute types more
* directly.
*/
-case class AttrDecl( name:String, tpe:String, default:DefaultDecl ) {
+case class AttrDecl(name: String, tpe: String, default: DefaultDecl) {
override def toString(): String =
toString(new StringBuilder()).toString();
@@ -69,7 +67,7 @@ case class AttrDecl( name:String, tpe:String, default:DefaultDecl ) {
abstract class EntityDecl extends MarkupDecl;
/** a parsed general entity declaration */
-case class ParsedEntityDecl( name:String, entdef:EntityDef ) extends EntityDecl {
+case class ParsedEntityDecl(name: String, entdef: EntityDef) extends EntityDecl {
override def toString(sb: StringBuilder): StringBuilder = {
sb.append("<!ENTITY ").append( name ).append(' ');
@@ -101,11 +99,11 @@ case class NotationDecl( name:String, extID:ExternalID ) extends MarkupDecl {
}
abstract class EntityDef {
- def toString(sb: StringBuilder): StringBuilder;
+ def toString(sb: StringBuilder): StringBuilder
}
case class IntDef(value:String) extends EntityDef {
- private def validateValue(): Unit = {
+ private def validateValue() {
var tmp = value;
var ix = tmp.indexOf('%');
while( ix != -1) {
@@ -136,7 +134,6 @@ case class ExtDef(extID:ExternalID) extends EntityDef {
}
-
/** a parsed entity reference */
case class PEReference(ent:String) extends MarkupDecl {
if( !Utility.isName( ent ))
@@ -150,27 +147,26 @@ case class PEReference(ent:String) extends MarkupDecl {
// default declarations for attributes
abstract class DefaultDecl {
- override def toString(): String;
- def toString(sb: StringBuilder): StringBuilder;
+ override def toString(): String
+ def toString(sb: StringBuilder): StringBuilder
}
case object REQUIRED extends DefaultDecl {
- override def toString(): String = "#REQUIRED";
- override def toString(sb:StringBuilder) = sb.append("#REQUIRED");
+ override def toString(): String = "#REQUIRED"
+ override def toString(sb: StringBuilder) = sb.append("#REQUIRED")
}
case object IMPLIED extends DefaultDecl {
- override def toString(): String = "#IMPLIED";
- override def toString(sb:StringBuilder) = sb.append("#IMPLIED");
+ override def toString(): String = "#IMPLIED"
+ override def toString(sb: StringBuilder) = sb.append("#IMPLIED")
}
case class DEFAULT(fixed: Boolean, attValue:String) extends DefaultDecl {
override def toString(): String =
toString(new StringBuilder()).toString();
- override def toString(sb:StringBuilder): StringBuilder = {
- if(fixed)
- sb.append("#FIXED ");
- Utility.appendEscapedQuoted( attValue, sb );
+ override def toString(sb: StringBuilder): StringBuilder = {
+ if (fixed) sb.append("#FIXED ")
+ Utility.appendEscapedQuoted(attValue, sb)
}
}
diff --git a/src/library/scala/xml/dtd/ExternalID.scala b/src/library/scala/xml/dtd/ExternalID.scala
index 514db9c60f..5f384f610d 100644
--- a/src/library/scala/xml/dtd/ExternalID.scala
+++ b/src/library/scala/xml/dtd/ExternalID.scala
@@ -1,7 +1,7 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
+** / __/ __// _ | / / / _ | (c) 2003-2008, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://www.scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
@@ -12,8 +12,6 @@
package scala.xml.dtd
-import compat.StringBuilder
-
/** an ExternalIDs - either PublicID or SystemID
*
* @author Burak Emir
@@ -41,16 +39,16 @@ abstract class ExternalID {
case class SystemID( systemId:String ) extends ExternalID with parsing.TokenTests{
- if( !checkSysID( systemId ) )
+ if( !checkSysID(systemId) )
throw new IllegalArgumentException(
"can't use both \" and ' in systemLiteral"
)
/** returns " SYSTEM "+systemLiteral */
override def toString() =
- Utility.systemLiteralToString( systemId )
+ Utility.systemLiteralToString(systemId)
override def toString(sb: StringBuilder): StringBuilder =
- Utility.systemLiteralToString( sb, systemId )
+ Utility.systemLiteralToString(sb, systemId)
}
@@ -60,7 +58,8 @@ case class SystemID( systemId:String ) extends ExternalID with parsing.TokenTest
* @param publicLiteral the public identifier literal
* @param systemLiteral (can be null for notation pubIDs) the system identifier literal
**/
-case class PublicID( publicId:String, systemId:String ) extends ExternalID with parsing.TokenTests{
+case class PublicID(publicId: String, systemId: String)
+extends ExternalID with parsing.TokenTests {
if( !checkPubID( publicId ))
throw new IllegalArgumentException(
diff --git a/src/library/scala/xml/dtd/Scanner.scala b/src/library/scala/xml/dtd/Scanner.scala
index 9cb5ef917e..1d32f7c3f7 100644
--- a/src/library/scala/xml/dtd/Scanner.scala
+++ b/src/library/scala/xml/dtd/Scanner.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -86,7 +86,7 @@ class Scanner extends Tokens with parsing.TokenTests {
}
final def name = {
- val sb = new compat.StringBuilder()
+ val sb = new StringBuilder()
do { sb.append(c); next } while (isNameChar(c));
value = sb.toString()
NAME
diff --git a/src/library/scala/xml/dtd/ValidationException.scala b/src/library/scala/xml/dtd/ValidationException.scala
index a37d6f3231..021fca54fd 100644
--- a/src/library/scala/xml/dtd/ValidationException.scala
+++ b/src/library/scala/xml/dtd/ValidationException.scala
@@ -1,7 +1,7 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://www.scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
@@ -9,37 +9,38 @@
// $Id$
-package scala.xml.dtd;
+package scala.xml.dtd
-case class ValidationException( e:String ) extends Exception( e );
+case class ValidationException(e: String) extends Exception(e)
+/**
+ * @author Burak Emir
+ */
object MakeValidationException {
- def fromFixedAttribute( k: String, value: String, actual: String ) =
- ValidationException("value of attribute " + k + " FIXED to \""+value+"\", but document tries \""+actual+"\"");
+ def fromFixedAttribute(k: String, value: String, actual: String) =
+ ValidationException("value of attribute " + k + " FIXED to \""+value+"\", but document tries \""+actual+"\"")
def fromNonEmptyElement() = {
- new ValidationException("element should be *empty*");
+ new ValidationException("element should be *empty*")
}
def fromUndefinedElement( label:String ) =
- new ValidationException("element \""+ label +"\" not allowed here");
+ new ValidationException("element \""+ label +"\" not allowed here")
def fromUndefinedAttribute( key:String ) =
- new ValidationException("attribute " + key +" not allowed here" );
+ new ValidationException("attribute " + key +" not allowed here" )
def fromMissingAttribute( allKeys:scala.collection.Set[String] ) = {
- val sb = new compat.StringBuilder();
- sb.append("missing value for REQUIRED attribute");
- if( allKeys.size > 1 ) sb.append('s');
- val it = allKeys.elements;
+ val sb = new StringBuilder("missing value for REQUIRED attribute")
+ if (allKeys.size > 1) sb.append('s');
+ val it = allKeys.elements
while (it.hasNext) {
sb.append('\'').append(it.next).append('\'')
}
- new ValidationException(sb.toString());
+ new ValidationException(sb.toString())
}
- def fromMissingAttribute( key: String, tpe: String ) = {
- new ValidationException("missing value for REQUIRED attribute "+key+" of type "+tpe);
- }
+ def fromMissingAttribute(key: String, tpe: String) =
+ new ValidationException("missing value for REQUIRED attribute "+key+" of type "+tpe)
}
diff --git a/src/library/scala/xml/parsing/MarkupParser.scala b/src/library/scala/xml/parsing/MarkupParser.scala
index e8cd0edb85..58d6858d7d 100644
--- a/src/library/scala/xml/parsing/MarkupParser.scala
+++ b/src/library/scala/xml/parsing/MarkupParser.scala
@@ -105,7 +105,7 @@ trait MarkupParser extends AnyRef with TokenTests { self: MarkupParser with Mar
m("version") match {
case null => ;
- case Text("1.0") => info_ver = Some("1.0"); n = n + 1
+ case Text("1.0") => info_ver = Some("1.0"); n += 1
case _ => reportSyntaxError("cannot deal with versions != 1.0")
}
@@ -116,13 +116,13 @@ trait MarkupParser extends AnyRef with TokenTests { self: MarkupParser with Mar
reportSyntaxError("\"" + enc + "\" is not a valid encoding")
else {
info_enc = Some(enc.toString())
- n = n + 1
+ n += 1
}
}
m("standalone") match {
case null => ;
- case Text("yes") => info_stdl = Some(true); n = n + 1
- case Text("no") => info_stdl = Some(false); n = n + 1
+ case Text("yes") => info_stdl = Some(true); n += 1
+ case Text("no") => info_stdl = Some(false); n += 1
case _ => reportSyntaxError("either 'yes' or 'no' expected")
}
@@ -144,7 +144,7 @@ trait MarkupParser extends AnyRef with TokenTests { self: MarkupParser with Mar
m("version") match {
case null => ;
- case Text("1.0") => info_ver = Some("1.0"); n = n + 1
+ case Text("1.0") => info_ver = Some("1.0"); n += 1
case _ => reportSyntaxError("cannot deal with versions != 1.0")
}
@@ -155,7 +155,7 @@ trait MarkupParser extends AnyRef with TokenTests { self: MarkupParser with Mar
reportSyntaxError("\"" + enc + "\" is not a valid encoding")
else {
info_enc = Some(enc.toString())
- n = n + 1
+ n += 1
}
}
@@ -259,7 +259,7 @@ trait MarkupParser extends AnyRef with TokenTests { self: MarkupParser with Mar
/** munch expected XML token, report syntax error for unexpected
*/
- def xToken(that: Char): Unit = {
+ def xToken(that: Char) {
if (ch == that)
nextch
else {
diff --git a/test/files/jvm5/stringbuilder.scala b/test/files/jvm5/stringbuilder.scala
new file mode 100644
index 0000000000..c39a5d7600
--- /dev/null
+++ b/test/files/jvm5/stringbuilder.scala
@@ -0,0 +1,85 @@
+/* $Id: $ */
+
+import testing.SUnit._
+
+/** Test the Scala implementation of class <code>scala.StringBuilder</code>.
+ *
+ * @author Stephane Micheloud
+ */
+object Test extends TestConsoleMain {
+ def suite = new TestSuite(
+ Test1, //ctor, reverse
+ Test2, //append
+ Test3, //insert
+ Test4 //indexOf, lastIndexOf
+ )
+}
+
+object Test1 extends TestCase("ctor") with Assert {
+ override def enableStackTrace = false
+ override def runTest {
+ val j0 = new java.lang.StringBuilder("abc") // Java 1.5+
+ val s0 = new StringBuilder("abc")
+ assertEquals("s0 equals j0", false, s0 equals j0)
+ assertEquals("s0.toString equals j0.toString", true, s0.toString equals j0.toString)
+
+ val str = """
+Scala is a general purpose programming language designed to express common programming patterns in a concise, elegant, and type-safe way. It smoothly integrates features of object-oriented and functional languages. It is also fully interoperable with Java."""
+ val j1 = new java.lang.StringBuilder(100) append str
+ val s1 = new java.lang.StringBuilder(100) append str
+ assertEquals("s1.toString equals j1.toString", true, s1.toString equals j1.toString)
+
+ val j2 = j0 reverse
+ val s2 = s0 reverse;
+ //println("j2="+j2+", s2="+s2)//debug
+ assertEquals("s2.toString equals j2.toString", true, s2.toString equals j2.toString)
+
+ val j3 = j2; j3 setCharAt (0, j3 charAt 2)
+ val s3 = s2; s3(0) = s3(2)
+ //println("j3="+j3+", s3="+s3)//debug
+ assertEquals("s3.toString equals j3.toString", true, s3.toString equals j3.toString)
+ }
+}
+
+object Test2 extends TestCase("append") with Assert {
+ override def enableStackTrace = false
+ override def runTest {
+ val j0 = new java.lang.StringBuilder("abc") // Java 1.5+
+ val s0 = new StringBuilder("abc")
+
+ val j1 = j0 append true append 'a' append 9 append -1L append 1.2e-10f append -2.1e+100d
+ val s1 = s0 append true append 'a' append 9 append -1L append 1.2e-10f append -2.1e+100d
+ assertEquals("s1.toString equals j1.toString", true, s1.toString equals j1.toString)
+ }
+}
+
+object Test3 extends TestCase("insert") with Assert {
+ override def enableStackTrace = false
+ override def runTest {
+ val j0 = new java.lang.StringBuilder("abc") // Java 1.5+
+ val s0 = new StringBuilder("abc")
+
+ val j1 = j0 insert (0, true) insert (0, 'a') insert (0, 9) insert (0, -1L)
+ val s1 = s0 insert (0, true) insert (0, 'a') insert (0, 9) insert (0, -1L)
+ //println("j1="+j1+", s1="+s1)//debug
+ assertEquals("s1.toString equals j1.toString", true, s1.toString equals j1.toString)
+ }
+}
+
+object Test4 extends TestCase("indefOf") with Assert {
+ override def enableStackTrace = false
+ override def runTest {
+ val j0 = new java.lang.StringBuilder("abc") // Java 1.5+
+ val s0 = new StringBuilder("abc")
+
+ val j1 = j0 indexOf("c")
+ val s1 = s0 indexOf("c")
+ //println("j1="+j1+", s1="+s1)//debug
+ assertEquals("s1 == j1", true, s1 == j1)
+
+ val j2 = j0 append "123abc" lastIndexOf("c")
+ val s2 = s0 append "123abc" lastIndexOf("c")
+ //println("j2="+j2+", s2="+s2)//debug
+ assertEquals("s2 == j2", true, s2 == j2)
+ }
+}