summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2005-09-14 08:51:59 +0000
committermichelou <michelou@epfl.ch>2005-09-14 08:51:59 +0000
commit26ae5058053b60b798ca100354ac2743181bc836 (patch)
tree09d7ad241372f43cc78cea338cab8f09b93adfea
parentf18f51cb99bae9472b89ae89fb3de2ccbd700093 (diff)
downloadscala-26ae5058053b60b798ca100354ac2743181bc836.tar.gz
scala-26ae5058053b60b798ca100354ac2743181bc836.tar.bz2
scala-26ae5058053b60b798ca100354ac2743181bc836.zip
- commented out "System.out.println" in doubleV...
- commented out "System.out.println" in doubleValue.
-rwxr-xr-xsources/scala/tools/nsc/symtab/Constants.scala177
1 files changed, 92 insertions, 85 deletions
diff --git a/sources/scala/tools/nsc/symtab/Constants.scala b/sources/scala/tools/nsc/symtab/Constants.scala
index 28955f6449..42bba1f735 100755
--- a/sources/scala/tools/nsc/symtab/Constants.scala
+++ b/sources/scala/tools/nsc/symtab/Constants.scala
@@ -2,7 +2,9 @@
* Copyright 2005 LAMP/EPFL
* @author Martin Odersky
*/
+
// $Id$
+
package scala.tools.nsc.symtab;
import classfile.PickleFormat._;
@@ -11,18 +13,18 @@ abstract class Constants: SymbolTable {
import definitions._;
- final val UnitTag = LITERALunit - LITERAL;
+ final val UnitTag = LITERALunit - LITERAL;
final val BooleanTag = LITERALboolean - LITERAL;
- final val ByteTag = LITERALbyte - LITERAL;
- final val ShortTag = LITERALshort - LITERAL;
- final val CharTag = LITERALchar - LITERAL;
- final val IntTag = LITERALint - LITERAL;
- final val LongTag = LITERALlong - LITERAL;
- final val FloatTag = LITERALfloat - LITERAL;
- final val DoubleTag = LITERALdouble - LITERAL;
- final val StringTag = LITERALstring - LITERAL;
- final val NullTag = LITERALnull - LITERAL;
- final val ZeroTag = LITERALzero - LITERAL;
+ final val ByteTag = LITERALbyte - LITERAL;
+ final val ShortTag = LITERALshort - LITERAL;
+ final val CharTag = LITERALchar - LITERAL;
+ final val IntTag = LITERALint - LITERAL;
+ final val LongTag = LITERALlong - LITERAL;
+ final val FloatTag = LITERALfloat - LITERAL;
+ final val DoubleTag = LITERALdouble - LITERAL;
+ final val StringTag = LITERALstring - LITERAL;
+ final val NullTag = LITERALnull - LITERAL;
+ final val ZeroTag = LITERALzero - LITERAL;
case class Constant(value: Any) {
val tag: int =
@@ -40,17 +42,17 @@ abstract class Constants: SymbolTable {
else throw new Error("bad constant value: " + value);
def tpe: Type = tag match {
- case UnitTag => UnitClass.tpe
+ case UnitTag => UnitClass.tpe
case BooleanTag => BooleanClass.tpe
- case ByteTag => ByteClass.tpe
- case ShortTag => ShortClass.tpe
- case CharTag => CharClass.tpe
- case IntTag => IntClass.tpe
- case LongTag => LongClass.tpe
- case FloatTag => FloatClass.tpe
- case DoubleTag => DoubleClass.tpe
- case StringTag => StringClass.tpe
- case NullTag => AllRefClass.tpe
+ case ByteTag => ByteClass.tpe
+ case ShortTag => ShortClass.tpe
+ case CharTag => CharClass.tpe
+ case IntTag => IntClass.tpe
+ case LongTag => LongClass.tpe
+ case FloatTag => FloatClass.tpe
+ case DoubleTag => DoubleClass.tpe
+ case StringTag => StringClass.tpe
+ case NullTag => AllRefClass.tpe
}
def booleanValue: boolean =
@@ -58,93 +60,96 @@ abstract class Constants: SymbolTable {
else throw new Error("value " + value + " is not a boolean");
def byteValue: byte = tag match {
- case ByteTag => value.asInstanceOf$erased[byte]
- case ShortTag => value.asInstanceOf$erased[short].asInstanceOf[byte]
- case CharTag => value.asInstanceOf$erased[char].asInstanceOf[byte]
- case IntTag => value.asInstanceOf$erased[int].asInstanceOf[byte]
- case LongTag => value.asInstanceOf$erased[long].asInstanceOf[byte]
- case FloatTag => value.asInstanceOf$erased[float].asInstanceOf[byte]
+ case ByteTag => value.asInstanceOf$erased[byte]
+ case ShortTag => value.asInstanceOf$erased[short].asInstanceOf[byte]
+ case CharTag => value.asInstanceOf$erased[char].asInstanceOf[byte]
+ case IntTag => value.asInstanceOf$erased[int].asInstanceOf[byte]
+ case LongTag => value.asInstanceOf$erased[long].asInstanceOf[byte]
+ case FloatTag => value.asInstanceOf$erased[float].asInstanceOf[byte]
case DoubleTag => value.asInstanceOf$erased[double].asInstanceOf[byte]
- case _ => throw new Error("value " + value + " is not a byte")
+ case _ => throw new Error("value " + value + " is not a byte")
}
def shortValue: short = tag match {
- case ByteTag => value.asInstanceOf$erased[byte].asInstanceOf[short]
- case ShortTag => value.asInstanceOf$erased[short]
- case CharTag => value.asInstanceOf$erased[char].asInstanceOf[short]
- case IntTag => value.asInstanceOf$erased[int].asInstanceOf[short]
- case LongTag => value.asInstanceOf$erased[long].asInstanceOf[short]
- case FloatTag => value.asInstanceOf$erased[float].asInstanceOf[short]
+ case ByteTag => value.asInstanceOf$erased[byte].asInstanceOf[short]
+ case ShortTag => value.asInstanceOf$erased[short]
+ case CharTag => value.asInstanceOf$erased[char].asInstanceOf[short]
+ case IntTag => value.asInstanceOf$erased[int].asInstanceOf[short]
+ case LongTag => value.asInstanceOf$erased[long].asInstanceOf[short]
+ case FloatTag => value.asInstanceOf$erased[float].asInstanceOf[short]
case DoubleTag => value.asInstanceOf$erased[double].asInstanceOf[short]
- case _ => throw new Error("value " + value + " is not a short")
+ case _ => throw new Error("value " + value + " is not a short")
}
def charValue: char = tag match {
- case ByteTag => value.asInstanceOf$erased[byte].asInstanceOf[char]
- case ShortTag => value.asInstanceOf$erased[short].asInstanceOf[char]
- case CharTag => value.asInstanceOf$erased[char]
- case IntTag => value.asInstanceOf$erased[int].asInstanceOf[char]
- case LongTag => value.asInstanceOf$erased[long].asInstanceOf[char]
- case FloatTag => value.asInstanceOf$erased[float].asInstanceOf[char]
+ case ByteTag => value.asInstanceOf$erased[byte].asInstanceOf[char]
+ case ShortTag => value.asInstanceOf$erased[short].asInstanceOf[char]
+ case CharTag => value.asInstanceOf$erased[char]
+ case IntTag => value.asInstanceOf$erased[int].asInstanceOf[char]
+ case LongTag => value.asInstanceOf$erased[long].asInstanceOf[char]
+ case FloatTag => value.asInstanceOf$erased[float].asInstanceOf[char]
case DoubleTag => value.asInstanceOf$erased[double].asInstanceOf[char]
- case _ => throw new Error("value " + value + " is not a char")
+ case _ => throw new Error("value " + value + " is not a char")
}
def intValue: int = tag match {
- case ByteTag => value.asInstanceOf$erased[byte].asInstanceOf[int]
- case ShortTag => value.asInstanceOf$erased[short].asInstanceOf[int]
- case CharTag => value.asInstanceOf$erased[char].asInstanceOf[int]
- case IntTag => value.asInstanceOf$erased[int]
- case LongTag => value.asInstanceOf$erased[long].asInstanceOf[int]
- case FloatTag => value.asInstanceOf$erased[float].asInstanceOf[int]
+ case ByteTag => value.asInstanceOf$erased[byte].asInstanceOf[int]
+ case ShortTag => value.asInstanceOf$erased[short].asInstanceOf[int]
+ case CharTag => value.asInstanceOf$erased[char].asInstanceOf[int]
+ case IntTag => value.asInstanceOf$erased[int]
+ case LongTag => value.asInstanceOf$erased[long].asInstanceOf[int]
+ case FloatTag => value.asInstanceOf$erased[float].asInstanceOf[int]
case DoubleTag => value.asInstanceOf$erased[double].asInstanceOf[int]
- case _ => throw new Error("value " + value + " is not an int")
+ case _ => throw new Error("value " + value + " is not an int")
}
def longValue: long = tag match {
- case ByteTag => value.asInstanceOf$erased[byte].asInstanceOf[long]
- case ShortTag => value.asInstanceOf$erased[short].asInstanceOf[long]
- case CharTag => value.asInstanceOf$erased[char].asInstanceOf[long]
- case IntTag => value.asInstanceOf$erased[int].asInstanceOf[long]
- case LongTag => value.asInstanceOf$erased[long]
- case FloatTag => value.asInstanceOf$erased[float].asInstanceOf[long]
+ case ByteTag => value.asInstanceOf$erased[byte].asInstanceOf[long]
+ case ShortTag => value.asInstanceOf$erased[short].asInstanceOf[long]
+ case CharTag => value.asInstanceOf$erased[char].asInstanceOf[long]
+ case IntTag => value.asInstanceOf$erased[int].asInstanceOf[long]
+ case LongTag => value.asInstanceOf$erased[long]
+ case FloatTag => value.asInstanceOf$erased[float].asInstanceOf[long]
case DoubleTag => value.asInstanceOf$erased[double].asInstanceOf[long]
- case _ => throw new Error("value " + value + " is not a long")
+ case _ => throw new Error("value " + value + " is not a long")
}
def floatValue: float = tag match {
- case ByteTag => value.asInstanceOf$erased[byte].asInstanceOf[float]
- case ShortTag => value.asInstanceOf$erased[short].asInstanceOf[float]
- case CharTag => value.asInstanceOf$erased[char].asInstanceOf[float]
- case IntTag => value.asInstanceOf$erased[int].asInstanceOf[float]
- case LongTag => value.asInstanceOf$erased[long].asInstanceOf[float]
- case FloatTag => value.asInstanceOf$erased[float]
+ case ByteTag => value.asInstanceOf$erased[byte].asInstanceOf[float]
+ case ShortTag => value.asInstanceOf$erased[short].asInstanceOf[float]
+ case CharTag => value.asInstanceOf$erased[char].asInstanceOf[float]
+ case IntTag => value.asInstanceOf$erased[int].asInstanceOf[float]
+ case LongTag => value.asInstanceOf$erased[long].asInstanceOf[float]
+ case FloatTag => value.asInstanceOf$erased[float]
case DoubleTag => value.asInstanceOf$erased[double].asInstanceOf[float]
- case _ => throw new Error("value " + value + " is not a float")
+ case _ => throw new Error("value " + value + " is not a float")
}
+/*
def doubleValue: double = {
System.out.println("doubleValue " + tag + " " + value);
tag match {
- case ByteTag => System.out.println("Byte"); value.asInstanceOf$erased[byte].asInstanceOf[double]
- case ShortTag => System.out.println("Short"); value.asInstanceOf$erased[short].asInstanceOf[double]
- case CharTag => System.out.println("Char"); value.asInstanceOf$erased[char].asInstanceOf[double]
- case IntTag => System.out.println("Int"); value.asInstanceOf$erased[int].asInstanceOf[double]
- case LongTag => System.out.println("Long"); value.asInstanceOf$erased[long].asInstanceOf[double]
- case FloatTag => System.out.println("Float"); value.asInstanceOf$erased[float].asInstanceOf[double]
- case DoubleTag => System.out.println("Double"); value.asInstanceOf$erased[double].asInstanceOf[double]
- case _ => System.out.println("error"); throw new Error("value " + value + " is not a double")
- }}
-/*
- def doubleValue: double =
- if (tag == ByteTag) value.asInstanceOf$erased[byte].asInstanceOf[double]
- else if (tag == ShortTag) value.asInstanceOf$erased[short].asInstanceOf[double]
- else if (tag == CharTag) value.asInstanceOf$erased[char].asInstanceOf[double]
- else if (tag == IntTag) value.asInstanceOf$erased[int].asInstanceOf[double]
- else if (tag == LongTag) value.asInstanceOf$erased[long].asInstanceOf[double]
- else if (tag == FloatTag) value.asInstanceOf$erased[float].asInstanceOf[double]
- else if (tag == DoubleTag) value.asInstanceOf$erased[double].asInstanceOf[double]
- else throw new Error("value " + value + " is not a double");
+ case ByteTag => System.out.println("Byte"); value.asInstanceOf$erased[byte].asInstanceOf[double]
+ case ShortTag => System.out.println("Short"); value.asInstanceOf$erased[short].asInstanceOf[double]
+ case CharTag => System.out.println("Char"); value.asInstanceOf$erased[char].asInstanceOf[double]
+ case IntTag => System.out.println("Int"); value.asInstanceOf$erased[int].asInstanceOf[double]
+ case LongTag => System.out.println("Long"); value.asInstanceOf$erased[long].asInstanceOf[double]
+ case FloatTag => System.out.println("Float"); value.asInstanceOf$erased[float].asInstanceOf[double]
+ case DoubleTag => System.out.println("Double"); value.asInstanceOf$erased[double]
+ case _ => System.out.println("error"); throw new Error("value " + value + " is not a double")
+ }
+ }
*/
+ def doubleValue: double = tag match {
+ case ByteTag => value.asInstanceOf$erased[byte].asInstanceOf[double]
+ case ShortTag => value.asInstanceOf$erased[short].asInstanceOf[double]
+ case CharTag => value.asInstanceOf$erased[char].asInstanceOf[double]
+ case IntTag => value.asInstanceOf$erased[int].asInstanceOf[double]
+ case LongTag => value.asInstanceOf$erased[long].asInstanceOf[double]
+ case FloatTag => value.asInstanceOf$erased[float].asInstanceOf[double]
+ case DoubleTag => value.asInstanceOf$erased[double]
+ case _ => throw new Error("value " + value + " is not a double")
+ }
+
/** Convert constant value to conform to given type */
def convertTo(pt: Type): Constant = {
val target = pt.symbol;
@@ -170,9 +175,11 @@ abstract class Constants: SymbolTable {
else null
}
- def stringValue: String = if (value == null) "<null>" else value.toString();
+ def stringValue: String =
+ if (value == null) "<null>" else value.toString();
- override def hashCode(): int = if (value == null) 0 else value.hashCode() * 41 + 17;
+ override def hashCode(): int =
+ if (value == null) 0 else value.hashCode() * 41 + 17;
}
-}
+}