diff options
author | michelou <michelou@epfl.ch> | 2011-07-12 18:42:00 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2011-07-12 18:42:00 +0000 |
commit | 5eefefb73b8ab01a442ddf946e86df410b528771 (patch) | |
tree | 2466b20ac678488fce53f5af69db8303602cb397 /src/compiler | |
parent | 66862fe9d88b7d6e4036077f584b2cabcdef3ab0 (diff) | |
download | scala-5eefefb73b8ab01a442ddf946e86df410b528771.tar.gz scala-5eefefb73b8ab01a442ddf946e86df410b528771.tar.bz2 scala-5eefefb73b8ab01a442ddf946e86df410b528771.zip |
Seeing about getting trunk building again, no r...
Seeing about getting trunk building again, no review.
Diffstat (limited to 'src/compiler')
4 files changed, 81 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 87a54c4fda..0530efa6e2 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala @@ -14,7 +14,7 @@ import scala.reflect.internal.pickling.{ PickleFormat, PickleBuffer } import scala.tools.reflect.SigParser import scala.tools.nsc.util.ScalaClassLoader import scala.tools.nsc.symtab._ -import scala.tools.nsc.symtab.classfile.ClassfileConstants._ +import scala.reflect.internal.ClassfileConstants._ import ch.epfl.lamp.fjbg._ import JAccessFlags._ import JObjectType.{ JAVA_LANG_STRING, JAVA_LANG_OBJECT } @@ -76,9 +76,9 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with icodes.classes -= sym val bytecodeWriter = settings.outputDirs.getSingleOutput match { - case Some(f) if f hasExtension "jar" => + case Some(f) if f hasExtension "jar" => new DirectToJarfileWriter(f) - case _ => + case _ => if (settings.Ygenjavap.isDefault) new ClassBytecodeWriter { } else new ClassBytecodeWriter with JavapBytecodeWriter { } } diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index 7963cc09f3..43f66a2fb7 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -25,7 +25,7 @@ abstract class ClassfileParser { val global: Global import global._ - import ClassfileConstants._ + import scala.reflect.internal.ClassfileConstants._ import Flags._ protected var in: AbstractFileReader = _ // the class file reader @@ -206,12 +206,12 @@ abstract class ClassfileParser { getExternalName(in.getChar(start + 1)) } - /** Return the symbol of the class member at <code>index</code>. + /** Return the symbol of the class member at `index`. * The following special cases exist: - * - If the member refers to special MODULE$ static field, return + * - If the member refers to special `MODULE$` static field, return * the symbol of the corresponding module. * - If the member is a field, and is not found with the given name, - * another try is made by appending nme.LOCAL_SUFFIX_STRING + * another try is made by appending `nme.LOCAL_SUFFIX_STRING` * - If no symbol is found in the right tpe, a new try is made in the * companion class, in case the owner is an implementation class. */ @@ -271,7 +271,7 @@ abstract class ClassfileParser { } /** Return a name and a type at the given index. If the type is a method - * type, a dummy symbol is created in 'ownerTpe', which is used as the + * type, a dummy symbol is created in `ownerTpe`, which is used as the * owner of its value parameters. This might lead to inconsistencies, * if a symbol of the given name already exists, and has a different * type. @@ -546,13 +546,13 @@ abstract class ClassfileParser { skipMembers() // fields skipMembers() // methods if (!isScala) { - clazz.setFlag(sflags) + clazz setFlag sflags setPrivateWithin(clazz, jflags) setPrivateWithin(staticModule, jflags) if (!hasMeta || isScalaRaw) { clazz.setInfo(classInfo) } - statics.setInfo(staticInfo) + statics setInfo staticInfo staticModule.setInfo(statics.tpe) staticModule.setFlag(JAVA) staticModule.moduleClass.setFlag(JAVA) @@ -676,7 +676,7 @@ abstract class ClassfileParser { } /** Convert array parameters denoting a repeated parameter of a Java method - * to JavaRepeatedParamClass types. + * to `JavaRepeatedParamClass` types. */ private def arrayToRepeated(tp: Type): Type = tp match { case MethodType(params, rtpe) => @@ -994,7 +994,7 @@ abstract class ClassfileParser { def parseScalaSigBytes: Option[ScalaSigBytes] = { val tag = in.nextByte.toChar assert(tag == STRING_TAG) - Some(ScalaSigBytes(pool.getBytes(in.nextChar))) + Some(ScalaSigBytes(pool getBytes in.nextChar)) } def parseScalaLongSigBytes: Option[ScalaSigBytes] = try { @@ -1106,10 +1106,10 @@ abstract class ClassfileParser { val innerClass = getOwner(jflags).newClass(NoPosition, name.toTypeName).setInfo(completer).setFlag(sflags) val innerModule = getOwner(jflags).newModule(NoPosition, name.toTermName).setInfo(completer).setFlag(sflags) - innerModule.moduleClass.setInfo(global.loaders.moduleClassLoader) + innerModule.moduleClass setInfo global.loaders.moduleClassLoader - getScope(jflags).enter(innerClass) - getScope(jflags).enter(innerModule) + getScope(jflags) enter innerClass + getScope(jflags) enter innerModule val decls = innerClass.enclosingPackage.info.decls val e = decls.lookupEntry(className(entry.externalName)) @@ -1135,8 +1135,8 @@ abstract class ClassfileParser { } } - /** Parse inner classes. Expects in.bp to point to the superclass entry. Restores the - * old bp. + /** Parse inner classes. Expects `in.bp` to point to the superclass entry. + * Restores the old `bp`. */ def parseInnerClasses() { val oldbp = in.bp @@ -1185,17 +1185,17 @@ abstract class ClassfileParser { /** An entry in the InnerClasses attribute of this class file. */ case class InnerClassEntry(external: Int, outer: Int, name: Int, jflags: Int) { - def externalName = pool.getClassName(external) - def outerName = pool.getClassName(outer) - def originalName = pool.getName(name) + def externalName = pool getClassName external + def outerName = pool getClassName outer + def originalName = pool getName name override def toString = originalName + " in " + outerName + "(" + externalName +")" } object innerClasses extends collection.mutable.HashMap[Name, InnerClassEntry] { - /** Return the Symbol of the top level class enclosing 'name', or 'name's symbol - * if no entry found for 'name'. + /** Return the Symbol of the top level class enclosing `name`, + * or 'name's symbol if no entry found for `name`. */ def topLevelClass(name: Name): Symbol = { val tlName = if (isDefinedAt(name)) { @@ -1208,10 +1208,10 @@ abstract class ClassfileParser { classNameToSymbol(tlName) } - /** Return the class symbol for 'externalName'. It looks it up in its outer class. + /** Return the class symbol for `externalName`. It looks it up in its outer class. * Forces all outer class symbols to be completed. * - * If the given name is not an inner class, it returns the symbol found in 'definitions'. + * If the given name is not an inner class, it returns the symbol found in `definitions`. */ def classSymbol(externalName: Name): Symbol = { /** Return the symbol of `innerName`, having the given `externalName`. */ diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala index f80e17273c..a5db788260 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala @@ -10,8 +10,9 @@ package classfile import scala.collection.{ mutable, immutable } import mutable.ListBuffer import backend.icode._ -import ClassfileConstants._ -import Flags._ +import scala.reflect.internal.ClassfileConstants +import scala.reflect.internal.ClassfileConstants._ +import scala.reflect.internal.Flags._ /** ICode reader from Java bytecode. * @@ -45,8 +46,8 @@ abstract class ICodeReader extends ClassfileParser { val name = cls.fullName('.') + (if (sym.hasFlag(MODULE)) "$" else "") classPath.findSourceFile(name) match { - case Some(classFile) => parse(classFile, sym) - case _ => throw new MissingRequirementError("Could not find bytecode for " + cls) + case Some(classFile) => parse(classFile, sym) + case _ => throw new MissingRequirementError("Could not find bytecode for " + cls) } (staticCode, instanceCode) @@ -64,9 +65,9 @@ abstract class ICodeReader extends ClassfileParser { this.staticCode = new IClass(staticModule) val jflags = in.nextChar val isAttribute = (jflags & JAVA_ACC_ANNOTATION) != 0 - var sflags = transFlags(jflags, true) + var sflags = toScalaFlags(jflags, true) if ((sflags & DEFERRED) != 0L) sflags = sflags & ~DEFERRED | ABSTRACT - val c = pool.getClassSymbol(in.nextChar) + val c = pool getClassSymbol in.nextChar parseInnerClasses() @@ -82,13 +83,13 @@ abstract class ICodeReader extends ClassfileParser { override def parseField() { val (jflags, sym) = parseMember(true) - getCode(jflags).addField(new IField(sym)) + getCode(jflags) addField new IField(sym) skipAttributes() } private def parseMember(field: Boolean): (Int, Symbol) = { val jflags = in.nextChar - val name = pool.getName(in.nextChar) + val name = pool getName in.nextChar val owner = getOwner(jflags) val dummySym = owner.newMethod(owner.pos, name) setFlag javaToScalaFlags(jflags) @@ -136,7 +137,7 @@ abstract class ICodeReader extends ClassfileParser { res } - /** Checks if tp1 is the same type as tp2, modulo implicit methods. + /** Checks if `tp1` is the same type as `tp2`, modulo implicit methods. * We don't care about the distinction between implicit and explicit * methods as this point, and we can't get back the information from * bytecode anyway. @@ -153,7 +154,7 @@ abstract class ICodeReader extends ClassfileParser { var beginning = in.bp try { if (sym != NoSymbol) { - this.method = new IMethod(sym); + this.method = new IMethod(sym) this.method.returnType = toTypeKind(sym.tpe.resultType) getCode(jflags).addMethod(this.method) if ((jflags & JAVA_ACC_NATIVE) != 0) @@ -232,7 +233,7 @@ abstract class ICodeReader extends ClassfileParser { /** Parse 16 bit jump target. */ def parseJumpTarget = { - size = size + 2 + size += 2 val offset = in.nextChar.toShort val target = pc + offset assert(target >= 0 && target < codeLength, "Illegal jump target: " + target) @@ -251,22 +252,22 @@ abstract class ICodeReader extends ClassfileParser { val instr = toUnsignedByte(in.nextByte) instr match { case JVM.nop => parseInstruction - case JVM.aconst_null => code.emit(CONSTANT(Constant(null))) - case JVM.iconst_m1 => code.emit(CONSTANT(Constant(-1))) - case JVM.iconst_0 => code.emit(CONSTANT(Constant(0))) - case JVM.iconst_1 => code.emit(CONSTANT(Constant(1))) - case JVM.iconst_2 => code.emit(CONSTANT(Constant(2))) - case JVM.iconst_3 => code.emit(CONSTANT(Constant(3))) - case JVM.iconst_4 => code.emit(CONSTANT(Constant(4))) - case JVM.iconst_5 => code.emit(CONSTANT(Constant(5))) - - case JVM.lconst_0 => code.emit(CONSTANT(Constant(0l))) - case JVM.lconst_1 => code.emit(CONSTANT(Constant(1l))) - case JVM.fconst_0 => code.emit(CONSTANT(Constant(0.0f))) - case JVM.fconst_1 => code.emit(CONSTANT(Constant(1.0f))) - case JVM.fconst_2 => code.emit(CONSTANT(Constant(2.0f))) - case JVM.dconst_0 => code.emit(CONSTANT(Constant(0.0))) - case JVM.dconst_1 => code.emit(CONSTANT(Constant(1.0))) + case JVM.aconst_null => code emit CONSTANT(Constant(null)) + case JVM.iconst_m1 => code emit CONSTANT(Constant(-1)) + case JVM.iconst_0 => code emit CONSTANT(Constant(0)) + case JVM.iconst_1 => code emit CONSTANT(Constant(1)) + case JVM.iconst_2 => code emit CONSTANT(Constant(2)) + case JVM.iconst_3 => code emit CONSTANT(Constant(3)) + case JVM.iconst_4 => code emit CONSTANT(Constant(4)) + case JVM.iconst_5 => code emit CONSTANT(Constant(5)) + + case JVM.lconst_0 => code emit CONSTANT(Constant(0l)) + case JVM.lconst_1 => code emit CONSTANT(Constant(1l)) + case JVM.fconst_0 => code emit CONSTANT(Constant(0.0f)) + case JVM.fconst_1 => code emit CONSTANT(Constant(1.0f)) + case JVM.fconst_2 => code emit CONSTANT(Constant(2.0f)) + 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(in.nextByte))); size += 1 case JVM.sipush => code.emit(CONSTANT(Constant(in.nextChar))); size += 2 @@ -501,9 +502,9 @@ abstract class ICodeReader extends ClassfileParser { case JVM.getstatic => val field = pool.getMemberSymbol(in.nextChar, true); size += 2 if (field.hasModuleFlag) - code.emit(LOAD_MODULE(field)) + code emit LOAD_MODULE(field) else - code.emit(LOAD_FIELD(field, true)) + code emit LOAD_FIELD(field, true) case JVM.putstatic => val field = pool.getMemberSymbol(in.nextChar, true); size += 2 code.emit(STORE_FIELD(field, true)) @@ -589,14 +590,14 @@ abstract class ICodeReader extends ClassfileParser { case JVM.multianewarray => size += 3 - val tpe = toTypeKind(pool.getClassOrArrayType(in.nextChar)) + val tpe = toTypeKind(pool getClassOrArrayType in.nextChar) val dim = in.nextByte // assert(dim == 1, "Cannot handle multidimensional arrays yet.") - code.emit(CREATE_ARRAY(tpe, dim)) + code emit CREATE_ARRAY(tpe, dim) - case JVM.ifnull => code.emit(LCZJUMP(parseJumpTarget, pc + size, EQ, ObjectReference)) - case JVM.ifnonnull => code.emit(LCZJUMP(parseJumpTarget, pc + size, NE, ObjectReference)) - case JVM.goto_w => code.emit(LJUMP(parseJumpTargetW)) + case JVM.ifnull => code emit LCZJUMP(parseJumpTarget, pc + size, EQ, ObjectReference) + case JVM.ifnonnull => code emit LCZJUMP(parseJumpTarget, pc + size, NE, ObjectReference) + case JVM.goto_w => code emit LJUMP(parseJumpTargetW) case JVM.jsr_w => sys.error("Cannot handle jsr/ret") // case _ => sys.error("Unknown bytecode") @@ -678,7 +679,7 @@ abstract class ICodeReader extends ClassfileParser { } /** Break this linear code in basic block representation - * As a side effect, it sets the 'code' field of the current + * As a side effect, it sets the `code` field of the current */ def toBasicBlock: Code = { import opcodes._ @@ -725,13 +726,13 @@ abstract class ICodeReader extends ClassfileParser { bb.emitOnly(SWITCH(tags, targets map blocks)) case RETURN(_) => - bb.emitOnly(instr) + bb emitOnly instr case THROW(clasz) => - bb.emitOnly(instr) + bb emitOnly instr case _ => - bb.emit(instr) + bb emit instr } } @@ -747,9 +748,9 @@ abstract class ICodeReader extends ClassfileParser { /** Abstract interpretation for one instruction. */ override def interpret(in: typeFlowLattice.Elem, i: Instruction): typeFlowLattice.Elem = { - var out = IState(new VarBinding(in.vars), new TypeStack(in.stack)); - val bindings = out.vars; - val stack = out.stack; + var out = IState(new VarBinding(in.vars), new TypeStack(in.stack)) + val bindings = out.vars + val stack = out.stack import stack.push i match { case DUP_X1 => @@ -808,9 +809,9 @@ abstract class ICodeReader extends ClassfileParser { case DUP_X1 => val one = info.stack.types(0) val two = info.stack.types(1) - assert(!one.isWideType, "DUP_X1 expects values of size 1 on top of stack " + info.stack); - val tmp1 = freshLocal(one); - val tmp2 = freshLocal(two); + assert(!one.isWideType, "DUP_X1 expects values of size 1 on top of stack " + info.stack) + val tmp1 = freshLocal(one) + val tmp2 = freshLocal(two) bb.replaceInstruction(i, List(STORE_LOCAL(tmp1), STORE_LOCAL(tmp2), LOAD_LOCAL(tmp1), @@ -820,9 +821,9 @@ abstract class ICodeReader extends ClassfileParser { case DUP_X2 => val one = info.stack.types(0) val two = info.stack.types(1) - assert (!one.isWideType, "DUP_X2 expects values of size 1 on top of stack " + info.stack); - val tmp1 = freshLocal(one); - val tmp2 = freshLocal(two); + assert (!one.isWideType, "DUP_X2 expects values of size 1 on top of stack " + info.stack) + val tmp1 = freshLocal(one) + val tmp2 = freshLocal(two) if (two.isWideType) bb.replaceInstruction(i, List(STORE_LOCAL(tmp1), STORE_LOCAL(tmp2), @@ -853,7 +854,7 @@ abstract class ICodeReader extends ClassfileParser { LOAD_LOCAL(tmp2), LOAD_LOCAL(tmp1))); } else { - val tmp3 = freshLocal(info.stack.types(2)); + val tmp3 = freshLocal(info.stack.types(2)) bb.replaceInstruction(i, List(STORE_LOCAL(tmp1), STORE_LOCAL(tmp2), STORE_LOCAL(tmp3), @@ -866,8 +867,8 @@ abstract class ICodeReader extends ClassfileParser { case DUP2_X2 => val one = info.stack.types(0) val two = info.stack.types(1) - val tmp1 = freshLocal(one); - val tmp2 = freshLocal(two); + val tmp1 = freshLocal(one) + val tmp2 = freshLocal(two) if (one.isWideType && two.isWideType) { bb.replaceInstruction(i, List(STORE_LOCAL(tmp1), STORE_LOCAL(tmp2), @@ -954,7 +955,7 @@ abstract class ICodeReader extends ClassfileParser { /** Return the local at given index, with the given type. */ def getLocal(idx: Int, kind: TypeKind): Local = { - assert(idx < maxLocals, "Index too large for local variable."); + assert(idx < maxLocals, "Index too large for local variable.") def checkValidIndex() { locals.get(idx - 1) match { @@ -1012,7 +1013,7 @@ abstract class ICodeReader extends ClassfileParser { /** add a method param with the given index. */ def enterParam(idx: Int, kind: TypeKind) = { - val sym = method.symbol.newVariable(NoPosition, "par" + idx).setInfo(kind.toType); + val sym = method.symbol.newVariable(NoPosition, "par" + idx).setInfo(kind.toType) val l = new Local(sym, kind, true) assert(!locals.isDefinedAt(idx)) locals += (idx -> List((l, kind))) @@ -1028,20 +1029,20 @@ abstract class ICodeReader extends ClassfileParser { case class LJUMP(pc: Int) extends LazyJump(pc); case class LCJUMP(success: Int, failure: Int, cond: TestOp, kind: TypeKind) extends LazyJump(success) { - override def toString(): String ="LCJUMP (" + kind + ") " + success + " : " + failure; + override def toString(): String = "LCJUMP (" + kind + ") " + success + " : " + failure jmpTargets += failure } case class LCZJUMP(success: Int, failure: Int, cond: TestOp, kind: TypeKind) extends LazyJump(success) { - override def toString(): String ="LCZJUMP (" + kind + ") " + success + " : " + failure; + override def toString(): String = "LCZJUMP (" + kind + ") " + success + " : " + failure jmpTargets += failure } case class LSWITCH(tags: List[List[Int]], targets: List[Int]) extends LazyJump(targets.head) { - override def toString(): String ="LSWITCH (tags: " + tags + ") targets: " + targets; + override def toString(): String = "LSWITCH (tags: " + tags + ") targets: " + targets jmpTargets ++= targets.tail } diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 1c6e2e9f90..d32824ca25 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -6,7 +6,7 @@ package scala.tools.nsc package transform -import scala.tools.nsc.symtab.classfile.ClassfileConstants._ +import scala.reflect.internal.ClassfileConstants._ import scala.collection.{ mutable, immutable } import symtab._ import Flags._ |