blob: 55baa6bc5ea272c549160fb5fa989c1ce50b45fe (
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
|
package dotty.tools.dotc.typer
import collection.mutable
case class Mode(val bits: Int) extends AnyVal {
import Mode._
def | (that: Mode) = Mode(bits | that.bits)
def & (that: Mode) = Mode(bits & that.bits)
def &~ (that: Mode) = Mode(bits & ~that.bits)
def is (that: Mode) = (bits & that.bits) == that.bits
def isExpr = (this & PatternOrType) == None
override def toString =
(0 until 31).filter(i => (bits & (1 << i)) != 0).map(modeName).mkString("Mode(", ",", ")")
}
object Mode {
val None = Mode(0)
private var modeName = new Array[String](32)
def newMode(bit: Int, name: String): Mode = {
modeName(bit) = name
Mode(1 << bit)
}
val Pattern = newMode(0, "Pattern")
val Type = newMode(1, "Type")
val ImplicitsEnabled = newMode(2, "ImplicitsEnabled")
val InferringReturnType = newMode(3, "InferringReturnType")
val TypevarsMissContext = newMode(4, "TypevarsMissContext")
val InSuperCall = newMode(5, "InSuperCall")
val PatternOrType = Pattern | Type
}
|