diff options
author | Miguel Garcia <miguelalfredo.garcia@epfl.ch> | 2012-03-07 12:45:36 +0100 |
---|---|---|
committer | Miguel Garcia <miguelalfredo.garcia@epfl.ch> | 2012-03-07 12:45:36 +0100 |
commit | 4c6ca5684b77ad63561dabfce1b23efe3bdbacac (patch) | |
tree | a47bf7cc9d94a0055c8c71a26238a71794599c89 /src | |
parent | 642c86a3fa720e837070ca6612fbdc10ebb63376 (diff) | |
download | scala-4c6ca5684b77ad63561dabfce1b23efe3bdbacac.tar.gz scala-4c6ca5684b77ad63561dabfce1b23efe3bdbacac.tar.bz2 scala-4c6ca5684b77ad63561dabfce1b23efe3bdbacac.zip |
replacing pattern matching with isWideType invocations
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala | 8 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala | 17 |
2 files changed, 7 insertions, 18 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala b/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala index d9e26a08a8..2ff0c1926c 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala @@ -80,9 +80,7 @@ trait TypeKinds { self: ICodes => */ def isIntSizedType: Boolean = false - /** On the JVM, - * similar to isIntSizedType except that BOOL isn't integral while LONG is. - */ + /** On the JVM, similar to isIntSizedType except that BOOL isn't integral while LONG is. */ def isIntegralType: Boolean = false /** On the JVM, FLOAT and DOUBLE. */ @@ -96,9 +94,7 @@ trait TypeKinds { self: ICodes => case _ => this eq other }) - /** Is this type a category 2 type in JVM terms? - * (ie, is is LONG or DOUBLE?) - */ + /** Is this type a category 2 type in JVM terms? (ie, is it LONG or DOUBLE?) */ def isWideType: Boolean = false /** The number of dimensions for array types. */ diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala index 08dfc18706..dc8526c73a 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala @@ -1564,16 +1564,12 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with jcode.emitATHROW() case DROP(kind) => - kind match { - case LONG | DOUBLE => jcode.emitPOP2() - case _ => jcode.emitPOP() - } + if(kind.isWideType) jcode.emitPOP2() + else jcode.emitPOP() case DUP(kind) => - kind match { - case LONG | DOUBLE => jcode.emitDUP2() - case _ => jcode.emitDUP() - } + if(kind.isWideType) jcode.emitDUP2() + else jcode.emitDUP() case MONITOR_ENTER() => jcode.emitMONITORENTER() @@ -1875,10 +1871,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with def sizeOf(sym: Symbol): Int = sizeOf(toTypeKind(sym.tpe)) - def sizeOf(k: TypeKind): Int = k match { - case DOUBLE | LONG => 2 - case _ => 1 - } + def sizeOf(k: TypeKind): Int = if(k.isWideType) 2 else 1 def indexOf(m: IMethod, sym: Symbol): Int = { val Some(local) = m lookupLocal sym |