aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Phases.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-08-14 16:07:59 +0200
committerMartin Odersky <odersky@gmail.com>2013-08-14 16:07:59 +0200
commitf19250b1a123aa63cf8f14096bfd8e29e7e548b2 (patch)
treea676a2d5c8e3dc494c4736c9d1454294b9b10341 /src/dotty/tools/dotc/core/Phases.scala
parentc6f0c00790c996bea57ea905a830dedcb4f2bb44 (diff)
downloaddotty-f19250b1a123aa63cf8f14096bfd8e29e7e548b2.tar.gz
dotty-f19250b1a123aa63cf8f14096bfd8e29e7e548b2.tar.bz2
dotty-f19250b1a123aa63cf8f14096bfd8e29e7e548b2.zip
Integrated parser/typer into compiler
Some initial bug fixes. Added -explaintypes diagnostics.
Diffstat (limited to 'src/dotty/tools/dotc/core/Phases.scala')
-rw-r--r--src/dotty/tools/dotc/core/Phases.scala33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/dotty/tools/dotc/core/Phases.scala b/src/dotty/tools/dotc/core/Phases.scala
index 40a9f64d3..7979d3c58 100644
--- a/src/dotty/tools/dotc/core/Phases.scala
+++ b/src/dotty/tools/dotc/core/Phases.scala
@@ -27,15 +27,17 @@ object Phases {
trait PhasesBase { this: ContextBase =>
+ def allPhases = phases.tail
+
object NoPhase extends Phase {
override def exists = false
def name = "<no phase>"
- def run() { throw new Error("NoPhase.run") }
+ def run(implicit ctx: Context): Unit = unsupported("run")
}
object SomePhase extends Phase {
def name = "<some phase>"
- def run() { throw new Error("SomePhase.run") }
+ def run(implicit ctx: Context): Unit = unsupported("run")
}
def phaseNamed(name: String) =
@@ -58,7 +60,20 @@ object Phases {
lazy val flattenPhase = phaseNamed(flattenName)
}
- abstract class Phase {
+ abstract class Phase extends DotClass {
+
+ def name: String
+
+ def run(implicit ctx: Context): Unit
+
+ def runOn(units: List[CompilationUnit])(implicit ctx: Context): Unit =
+ for (unit <- units) run(ctx.fresh.withCompilationUnit(unit))
+
+ def description: String = name
+
+ def checkable: Boolean = true
+
+ def exists: Boolean = true
private[this] var idCache = -1
@@ -77,17 +92,7 @@ object Phases {
}
}
- def name: String
-
- def run(): Unit
-
- def description: String = name
-
- def checkable: Boolean = true
-
- def exists: Boolean = true
-
- final def <= (that: Phase)(implicit ctx: Context) =
+ final def <= (that: Phase)(implicit ctx: Context) =
exists && id <= that.id
final def prev(implicit ctx: Context): Phase =