diff options
11 files changed, 80 insertions, 80 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala index 415a56712a..67f3f7f8b2 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala @@ -1518,15 +1518,15 @@ abstract class GenJVM extends SubComponent { def emitEntry(name: String, signature: String, idx: Short, start: Short, end: Short) { lvTab.putShort(start) lvTab.putShort(end) - lvTab.putShort(pool.addUtf8(name).asInstanceOf[Short]) - lvTab.putShort(pool.addUtf8(signature).asInstanceOf[Short]) + lvTab.putShort(pool.addUtf8(name).toShort) + lvTab.putShort(pool.addUtf8(signature).toShort) lvTab.putShort(idx) } - lvTab.putShort(entries.asInstanceOf[Short]) + lvTab.putShort(entries.toShort) if (!jmethod.isStatic()) { - emitEntry("this", jclass.getType().getSignature(), 0, 0.asInstanceOf[Short], pc.asInstanceOf[Short]) + emitEntry("this", jclass.getType().getSignature(), 0, 0.toShort, pc.toShort) } for (lv <- vars) { @@ -1535,10 +1535,10 @@ abstract class GenJVM extends SubComponent { "<anon" + anonCounter + ">" } else javaName(lv.sym) - val index = indexOf(lv).asInstanceOf[Short] + val index = indexOf(lv).toShort val tpe = javaType(lv.kind).getSignature() for ((start, end) <- lv.ranges) { - emitEntry(name, tpe, index, start.asInstanceOf[Short], (end - start).asInstanceOf[Short]) + emitEntry(name, tpe, index, start.toShort, (end - start).toShort) } } val attr = diff --git a/src/compiler/scala/tools/nsc/javac/JavaScanners.scala b/src/compiler/scala/tools/nsc/javac/JavaScanners.scala index c1bedd8d95..2ffea32307 100644 --- a/src/compiler/scala/tools/nsc/javac/JavaScanners.scala +++ b/src/compiler/scala/tools/nsc/javac/JavaScanners.scala @@ -158,7 +158,7 @@ trait JavaScanners { key(i) = IDENTIFIER for (j <- 0 until tokenCount) if (tokenName(j) ne null) - key(tokenName(j).start) = j.asInstanceOf[Byte] + key(tokenName(j).start) = j.toByte } diff --git a/src/compiler/scala/tools/nsc/symtab/Constants.scala b/src/compiler/scala/tools/nsc/symtab/Constants.scala index 5b1038f514..dfe7147270 100644 --- a/src/compiler/scala/tools/nsc/symtab/Constants.scala +++ b/src/compiler/scala/tools/nsc/symtab/Constants.scala @@ -85,77 +85,77 @@ trait Constants { def byteValue: Byte = tag match { case ByteTag => value.asInstanceOf[Byte] - case ShortTag => value.asInstanceOf[Short].asInstanceOf[Byte] - case CharTag => value.asInstanceOf[Char].asInstanceOf[Byte] - case IntTag => value.asInstanceOf[Int].asInstanceOf[Byte] - case LongTag => value.asInstanceOf[Long].asInstanceOf[Byte] - case FloatTag => value.asInstanceOf[Float].asInstanceOf[Byte] - case DoubleTag => value.asInstanceOf[Double].asInstanceOf[Byte] + case ShortTag => value.asInstanceOf[Short].toByte + case CharTag => value.asInstanceOf[Char].toByte + case IntTag => value.asInstanceOf[Int].toByte + case LongTag => value.asInstanceOf[Long].toByte + case FloatTag => value.asInstanceOf[Float].toByte + case DoubleTag => value.asInstanceOf[Double].toByte case _ => throw new Error("value " + value + " is not a Byte") } def shortValue: Short = tag match { - case ByteTag => value.asInstanceOf[Byte].asInstanceOf[Short] + case ByteTag => value.asInstanceOf[Byte].toShort case ShortTag => value.asInstanceOf[Short] - case CharTag => value.asInstanceOf[Char].asInstanceOf[Short] - case IntTag => value.asInstanceOf[Int].asInstanceOf[Short] - case LongTag => value.asInstanceOf[Long].asInstanceOf[Short] - case FloatTag => value.asInstanceOf[Float].asInstanceOf[Short] - case DoubleTag => value.asInstanceOf[Double].asInstanceOf[Short] + case CharTag => value.asInstanceOf[Char].toShort + case IntTag => value.asInstanceOf[Int].toShort + case LongTag => value.asInstanceOf[Long].toShort + case FloatTag => value.asInstanceOf[Float].toShort + case DoubleTag => value.asInstanceOf[Double].toShort case _ => throw new Error("value " + value + " is not a Short") } def charValue: Char = tag match { - case ByteTag => value.asInstanceOf[Byte].asInstanceOf[Char] - case ShortTag => value.asInstanceOf[Short].asInstanceOf[Char] + case ByteTag => value.asInstanceOf[Byte].toChar + case ShortTag => value.asInstanceOf[Short].toChar case CharTag => value.asInstanceOf[Char] - case IntTag => value.asInstanceOf[Int].asInstanceOf[Char] - case LongTag => value.asInstanceOf[Long].asInstanceOf[Char] - case FloatTag => value.asInstanceOf[Float].asInstanceOf[Char] - case DoubleTag => value.asInstanceOf[Double].asInstanceOf[Char] + case IntTag => value.asInstanceOf[Int].toChar + case LongTag => value.asInstanceOf[Long].toChar + case FloatTag => value.asInstanceOf[Float].toChar + case DoubleTag => value.asInstanceOf[Double].toChar case _ => throw new Error("value " + value + " is not a Char") } def intValue: Int = tag match { - case ByteTag => value.asInstanceOf[Byte].asInstanceOf[Int] - case ShortTag => value.asInstanceOf[Short].asInstanceOf[Int] - case CharTag => value.asInstanceOf[Char].asInstanceOf[Int] + case ByteTag => value.asInstanceOf[Byte].toInt + case ShortTag => value.asInstanceOf[Short].toInt + case CharTag => value.asInstanceOf[Char].toInt case IntTag => value.asInstanceOf[Int] - case LongTag => value.asInstanceOf[Long].asInstanceOf[Int] - case FloatTag => value.asInstanceOf[Float].asInstanceOf[Int] - case DoubleTag => value.asInstanceOf[Double].asInstanceOf[Int] + case LongTag => value.asInstanceOf[Long].toInt + case FloatTag => value.asInstanceOf[Float].toInt + case DoubleTag => value.asInstanceOf[Double].toInt case _ => throw new Error("value " + value + " is not an Int") } def longValue: Long = tag match { - case ByteTag => value.asInstanceOf[Byte].asInstanceOf[Long] - case ShortTag => value.asInstanceOf[Short].asInstanceOf[Long] - case CharTag => value.asInstanceOf[Char].asInstanceOf[Long] - case IntTag => value.asInstanceOf[Int].asInstanceOf[Long] + case ByteTag => value.asInstanceOf[Byte].toLong + case ShortTag => value.asInstanceOf[Short].toLong + case CharTag => value.asInstanceOf[Char].toLong + case IntTag => value.asInstanceOf[Int].toLong case LongTag => value.asInstanceOf[Long] - case FloatTag => value.asInstanceOf[Float].asInstanceOf[Long] - case DoubleTag => value.asInstanceOf[Double].asInstanceOf[Long] + case FloatTag => value.asInstanceOf[Float].toLong + case DoubleTag => value.asInstanceOf[Double].toLong case _ => throw new Error("value " + value + " is not a Long") } def floatValue: Float = tag match { - case ByteTag => value.asInstanceOf[Byte].asInstanceOf[Float] - case ShortTag => value.asInstanceOf[Short].asInstanceOf[Float] - case CharTag => value.asInstanceOf[Char].asInstanceOf[Float] - case IntTag => value.asInstanceOf[Int].asInstanceOf[Float] - case LongTag => value.asInstanceOf[Long].asInstanceOf[Float] + case ByteTag => value.asInstanceOf[Byte].toFloat + case ShortTag => value.asInstanceOf[Short].toFloat + case CharTag => value.asInstanceOf[Char].toFloat + case IntTag => value.asInstanceOf[Int].toFloat + case LongTag => value.asInstanceOf[Long].toFloat case FloatTag => value.asInstanceOf[Float] - case DoubleTag => value.asInstanceOf[Double].asInstanceOf[Float] + case DoubleTag => value.asInstanceOf[Double].toFloat case _ => throw new Error("value " + value + " is not a Float") } def doubleValue: Double = tag match { - case ByteTag => value.asInstanceOf[Byte].asInstanceOf[Double] - case ShortTag => value.asInstanceOf[Short].asInstanceOf[Double] - case CharTag => value.asInstanceOf[Char].asInstanceOf[Double] - case IntTag => value.asInstanceOf[Int].asInstanceOf[Double] - case LongTag => value.asInstanceOf[Long].asInstanceOf[Double] - case FloatTag => value.asInstanceOf[Float].asInstanceOf[Double] + case ByteTag => value.asInstanceOf[Byte].toDouble + case ShortTag => value.asInstanceOf[Short].toDouble + case CharTag => value.asInstanceOf[Char].toDouble + case IntTag => value.asInstanceOf[Int].toDouble + case LongTag => value.asInstanceOf[Long].toDouble + case FloatTag => value.asInstanceOf[Float].toDouble case DoubleTag => value.asInstanceOf[Double] case _ => throw new Error("value " + value + " is not a Double") } diff --git a/src/compiler/scala/tools/nsc/symtab/Flags.scala b/src/compiler/scala/tools/nsc/symtab/Flags.scala index 9b1380d5e8..0c7415e58a 100644 --- a/src/compiler/scala/tools/nsc/symtab/Flags.scala +++ b/src/compiler/scala/tools/nsc/symtab/Flags.scala @@ -287,7 +287,7 @@ object Flags { else if (flag == TRANS_FLAG ) "<trans-flag>" else if (flag == LOCKED ) "<locked>" else if (flag == LAZY ) "lazy" - else flag.asInstanceOf[Int] match { + else flag.toInt match { case IMPLICIT => "implicit" case FINAL => "final" case PRIVATE => "private" diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala index 49f9031dbd..3e0681ccdf 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala @@ -234,7 +234,7 @@ abstract class ICodeReader extends ClassfileParser { /** Parse 16 bit jump target. */ def parseJumpTarget = { size = size + 2 - val offset = in.nextChar.asInstanceOf[Short] + val offset = in.nextChar.toShort val target = pc + offset assert(target >= 0 && target < codeLength, "Illegal jump target: " + target) target diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/PickleBuffer.scala b/src/compiler/scala/tools/nsc/symtab/classfile/PickleBuffer.scala index 76ac3d4e1f..9b4f6a6a42 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/PickleBuffer.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/PickleBuffer.scala @@ -35,7 +35,7 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) { /** Write a byte of data */ def writeByte(b: Int) { if (writeIndex == bytes.length) dble() - bytes(writeIndex) = b.asInstanceOf[Byte] + bytes(writeIndex) = b.toByte writeIndex += 1 } @@ -43,7 +43,7 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) { * All but the last digits have bit 0x80 set. */ def writeNat(x: Int) = - writeLongNat(x.asInstanceOf[Long] & 0x00000000FFFFFFFFL) + writeLongNat(x.toLong & 0x00000000FFFFFFFFL) /** * Like writeNat, but for longs. This is not the same as @@ -56,11 +56,11 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) { def writeNatPrefix(x: Long) { val y = x >>> 7 if (y != 0L) writeNatPrefix(y) - writeByte(((x & 0x7f) | 0x80).asInstanceOf[Int]) + writeByte(((x & 0x7f) | 0x80).toInt) } val y = x >>> 7 if (y != 0L) writeNatPrefix(y) - writeByte((x & 0x7f).asInstanceOf[Int]) + writeByte((x & 0x7f).toInt) } /** Write a natural number <code>x</code> at position <code>pos</code>. @@ -73,11 +73,11 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) { def patchNatPrefix(x: Int) { writeByte(0) Array.copy(bytes, pos, bytes, pos+1, writeIndex - (pos+1)) - bytes(pos) = ((x & 0x7f) | 0x80).asInstanceOf[Byte] + bytes(pos) = ((x & 0x7f) | 0x80).toByte val y = x >>> 7 if (y != 0) patchNatPrefix(y) } - bytes(pos) = (x & 0x7f).asInstanceOf[Byte] + bytes(pos) = (x & 0x7f).toByte val y = x >>> 7 if (y != 0) patchNatPrefix(y) } @@ -90,7 +90,7 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) { val y = x >> 8 val z = x & 0xff if (-y != (z >> 7)) writeLong(y) - writeByte(z.asInstanceOf[Int]) + writeByte(z.toInt) } // -- Basic input routines -------------------------------------------- @@ -105,7 +105,7 @@ class PickleBuffer(data: Array[Byte], from: Int, to: Int) { /** Read a natural number in big endian format, base 128. * All but the last digits have bit 0x80 set.*/ - def readNat(): Int = readLongNat().asInstanceOf[Int] + def readNat(): Int = readLongNat().toInt def readLongNat(): Long = { var b = 0L diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala index d9c64c6531..909ecae77a 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/UnPickler.scala @@ -351,12 +351,12 @@ abstract class UnPickler { (tag: @switch) match { case LITERALunit => Constant(()) case LITERALboolean => Constant(if (readLong(len) == 0L) false else true) - case LITERALbyte => Constant(readLong(len).asInstanceOf[Byte]) - case LITERALshort => Constant(readLong(len).asInstanceOf[Short]) - case LITERALchar => Constant(readLong(len).asInstanceOf[Char]) - case LITERALint => Constant(readLong(len).asInstanceOf[Int]) + case LITERALbyte => Constant(readLong(len).toByte) + case LITERALshort => Constant(readLong(len).toShort) + case LITERALchar => Constant(readLong(len).toChar) + case LITERALint => Constant(readLong(len).toInt) case LITERALlong => Constant(readLong(len)) - case LITERALfloat => Constant(Float.intBitsToFloat(readLong(len).asInstanceOf[Int])) + case LITERALfloat => Constant(Float.intBitsToFloat(readLong(len).toInt)) case LITERALdouble => Constant(Double.longBitsToDouble(readLong(len))) case LITERALstring => Constant(readNameRef().toString()) case LITERALnull => Constant(null) diff --git a/src/compiler/scala/tools/nsc/util/ShowPickled.scala b/src/compiler/scala/tools/nsc/util/ShowPickled.scala index c89e16ac72..dcb87a38b5 100644 --- a/src/compiler/scala/tools/nsc/util/ShowPickled.scala +++ b/src/compiler/scala/tools/nsc/util/ShowPickled.scala @@ -129,17 +129,17 @@ object ShowPickled extends Names { case LITERALboolean => out.print(if (buf.readLong(len) == 0L) " false" else " true") case LITERALbyte => - out.print(" " + buf.readLong(len).asInstanceOf[Byte]) + out.print(" " + buf.readLong(len).toByte) case LITERALshort => - out.print(" " + buf.readLong(len).asInstanceOf[Short]) + out.print(" " + buf.readLong(len).toShort) case LITERALchar => - out.print(" " + buf.readLong(len).asInstanceOf[Char]) + out.print(" " + buf.readLong(len).toChar) case LITERALint => - out.print(" " + buf.readLong(len).asInstanceOf[Int]) + out.print(" " + buf.readLong(len).toInt) case LITERALlong => out.print(" " + buf.readLong(len)) case LITERALfloat => - out.print(" " + intBitsToFloat(buf.readLong(len).asInstanceOf[Int])) + out.print(" " + intBitsToFloat(buf.readLong(len).toInt)) case LITERALdouble => out.print(" " + longBitsToDouble(buf.readLong(len))) case LITERALstring => diff --git a/src/msil/ch/epfl/lamp/compiler/msil/emit/OpCode.scala b/src/msil/ch/epfl/lamp/compiler/msil/emit/OpCode.scala index 076bf50360..e7bff447cc 100644 --- a/src/msil/ch/epfl/lamp/compiler/msil/emit/OpCode.scala +++ b/src/msil/ch/epfl/lamp/compiler/msil/emit/OpCode.scala @@ -52,13 +52,13 @@ class OpCode extends Visitable { protected def length(): byte = { val code = OpCode.length(CEE_code) val inline = OpCode.INLINE_length(CEE_inline) - return if(inline < 0) { -1 } else { (code + inline).asInstanceOf[byte] } + return if(inline < 0) { -1 } else { (code + inline).toByte } } protected def popush(): byte = { val pop = OpCode.POP_size(CEE_pop) val push = OpCode.PUSH_size(CEE_push) - return if(pop < 0 || push < 0) { OpCode.POPUSH_SPECIAL } else { (push - pop).asInstanceOf[byte] } + return if(pop < 0 || push < 0) { OpCode.POPUSH_SPECIAL } else { (push - pop).toByte } } override def toString(): String = { @@ -524,7 +524,7 @@ object OpCode { pop: byte, push: byte, inline: byte, flow: byte) { that.CEE_opcode = opcode that.CEE_string = string - that.CEE_code = code.asInstanceOf[short] + that.CEE_code = code.toShort that.CEE_pop = pop that.CEE_push = push that.CEE_inline = inline diff --git a/src/scalap/scala/tools/scalap/ByteArrayReader.scala b/src/scalap/scala/tools/scalap/ByteArrayReader.scala index 9f9fceab26..2fde050782 100644 --- a/src/scalap/scala/tools/scalap/ByteArrayReader.scala +++ b/src/scalap/scala/tools/scalap/ByteArrayReader.scala @@ -61,7 +61,7 @@ class ByteArrayReader(content: Array[Byte]) { /** read a long */ def nextLong: Long = - (nextInt.asInstanceOf[Long] << 32) + (nextInt.asInstanceOf[Long] & 0xffffffffL) + (nextInt.toLong << 32) + (nextInt.toLong & 0xffffffffL) /** read a float */ @@ -138,7 +138,7 @@ class ByteArrayReader(content: Array[Byte]) { /** extract a long integer at position bp from buf */ def getLong(bp: Int): Long = - (getInt(bp).asInstanceOf[Long] << 32) + (getInt(bp + 4).asInstanceOf[Long] & 0xffffffffL) + (getInt(bp).toLong << 32) + (getInt(bp + 4).toLong & 0xffffffffL) /** extract a float at position bp from buf */ diff --git a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSig.scala b/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSig.scala index 5ae6ef7c64..c78ed83a33 100644 --- a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSig.scala +++ b/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSig.scala @@ -247,12 +247,12 @@ object ScalaSigEntryParsers extends RulesWithState with MemoisableRules { lazy val literal = oneOf( 24 -^ (), 25 -~ longValue ^^ (_ != 0L), - 26 -~ longValue ^^ (_.asInstanceOf[Byte]), - 27 -~ longValue ^^ (_.asInstanceOf[Short]), - 28 -~ longValue ^^ (_.asInstanceOf[Char]), - 29 -~ longValue ^^ (_.asInstanceOf[Int]), - 30 -~ longValue ^^ (_.asInstanceOf[Long]), - 31 -~ longValue ^^ (l => java.lang.Float.intBitsToFloat(l.asInstanceOf[Int])), + 26 -~ longValue ^^ (_.toByte), + 27 -~ longValue ^^ (_.toShort), + 28 -~ longValue ^^ (_.toChar), + 29 -~ longValue ^^ (_.toInt), + 30 -~ longValue ^^ (_.toLong), + 31 -~ longValue ^^ (l => java.lang.Float.intBitsToFloat(l.toInt)), 32 -~ longValue ^^ (java.lang.Double.longBitsToDouble), 33 -~ nameRef, 34 -^ null, |