summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@epfl.ch>2010-04-29 08:09:38 +0000
committerLukas Rytz <lukas.rytz@epfl.ch>2010-04-29 08:09:38 +0000
commit54e1e31679f4e5ca78238a092b0b857190e8bfde (patch)
tree6a9aadcb7ec3d218676e69a98fd683751944e02e
parent922938dc879463180acd42c3a930fe74433ee510 (diff)
downloadscala-54e1e31679f4e5ca78238a092b0b857190e8bfde.tar.gz
scala-54e1e31679f4e5ca78238a092b0b857190e8bfde.tar.bz2
scala-54e1e31679f4e5ca78238a092b0b857190e8bfde.zip
fix msil backend. no review
-rw-r--r--src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala38
1 files changed, 27 insertions, 11 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala
index 285e09295d..554dcd4e6d 100644
--- a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala
+++ b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala
@@ -1053,7 +1053,7 @@ abstract class GenMSIL extends SubComponent {
}
var doEmit = true
- types.get(msym.owner) match {
+ getTypeOpt(msym.owner) match {
case Some(typ) if (typ.IsEnum) => {
def negBool = {
mcode.Emit(OpCodes.Ldc_I4_0)
@@ -1577,9 +1577,9 @@ abstract class GenMSIL extends SubComponent {
mf = mf | FieldAttributes.Static
else {
mf = mf | MethodAttributes.Virtual
- if (sym.isFinal && !types(sym.owner).IsInterface)
+ if (sym.isFinal && !getType(sym.owner).IsInterface)
mf = mf | MethodAttributes.Final
- if (sym.hasFlag(Flags.DEFERRED) || types(sym.owner).IsInterface)
+ if (sym.hasFlag(Flags.DEFERRED) || getType(sym.owner).IsInterface)
mf = mf | MethodAttributes.Abstract
}
}
@@ -1679,8 +1679,14 @@ abstract class GenMSIL extends SubComponent {
sym.tpe.paramTypes.map(msilType).toArray
}
- def getType(sym: Symbol): MsilType = types.get(sym) match {
- case Some(typ) => typ
+ def getType(sym: Symbol) = getTypeOpt(sym).getOrElse(abort(showsym(sym)))
+
+ /**
+ * Get an MSIL type form a symbol. First look in the clrTypes.types map, then
+ * lookup the name using clrTypes.getType
+ */
+ def getTypeOpt(sym: Symbol): Option[MsilType] = types.get(sym) match {
+ case typ @ Some(_) => typ
case None =>
def typeString(sym: Symbol): String = {
val s = if (sym.isNestedClass) typeString(sym.owner) +"+"+ sym.simpleName
@@ -1690,10 +1696,10 @@ abstract class GenMSIL extends SubComponent {
val name = typeString(sym)
val typ = clrTypes.getType(name)
if (typ == null)
- abort(showsym(sym) + " with name " + name)
+ None
else {
- clrTypes.types(sym) = typ
- typ
+ types(sym) = typ
+ Some(typ)
}
}
@@ -1703,10 +1709,20 @@ abstract class GenMSIL extends SubComponent {
}
def createTypeBuilder(iclass: IClass) {
+ /**
+ * First look in the clrTypes.types map, then see if it's a class we're
+ * currently compiling by looking at the icodes.classes map, then finally
+ * lookup the name using clrTypes.getType (by calling getType).
+ */
def msilTypeFromSym(sym: Symbol): MsilType = {
- types.get(sym) match {
- case Some(mtype) => mtype
- case None => createTypeBuilder(classes(sym)); types(sym)
+ types.get(sym).getOrElse {
+ classes.get(sym) match {
+ case Some(iclass) =>
+ createTypeBuilder(iclass)
+ types (sym)
+ case None =>
+ getType(sym)
+ }
}
}