summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala24
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Definitions.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/CleanUp.scala7
-rw-r--r--src/dotnet-library/scala/Console.scala24
-rw-r--r--src/dotnet-library/scala/Math.scala46
-rw-r--r--src/dotnet-library/scala/Predef.scala196
-rw-r--r--src/dotnet-library/scala/Symbol.scala9
-rw-r--r--src/dotnet-library/scala/compat/StringBuilder.scala82
-rw-r--r--src/dotnet-library/scala/runtime/RichChar.scala7
-rw-r--r--src/dotnet-library/scala/runtime/RichString.scala2
-rw-r--r--src/dotnet-library/scala/util/DynamicVariable.scala83
-rw-r--r--src/dotnet-library/scala/util/Fluid.scala78
12 files changed, 287 insertions, 273 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala
index fc95c4bfd9..2c883c2513 100644
--- a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala
+++ b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala
@@ -458,18 +458,18 @@ abstract class GenMSIL extends SubComponent {
log("output file name: " + filename)
try {
massembly.Save(filename)
- val fm = Properties.ilasmFormat
- if (fm != null) {
- val exeName = new File(outDir, assemName + ".exe").getPath()
- val cmd = fm.format(Array(/*output*/exeName, /*input*/filename))
- try {
- Runtime.getRuntime().exec(cmd)
- } catch {
- case ex: java.io.IOException =>
- Console.println("Cannot run command: " + cmd)
- exit(1)
- }
- }
+// val fm = Properties.ilasmFormat
+// if (fm != null) {
+// val exeName = new File(outDir, assemName + ".exe").getPath()
+// val cmd = fm.format(Array(/*output*/exeName, /*input*/filename))
+// try {
+// Runtime.getRuntime().exec(cmd)
+// } catch {
+// case ex: java.io.IOException =>
+// Console.println("Cannot run command: " + cmd)
+// exit(1)
+// }
+// }
} catch {
case _: Error => abort("Could not save file " + filename)
}
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
index 566568b16a..d98362280b 100644
--- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
@@ -761,7 +761,7 @@ trait Definitions {
StringClass = getClass(if (forMSIL) "System.String" else "java.lang.String")
ClassClass = getClass(if (forMSIL) "System.Type" else "java.lang.Class")
- MethodClass = getClass("java.lang.reflect.Method")
+ MethodClass = if (forMSIL) null else getClass("java.lang.reflect.Method")
ThrowableClass = getClass(if (forMSIL) "System.Exception" else "java.lang.Throwable")
NullPointerExceptionClass = getClass(if (forMSIL) "System.NullReferenceException"
else "java.lang.NullPointerException")
diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
index a734078614..844856355b 100644
--- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala
+++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
@@ -292,7 +292,7 @@ abstract class CleanUp extends Transform {
/* end of dynamic call transformer. */
- case Template(parents, self, body) =>
+ case Template(parents, self, body) if !forMSIL =>
localTyper = typer.atOwner(tree, currentOwner)
if (settings.target.value != "jvm-1.5" && !forMSIL) {
classConstantMeth.clear
@@ -300,13 +300,14 @@ abstract class CleanUp extends Transform {
val body1 = transformTrees(body)
copy.Template(tree, parents, self, newDefs.toList ::: body1)
} else super.transform(tree)
- case Literal(c) if (c.tag == ClassTag) =>
+
+ case Literal(c) if (c.tag == ClassTag) && !forMSIL=>
val tpe = c.typeValue
atPos(tree.pos) {
localTyper.typed {
if (isValueClass(tpe.symbol))
Select(gen.mkAttributedRef(javaBoxClassModule(tpe.symbol)), "TYPE")
- else if (settings.target.value != "jvm-1.5" && !forMSIL)
+ else if (settings.target.value != "jvm-1.5")
Apply(
gen.mkAttributedRef(classConstantMethod(tree.pos, signature(tpe))),
List())
diff --git a/src/dotnet-library/scala/Console.scala b/src/dotnet-library/scala/Console.scala
index 900f8f18e3..23d70cd081 100644
--- a/src/dotnet-library/scala/Console.scala
+++ b/src/dotnet-library/scala/Console.scala
@@ -12,10 +12,12 @@
package scala
-import Predef._
-import scala.util.Fluid
import System.IO.{TextReader,TextWriter}
+import scala.util.DynamicVariable
+import Predef._
+
+
/** The <code>Console</code> object implements functionality for
* printing Scala values on the terminal. There are also functions
* for reading specific values. <code>Console</code> also defines
@@ -54,17 +56,17 @@ object Console {
final val REVERSED = "\033[7m"
final val INVISIBLE = "\033[8m"
- private val outFluid = new Fluid[TextWriter](System.Console.Out)
- private val inFluid = new Fluid[TextReader](System.Console.In)
+ private val outVar = new DynamicVariable[TextWriter](System.Console.Out)
+ private val inVar = new DynamicVariable[TextReader](System.Console.In)
- def out = outFluid.value
- def in = inFluid.value
+ def out = outVar.value
+ def in = inVar.value
/** Set the default output stream.
*
* @param out the new output stream.
*/
- def setOut(out: TextWriter): Unit = outFluid.value = out
+ def setOut(out: TextWriter): Unit = outVar.value = out
/** Set the default output stream for the duration
* of execution of one thunk.
@@ -74,14 +76,15 @@ object Console {
* the new output stream active
*/
def withOut[T](out: TextWriter)(thunk: =>T): T =
- outFluid.withValue(out)(thunk)
+ outVar.withValue(out)(thunk)
+
/** Set the default input stream.
*
* @param reader specifies the new input stream.
*/
def setIn(reader: TextReader): Unit = {
- inFluid.value = reader
+ inVar.value = reader
}
/** Set the default input stream for the duration
@@ -92,8 +95,7 @@ object Console {
* the new input stream active
*/
def withIn[T](reader: TextReader)(thunk: =>T): T =
- inFluid.withValue(reader)(thunk)
-
+ inVar.withValue(reader)(thunk)
/** Print an object on the terminal.
*
diff --git a/src/dotnet-library/scala/Math.scala b/src/dotnet-library/scala/Math.scala
index ace7d54c0a..e1ef9e771e 100644
--- a/src/dotnet-library/scala/Math.scala
+++ b/src/dotnet-library/scala/Math.scala
@@ -1,7 +1,7 @@
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
@@ -16,55 +16,55 @@ import Predef._
object Math {
- /** The smalles possible value for scala.Byte. */
+ /** The smallest possible value for <a href="Byte.html" target="_self">scala.Byte</a>. */
val MIN_BYTE = System.Byte.MinValue
- /** The greatest possible value for scala.Byte. */
+ /** The greatest possible value for <a href="Byte.html" target="_self">scala.Byte</a>. */
val MAX_BYTE = System.Byte.MaxValue
- /** The smalles possible value for scala.Short. */
+ /** The smallest possible value for <a href="Short.html" target="_self">scala.Short</a>. */
val MIN_SHORT = System.Int16.MinValue
- /** The greatest possible value for scala.Short. */
+ /** The greatest possible value for <a href="Short.html" target="_self">scala.Short</a>. */
val MAX_SHORT = System.Int16.MaxValue
- /** The smalles possible value for scala.Char. */
+ /** The smallest possible value for <a href="Char.html" target="_self">scala.Char</a>. */
val MIN_CHAR = System.Char.MinValue
- /** The greatest possible value for scala.Char. */
+ /** The greatest possible value for <a href="Char.html" target="_self">scala.Char</a>. */
val MAX_CHAR = System.Char.MaxValue
- /** The smalles possible value for scala.Int. */
+ /** The smallest possible value for <a href="Int.html" target="_self">scala.Int</a>. */
val MIN_INT = System.Int32.MinValue
- /** The greatest possible value for scala.Int. */
+ /** The greatest possible value for <a href="Int.html" target="_self">scala.Int</a>. */
val MAX_INT = System.Int32.MaxValue
- /** The smalles possible value for scala.Long. */
+ /** The smallest possible value for <a href="Long.html" target="_self">scala.Long</a>. */
val MIN_LONG = System.Int64.MinValue
- /** The greatest possible value for scala.Long. */
+ /** The greatest possible value for <a href="Long.html" target="_self">scala.Long</a>. */
val MAX_LONG = System.Int64.MaxValue
- /** The smalles possible value for scala.Float. */
+ /** The smallest possible value for <a href="Float.html" target="_self">scala.Float</a>. */
val MIN_FLOAT = System.Single.MinValue
- /** The smalles difference between two values of scala.Float. */
+ /** The smallest difference between two values of <a href="Float.html" target="_self">scala.Float</a>. */
val EPS_FLOAT = System.Single.Epsilon
- /** The greatest possible value for scala.Float. */
+ /** The greatest possible value for <a href="Float.html" target="_self">scala.Float</a>. */
val MAX_FLOAT = System.Single.MinValue
- /** A value of type scala.Float that represents no number. */
+ /** A value of type <a href="Float.html" target="_self">scala.Float</a> that represents no number. */
//val NaN_FLOAT = System.Single.NaN
- /** Negative infinity of type scala.Float*/
+ /** Negative infinity of type <a href="Float.html" target="_self">scala.Float</a>. */
//val NEG_INF_FLOAT = System.Double.NegativeInfinity
- /** Positive infinity of type scala.Float*/
+ /** Positive infinity of type <a href="Float.html" target="_self">scala.Float</a>. */
//val POS_INF_FLOAT = System.Double.PositiveInfinity
- /** The smalles possible value for scala.Double. */
+ /** The smallest possible value for <a href="Double.html" target="_self">scala.Double</a>. */
val MIN_DOUBLE = System.Double.MinValue
- /** The smalles difference between two values of scala.Double. */
+ /** The smallest difference between two values of <a href="Double.html" target="_self">scala.Double</a>. */
val EPS_DOUBLE = System.Double.Epsilon
- /** The greatest possible value for scala.Double. */
+ /** The greatest possible value for <a href="Double.html" target="_self">scala.Double</a>. */
val MAX_DOUBLE = System.Double.MaxValue
- /** A value of type scala.Double that represents no number. */
+ /** A value of type <a href="Double.html" target="_self">scala.Double</a> that represents no number. */
//val NaN_DOUBLE = System.Double.NaN
- /** Negative infinity of type scala.Double*/
+ /** Negative infinity of type <a href="Double.html" target="_self">scala.Double</a>. */
//val NEG_INF_DOUBLE = System.Double.NegativeInfinity
- /** Positive infinity of type scala.Double*/
+ /** Positive infinity of type <a href="Double.html" target="_self">scala.Double</a>. */
//val POS_INF_DOUBLE = System.Double.PositiveInfinity
/** The <code>double</code> value that is closer than any other to
diff --git a/src/dotnet-library/scala/Predef.scala b/src/dotnet-library/scala/Predef.scala
index 142181d91f..50bac1d91b 100644
--- a/src/dotnet-library/scala/Predef.scala
+++ b/src/dotnet-library/scala/Predef.scala
@@ -18,34 +18,35 @@ package scala
*/
object Predef {
- // classOf dummy -------------------------------------------------
+ // classOf dummy ------------------------------------------------------
/** Return the runtime representation of a class type. */
def classOf[T]: Class = null
- // aliases -------------------------------------------------------
+ // aliases ------------------------------------------------------------
- type byte = scala.Byte
- type short = scala.Short
- type char = scala.Char
- type int = scala.Int
- type long = scala.Long
- type float = scala.Float
- type double = scala.Double
+ type byte = scala.Byte
+ type short = scala.Short
+ type char = scala.Char
+ type int = scala.Int
+ type long = scala.Long
+ type float = scala.Float
+ type double = scala.Double
type boolean = scala.Boolean
- type unit = scala.Unit
+ type unit = scala.Unit
- type All = Nothing
+ type All = Nothing
type AllRef = Null
- type String = System.String
+ type String = System.String
type StringBuilder = compat.StringBuilder
- type Class = System.Type
- type Runnable = scala.runtime.Runnable
+ type Class = System.Type
+ type Runnable = scala.runtime.Runnable
type Throwable = System.Exception
type Exception = System.Exception
- type Error = System.Exception
+ type Error = System.Exception
+
type RuntimeException = System.Exception
type NullPointerException = System.NullReferenceException
type ClassCastException = System.InvalidCastException
@@ -56,19 +57,18 @@ object Predef {
type NoSuchElementException = System.InvalidOperationException
//type NumberFormatException = java.lang.NumberFormatException
- // --- Miscelleaneous -----------------------------------------------
+ // miscelleaneous -----------------------------------------------------
//val $scope = scala.xml.TopScope
- type Function[-a,+b] = Function1[a,b]
+ type Function[-A, +B] = Function1[A, B]
- type Map[a, b] = collection.immutable.Map[a, b]
- type Set[a] = collection.immutable.Set[a]
+ type Map[A, B] = collection.immutable.Map[A, B]
+ type Set[A] = collection.immutable.Set[A]
val Map = collection.immutable.Map
val Set = collection.immutable.Set
-
// errors and asserts -------------------------------------------------
def error(message: String): Nothing = throw new Error(message)
@@ -100,36 +100,36 @@ object Predef {
throw new Error("assumption failed: " + message)
}
- // --- Tupling ----------------------------------------------
+ // tupling ------------------------------------------------------------
- type Pair[+a, +b] = Tuple2[a, b]
+ type Pair[+A, +B] = Tuple2[A, B]
object Pair {
- def apply[a, b](x: a, y: b) = Tuple2(x, y)
- def unapply[a, b](x: Tuple2[a, b]): Option[Tuple2[a, b]] = Some(x)
+ def apply[A, B](x: A, y: B) = Tuple2(x, y)
+ def unapply[A, B](x: Tuple2[A, B]): Option[Tuple2[A, B]] = Some(x)
}
- type Triple[+a, +b, +c] = Tuple3[a, b, c]
+ type Triple[+A, +B, +C] = Tuple3[A, B, C]
object Triple {
- def apply[a, b, c](x: a, y: b, z: c) = Tuple3(x, y, z)
- def unapply[a, b, c](x: Tuple3[a, b, c]): Option[Tuple3[a, b, c]] = Some(x)
+ def apply[A, B, C](x: A, y: B, z: C) = Tuple3(x, y, z)
+ def unapply[A, B, C](x: Tuple3[A, B, C]): Option[Tuple3[A, B, C]] = Some(x)
}
- class ArrowAssoc[a](x: a) {
- def -> [b](y: b): Tuple2[a, b] = Tuple2(x, y)
+ class ArrowAssoc[A](x: A) {
+ def -> [B](y: B): Tuple2[A, B] = Tuple2(x, y)
}
- implicit def any2ArrowAssoc[a](x: a): ArrowAssoc[a] = new ArrowAssoc(x)
+ implicit def any2ArrowAssoc[A](x: A): ArrowAssoc[A] = new ArrowAssoc(x)
- def Tuple[a1](x1: a1) = Tuple1(x1)
- def Tuple[a1, a2](x1: a1, x2: a2) = Tuple2(x1, x2)
- def Tuple[a1, a2, a3](x1: a1, x2: a2, x3: a3) = Tuple3(x1, x2, x3)
- def Tuple[a1, a2, a3, a4](x1: a1, x2: a2, x3: a3, x4: a4) = Tuple4(x1, x2, x3, x4)
- def Tuple[a1, a2, a3, a4, a5](x1: a1, x2: a2, x3: a3, x4: a4, x5: a5) = Tuple5(x1, x2, x3, x4, x5)
- def Tuple[a1, a2, a3, a4, a5, a6](x1: a1, x2: a2, x3: a3, x4: a4, x5: a5, x6: a6) = Tuple6(x1, x2, x3, x4, x5, x6)
- def Tuple[a1, a2, a3, a4, a5, a6, a7](x1: a1, x2: a2, x3: a3, x4: a4, x5: a5, x6: a6, x7: a7) = Tuple7(x1, x2, x3, x4, x5, x6, x7)
- def Tuple[a1, a2, a3, a4, a5, a6, a7, a8](x1: a1, x2: a2, x3: a3, x4: a4, x5: a5, x6: a6, x7: a7, x8: a8) = Tuple8(x1, x2, x3, x4, x5, x6, x7, x8)
- def Tuple[a1, a2, a3, a4, a5, a6, a7, a8, a9](x1: a1, x2: a2, x3: a3, x4: a4, x5: a5, x6: a6, x7: a7, x8: a8, x9: a9) = Tuple9(x1, x2, x3, x4, x5, x6, x7, x8, x9)
+ def Tuple[A1](x1: A1) = Tuple1(x1)
+ def Tuple[A1, A2](x1: A1, x2: A2) = Tuple2(x1, x2)
+ def Tuple[A1, A2, A3](x1: A1, x2: A2, x3: A3) = Tuple3(x1, x2, x3)
+ def Tuple[A1, A2, A3, A4](x1: A1, x2: A2, x3: A3, x4: A4) = Tuple4(x1, x2, x3, x4)
+ def Tuple[A1, A2, A3, A4, A5](x1: A1, x2: A2, x3: A3, x4: A4, x5: A5) = Tuple5(x1, x2, x3, x4, x5)
+ def Tuple[A1, A2, A3, A4, A5, A6](x1: A1, x2: A2, x3: A3, x4: A4, x5: A5, x6: A6) = Tuple6(x1, x2, x3, x4, x5, x6)
+ def Tuple[A1, A2, A3, A4, A5, A6, A7](x1: A1, x2: A2, x3: A3, x4: A4, x5: A5, x6: A6, x7: A7) = Tuple7(x1, x2, x3, x4, x5, x6, x7)
+ def Tuple[A1, A2, A3, A4, A5, A6, A7, A8](x1: A1, x2: A2, x3: A3, x4: A4, x5: A5, x6: A6, x7: A7, x8: A8) = Tuple8(x1, x2, x3, x4, x5, x6, x7, x8)
+ def Tuple[A1, A2, A3, A4, A5, A6, A7, A8, A9](x1: A1, x2: A2, x3: A3, x4: A4, x5: A5, x6: A6, x7: A7, x8: A8, x9: A9) = Tuple9(x1, x2, x3, x4, x5, x6, x7, x8, x9)
- // printing and reading ----------------------------------------------
+ // printing and reading -----------------------------------------------
def print(x: Any) = Console.print(x)
def println() = Console.println()
@@ -152,19 +152,19 @@ object Predef {
//def readf2(format: String) = Console.readf2(format)
//def readf3(format: String) = Console.readf3(format)
- // views -------------------------------------------------------------
+ // views --------------------------------------------------------------
- implicit def identity[a](x: a): a = x
+ implicit def identity[A](x: A): A = x
- implicit def byteWrapper(x: byte) = new runtime.RichByte(x)
- implicit def shortWrapper(x: short) = new runtime.RichShort(x)
- implicit def intWrapper(x: int) = new runtime.RichInt(x)
- implicit def charWrapper(c: char) = new runtime.RichChar(c)
- implicit def longWrapper(x: long) = new runtime.RichLong(x)
- implicit def floatWrapper(x: float) = new runtime.RichFloat(x)
- implicit def doubleWrapper(x: double) = new runtime.RichDouble(x)
+ implicit def byteWrapper(x: Byte) = new runtime.RichByte(x)
+ implicit def shortWrapper(x: Short) = new runtime.RichShort(x)
+ implicit def intWrapper(x: Int) = new runtime.RichInt(x)
+ implicit def charWrapper(c: Char) = new runtime.RichChar(c)
+ implicit def longWrapper(x: Long) = new runtime.RichLong(x)
+ implicit def floatWrapper(x: Float) = new runtime.RichFloat(x)
+ implicit def doubleWrapper(x: Double) = new runtime.RichDouble(x)
- implicit def booleanWrapper(x: boolean) = new runtime.RichBoolean(x)
+ implicit def booleanWrapper(x: Boolean) = new runtime.RichBoolean(x)
implicit def stringWrapper(x: String) = new runtime.RichString(x)
@@ -178,15 +178,15 @@ object Predef {
implicit def getClassWrapper(obj: AnyRef) = new GetClassWrapper(obj)
implicit def classWrapper(clazz: Class): runtime.RichClass = new runtime.RichClass(clazz)
- implicit def unit2ordered(x: unit): Ordered[unit] = new Ordered[unit] with Proxy {
+ implicit def unit2ordered(x: Unit): Ordered[Unit] = new Ordered[Unit] with Proxy {
def self: Any = x
- def compare (y: unit): int = 0
+ def compare(y: Unit): Int = 0
}
- implicit def iterable2ordered[a <% Ordered[a]](xs: Iterable[a]): Ordered[Iterable[a]] =
- new Ordered[Iterable[a]] with Proxy {
+ implicit def iterable2ordered[A <% Ordered[A]](xs: Iterable[A]): Ordered[Iterable[A]] =
+ new Ordered[Iterable[A]] with Proxy {
val self = xs
- def compare (that: Iterable[a]) = {
+ def compare(that: Iterable[A]): Int = {
var res = 0
val these = xs.elements
val those = that.elements
@@ -196,110 +196,110 @@ object Predef {
}
}
- implicit def tuple22ordered[a1 <% Ordered[a1], a2 <% Ordered[a2]](x: Tuple2[a1, a2]): Ordered[Tuple2[a1, a2]] =
- new Ordered[Tuple2[a1, a2]] with Proxy {
+ implicit def tuple22ordered[A1 <% Ordered[A1], A2 <% Ordered[A2]](x: Tuple2[A1, A2]): Ordered[Tuple2[A1, A2]] =
+ new Ordered[Tuple2[A1, A2]] with Proxy {
val self = x
- def compare (y: Tuple2[a1, a2]): Int = {
+ def compare(y: Tuple2[A1, A2]): Int = {
val res = x._1 compare y._1
if (res == 0) x._2 compare y._2
else res
}
}
- implicit def tuple32ordered[a1 <% Ordered[a1], a2 <% Ordered[a2], a3 <% Ordered[a3]](x: Tuple3[a1, a2, a3]): Ordered[Tuple3[a1, a2, a3]] =
- new Ordered[Tuple3[a1, a2, a3]] with Proxy {
+ implicit def tuple32ordered[A1 <% Ordered[A1], A2 <% Ordered[A2], A3 <% Ordered[A3]](x: Tuple3[A1, A2, A3]): Ordered[Tuple3[A1, A2, A3]] =
+ new Ordered[Tuple3[A1, A2, A3]] with Proxy {
val self = x
- def compare (y: Tuple3[a1, a2, a3]): Int = {
+ def compare(y: Tuple3[A1, A2, A3]): Int = {
val res = x._1 compare y._1
if (res == 0) Tuple2(x._2, x._3) compare Tuple2(y._2, y._3)
else res
}
}
- implicit def tuple42ordered[a1 <% Ordered[a1], a2 <% Ordered[a2], a3 <% Ordered[a3], a4 <% Ordered[a4]](x: Tuple4[a1, a2, a3, a4]): Ordered[Tuple4[a1, a2, a3, a4]] =
- new Ordered[Tuple4[a1, a2, a3, a4]] with Proxy {
+ implicit def tuple42ordered[A1 <% Ordered[A1], A2 <% Ordered[A2], A3 <% Ordered[A3], A4 <% Ordered[A4]](x: Tuple4[A1, A2, A3, A4]): Ordered[Tuple4[A1, A2, A3, A4]] =
+ new Ordered[Tuple4[A1, A2, A3, A4]] with Proxy {
val self = x
- def compare (y: Tuple4[a1, a2, a3, a4]): Int = {
+ def compare(y: Tuple4[A1, A2, A3, A4]): Int = {
val res = x._1 compare y._1
if (res == 0) Tuple3(x._2, x._3, x._4) compare Tuple3(y._2, y._3, y._4)
else res
}
}
- implicit def tuple52ordered[a1 <% Ordered[a1], a2 <% Ordered[a2], a3 <% Ordered[a3], a4 <% Ordered[a4], a5 <% Ordered[a5]](x: Tuple5[a1, a2, a3, a4, a5]): Ordered[Tuple5[a1, a2, a3, a4, a5]] =
- new Ordered[Tuple5[a1, a2, a3, a4, a5]] with Proxy {
+ implicit def tuple52ordered[A1 <% Ordered[A1], A2 <% Ordered[A2], A3 <% Ordered[A3], A4 <% Ordered[A4], A5 <% Ordered[A5]](x: Tuple5[A1, A2, A3, A4, A5]): Ordered[Tuple5[A1, A2, A3, A4, A5]] =
+ new Ordered[Tuple5[A1, A2, A3, A4, A5]] with Proxy {
val self = x
- def compare (y: Tuple5[a1, a2, a3, a4, a5]): Int = {
+ def compare(y: Tuple5[A1, A2, A3, A4, A5]): Int = {
val res = x._1 compare y._1
if (res == 0) Tuple4(x._2, x._3, x._4, x._5) compare Tuple4(y._2, y._3, y._4, y._5)
else res
}
}
- implicit def tuple62ordered[a1 <% Ordered[a1], a2 <% Ordered[a2], a3 <% Ordered[a3], a4 <% Ordered[a4], a5 <% Ordered[a5], a6 <% Ordered[a6]](x: Tuple6[a1, a2, a3, a4, a5, a6]): Ordered[Tuple6[a1, a2, a3, a4, a5, a6]] =
- new Ordered[Tuple6[a1, a2, a3, a4, a5, a6]] with Proxy {
+ implicit def tuple62ordered[A1 <% Ordered[A1], A2 <% Ordered[A2], A3 <% Ordered[A3], A4 <% Ordered[A4], A5 <% Ordered[A5], A6 <% Ordered[A6]](x: Tuple6[A1, A2, A3, A4, A5, A6]): Ordered[Tuple6[A1, A2, A3, A4, A5, A6]] =
+ new Ordered[Tuple6[A1, A2, A3, A4, A5, A6]] with Proxy {
val self = x
- def compare (y: Tuple6[a1, a2, a3, a4, a5, a6]): Int = {
+ def compare(y: Tuple6[A1, A2, A3, A4, A5, A6]): Int = {
val res = x._1 compare y._1
if (res == 0) Tuple5(x._2, x._3, x._4, x._5, x._6) compare Tuple5(y._2, y._3, y._4, y._5, y._6)
else res
}
}
- implicit def tuple72ordered[a1 <% Ordered[a1], a2 <% Ordered[a2], a3 <% Ordered[a3], a4 <% Ordered[a4], a5 <% Ordered[a5], a6 <% Ordered[a6], a7 <% Ordered[a7]](x: Tuple7[a1, a2, a3, a4, a5, a6, a7]): Ordered[Tuple7[a1, a2, a3, a4, a5, a6, a7]] =
- new Ordered[Tuple7[a1, a2, a3, a4, a5, a6, a7]] with Proxy {
+ implicit def tuple72ordered[A1 <% Ordered[A1], A2 <% Ordered[A2], A3 <% Ordered[A3], A4 <% Ordered[A4], A5 <% Ordered[A5], A6 <% Ordered[A6], A7 <% Ordered[A7]](x: Tuple7[A1, A2, A3, A4, A5, A6, A7]): Ordered[Tuple7[A1, A2, A3, A4, A5, A6, A7]] =
+ new Ordered[Tuple7[A1, A2, A3, A4, A5, A6, A7]] with Proxy {
val self = x
- def compare (y: Tuple7[a1, a2, a3, a4, a5, a6, a7]): Int = {
+ def compare(y: Tuple7[A1, A2, A3, A4, A5, A6, A7]): Int = {
val res = x._1 compare y._1
if (res == 0) Tuple6(x._2, x._3, x._4, x._5, x._6, x._7) compare Tuple6(y._2, y._3, y._4, y._5, y._6, y._7)
else res
}
}
- implicit def tuple82ordered[a1 <% Ordered[a1], a2 <% Ordered[a2], a3 <% Ordered[a3], a4 <% Ordered[a4], a5 <% Ordered[a5], a6 <% Ordered[a6], a7 <% Ordered[a7], a8 <% Ordered[a8]](x: Tuple8[a1, a2, a3, a4, a5, a6, a7, a8]): Ordered[Tuple8[a1, a2, a3, a4, a5, a6, a7, a8]] =
- new Ordered[Tuple8[a1, a2, a3, a4, a5, a6, a7, a8]] with Proxy {
+ implicit def tuple82ordered[A1 <% Ordered[A1], A2 <% Ordered[A2], A3 <% Ordered[A3], A4 <% Ordered[A4], A5 <% Ordered[A5], A6 <% Ordered[A6], A7 <% Ordered[A7], A8 <% Ordered[A8]](x: Tuple8[A1, A2, A3, A4, A5, A6, A7, A8]): Ordered[Tuple8[A1, A2, A3, A4, A5, A6, A7, A8]] =
+ new Ordered[Tuple8[A1, A2, A3, A4, A5, A6, A7, A8]] with Proxy {
val self = x
- def compare (y: Tuple8[a1, a2, a3, a4, a5, a6, a7, a8]): Int = {
+ def compare(y: Tuple8[A1, A2, A3, A4, A5, A6, A7, A8]): Int = {
val res = x._1 compare y._1
if (res == 0) Tuple7(x._2, x._3, x._4, x._5, x._6, x._7, x._8) compare Tuple7(y._2, y._3, y._4, y._5, y._6, y._7, y._8)
else res
}
}
- implicit def tuple92ordered[a1 <% Ordered[a1], a2 <% Ordered[a2], a3 <% Ordered[a3], a4 <% Ordered[a4], a5 <% Ordered[a5], a6 <% Ordered[a6], a7 <% Ordered[a7], a8 <% Ordered[a8], a9 <% Ordered[a9]](x: Tuple9[a1, a2, a3, a4, a5, a6, a7, a8, a9]): Ordered[Tuple9[a1, a2, a3, a4, a5, a6, a7, a8, a9]] =
- new Ordered[Tuple9[a1, a2, a3, a4, a5, a6, a7, a8, a9]] with Proxy {
+ implicit def tuple92ordered[A1 <% Ordered[A1], A2 <% Ordered[A2], A3 <% Ordered[A3], A4 <% Ordered[A4], A5 <% Ordered[A5], A6 <% Ordered[A6], A7 <% Ordered[A7], A8 <% Ordered[A8], A9 <% Ordered[A9]](x: Tuple9[A1, A2, A3, A4, A5, A6, A7, A8, A9]): Ordered[Tuple9[A1, A2, A3, A4, A5, A6, A7, A8, A9]] =
+ new Ordered[Tuple9[A1, A2, A3, A4, A5, A6, A7, A8, A9]] with Proxy {
val self = x
- def compare (y: Tuple9[a1, a2, a3, a4, a5, a6, a7, a8, a9]): Int = {
+ def compare(y: Tuple9[A1, A2, A3, A4, A5, A6, A7, A8, A9]): Int = {
val res = x._1 compare y._1
if (res == 0) Tuple8(x._2, x._3, x._4, x._5, x._6, x._7, x._8, x._9) compare Tuple8(y._2, y._3, y._4, y._5, y._6, y._7, y._8, y._9)
else res
}
}
- implicit def byte2short(x: byte): short = x.toShort
- implicit def byte2int(x: byte): int = x.toInt
- implicit def byte2long(x: byte): long = x.toLong
- implicit def byte2float(x: byte): float = x.toFloat
- implicit def byte2double(x: byte): double = x.toDouble
+ implicit def byte2short(x: Byte): Short = x.toShort
+ implicit def byte2int(x: Byte): Int = x.toInt
+ implicit def byte2long(x: Byte): Long = x.toLong
+ implicit def byte2float(x: Byte): Float = x.toFloat
+ implicit def byte2double(x: Byte): Double = x.toDouble
- implicit def short2int(x: short): int = x.toInt
- implicit def short2long(x: short): long = x.toLong
- implicit def short2float(x: short): float = x.toFloat
- implicit def short2double(x: short): double = x.toDouble
+ implicit def short2int(x: Short): Int = x.toInt
+ implicit def short2long(x: Short): Long = x.toLong
+ implicit def short2float(x: Short): Float = x.toFloat
+ implicit def short2double(x: Short): Double = x.toDouble
- implicit def char2int(x: char): int = x.toInt
- implicit def char2long(x: char): long = x.toLong
- implicit def char2float(x: char): float = x.toFloat
- implicit def char2double(x: char): double = x.toDouble
+ implicit def char2int(x: Char): Int = x.toInt
+ implicit def char2long(x: Char): Long = x.toLong
+ implicit def char2float(x: Char): Float = x.toFloat
+ implicit def char2double(x: Char): Double = x.toDouble
- implicit def int2long(x: int): long = x.toLong
- implicit def int2float(x: int): float = x.toFloat
- implicit def int2double(x: int): double = x.toDouble
+ implicit def int2long(x: Int): Long = x.toLong
+ implicit def int2float(x: Int): Float = x.toFloat
+ implicit def int2double(x: Int): Double = x.toDouble
- implicit def long2float(x: long): float = x.toFloat
- implicit def long2double(x: long): double = x.toDouble
+ implicit def long2float(x: Long): Float = x.toFloat
+ implicit def long2double(x: Long): Double = x.toDouble
- implicit def float2double(x: float): double = x.toDouble
+ implicit def float2double(x: Float): Double = x.toDouble
def currentThread = System.Threading.Thread.CurrentThread
diff --git a/src/dotnet-library/scala/Symbol.scala b/src/dotnet-library/scala/Symbol.scala
index 91cdf065e4..27bc2de7e1 100644
--- a/src/dotnet-library/scala/Symbol.scala
+++ b/src/dotnet-library/scala/Symbol.scala
@@ -11,9 +11,6 @@
package scala
-//import scala.collection.jcl
-
-//private[scala] object internedSymbols extends jcl.HashMap[String, ref.WeakReference[Symbol]]
/** <p>
* Instances of <code>Symbol</code> can be created easily with
@@ -49,10 +46,4 @@ final case class Symbol(name: String) {
*/
def intern: Symbol = this
-// def intern: Symbol = synchronized { internedSymbols get name match {
-// case Some(sym) if sym.isValid => sym.apply
-// case _ =>
-// internedSymbols(name) = new ref.WeakReference(this); this
-// } }
-
}
diff --git a/src/dotnet-library/scala/compat/StringBuilder.scala b/src/dotnet-library/scala/compat/StringBuilder.scala
index 8417184235..1f2e6612ec 100644
--- a/src/dotnet-library/scala/compat/StringBuilder.scala
+++ b/src/dotnet-library/scala/compat/StringBuilder.scala
@@ -11,49 +11,61 @@
package scala.compat
+
import System.Text.{StringBuilder => StringBuffer}
-final class StringBuilder(str: StringBuffer) {
+
+/** Consult the documentation of java.lang.StringBuffer 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 charAt(i: Int): Char = str(i)
-
- def setCharAt(index: Int, c: Char): Unit = str(index) = c
-
- def append(x: Any): StringBuilder = { str.Append(x); this }
- def append(x: Boolean): StringBuilder = { str.Append(x); this }
- def append(x: Byte): StringBuilder = { str.Append(x); this }
- def append(x: Short): StringBuilder = { str.Append(x); this }
- def append(x: Char): StringBuilder = { str.Append(x); this }
- def append(x: Int): StringBuilder = { str.Append(x); this }
- def append(x: Long): StringBuilder = { str.Append(x); this }
- def append(x: Float): StringBuilder = { str.Append(x); this }
- def append(x: Double): StringBuilder = { str.Append(x); this }
- def append(x: String): StringBuilder = { str.Append(x); this }
- def append(x: Array[Char]): StringBuilder = { str.Append(x); this }
- def append(x: Array[Char], start: Int, length: Int): StringBuilder =
- { str.Append(x, start, length); this }
-
- def insert(at: Int, x: Any): StringBuilder = { str.Insert(at, x); this }
- def insert(at: Int, x: Boolean): StringBuilder = { str.Insert(at, x); this }
- def insert(at: Int, x: Byte): StringBuilder = { str.Insert(at, x); this }
- def insert(at: Int, x: Short): StringBuilder = { str.Insert(at, x); this }
- def insert(at: Int, x: Char): StringBuilder = { str.Insert(at, x); this }
- def insert(at: Int, x: Int): StringBuilder = { str.Insert(at, x); this }
- def insert(at: Int, x: Long): StringBuilder = { str.Insert(at, x); this }
- def insert(at: Int, x: Float): StringBuilder = { str.Insert(at, x); this }
- def insert(at: Int, x: Double): StringBuilder = { str.Insert(at, x); this }
- def insert(at: Int, x: String): StringBuilder = { str.Insert(at, x); this }
- def insert(at: Int, x: Array[Char]): StringBuilder = { str.Insert(at, x); this }
- def insert(at: Int, x: Array[Char], start: Int, length: Int): StringBuilder =
- { str.Insert(at, x, start, length); this }
+ 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 length(): Int = str.Length
+ def charAt(i: Int): Char = self(i)
+ def apply(i: Int): Char = self(i)
- def setLength(i: Int) = str.Capacity = i
+ 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 }
- override def toString() = str.toString()
}
diff --git a/src/dotnet-library/scala/runtime/RichChar.scala b/src/dotnet-library/scala/runtime/RichChar.scala
index e35663a6dd..285530e5be 100644
--- a/src/dotnet-library/scala/runtime/RichChar.scala
+++ b/src/dotnet-library/scala/runtime/RichChar.scala
@@ -11,6 +11,7 @@
package scala.runtime
+
import Predef.NoSuchElementException
/** <p>
@@ -30,12 +31,15 @@ import Predef.NoSuchElementException
* </p>
*/
final class RichChar(x: Char) extends Proxy with Ordered[Char] {
+
// Proxy.self
def self: Any = x
// Ordered[Char].compare
def compare (y: Char): Int = if (x < y) -1 else if (x > y) 1 else 0
+ def asDigit: Int = System.Char.GetNumericValue(x).toInt
+
def isControl: Boolean = System.Char.IsControl(x)
def isDigit: Boolean = System.Char.IsDigit(x)
def isLetter: Boolean = System.Char.IsLetter(x)
@@ -43,11 +47,10 @@ final class RichChar(x: Char) extends Proxy with Ordered[Char] {
def isLowerCase: Boolean = System.Char.IsLower(x)
def isUpperCase: Boolean = System.Char.IsUpper(x)
def isWhitespace: Boolean = System.Char.IsWhiteSpace(x)
+
def toLowerCase: Char = System.Char.ToLower(x)
def toUpperCase: Char = System.Char.ToUpper(x)
- def asDigit: Int = System.Char.GetNumericValue(x).toInt
-
/** Create an Iterator[Char] over the characters from 'x' to 'y' - 1
*/
def until(limit: Char): Iterator[Char] = new Iterator[Char] {
diff --git a/src/dotnet-library/scala/runtime/RichString.scala b/src/dotnet-library/scala/runtime/RichString.scala
index 667b972f72..b7fb269cbc 100644
--- a/src/dotnet-library/scala/runtime/RichString.scala
+++ b/src/dotnet-library/scala/runtime/RichString.scala
@@ -21,7 +21,7 @@ final class RichString(val self: String) extends Proxy with Seq[Char] with Order
// Seq[Char]
def length = self.length
- def elements = Iterator.fromString(self)
+ override def elements = Iterator.fromString(self)
/** Retrieve the n-th character of the string
*
diff --git a/src/dotnet-library/scala/util/DynamicVariable.scala b/src/dotnet-library/scala/util/DynamicVariable.scala
new file mode 100644
index 0000000000..101ebe9573
--- /dev/null
+++ b/src/dotnet-library/scala/util/DynamicVariable.scala
@@ -0,0 +1,83 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2006-2007, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+// $Id$
+
+
+package scala.util
+
+
+import Predef._
+import System.Threading.Thread
+import System.LocalDataStoreSlot
+
+/** <p>
+ * DynamicVariables provide a binding mechanism where the current
+ * value is found through <em>dynamic scope</em>, but where
+ * access to the variable itself is resolved through <em>static
+ * scope</em>.
+ * </p>
+ * <p>
+ * The current value can be retrieved with the
+ * <code>value</code> method. New values should be
+ * pushed using the <code>withValue</code> method.
+ * Values pushed via <code>withValue</code> only
+ * stay valid while the <code>withValue</code>'s
+ * <em>second</em> argument, a parameterless closure,
+ * executes. When the second argument finishes,
+ * the variable reverts to the previous value.
+ * </p>
+ * <p>
+ * Usage of <code>withValue</code> looks like this:
+ * </p>
+ * <blockquote><pre>
+ * someDynamicVariable.withValue(newValue) {
+ * // ... code called in here that calls value ...
+ * // ... will be given back the newValue ...
+ * }
+ * </pre></blockquote>
+ * <p>
+ * Each thread gets its own stack of bindings. When a
+ * new thread is created, the fluid gets a copy of
+ * the stack of bindings from the parent thread, and
+ * from then on the bindings for the new thread
+ * are independent of those for the original thread.
+ * </p>
+ *
+ * @author Lex Spoon
+ * @version 1.1, 2007-5-21
+ */
+class DynamicVariable[T](init: T) {
+ private val slot: LocalDataStoreSlot = Thread.AllocateDataSlot()
+ value = init
+
+ /** Retrieve the current value */
+ def value: T = Thread.GetData(slot).asInstanceOf[T]
+
+ /** Set the value of the fluid while executing the specified
+ * thunk.
+ *
+ * @param newval The value to which to set the fluid
+ * @param thunk The code to evaluate under the new setting
+ */
+ def withValue[S](newval: T)(thunk: =>S): S = {
+ val oldval = value
+ value = newval
+
+ try { thunk } finally {
+ value = oldval
+ }
+ }
+
+ /** Change the currently bound value, discarding the old value.
+ * Usually withValue() gives better semantics.
+ */
+ def value_=(newval: T) = { Thread.SetData(slot, newval.asInstanceOf[AnyRef]) }
+
+ override def toString: String = "DynamicVariable(" + value +")"
+}
diff --git a/src/dotnet-library/scala/util/Fluid.scala b/src/dotnet-library/scala/util/Fluid.scala
deleted file mode 100644
index 824ac373bc..0000000000
--- a/src/dotnet-library/scala/util/Fluid.scala
+++ /dev/null
@@ -1,78 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-// $Id$
-
-
-package scala.util
-
-
-import Predef._
-import System.Threading.Thread
-import System.LocalDataStoreSlot
-
-/** Fluids provide a binding mechanism where the current
- * value is found through <em>dynamic scope</em>, but where
- * access to the fluid itself is resolved through </em>static
- * binding</em> to a variable referencing the fluid.
- *
- * The current value can be retrieved with the
- * <code>value</code> method. New values can be
- * pushed using the <code>withValue</code> method.
- * Values pushed via <code>withValue</code> only
- * stay valid while the <code>withValue</code>'s
- * <em>second</em> argument, a parameterless closure,
- * executes. When the second argument finishes,
- * the fluid reverts to the previous value.
- *
- * Usage of <code>withValue</code> looks like this:
- * <blockquote><pre>
- * someFluid.withValue(newValue) {
- * // ... code called in here that calls value ...
- * // ... will be given back the newValue ...
- * }
- * </pre></blockquote>
- *
- * Each thread gets its own stack of bindings. When a
- * new thread is created, the fluid gets a copy of
- * the stack of bindings from the parent thread, and
- * from then on the bindings for the new thread
- * are independent of those for the original thread.
- *
- * @author Lex Spoon
- * @version 1.0, 21/03/2006
- */
-class Fluid[T](init: T) {
- private val slot: LocalDataStoreSlot = Thread.AllocateDataSlot()
- value = init
-
- /** Retrieve the current value */
- def value: T = Thread.GetData(slot).asInstanceOf[T]
-
- /** Set the value of the fluid while executing the specified
- * thunk.
- *
- * @param newval The value to which to set the fluid
- * @param thunk The code to evaluate under the new setting
- */
- def withValue[S](newval: T)(thunk: =>S): S = {
- val oldval = value
- value = newval
-
- try { thunk } finally {
- value = oldval
- }
- }
-
- /** Change the currently bound value, discarding the old value.
- * Usually withValue() gives better semantics.
- */
- def value_=(newval: T) = { Thread.SetData(slot, newval.asInstanceOf[AnyRef]) }
-
- override def toString: String = "Fluid(" + value +")"
-}