aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Mode.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-07-21 14:42:02 +0200
committerMartin Odersky <odersky@gmail.com>2013-07-21 14:42:02 +0200
commit1ed37543f0dc893ba697c212c310063541018f5c (patch)
treec0e76ae1e556ad40bb3e6c3ff6aef90b2ce342ef /src/dotty/tools/dotc/typer/Mode.scala
parent7e1bd23bf01c6949e08785eb5afc0fcf46b72afb (diff)
downloaddotty-1ed37543f0dc893ba697c212c310063541018f5c.tar.gz
dotty-1ed37543f0dc893ba697c212c310063541018f5c.tar.bz2
dotty-1ed37543f0dc893ba697c212c310063541018f5c.zip
Added code for adapt and more.
- Pushed mode into context - Elimintaed scope nesting level - Fixed a desugar bug - Added constant folding
Diffstat (limited to 'src/dotty/tools/dotc/typer/Mode.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Mode.scala25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/typer/Mode.scala b/src/dotty/tools/dotc/typer/Mode.scala
index 11f2ac458..d71c0c020 100644
--- a/src/dotty/tools/dotc/typer/Mode.scala
+++ b/src/dotty/tools/dotc/typer/Mode.scala
@@ -1,20 +1,35 @@
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(1 << 0)
+// val None = Mode(1 << 0)
+ val None = Mode(0)
+
+ private var modeName = new Array[String](32)
- val Expr = Mode(1 << 1)
- val Pattern = Mode(1 << 2)
- val Type = Mode(1 << 3)
+ def newMode(bit: Int, name: String): Mode = {
+ modeName(bit) = name
+ Mode(1 << bit)
+ }
- val Fun = Mode(1 << 4)
+ val Pattern = newMode(0, "Pattern")
+ val Type = newMode(1, "Type")
+ val ImplicitsDisabled = newMode(2, "ImplicitsDisabled")
+ val PatternOrType = Pattern | Type
} \ No newline at end of file