diff options
author | Som Snytt <som.snytt@gmail.com> | 2013-07-25 12:05:08 -0700 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2013-08-21 17:03:03 -0700 |
commit | 26ad989f49640693c78e7af42abae3d75cf36f68 (patch) | |
tree | 0a06bed77e9538d21f8cc31704db3799773323be | |
parent | 508ee772ff211d290e0fadc81d8cea70595b7984 (diff) | |
download | scala-26ad989f49640693c78e7af42abae3d75cf36f68.tar.gz scala-26ad989f49640693c78e7af42abae3d75cf36f68.tar.bz2 scala-26ad989f49640693c78e7af42abae3d75cf36f68.zip |
SI-7622 -Xgenerate-phase-graph is an info option
-Xgenerate-phase-graph is comparable to -Xshow-phases.
The knowledge about what is an info-only option is refactored
to Settings, which also knows which group of options comprise
the optimiser set.
-rw-r--r-- | src/compiler/scala/tools/nsc/CompilerCommand.scala | 28 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/settings/ScalaSettings.scala | 6 |
2 files changed, 20 insertions, 14 deletions
diff --git a/src/compiler/scala/tools/nsc/CompilerCommand.scala b/src/compiler/scala/tools/nsc/CompilerCommand.scala index f1f5130fb8..bab0768ca9 100644 --- a/src/compiler/scala/tools/nsc/CompilerCommand.scala +++ b/src/compiler/scala/tools/nsc/CompilerCommand.scala @@ -27,7 +27,7 @@ class CompilerCommand(arguments: List[String], val settings: Settings) { |-- Notes on option parsing -- |Boolean settings are always false unless set. |Where multiple values are accepted, they should be comma-separated. - | example: -Xplugin:plugin1,plugin2 + | example: -Xplugin:option1,option2 |<phases> means one or a comma-separated list of: | (partial) phase names, phase ids, phase id ranges, or the string "all". | example: -Xprint:all prints all phases. @@ -80,23 +80,23 @@ class CompilerCommand(arguments: List[String], val settings: Settings) { def xusageMsg = createUsageMsg("Possible advanced", shouldExplain = true, _.isAdvanced) def yusageMsg = createUsageMsg("Possible private", shouldExplain = true, _.isPrivate) - // If any of these settings is set, the compiler shouldn't start; - // an informative message of some sort should be printed instead. - def shouldStopWithInfo = { - import settings.{ Setting => _, _ } - Set[BooleanSetting](help, Xhelp, Yhelp, showPlugins, showPhases) exists (_.value) - } + /** For info settings, compiler should just print a message and quit. */ + def shouldStopWithInfo = settings.isInfo def getInfoMessage(global: Global): String = { import settings._ - if (help.value) usageMsg + global.pluginOptionsHelp - else if (Xhelp.value) xusageMsg - else if (Yhelp.value) yusageMsg - else if (showPlugins.value) global.pluginDescriptions - else if (showPhases.value) global.phaseDescriptions + ( - if (debug.value) "\n" + global.phaseFlagDescriptions else "" + if (help) usageMsg + global.pluginOptionsHelp + else if (Xhelp) xusageMsg + else if (Yhelp) yusageMsg + else if (showPlugins) global.pluginDescriptions + else if (showPhases) global.phaseDescriptions + ( + if (debug) "\n" + global.phaseFlagDescriptions else "" ) - else "" + else if (genPhaseGraph.isSetByUser) { + val components = global.phaseNames // global.phaseDescriptors // one initializes + s"Phase graph of ${components.size} components output to ${genPhaseGraph.value}*.dot." + } + else "" } /** diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala index 32f0571e83..90f7672293 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala @@ -41,6 +41,12 @@ trait ScalaSettings extends AbsScalaSettings /** Enabled under -optimise. */ def optimiseSettings = List[BooleanSetting](inline, inlineHandlers, Xcloselim, Xdce, YconstOptimization) + /** If any of these settings is enabled, the compiler should print a message and exit. */ + def infoSettings = List[Setting](help, Xhelp, Yhelp, showPlugins, showPhases, genPhaseGraph) + + /** Is an info setting set? */ + def isInfo = infoSettings exists (_.isSetByUser) + /** Internal use - syntax enhancements. */ private class EnableSettings[T <: BooleanSetting](val s: T) { def enabling(toEnable: List[BooleanSetting]): s.type = s withPostSetHook (_ => toEnable foreach (_.value = s.value)) |