summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/symtab
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2015-07-27 13:33:16 +1000
committerJason Zaugg <jzaugg@gmail.com>2015-07-27 13:33:16 +1000
commitf682441f6f402cc22a747ea93547631af9cb669d (patch)
treea54803d9231347bfa92e72e94d19fac125b22f22 /src/compiler/scala/tools/nsc/symtab
parentf2d7838d904572b3dd15a9ef223ecfd1a6e14697 (diff)
parent2678d349b2b2738d9db38d890199f32aa39d8c3e (diff)
downloadscala-f682441f6f402cc22a747ea93547631af9cb669d.tar.gz
scala-f682441f6f402cc22a747ea93547631af9cb669d.tar.bz2
scala-f682441f6f402cc22a747ea93547631af9cb669d.zip
Merge pull request #4653 from lrytz/t9403
SI-9403 fix ICodeReader for negative BIPUSH / SIPUSH values
Diffstat (limited to 'src/compiler/scala/tools/nsc/symtab')
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala3
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala6
2 files changed, 6 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
index 06a0299d2a..99e61d2482 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
@@ -84,6 +84,9 @@ abstract class ClassfileParser {
protected final def u2(): Int = in.nextChar.toInt
protected final def u4(): Int = in.nextInt
+ protected final def s1(): Int = in.nextByte.toInt // sign-extend the byte to int
+ protected final def s2(): Int = (in.nextByte.toInt << 8) | u1 // sign-extend and shift the first byte, or with the unsigned second byte
+
private def readInnerClassFlags() = readClassFlags()
private def readClassFlags() = JavaAccFlags classFlags u2
private def readMethodFlags() = JavaAccFlags methodFlags u2
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala
index 438a71061e..b2f5a4119d 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala
@@ -326,8 +326,8 @@ abstract class ICodeReader extends ClassfileParser {
case JVM.dconst_0 => code emit CONSTANT(Constant(0.0))
case JVM.dconst_1 => code emit CONSTANT(Constant(1.0))
- case JVM.bipush => code.emit(CONSTANT(Constant(u1))); size += 1
- case JVM.sipush => code.emit(CONSTANT(Constant(u2))); size += 2
+ case JVM.bipush => code.emit(CONSTANT(Constant(s1))); size += 1
+ case JVM.sipush => code.emit(CONSTANT(Constant(s2))); size += 2
case JVM.ldc => code.emit(CONSTANT(pool.getConstant(u1))); size += 1
case JVM.ldc_w => code.emit(CONSTANT(pool.getConstant(u2))); size += 2
case JVM.ldc2_w => code.emit(CONSTANT(pool.getConstant(u2))); size += 2
@@ -466,7 +466,7 @@ abstract class ICodeReader extends ClassfileParser {
size += 2
val local = code.getLocal(u1, INT)
code.emit(LOAD_LOCAL(local))
- code.emit(CONSTANT(Constant(u1)))
+ code.emit(CONSTANT(Constant(s1)))
code.emit(CALL_PRIMITIVE(Arithmetic(ADD, INT)))
code.emit(STORE_LOCAL(local))