diff options
author | Martin Odersky <odersky@gmail.com> | 2014-03-27 13:51:30 +0100 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-03-29 09:29:12 +0100 |
commit | e8748e29279f30167516ef7ca8d24f4e4229687f (patch) | |
tree | 18b4eba1b5b7570bcea23e40df87cf8c2c0f952a /src/dotty/tools/dotc/Run.scala | |
parent | 35de6f1847d2d6dc5bde3d97929933525b3f13f8 (diff) | |
download | dotty-e8748e29279f30167516ef7ca8d24f4e4229687f.tar.gz dotty-e8748e29279f30167516ef7ca8d24f4e4229687f.tar.bz2 dotty-e8748e29279f30167516ef7ca8d24f4e4229687f.zip |
Take phase control settings into account
Run now interprets correctly
-YstopBefore
-YstopAfter
-Yskip
-Tprint
phase settings. For now, we stop by default before
erasure, until erasure is fully debugged.
Diffstat (limited to 'src/dotty/tools/dotc/Run.scala')
-rw-r--r-- | src/dotty/tools/dotc/Run.scala | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/Run.scala b/src/dotty/tools/dotc/Run.scala index 89ca45071..972e3aa86 100644 --- a/src/dotty/tools/dotc/Run.scala +++ b/src/dotty/tools/dotc/Run.scala @@ -2,7 +2,7 @@ package dotty.tools package dotc import core._ -import Contexts._, Periods._, Symbols._ +import Contexts._, Periods._, Symbols._, Phases._, Decorators._ import io.PlainFile import util.{SourceFile, NoSource, Stats, SimpleMap} import reporting.Reporter @@ -30,13 +30,29 @@ class Run(comp: Compiler)(implicit ctx: Context) { def compileSources(sources: List[SourceFile]) = Stats.monitorHeartBeat { if (sources forall (_.exists)) { units = sources map (new CompilationUnit(_)) - for (phase <- ctx.allPhases.init) { - if (!ctx.reporter.hasErrors) + def stoppedBefore(phase: Phase) = + ctx.settings.YstopBefore.value.containsPhase(phase) || + ctx.settings.YstopAfter.value.containsPhase(phase.prev) + val phasesToRun = ctx.allPhases.init + .takeWhile(!stoppedBefore(_)) + .filterNot(ctx.settings.Yskip.value.containsPhase(_)) + for (phase <- phasesToRun) { + if (!ctx.reporter.hasErrors) { phase.runOn(units) + if (ctx.settings.Xprint.value.containsPhase(phase)) + for (unit <- units) + printTree(ctx.fresh.withNewPhase(phase).withCompilationUnit(unit)) + } } } } + private def printTree(implicit ctx: Context) = { + val unit = ctx.compilationUnit + println(s"result of $unit after ${ctx.phase}:") + println(unit.tpdTree.show) + } + def compile(sourceCode: String): Unit = { val virtualFile = new VirtualFile(sourceCode) // use source code as name as it's used for equals val writer = new BufferedWriter(new OutputStreamWriter(virtualFile.output, "UTF-8")) // buffering is still advised by javadoc |