diff options
author | Paul Phillips <paulp@improving.org> | 2011-01-04 01:16:48 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-01-04 01:16:48 +0000 |
commit | 7d0e5ac4bb93009c9ae1392bd9a7b3628dee4e2a (patch) | |
tree | 167e0548aef4bc7e32d3ff9a51d2812b8b138f2b /src | |
parent | e8b450d51d3db4f6fd181910a83799f2ebd9ef59 (diff) | |
download | scala-7d0e5ac4bb93009c9ae1392bd9a7b3628dee4e2a.tar.gz scala-7d0e5ac4bb93009c9ae1392bd9a7b3628dee4e2a.tar.bz2 scala-7d0e5ac4bb93009c9ae1392bd9a7b3628dee4e2a.zip |
Misc icode cleanup. No review.
Diffstat (limited to 'src')
3 files changed, 21 insertions, 25 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index c1623c1fbf..1157b1836d 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -1940,7 +1940,7 @@ abstract class GenICode extends SubComponent { def enterMethod(m: IMethod, d: DefDef): Context = { val ctx1 = new Context(this) setMethod(m) ctx1.labels = new mutable.HashMap() - ctx1.method.code = new Code(m.symbol.simpleName.toString(), m) + ctx1.method.code = new Code(m) ctx1.bb = ctx1.method.code.startBlock ctx1.defdef = d ctx1.scope = EmptyScope diff --git a/src/compiler/scala/tools/nsc/backend/icode/Members.scala b/src/compiler/scala/tools/nsc/backend/icode/Members.scala index fccab4a44c..f9fee3c29f 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Members.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Members.scala @@ -26,6 +26,7 @@ trait Members { self: ICodes => * other multi-block piece of code, like exception handlers. */ class Code(label: String, method: IMethod) { + def this(method: IMethod) = this(method.symbol.simpleName.toString, method) /** The set of all blocks */ val blocks: ListBuffer[BasicBlock] = new ListBuffer diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala index 1d8df4fa02..f944a168e9 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala @@ -9,9 +9,8 @@ package classfile import scala.collection.{ mutable, immutable } import mutable.ListBuffer -import scala.tools.nsc._ -import scala.tools.nsc.backend.icode._ -import scala.tools.nsc.io._ +import backend.icode._ +import io.AbstractFile import ClassfileConstants._ import Flags._ @@ -29,8 +28,8 @@ abstract class ICodeReader extends ClassfileParser { var staticCode: IClass = null // the ICode class static members var method: IMethod = _ // the current IMethod - val nothingName = newTermName(ClassfileConstants.SCALA_NOTHING) - val nullName = newTermName(ClassfileConstants.SCALA_NULL) + val nothingName = newTermName(SCALA_NOTHING) + val nullName = newTermName(SCALA_NULL) var isScalaModule = false /** Read back bytecode for the given class symbol. It returns @@ -608,9 +607,11 @@ abstract class ICodeReader extends ClassfileParser { // add parameters var idx = if (method.isStatic) 0 else 1 - for (t <- method.symbol.tpe.paramTypes; val kind = toTypeKind(t)) { - this.method.addParam(code.enterParam(idx, kind)) - idx += (if (kind.isWideType) 2 else 1) + for (t <- method.symbol.tpe.paramTypes) { + val kind = toTypeKind(t) + this.method addParam code.enterParam(idx, kind) + val width = if (kind.isWideType) 2 else 1 + idx += width } pc = 0 @@ -683,7 +684,7 @@ abstract class ICodeReader extends ClassfileParser { def toBasicBlock: Code = { import opcodes._ - val code = new Code(method.symbol.name.toString, method); + val code = new Code(method) method.setCode(code) var bb = code.startBlock @@ -709,39 +710,33 @@ abstract class ICodeReader extends ClassfileParser { instr match { case LJUMP(target) => otherBlock = blocks(target) - bb.emit(JUMP(otherBlock)) - bb.close + bb.emitOnly(JUMP(otherBlock)) case LCJUMP(success, failure, cond, kind) => otherBlock = blocks(success) val failBlock = blocks(failure) - bb.emit(CJUMP(otherBlock, failBlock, cond, kind)) - bb.close + bb.emitOnly(CJUMP(otherBlock, failBlock, cond, kind)) case LCZJUMP(success, failure, cond, kind) => otherBlock = blocks(success) val failBlock = blocks(failure) - bb.emit(CZJUMP(otherBlock, failBlock, cond, kind)) - bb.close + bb.emitOnly(CZJUMP(otherBlock, failBlock, cond, kind)) case LSWITCH(tags, targets) => - bb.emit(SWITCH(tags, targets map blocks)) - bb.close + bb.emitOnly(SWITCH(tags, targets map blocks)) case RETURN(_) => - bb.emit(instr) - bb.close + bb.emitOnly(instr) case THROW(clasz) => - bb.emit(instr) - bb.close + bb.emitOnly(instr) case _ => bb.emit(instr) } } - code + method.code } def resolveDups { @@ -930,7 +925,7 @@ abstract class ICodeReader extends ClassfileParser { def resolveNEWs { import opcodes._ - val rdef = new reachingDefinitions.ReachingDefinitionsAnalysis; + val rdef = new reachingDefinitions.ReachingDefinitionsAnalysis rdef.init(method) rdef.run @@ -970,7 +965,7 @@ abstract class ICodeReader extends ClassfileParser { } kind match { case LONG | DOUBLE if (locals.isDefinedAt(idx + 1)) => - global.globalError("Illegal index: " + idx + " overlaps " + locals(idx + 1)) + global.globalError("Illegal index: " + idx + " overlaps " + locals(idx + 1) + "\nlocals: " + locals) case _ => () } } |