diff options
author | Paul Phillips <paulp@improving.org> | 2011-04-01 17:18:34 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-04-01 17:18:34 +0000 |
commit | a6ba30b8eb1968979db92d3a006d57343983e684 (patch) | |
tree | c47af0e4a8de82d811dd298b8feee5945c5084ec /src/compiler/scala/tools/nsc/Global.scala | |
parent | 4df2e9335b7f8831f7877baf855c28bb35d90c18 (diff) | |
download | scala-a6ba30b8eb1968979db92d3a006d57343983e684.tar.gz scala-a6ba30b8eb1968979db92d3a006d57343983e684.tar.bz2 scala-a6ba30b8eb1968979db92d3a006d57343983e684.zip |
Finding myself wanting a working -Ystop, I did ...
Finding myself wanting a working -Ystop, I did the following.
-Ystop-after:phase works
-Ystop-before:phase works
-Ystop:phase is a backward compat alias for -Ystop-after
Until now -Ystop, although documented to "stop after phase", actually
stopped before phase, to the consternation of some. Furthermore the
programmatic way to influence the stop phase (protected def stopPhase in
Global#Run) involved returning true if you wanted to stop before the
phase. So now the command line option works as advertised, and the
method has the same semantics. The only potential loser is some script
which uses -Ystop: based on the actual behavior rather than the documented
behavior. Well, someone had to lose. No review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/Global.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/Global.scala | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 40d8bd5c82..2e2f9c1ad7 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -661,8 +661,21 @@ class Global(var settings: Settings, var reporter: Reporter) extends SymbolTable /** To be initialized from firstPhase. */ private var terminalPhase: Phase = NoPhase - /** Whether compilation should stop at or skip the phase with given name. */ - protected def stopPhase(name: String) = settings.stop contains name + // Calculate where to stop based on settings -Ystop-before or -Ystop-after. + // Slightly complicated logic due to wanting -Ystop-before:parser to fail rather + // than mysteriously running to completion. + private lazy val stopPhaseSetting = { + val result = phaseDescriptors sliding 2 collectFirst { + case xs if xs exists (settings.stopBefore contains _.phaseName) => if (settings.stopBefore contains xs.head.phaseName) xs.head else xs.last + case xs if settings.stopAfter contains xs.head.phaseName => xs.last + } + if (result exists (_.phaseName == "parser")) + globalError("Cannot stop before parser phase.") + + result + } + // The phase to stop BEFORE running. + protected def stopPhase(name: String) = stopPhaseSetting exists (_.phaseName == name) protected def skipPhase(name: String) = settings.skip contains name /** As definitions.init requires phase != NoPhase, and calling phaseDescriptors.head |