Skip to content

Commit

Permalink
Phase name match is partial
Browse files Browse the repository at this point in the history
  • Loading branch information
som-snytt committed May 12, 2024
1 parent ab86a34 commit 2fa3c7d
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/Run.scala
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
val phasesSettings = List("-Vphases", "-Vprint")
for phasesSetting <- ctx.settings.allSettings if phasesSettings.contains(phasesSetting.name) do
for case vs: List[String] <- phasesSetting.userValue; p <- vs do
if !phases.exists(_.phaseName == p) then report.warning(s"'$p' specifies no phase")
if !phases.exists(List(p).containsPhase) then report.warning(s"'$p' specifies no phase")

if ctx.settings.YnoDoubleBindings.value then
ctx.base.checkNoDoubleBindings = true
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/config/CliCommand.scala
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ trait CliCommand:
val maxCol = ctx.settings.pageWidth.value
val field1 = maxField.min(texts.flatten.map(_._1.length).filter(_ < maxField).max) // widest field under maxField
val field2 = if field1 + separation + maxField < maxCol then maxCol - field1 - separation else 0 // skinny window -> terminal wrap
val toMark = ctx.settings.XshowPhases.value.toSet
def toMark(name: String) = ctx.settings.Vphases.value.exists(name.contains)
def separator(name: String) = if toMark(name) then "->" + " " * (separation - 2) else " " * separation
val EOL = "\n"
def formatField1(text: String): String = if text.length <= field1 then text.padLeft(field1) else text + EOL + "".padLeft(field1)
Expand Down
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/config/CompilerCommand.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ abstract class CompilerCommand extends CliCommand:
else if (settings.Xhelp.value) xusageMessage
else if (settings.Yhelp.value) yusageMessage
else if (settings.showPlugins.value) ctx.base.pluginDescriptions
else if settings.XshowPhases.isPresentIn(summon[SettingsState]) then phasesMessage
else if settings.Vphases.isPresent then phasesMessage
else ""

final def isHelpFlag(using settings: ConcreteSettings)(using SettingsState): Boolean =
final def isHelpFlag(using settings: ConcreteSettings)(using ss: SettingsState): Boolean =
import settings.*
val flags = Set(help, Vhelp, Whelp, Xhelp, Yhelp, showPlugins)
flags.exists(_.value) || XshowPhases.isPresentIn(summon[SettingsState]) || allSettings.exists(isHelping)
flags.exists(_.value) || Vphases.isPresentIn(ss) || allSettings.exists(isHelping)
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private sealed trait VerboseSettings:
self: SettingGroup =>
val Vhelp: Setting[Boolean] = BooleanSetting(VerboseSetting, "V", "Print a synopsis of verbose options.")
val Vprint: Setting[List[String]] = PhasesSetting(VerboseSetting, "Vprint", "Print out program after", default = "typer", aliases = List("-Xprint"))
val XshowPhases: Setting[List[String]] = PhasesSetting(VerboseSetting, "Vphases", "List compiler phases.", default = "none", aliases = List("-Xshow-phases"))
val Vphases: Setting[List[String]] = PhasesSetting(VerboseSetting, "Vphases", "List compiler phases.", default = "none", aliases = List("-Xshow-phases"))

val Vprofile: Setting[Boolean] = BooleanSetting(VerboseSetting, "Vprofile", "Show metrics about sources and internal representations to estimate compile-time complexity.")
val VprofileSortedBy = ChoiceSetting(VerboseSetting, "Vprofile-sorted-by", "key", "Show metrics about sources and internal representations sorted by given column name", List("name", "path", "lines", "tokens", "tasty", "complexity"), "")
Expand Down
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/config/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ object Settings:
def userValue(using Context): Option[T] = setting.userValueIn(ctx.settingsState)
def update(x: T)(using Context): SettingsState = setting.updateIn(ctx.settingsState, x)
def isDefault(using Context): Boolean = setting.isDefaultIn(ctx.settingsState)
def isPresent(using Context): Boolean = setting.isPresentIn(ctx.settingsState)

/**
* A choice with help description.
Expand Down

0 comments on commit 2fa3c7d

Please sign in to comment.