summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2007-12-21 14:42:31 +0000
committermichelou <michelou@epfl.ch>2007-12-21 14:42:31 +0000
commitc6f96a7ef30be23a8d3cda6fcaa0c0563a9373bb (patch)
treeceba2822ca118aba3b58285eb1c496dcc3690c27
parentb186613b3e9e65197d855f0924c211844d91be68 (diff)
downloadscala-c6f96a7ef30be23a8d3cda6fcaa0c0563a9373bb.tar.gz
scala-c6f96a7ef30be23a8d3cda6fcaa0c0563a9373bb.tar.bz2
scala-c6f96a7ef30be23a8d3cda6fcaa0c0563a9373bb.zip
updated MSIL library for class[T]
-rw-r--r--src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala53
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/SymblfileParser.scala37
-rw-r--r--src/dotnet-library/scala/Predef.scala16
-rw-r--r--src/dotnet-library/scala/compat/Platform.scala6
-rw-r--r--src/dotnet-library/scala/runtime/RichClass.scala10
-rw-r--r--src/dotnet-library/scala/runtime/RichException.scala4
-rw-r--r--src/dotnet-library/scala/runtime/RichInt.scala2
-rw-r--r--src/library/scala/mobile/Code.scala4
8 files changed, 40 insertions, 92 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala
index 35bab26b26..680eedd14c 100644
--- a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala
+++ b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala
@@ -1,5 +1,5 @@
/* NSC -- new Scala compiler
- * Copyright 2005-2007 LAMP/EPFL
+ * Copyright 2005-2008 LAMP/EPFL
* @author Martin Odersky
*/
// $Id$
@@ -119,11 +119,11 @@ abstract class SymbolLoaders {
assert(owner.info.decls.lookup(name) == NoSymbol, owner.fullNameString + "." + name)
val clazz = owner.newClass(NoPosition, name.toTypeName)
val module = owner.newModule(NoPosition, name)
- clazz.setInfo(completer)
- module.setInfo(completer)
- module.moduleClass.setInfo(moduleClassLoader)
- owner.info.decls.enter(clazz)
- owner.info.decls.enter(module)
+ clazz setInfo completer
+ module setInfo completer
+ module.moduleClass setInfo moduleClassLoader
+ owner.info.decls enter clazz
+ owner.info.decls enter module
// if (completer.sourceFile != null) {
// clazz.sourceFile = completer.sourceFile;
// module.moduleClass.sourceFile = completer.sourceFile
@@ -135,8 +135,8 @@ abstract class SymbolLoaders {
}
def checkAdd(name0 : String) = {
var name = name0
- while (name.indexOf('$') != -1) {
- name = name.substring(0, name.indexOf('$'))
+ while ((name indexOf '$') != -1) {
+ name = name.substring(0, name indexOf '$')
}
}
protected def doComplete(root: Symbol) {
@@ -201,12 +201,6 @@ abstract class SymbolLoaders {
}
}
-/*
- private object symblfileParser extends SymblfileParser {
- val global: SymbolLoaders.this.global.type = SymbolLoaders.this.global;
- }
-*/
-
class NamespaceLoader(directory: global.classPath0.Context) extends PackageLoader(directory) {
override protected def kindString: String = "namespace " + namespace
@@ -232,7 +226,7 @@ abstract class SymbolLoaders {
super.doComplete(root)
for (namespace <- namespaces.elements) {
- val oldPkg = root.info.decls.lookup(newTermName(namespace))
+ val oldPkg = root.info.decls lookup newTermName(namespace)
if (oldPkg == NoSymbol)
enterPackage(namespace, new NamespaceLoader(new classPath0.Context(List())))
//else System.out.println("PackageLoader: package already in scope: " + oldPkg.fullNameString)
@@ -240,7 +234,7 @@ abstract class SymbolLoaders {
// import the CLR types contained in the package (namespace)
for ((name, typ) <- types.elements) {
- assert(namespace == typ.Namespace, typ.FullName);
+ assert(namespace == typ.Namespace, typ.FullName)
if (typ.IsDefined(clrTypes.SCALA_SYMTAB_ATTR, false)) {
val attrs = typ.GetCustomAttributes(clrTypes.SCALA_SYMTAB_ATTR, false)
@@ -266,8 +260,8 @@ abstract class SymbolLoaders {
protected def sourceString = typ.Assembly.FullName
}
// IDE hook.
- protected def completeClassfile(root : Symbol, loader : ClassfileLoader)(f : => Unit) : Unit = f
- protected def completeSourcefile(root : Symbol, loader : SourcefileLoader)(f : => Unit) : Unit = f
+ protected def completeClassfile(root: Symbol, loader: ClassfileLoader)(f: => Unit): Unit = f
+ protected def completeSourcefile(root: Symbol, loader: SourcefileLoader)(f: => Unit): Unit = f
class ClassfileLoader(val classFile: AbstractFile, override val sourceFile: AbstractFile, sourcePath0: AbstractFile) extends SymbolLoader {
if (sourcePath0 == null) {
@@ -284,12 +278,12 @@ abstract class SymbolLoaders {
classfileParser.parse(classFile, root)
}
root match {
- case clazz : ClassSymbol =>
- global.attachSourceToClass(clazz, this, if (sourceFile ne null) sourceFile else clazz.sourceFile)
- case module : ModuleSymbol if module.moduleClass.isInstanceOf[ClassSymbol] =>
- val clazz = module.moduleClass.asInstanceOf[ClassSymbol]
- global.attachSourceToClass(module, this, if (sourceFile ne null) sourceFile else clazz.sourceFile)
- case _ =>
+ case clazz: ClassSymbol =>
+ global.attachSourceToClass(clazz, this, if (sourceFile ne null) sourceFile else clazz.sourceFile)
+ case module: ModuleSymbol if module.moduleClass.isInstanceOf[ClassSymbol] =>
+ val clazz = module.moduleClass.asInstanceOf[ClassSymbol]
+ global.attachSourceToClass(module, this, if (sourceFile ne null) sourceFile else clazz.sourceFile)
+ case _ =>
}
if (root.sourceFile ne null) {
//global.generateIdeMaps.sourceFiles(root.sourceFile) = classFile.container
@@ -298,15 +292,10 @@ abstract class SymbolLoaders {
protected def kindString: String = "class file"
protected def sourceString = classFile.toString()
}
-/*
- class SymblfileLoader(file: AbstractFile) extends SymbolLoader(file) {
- protected def doComplete(root: Symbol) { symblfileParser.parse(file, root) }
- protected def kindString: String = "symbl file";
- }
-*/
+
class SourcefileLoader(override val sourceFile: AbstractFile) extends SymbolLoader {
- protected def doComplete(root: Symbol): Unit = completeSourcefile(root, this){
- global.currentRun.compileLate(sourceFile)
+ protected def doComplete(root: Symbol): Unit = completeSourcefile(root, this) {
+ global.currentRun compileLate sourceFile
}
protected def kindString: String = "source file"
protected def sourceString = sourceFile.toString()
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/SymblfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/SymblfileParser.scala
deleted file mode 100644
index 485496b283..0000000000
--- a/src/compiler/scala/tools/nsc/symtab/classfile/SymblfileParser.scala
+++ /dev/null
@@ -1,37 +0,0 @@
-/* NSC -- new Scala compiler
- * Copyright 2005-2007 LAMP/EPFL
- * @author Martin Odersky
- */
-// $Id$
-
-package scala.tools.nsc.symtab.classfile
-
-import scala.tools.nsc.io.AbstractFile
-
-/** This abstract class implements ..
- *
- * @author Martin Odersky
- * @version 1.0
- */
-abstract class SymblfileParser {
-
- val global: Global
- import global._
-
- private var current: AbstractFile = null // lock to detect recursive reads
-
- private object unpickler extends UnPickler {
- val global: SymblfileParser.this.global.type = SymblfileParser.this.global
- }
-
- def parse(file: AbstractFile, root: Symbol) {
- assert(current eq null, current)
- current = file
- val bytes = new AbstractFileReader(file).buf
- if (root.isModule)
- unpickler.unpickle(bytes, 0, root.linkedClassOfModule, root, file.toString())
- else
- unpickler.unpickle(bytes, 0, root, root.linkedModuleOfClass, file.toString())
- current = null
- }
-}
diff --git a/src/dotnet-library/scala/Predef.scala b/src/dotnet-library/scala/Predef.scala
index f03be9ed93..82dfb658f5 100644
--- a/src/dotnet-library/scala/Predef.scala
+++ b/src/dotnet-library/scala/Predef.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -21,7 +21,7 @@ object Predef {
// classOf dummy ------------------------------------------------------
/** Return the runtime representation of a class type. */
- def classOf[T]: Class = null
+ def classOf[T]: Class[T] = null
// aliases ------------------------------------------------------------
@@ -35,14 +35,9 @@ object Predef {
type boolean = scala.Boolean
type unit = scala.Unit
- /** @deprecated use <code>Nothing</code> instead */
- @deprecated type All = Nothing
- /** @deprecated use <code>Null</code> instead */
- @deprecated type AllRef = Null
-
type String = System.String
type StringBuilder = compat.StringBuilder
- type Class = System.Type
+ type Class[T] = System.Type
type Runnable = scala.runtime.Runnable
type Throwable = System.Exception
@@ -176,10 +171,11 @@ object Predef {
implicit def exceptionWrapper(exc: Throwable) = new runtime.RichException(exc)
final class GetClassWrapper(obj: AnyRef) {
- def getClass(): runtime.RichClass = classWrapper(obj.GetType())
+ def getClass(): runtime.RichClass[Any] = classWrapper(obj.GetType())
}
implicit def getClassWrapper(obj: AnyRef) = new GetClassWrapper(obj)
- implicit def classWrapper(clazz: Class): runtime.RichClass = new runtime.RichClass(clazz)
+ implicit def classWrapper[A](clazz: Class[A]): runtime.RichClass[A] =
+ new runtime.RichClass(clazz)
implicit def unit2ordered(x: Unit): Ordered[Unit] = new Ordered[Unit] with Proxy {
def self: Any = x
diff --git a/src/dotnet-library/scala/compat/Platform.scala b/src/dotnet-library/scala/compat/Platform.scala
index 7d5ec48b67..6caac5b781 100644
--- a/src/dotnet-library/scala/compat/Platform.scala
+++ b/src/dotnet-library/scala/compat/Platform.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -39,14 +39,14 @@ object Platform {
* @param length ..
* @return ..
*/
- def createArray(elemClass: Class, length: Int): AnyRef =
+ def createArray(elemClass: Class[_], length: Int): AnyRef =
System.Array.CreateInstance(elemClass, length)
def arrayclear(arr: Array[Int]) {
System.Array.Clear(arr.asInstanceOf[System.Array], 0, arr.length)
}
- def getClassForName(name: String): Class = System.Type.GetType(name)
+ def getClassForName(name: String): Class[_] = System.Type.GetType(name)
val EOL = System.Environment.NewLine
diff --git a/src/dotnet-library/scala/runtime/RichClass.scala b/src/dotnet-library/scala/runtime/RichClass.scala
index 0c18a4aecd..fc21f537ac 100644
--- a/src/dotnet-library/scala/runtime/RichClass.scala
+++ b/src/dotnet-library/scala/runtime/RichClass.scala
@@ -1,7 +1,7 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2006, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
@@ -13,13 +13,13 @@ package scala.runtime
import Predef.Class
-final class RichClass(val self: Class) extends Proxy {
+final class RichClass[A](val self: Class[A]) extends Proxy {
def isPrimitive(): Boolean = self.IsPrimitive
def isArray(): Boolean = self.IsArray
- def getClass(): RichClass = this
+ def getClass(): RichClass[A] = this
def getName(): String = self.Name
- def getComponentType(): Class = self.GetElementType
+ def getComponentType(): Class[A] = self.GetElementType
}
diff --git a/src/dotnet-library/scala/runtime/RichException.scala b/src/dotnet-library/scala/runtime/RichException.scala
index ebc7ddd8b9..d08e2e0edf 100644
--- a/src/dotnet-library/scala/runtime/RichException.scala
+++ b/src/dotnet-library/scala/runtime/RichException.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -14,7 +14,7 @@ package scala.runtime
final class RichException(exc: System.Exception) {
- def printStackTrace() = System.Console.WriteLine(exc.StackTrace);
+ def printStackTrace() = System.Console.WriteLine(exc.StackTrace)
def getMessage() = exc.Message
def getStackTraceString: String = exc.StackTrace
diff --git a/src/dotnet-library/scala/runtime/RichInt.scala b/src/dotnet-library/scala/runtime/RichInt.scala
index 204e50fd2c..368a886df9 100644
--- a/src/dotnet-library/scala/runtime/RichInt.scala
+++ b/src/dotnet-library/scala/runtime/RichInt.scala
@@ -6,7 +6,7 @@
** |/ **
\* */
-// $Id: RichInt.scala 12529 2007-08-14 14:02:27Z michelou $
+// $Id$
package scala.runtime
diff --git a/src/library/scala/mobile/Code.scala b/src/library/scala/mobile/Code.scala
index f34d39e24a..c9728ea7f0 100644
--- a/src/library/scala/mobile/Code.scala
+++ b/src/library/scala/mobile/Code.scala
@@ -1,7 +1,7 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2007, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
+** / __/ __// _ | / / / _ | (c) 2002-2008, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */