aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2014-12-18 10:55:11 +0100
committerGuillaume Martres <smarter@ubuntu.com>2014-12-18 17:02:47 +0100
commit7bef54de2fcdb5585031c2d6a81952659f4e5d7c (patch)
tree5e97b7952ff014cb529f5cf3c3228d4e896ff779 /src
parenta68980c1d322095cdd8d7a2b45b05d901072eeb1 (diff)
downloaddotty-7bef54de2fcdb5585031c2d6a81952659f4e5d7c.tar.gz
dotty-7bef54de2fcdb5585031c2d6a81952659f4e5d7c.tar.bz2
dotty-7bef54de2fcdb5585031c2d6a81952659f4e5d7c.zip
-Ylog:X now only log phase X, use -Ylog:X+ to also log phase X+1
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/config/CompilerCommand.scala10
-rw-r--r--src/dotty/tools/dotc/core/Decorators.scala19
-rw-r--r--src/dotty/tools/dotc/reporting/Reporter.scala12
3 files changed, 23 insertions, 18 deletions
diff --git a/src/dotty/tools/dotc/config/CompilerCommand.scala b/src/dotty/tools/dotc/config/CompilerCommand.scala
index ec8b17b0d..aa8e7abbf 100644
--- a/src/dotty/tools/dotc/config/CompilerCommand.scala
+++ b/src/dotty/tools/dotc/config/CompilerCommand.scala
@@ -19,11 +19,13 @@ object CompilerCommand extends DotClass {
|Where multiple values are accepted, they should be comma-separated.
| example: -Xplugin:plugin1,plugin2
|<phases> means one or a comma-separated list of:
- | (partial) phase names, phase ids, phase id ranges, or the string "all".
+ | - (partial) phase names with an optional "+" suffix to include the next phase
+ | - the string "all"
| example: -Xprint:all prints all phases.
- | example: -Xprint:expl,24-26 prints phases explicitouter, closelim, dce, jvm.
- | example: -Xprint:-4 prints only the phases up to typer.
- |
+ | example: -Xprint:front,mixin prints the frontend and mixin phases.
+ | example: -Ylog:erasure+ logs the erasure phase and the phase after the erasure phase.
+ | This is useful because during the tree transform of phase X, we often
+ | already are in phase X+1.
""".stripMargin.trim + "\n"
def shortUsage = s"Usage: $cmdName <options> <source files>"
diff --git a/src/dotty/tools/dotc/core/Decorators.scala b/src/dotty/tools/dotc/core/Decorators.scala
index e0d7fae33..882729063 100644
--- a/src/dotty/tools/dotc/core/Decorators.scala
+++ b/src/dotty/tools/dotc/core/Decorators.scala
@@ -128,15 +128,22 @@ object Decorators {
def show(implicit ctx: Context) = text.mkString(ctx.settings.pageWidth.value)
}
- /** Implements a test whether a list of strings representing phases contains
- * a given phase. The test returns true if the given phase starts with
- * one of the names in the list of strings, or if the list of strings
- * contains "all".
+ /** Test whether a list of strings representing phases contains
+ * a given phase. See [[config.CompilerCommand#explainAdvanced]] for the
+ * exact meaning of "contains" here.
*/
implicit class PhaseListDecorator(val names: List[String]) extends AnyVal {
- def containsPhase(phase: Phase): Boolean = phase match {
+ def containsPhase(phase: Phase): Boolean = phase match {
case phase: TreeTransformer => phase.transformations.exists(trans => containsPhase(trans.phase))
- case _ => names exists (n => n == "all" || phase.phaseName.startsWith(n))
+ case _ =>
+ names exists { name =>
+ name == "all" || {
+ val strippedName = name.stripSuffix("+")
+ val logNextPhase = name ne strippedName
+ phase.phaseName.startsWith(strippedName) ||
+ (logNextPhase && phase.prev.phaseName.startsWith(strippedName))
+ }
+ }
}
}
diff --git a/src/dotty/tools/dotc/reporting/Reporter.scala b/src/dotty/tools/dotc/reporting/Reporter.scala
index dc6d8c6ab..41f007e66 100644
--- a/src/dotty/tools/dotc/reporting/Reporter.scala
+++ b/src/dotty/tools/dotc/reporting/Reporter.scala
@@ -101,16 +101,12 @@ trait Reporting { this: Context =>
def incompleteInputError(msg: String, pos: SourcePosition = NoSourcePosition)(implicit ctx: Context): Unit =
reporter.incomplete(new Error(msg, pos))(ctx)
- /** Log msg if current phase or its precedessor is mentioned in
- * settings.log.
- * The reason we also pick the predecessor is that during the
- * tree transform of phase X, we often are already in phase X+1.
- * It's convenient to have logging work independently of whether
- * we have advanced the phase or not.
+ /** Log msg if settings.log contains the current phase.
+ * See [[config.CompilerCommand#explainAdvanced]] for the exact meaning of
+ * "contains" here.
*/
def log(msg: => String): Unit =
- if (this.settings.log.value.containsPhase(phase) ||
- this.settings.log.value.containsPhase(phase.prev))
+ if (this.settings.log.value.containsPhase(phase))
echo(s"[log ${ctx.phasesStack.reverse.mkString(" -> ")}] $msg")
def debuglog(msg: => String): Unit =