summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authormihaylov <mihaylov@epfl.ch>2007-02-11 14:19:25 +0000
committermihaylov <mihaylov@epfl.ch>2007-02-11 14:19:25 +0000
commit37dd5e78a7bf2ac0485659365e52c5a51e616eb5 (patch)
treea024054afebd6c05cd9914efabeb8e9bd8128dc2 /src/compiler
parentf2ccc14292a7a997d3fc452f20e5cd265e2f3537 (diff)
downloadscala-37dd5e78a7bf2ac0485659365e52c5a51e616eb5.tar.gz
scala-37dd5e78a7bf2ac0485659365e52c5a51e616eb5.tar.bz2
scala-37dd5e78a7bf2ac0485659365e52c5a51e616eb5.zip
Generate direct reference to the TYPE field of ...
Generate direct reference to the TYPE field of the Java box classes for classOf[PrimitiveType]
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/transform/CleanUp.scala16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
index 52070f7083..499ff83e12 100644
--- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala
+++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
@@ -27,6 +27,20 @@ abstract class CleanUp extends Transform {
private val newDefs = new ListBuffer[Tree]
private val classConstantMeth = new HashMap[String, Symbol]
+ // a map from the symbols of the Scala primitive types to the symbols
+ // of the modules of the Java box classes
+ private val javaBoxClassModule = new HashMap[Symbol, Symbol]
+
+ javaBoxClassModule(UnitClass) = getModule("java.lang.Void")
+ javaBoxClassModule(BooleanClass) = getModule("java.lang.Boolean")
+ javaBoxClassModule(ByteClass) = getModule("java.lang.Byte")
+ javaBoxClassModule(ShortClass) = getModule("java.lang.Short")
+ javaBoxClassModule(IntClass) = getModule("java.lang.Integer")
+ javaBoxClassModule(CharClass) = getModule("java.lang.Character")
+ javaBoxClassModule(LongClass) = getModule("java.lang.Long")
+ javaBoxClassModule(FloatClass) = getModule("java.lang.Float")
+ javaBoxClassModule(DoubleClass) = getModule("java.lang.Double")
+
private var localTyper: analyzer.Typer = null;
private def freshClassConstantMethName() = unit.fresh.newName("class$Method")
@@ -85,7 +99,7 @@ abstract class CleanUp extends Transform {
atPos(tree.pos) {
localTyper.typed {
if (isValueClass(tpe.symbol))
- gen.mkRuntimeCall(tpe.symbol.name.toString() + "TYPE", List())
+ Select(gen.mkAttributedRef(javaBoxClassModule(tpe.symbol)), "TYPE")
else
Apply(
gen.mkAttributedRef(classConstantMethod(tree.pos, signature(tpe))),