From f19250b1a123aa63cf8f14096bfd8e29e7e548b2 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 14 Aug 2013 16:07:59 +0200 Subject: Integrated parser/typer into compiler Some initial bug fixes. Added -explaintypes diagnostics. --- src/dotty/tools/dotc/core/Phases.scala | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'src/dotty/tools/dotc/core/Phases.scala') 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 = "" - def run() { throw new Error("NoPhase.run") } + def run(implicit ctx: Context): Unit = unsupported("run") } object SomePhase extends Phase { def name = "" - 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 = -- cgit v1.2.3