summaryrefslogtreecommitdiff
path: root/src/compiler/scala/reflect/api/Constants.scala
blob: 42a0fa8a2762d0fac1f68c113b4fa2f9d3e17340 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* NSC -- new Scala compiler
 * Copyright 2005-2011 LAMP/EPFL
 * @author  Martin Odersky
 */

package scala.reflect
package api

import java.lang.Integer.toOctalString
import annotation.switch

trait Constants {
  self: Universe =>

  abstract class AbsConstant {
    val value: Any
    def tpe: Type
    def isNaN: Boolean

    def booleanValue: Boolean
    def byteValue: Byte
    def shortValue: Short
    def charValue: Char
    def intValue: Int
    def longValue: Long
    def floatValue: Float
    def doubleValue: Double
    def stringValue: String
    def typeValue: Type
    def symbolValue: Symbol

    def convertTo(pt: Type): Constant
  }

  type Constant <: AbsConstant

  val Constant: ConstantExtractor

  abstract class ConstantExtractor {
    def apply(const: Any): Constant
    def unapply(arg: Constant): Option[Any]
  }
}