diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2007-07-12 09:59:49 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2007-07-12 09:59:49 +0000 |
commit | 7ccd176538e8d5b18ad7e5a9370fbc4510d93640 (patch) | |
tree | 11d03d909ab1d857347839976fe9667092c26b47 /src | |
parent | 27afc3c269ea7027177794b4a327759de91127f0 (diff) | |
download | scala-7ccd176538e8d5b18ad7e5a9370fbc4510d93640.tar.gz scala-7ccd176538e8d5b18ad7e5a9370fbc4510d93640.tar.bz2 scala-7ccd176538e8d5b18ad7e5a9370fbc4510d93640.zip |
Improved code generation for numeric literals w...
Improved code generation for numeric literals when they are immediately
converted.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/icode/GenICode.scala | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index 198522829e..33d8739333 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -909,12 +909,20 @@ abstract class GenICode extends SubComponent { ctx case Literal(value) => - if (value.tag != UnitTag) - ctx.bb.emit(CONSTANT(value), tree.pos); - if (value.tag == NullTag) - generatedType = expectedType - else - generatedType = toTypeKind(value.tpe) + if (value.tag != UnitTag) (value.tag, expectedType) match { + case (IntTag, LONG) => + ctx.bb.emit(CONSTANT(Constant(value.longValue)), tree.pos); + generatedType = LONG + case (FloatTag, DOUBLE) => + ctx.bb.emit(CONSTANT(Constant(value.doubleValue)), tree.pos); + generatedType = DOUBLE + case (NullTag, _) => + ctx.bb.emit(CONSTANT(value), tree.pos); + generatedType = expectedType + case _ => + ctx.bb.emit(CONSTANT(value), tree.pos); + generatedType = toTypeKind(value.tpe) + } ctx case Block(stats, expr) => |