summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormihaylov <mihaylov@epfl.ch>2007-05-01 11:47:56 +0000
committermihaylov <mihaylov@epfl.ch>2007-05-01 11:47:56 +0000
commit86e18d84dc41c3064734ff866072a9c71475939c (patch)
tree807efcb5e7775a99262433368b3e3ccae9c6f728
parentcf626598eabab3f238f255af162e3f71a6a18d2e (diff)
downloadscala-86e18d84dc41c3064734ff866072a9c71475939c.tar.gz
scala-86e18d84dc41c3064734ff866072a9c71475939c.tar.bz2
scala-86e18d84dc41c3064734ff866072a9c71475939c.zip
Made mutable.{Set, BitSet} platform-independent
-rw-r--r--build.xml2
-rw-r--r--src/dotnet-library/scala/compat/Platform.scala3
-rw-r--r--src/library/scala/collection/mutable/BitSet.scala4
-rw-r--r--src/library/scala/collection/mutable/Set.scala4
-rw-r--r--src/library/scala/compat/Platform.scala3
-rw-r--r--test/files/run/Course-2002-04-msil.check84
-rw-r--r--test/files/run/bitsets-msil.check33
7 files changed, 87 insertions, 46 deletions
diff --git a/build.xml b/build.xml
index 16ef7b027a..c4f7bc8490 100644
--- a/build.xml
+++ b/build.xml
@@ -607,7 +607,7 @@ MSIL
<include name="scala/Console.scala" />
<include name="scala/Application.scala" />
<include name="scala/ByNameFunction.scala" />
- <include name="scala/*Attribute.scala" />
+ <include name="scala/*Annotation.scala" />
<include name="scala/Function*.scala" />
<include name="scala/Tuple*.scala" />
<include name="scala/Product*.scala" />
diff --git a/src/dotnet-library/scala/compat/Platform.scala b/src/dotnet-library/scala/compat/Platform.scala
index 161423bedb..8b31b52539 100644
--- a/src/dotnet-library/scala/compat/Platform.scala
+++ b/src/dotnet-library/scala/compat/Platform.scala
@@ -17,6 +17,7 @@ import Predef._
object Platform {
type StackOverflowError = System.StackOverflowException
+ type ConcurrentModificationException = System.Exception
/**
* @param src ..
@@ -41,6 +42,8 @@ object Platform {
def createArray(elemClass: Class, length: Int): AnyRef =
System.Array.CreateInstance(elemClass, length);
+ def arrayclear(arr: Array[Int]): Unit = System.Array.Clear(arr.asInstanceOf[System.Array], 0, arr.length)
+
def getClassForName(name: String): Class = System.Type.GetType(name)
val EOL = System.Environment.NewLine
diff --git a/src/library/scala/collection/mutable/BitSet.scala b/src/library/scala/collection/mutable/BitSet.scala
index 455d8e3687..fdf1df2454 100644
--- a/src/library/scala/collection/mutable/BitSet.scala
+++ b/src/library/scala/collection/mutable/BitSet.scala
@@ -24,7 +24,7 @@ package scala.collection.mutable
@serializable
class BitSet(initSize: Int) extends collection.BitSet with Set[Int] {
- import compat.Platform.arraycopy
+ import compat.Platform.{arraycopy, arrayclear}
/** default constructor, initial size of 512 bits. */
def this() = this(0)
@@ -78,7 +78,7 @@ class BitSet(initSize: Int) extends collection.BitSet with Set[Int] {
/** Clears all bits of the set.
*/
override def clear(): Unit = {
- java.util.Arrays.fill(arr, 0)
+ arrayclear(arr)
size = 0
}
diff --git a/src/library/scala/collection/mutable/Set.scala b/src/library/scala/collection/mutable/Set.scala
index 8e081191b6..faa712edf8 100644
--- a/src/library/scala/collection/mutable/Set.scala
+++ b/src/library/scala/collection/mutable/Set.scala
@@ -12,6 +12,8 @@
package scala.collection.mutable
+import compat.Platform.ConcurrentModificationException
+
/** The canonical factory methods for <a href="Set.html">mutable sets</a>.
* Currently these return <a href="HashSet.html">HashSet's</a>.
*/
@@ -209,7 +211,7 @@ trait Set[A] extends collection.Set[A] with Scriptable[Message[A]] {
override val hashCode = Set.this.hashCode
private def check =
if (false && hashCode != Set.this.hashCode)
- throw new java.util.ConcurrentModificationException
+ throw new ConcurrentModificationException
def contains(item : A) = {
check
diff --git a/src/library/scala/compat/Platform.scala b/src/library/scala/compat/Platform.scala
index 724102794e..7d0cec4b72 100644
--- a/src/library/scala/compat/Platform.scala
+++ b/src/library/scala/compat/Platform.scala
@@ -18,6 +18,7 @@ import Predef._
object Platform {
type StackOverflowError = java.lang.StackOverflowError
+ type ConcurrentModificationException = java.util.ConcurrentModificationException
/**
* @param src ..
@@ -39,6 +40,8 @@ object Platform {
def createArray(elemClass: Class, length: Int): AnyRef =
java.lang.reflect.Array.newInstance(elemClass, length)
+ def arrayclear(arr: Array[Int]): Unit = java.util.Arrays.fill(arr, 0)
+
def getClassForName(name: String): Class = java.lang.Class.forName(name)
val EOL = System.getProperty("line.separator", "\n")
diff --git a/test/files/run/Course-2002-04-msil.check b/test/files/run/Course-2002-04-msil.check
index c5709d2116..fc6ad96eed 100644
--- a/test/files/run/Course-2002-04-msil.check
+++ b/test/files/run/Course-2002-04-msil.check
@@ -1,22 +1,22 @@
-list0 = List(6,3,1,8,7,1,2,5,8,4,3,4,8)
-list1 = List(1,1,2,3,3,4,4,5,6,7,8,8,8)
-list2 = List(1,1,2,3,3,4,4,5,6,7,8,8,8)
-list3 = List(1,1,2,3,3,4,4,5,6,7,8,8,8)
-list4 = List(1,1,2,3,3,4,4,5,6,7,8,8,8)
-list5 = List(8,8,8,7,6,5,4,4,3,3,2,1,1)
-list6 = List(8,8,8,7,6,5,4,4,3,3,2,1,1)
+list0 = List(6, 3, 1, 8, 7, 1, 2, 5, 8, 4, 3, 4, 8)
+list1 = List(1, 1, 2, 3, 3, 4, 4, 5, 6, 7, 8, 8, 8)
+list2 = List(1, 1, 2, 3, 3, 4, 4, 5, 6, 7, 8, 8, 8)
+list3 = List(1, 1, 2, 3, 3, 4, 4, 5, 6, 7, 8, 8, 8)
+list4 = List(1, 1, 2, 3, 3, 4, 4, 5, 6, 7, 8, 8, 8)
+list5 = List(8, 8, 8, 7, 6, 5, 4, 4, 3, 3, 2, 1, 1)
+list6 = List(8, 8, 8, 7, 6, 5, 4, 4, 3, 3, 2, 1, 1)
list0: List() -> List()
list1: List(0) -> List(0)
-list2: List(0,1) -> List(0,1)
-list3: List(1,0) -> List(0,1)
-list4: List(0,1,2) -> List(0,1,2)
-list5: List(1,0,2) -> List(0,1,2)
-list6: List(0,1,2) -> List(0,1,2)
-list7: List(1,0,2) -> List(0,1,2)
-list8: List(2,0,1) -> List(0,1,2)
-list9: List(2,1,0) -> List(0,1,2)
-listA: List(6,3,1,8,7,1,2,5,8,4) -> List(1,1,2,3,4,5,6,7,8,8)
+list2: List(0, 1) -> List(0, 1)
+list3: List(1, 0) -> List(0, 1)
+list4: List(0, 1, 2) -> List(0, 1, 2)
+list5: List(1, 0, 2) -> List(0, 1, 2)
+list6: List(0, 1, 2) -> List(0, 1, 2)
+list7: List(1, 0, 2) -> List(0, 1, 2)
+list8: List(2, 0, 1) -> List(0, 1, 2)
+list9: List(2, 1, 0) -> List(0, 1, 2)
+listA: List(6, 3, 1, 8, 7, 1, 2, 5, 8, 4) -> List(1, 1, 2, 3, 4, 5, 6, 7, 8, 8)
f(x) = 5x^3+7x^2+5x+9
f(0) = 9
@@ -24,41 +24,41 @@ f(1) = 26
f(2) = 87
f(3) = 222
-v1 = List(2,3,4)
-v2 = List(6,7,8)
+v1 = List(2, 3, 4)
+v2 = List(6, 7, 8)
-id = List(List(1,0,0),List(0,1,0),List(0,0,1))
-m1 = List(List(2,0,0),List(0,2,0),List(0,0,2))
-m2 = List(List(1,2,3),List(4,5,6),List(7,8,9))
+id = List(List(1, 0, 0), List(0, 1, 0), List(0, 0, 1))
+m1 = List(List(2, 0, 0), List(0, 2, 0), List(0, 0, 2))
+m2 = List(List(1, 2, 3), List(4, 5, 6), List(7, 8, 9))
v1 * v1 = 29
v1 * v2 = 65
v2 * v1 = 65
v1 * v2 = 65
-id * v1 = List(2,3,4)
-m1 * v1 = List(4,6,8)
-m2 * v1 = List(20,47,74)
+id * v1 = List(2, 3, 4)
+m1 * v1 = List(4, 6, 8)
+m2 * v1 = List(20, 47, 74)
-trn(id) = List(List(1,0,0),List(0,1,0),List(0,0,1))
-trn(m1) = List(List(2,0,0),List(0,2,0),List(0,0,2))
-trn(m2) = List(List(1,4,7),List(2,5,8),List(3,6,9))
+trn(id) = List(List(1, 0, 0), List(0, 1, 0), List(0, 0, 1))
+trn(m1) = List(List(2, 0, 0), List(0, 2, 0), List(0, 0, 2))
+trn(m2) = List(List(1, 4, 7), List(2, 5, 8), List(3, 6, 9))
-List(v1) * id = List(List(2,3,4))
-List(v1) * m1 = List(List(4,6,8))
-List(v1) * m2 = List(List(42,51,60))
+List(v1) * id = List(List(2, 3, 4))
+List(v1) * m1 = List(List(4, 6, 8))
+List(v1) * m2 = List(List(42, 51, 60))
-id * List(v1) = List(List(2,3,4),List(0,0,0),List(0,0,0))
-m1 * List(v1) = List(List(4,6,8),List(0,0,0),List(0,0,0))
-m2 * List(v1) = List(List(2,3,4),List(8,12,16),List(14,21,28))
+id * List(v1) = List(List(2, 3, 4), List(0, 0, 0), List(0, 0, 0))
+m1 * List(v1) = List(List(4, 6, 8), List(0, 0, 0), List(0, 0, 0))
+m2 * List(v1) = List(List(2, 3, 4), List(8, 12, 16), List(14, 21, 28))
-id * id = List(List(1,0,0),List(0,1,0),List(0,0,1))
-id * m1 = List(List(2,0,0),List(0,2,0),List(0,0,2))
-m1 * id = List(List(2,0,0),List(0,2,0),List(0,0,2))
-m1 * m1 = List(List(4,0,0),List(0,4,0),List(0,0,4))
-id * m2 = List(List(1,2,3),List(4,5,6),List(7,8,9))
-m2 * id = List(List(1,2,3),List(4,5,6),List(7,8,9))
-m1 * m2 = List(List(2,4,6),List(8,10,12),List(14,16,18))
-m2 * m1 = List(List(2,4,6),List(8,10,12),List(14,16,18))
-m2 * m2 = List(List(30,36,42),List(66,81,96),List(102,126,150))
+id * id = List(List(1, 0, 0), List(0, 1, 0), List(0, 0, 1))
+id * m1 = List(List(2, 0, 0), List(0, 2, 0), List(0, 0, 2))
+m1 * id = List(List(2, 0, 0), List(0, 2, 0), List(0, 0, 2))
+m1 * m1 = List(List(4, 0, 0), List(0, 4, 0), List(0, 0, 4))
+id * m2 = List(List(1, 2, 3), List(4, 5, 6), List(7, 8, 9))
+m2 * id = List(List(1, 2, 3), List(4, 5, 6), List(7, 8, 9))
+m1 * m2 = List(List(2, 4, 6), List(8, 10, 12), List(14, 16, 18))
+m2 * m1 = List(List(2, 4, 6), List(8, 10, 12), List(14, 16, 18))
+m2 * m2 = List(List(30, 36, 42), List(66, 81, 96), List(102, 126, 150))
diff --git a/test/files/run/bitsets-msil.check b/test/files/run/bitsets-msil.check
new file mode 100644
index 0000000000..9fefa3125e
--- /dev/null
+++ b/test/files/run/bitsets-msil.check
@@ -0,0 +1,33 @@
+ms0 = Set(2)
+ms1 = Set(2)
+ms2 = Set(2)
+mb0 = False
+mb1 = True
+mb2 = False
+xs0 = List(2)
+xs1 = List(2)
+xs2 = List(2)
+ma0 = List(4)
+ma1 = List(4)
+ma2 = List(4)
+mi0 = Set(2)
+mi1 = Set(2)
+mi2 = Set(2)
+
+is0 = Set()
+is1 = Set()
+is2 = Set(2)
+is3 = Set()
+ib0 = False
+ib1 = False
+ib2 = True
+ib3 = False
+ys0 = List()
+ys1 = List()
+ys2 = List(2)
+ys3 = List()
+ia0 = List(0)
+ia1 = List(0)
+ia2 = List(4)
+ia3 = List()
+