diff options
author | Paul Phillips <paulp@improving.org> | 2010-03-05 18:17:26 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-03-05 18:17:26 +0000 |
commit | 603f715f52462de73481fd79e12c0deec68d269e (patch) | |
tree | 07d58e4a85d50ddca379d841d37cd13f8c2681e5 | |
parent | dcca0ea0d7bb7a84b450deff820a0ce5e14328b3 (diff) | |
download | scala-603f715f52462de73481fd79e12c0deec68d269e.tar.gz scala-603f715f52462de73481fd79e12c0deec68d269e.tar.bz2 scala-603f715f52462de73481fd79e12c0deec68d269e.zip |
Cleaning up some redundancy martin noticed.
3 files changed, 18 insertions, 24 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index e13c72a8a5..64e6759da2 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -26,8 +26,9 @@ abstract class GenICode extends SubComponent { import icodes._ import icodes.opcodes._ import definitions.{ - ArrayClass, ObjectClass, ThrowableClass, - Object_equals, Object_isInstanceOf, Object_asInstanceOf + ArrayClass, ObjectClass, ThrowableClass, StringClass, NothingClass, NullClass, + Object_equals, Object_isInstanceOf, Object_asInstanceOf, ScalaRunTimeModule, + getMember } import scalaPrimitives.{ isArrayOp, isComparisonOp, isLogicalOp, @@ -49,13 +50,13 @@ abstract class GenICode extends SubComponent { var unit: CompilationUnit = _ // We assume definitions are alread initialized - val STRING = REFERENCE(definitions.StringClass) + val STRING = REFERENCE(StringClass) // this depends on the backend! should be changed. val ANY_REF_CLASS = REFERENCE(ObjectClass) - val SCALA_ALL = REFERENCE(definitions.NothingClass) - val SCALA_ALLREF = REFERENCE(definitions.NullClass) + val SCALA_ALL = REFERENCE(NothingClass) + val SCALA_ALLREF = REFERENCE(NullClass) val THROWABLE = REFERENCE(ThrowableClass) override def run { @@ -1172,8 +1173,8 @@ abstract class GenICode extends SubComponent { */ def genScalaHash(tree: Tree, ctx: Context): Context = { val hashMethod = { - ctx.bb.emit(LOAD_MODULE(definitions.ScalaRunTimeModule)) - definitions.getMember(definitions.ScalaRunTimeModule, "hash") + ctx.bb.emit(LOAD_MODULE(ScalaRunTimeModule)) + getMember(ScalaRunTimeModule, "hash") } val ctx1 = genLoad(tree, ctx, ANY_REF_CLASS) @@ -1369,8 +1370,8 @@ abstract class GenICode extends SubComponent { val equalsMethod = if (!settings.XO.value) platform.externalEquals else { - ctx.bb.emit(LOAD_MODULE(definitions.ScalaRunTimeModule)) - definitions.getMember(definitions.ScalaRunTimeModule, nme.inlinedEquals) + ctx.bb.emit(LOAD_MODULE(ScalaRunTimeModule)) + getMember(ScalaRunTimeModule, nme.inlinedEquals) } val ctx1 = genLoad(l, ctx, ANY_REF_CLASS) diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala index f1a9a8ae97..68c75a721a 100644 --- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala +++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala @@ -576,20 +576,8 @@ trait Definitions extends reflect.generic.StandardDefinitions { val unboxMethod = new HashMap[Symbol, Symbol] // Type -> Method val boxMethod = new HashMap[Symbol, Symbol] // Type -> Method - def isUnbox(m: Symbol) = (m.name == nme.unbox) && cond(m.tpe) { - case MethodType(_, restpe) => cond(unboxMethod get restpe.typeSymbol) { - case Some(`m`) => true - } - } - - /** Test whether a method symbol is that of a boxing method - * Martin @Paul: why the condition? Is not (boxMethod.valuesIterator contains m) enough? - */ - def isBox(m: Symbol) = (boxMethod.valuesIterator contains m) && cond(m.tpe) { - case MethodType(List(arg), _) => cond(boxMethod get arg.tpe.typeSymbol) { - case Some(`m`) => true - } - } + def isUnbox(m: Symbol) = unboxMethod.valuesIterator contains m + def isBox(m: Symbol) = boxMethod.valuesIterator contains m val refClass = new HashMap[Symbol, Symbol] val abbrvTag = new HashMap[Symbol, Char] diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala index 0e00f640ca..5bd3955604 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala @@ -627,7 +627,12 @@ abstract class ICodeReader extends ClassfileParser { if (code.containsNEW) code.resolveNEWs } - /** TODO: move in Definitions and remove obsolete isBox/isUnbox found there. */ + /** Note: these methods are different from the methods of the same name found + * in Definitions. These test whether a symbol represents one of the boxTo/unboxTo + * methods found in BoxesRunTime. The others test whether a symbol represents a + * synthetic method from one of the fake companion classes of the primitive types, + * such as Int.box(5). + */ def isBox(m: Symbol): Boolean = (m.owner == definitions.BoxesRunTimeClass.moduleClass && m.name.startsWith("boxTo")) |