From 217415af22e2909a44405cf75ab34933023d1612 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 8 Mar 2010 06:06:36 +0000 Subject: More progress toward immutable Settings, and va... More progress toward immutable Settings, and various cleanups encountered along the way. No review. --- src/compiler/scala/tools/nsc/doc/Settings.scala | 1 - .../tools/nsc/settings/AbsScalaSettings.scala | 40 +++++ .../tools/nsc/settings/AbsScalacSettings.scala | 33 ---- .../scala/tools/nsc/settings/AbsSettings.scala | 10 +- .../tools/nsc/settings/AdvancedScalaSettings.scala | 76 +++++++++ .../scala/tools/nsc/settings/MutableSettings.scala | 12 +- .../scala/tools/nsc/settings/ScalaSettings.scala | 162 ++++++++++++++++++ .../scala/tools/nsc/settings/ScalacSettings.scala | 185 --------------------- .../tools/nsc/settings/StandardScalaSettings.scala | 71 ++++---- 9 files changed, 322 insertions(+), 268 deletions(-) create mode 100644 src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala delete mode 100644 src/compiler/scala/tools/nsc/settings/AbsScalacSettings.scala create mode 100644 src/compiler/scala/tools/nsc/settings/AdvancedScalaSettings.scala create mode 100644 src/compiler/scala/tools/nsc/settings/ScalaSettings.scala delete mode 100644 src/compiler/scala/tools/nsc/settings/ScalacSettings.scala (limited to 'src/compiler') diff --git a/src/compiler/scala/tools/nsc/doc/Settings.scala b/src/compiler/scala/tools/nsc/doc/Settings.scala index 0ea17970f6..3d02689605 100644 --- a/src/compiler/scala/tools/nsc/doc/Settings.scala +++ b/src/compiler/scala/tools/nsc/doc/Settings.scala @@ -32,5 +32,4 @@ class Settings(error: String => Unit) extends scala.tools.nsc.Settings(error) { // working around issue described in r18708. suppressVTWarn.value = true - } diff --git a/src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala new file mode 100644 index 0000000000..790f4cce00 --- /dev/null +++ b/src/compiler/scala/tools/nsc/settings/AbsScalaSettings.scala @@ -0,0 +1,40 @@ +/* NSC -- new Scala compiler + * Copyright 2005-2010 LAMP/EPFL + * @author Paul Phillips + */ + +package scala.tools.nsc +package settings + +trait AbsScalaSettings { + self: AbsSettings => + + type BooleanSetting <: AbsSetting { type T = Boolean } + type ChoiceSetting <: AbsSetting { type T = String } + type DefinesSetting <: AbsSetting { type T = List[(String, String)] } + type IntSetting <: AbsSetting { type T = Int } + type MultiStringSetting <: AbsSetting { type T = List[String] } + type PathSetting <: AbsSetting { type T = String } + type PhasesSetting <: AbsSetting { type T = List[String] } + type StringSetting <: AbsSetting { type T = String } + + type OutputDirs + type OutputSetting <: AbsSetting + + def BooleanSetting(name: String, descr: String): BooleanSetting + def ChoiceSetting(name: String, descr: String, choices: List[String], default: String): ChoiceSetting + def DefinesSetting(): DefinesSetting + def IntSetting(name: String, descr: String, default: Int, range: Option[(Int, Int)], parser: String => Option[Int]): IntSetting + def MultiStringSetting(name: String, arg: String, descr: String): MultiStringSetting + def OutputSetting(outputDirs: OutputDirs, default: String): OutputSetting + def PathSetting(name: String, arg: String, descr: String, default: String): PathSetting + def PhasesSetting(name: String, descr: String): PhasesSetting + def StringSetting(name: String, arg: String, descr: String, default: String): StringSetting + + /** **/ + abstract class SettingGroup(val prefix: String) extends AbsSetting { + def name = prefix + def helpDescription: String = error("todo") + def unparse: List[String] = List(name) + } +} diff --git a/src/compiler/scala/tools/nsc/settings/AbsScalacSettings.scala b/src/compiler/scala/tools/nsc/settings/AbsScalacSettings.scala deleted file mode 100644 index bb0c6f8ee7..0000000000 --- a/src/compiler/scala/tools/nsc/settings/AbsScalacSettings.scala +++ /dev/null @@ -1,33 +0,0 @@ -/* NSC -- new Scala compiler - * Copyright 2005-2010 LAMP/EPFL - * @author Paul Phillips - */ - -package scala.tools.nsc -package settings - -trait AbsScalacSettings { - self: AbsSettings => - - type BooleanSetting <: AbsSetting - type ChoiceSetting <: AbsSetting - type DefinesSetting <: AbsSetting - type IntSetting <: AbsSetting - type MultiStringSetting <: AbsSetting - type PathSetting <: AbsSetting - type PhasesSetting <: AbsSetting - type StringSetting <: AbsSetting - - type OutputDirs - type OutputSetting <: AbsSetting - - def BooleanSetting(name: String, descr: String): BooleanSetting - def ChoiceSetting(name: String, descr: String, choices: List[String], default: String): ChoiceSetting - def DefinesSetting(): DefinesSetting - def IntSetting(name: String, descr: String, default: Int, range: Option[(Int, Int)], parser: String => Option[Int]): IntSetting - def MultiStringSetting(name: String, arg: String, descr: String): MultiStringSetting - def OutputSetting(outputDirs: OutputDirs, default: String): OutputSetting - def PathSetting(name: String, arg: String, descr: String, default: String): PathSetting - def PhasesSetting(name: String, descr: String): PhasesSetting - def StringSetting(name: String, arg: String, descr: String, default: String): StringSetting -} diff --git a/src/compiler/scala/tools/nsc/settings/AbsSettings.scala b/src/compiler/scala/tools/nsc/settings/AbsSettings.scala index 8b51c00a48..91b26d083a 100644 --- a/src/compiler/scala/tools/nsc/settings/AbsSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/AbsSettings.scala @@ -17,7 +17,7 @@ trait AbsSettings { type Setting <: AbsSetting // Fix to the concrete Setting type type ResultOfTryToSet // List[String] in mutable, (Settings, List[String]) in immutable def errorFn: String => Unit - protected def allSettings: Set[Setting] + protected def allSettings: collection.Set[Setting] // settings minus internal usage settings def visibleSettings = allSettings filterNot (_.isInternalOnly) @@ -59,6 +59,14 @@ trait AbsSettings { def helpDescription: String def unparse: List[String] // A list of Strings which can recreate this setting. + /** In mutable Settings, these return the same object with a var set. + * In immutable, of course they will return a new object, which means + * we can't use "this.type", at least not in a non-casty manner, which + * is unfortunate because we lose type information without it. + */ + def withAbbreviation(name: String): Setting + def withHelpSyntax(help: String): Setting + def helpSyntax: String = name def abbreviations: List[String] = Nil def dependencies: List[(Setting, String)] = Nil diff --git a/src/compiler/scala/tools/nsc/settings/AdvancedScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/AdvancedScalaSettings.scala new file mode 100644 index 0000000000..a68963f6d8 --- /dev/null +++ b/src/compiler/scala/tools/nsc/settings/AdvancedScalaSettings.scala @@ -0,0 +1,76 @@ +/* NSC -- new Scala compiler + * Copyright 2005-2010 LAMP/EPFL + * @author Paul Phillips + */ + +package scala.tools.nsc +package settings + +trait AdvancedScalaSettings { + self: AbsScalaSettings => + + abstract class X extends SettingGroup("-X") { + val assemextdirs: StringSetting + val assemname: StringSetting + val assempath: StringSetting + val checkinit: BooleanSetting + val disableassertions: BooleanSetting + val elidelevel: IntSetting + val experimental: BooleanSetting + val future: BooleanSetting + val generatephasegraph: StringSetting + val logimplicits: BooleanSetting + val migration: BooleanSetting + val noforwarders: BooleanSetting + val nojline: BooleanSetting + val nouescape: BooleanSetting + val plugin: MultiStringSetting + val plugindisable: MultiStringSetting + val pluginlist: BooleanSetting + val pluginrequire: MultiStringSetting + val pluginsdir: StringSetting + val print: PhasesSetting + val printicode: BooleanSetting + val printpos: BooleanSetting + val printtypes: BooleanSetting + val prompt: BooleanSetting + val resident: BooleanSetting + val script: StringSetting + val showclass: StringSetting + val showobject: StringSetting + val showphases: BooleanSetting + val sourcedir: StringSetting + val sourcereader: StringSetting + } + // def Xexperimental = X.experimental + // def Xmigration28 = X.migration + // def Xnojline = X.nojline + // def Xprint = X.print + // def Xprintpos = X.printpos + // def Xshowcls = X.showclass + // def Xshowobj = X.showobject + // def assemextdirs = X.assemextdirs + // def assemname = X.assemname + // def assemrefs = X.assempath + // def checkInit = X.checkinit + // def disable = X.plugindisable + // def elideLevel = X.elidelevel + // def future = X.future + // def genPhaseGraph = X.generatephasegraph + // def logimplicits = X.logimplicits + // def noForwarders = X.noforwarders + // def noassertions = X.disableassertions + // def nouescape = X.nouescape + // def plugin = X.plugin + // def pluginsDir = X.pluginsdir + // def printtypes = X.printtypes + // def prompt = X.prompt + // def require = X.require + // def resident = X.resident + // def script = X.script + // def showPhases = X.showphases + // def showPlugins = X.pluginlist + // def sourceReader = X.sourcereader + // def sourcedir = X.sourcedir + // def writeICode = X.printicode +} \ No newline at end of file diff --git a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala index 8e11b4f506..9bcf48e1b7 100644 --- a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala @@ -16,7 +16,7 @@ import interpreter.{ returning } /** A mutable Settings object. */ -class MutableSettings(val errorFn: String => Unit) extends AbsSettings with ScalacSettings with Mutable { +class MutableSettings(val errorFn: String => Unit) extends AbsSettings with ScalaSettings with Mutable { type ResultOfTryToSet = List[String] /** Iterates over the arguments applying them to settings where applicable. @@ -166,9 +166,7 @@ class MutableSettings(val errorFn: String => Unit) extends AbsSettings with Scal } // a wrapper for all Setting creators to keep our list up to date - // and tell them how to announce errors private def add[T <: Setting](s: T): T = { - s setErrorHandler errorFn allSettings += s s } @@ -309,11 +307,6 @@ class MutableSettings(val errorFn: String => Unit) extends AbsSettings with Scal * Subclasses each define a `value' field of the appropriate type. */ abstract class Setting(val name: String, val helpDescription: String) extends AbsSetting with SettingValue with Mutable { - /** Error handling function, set after creation by enclosing Settings instance */ - private var _errorFn: String => Unit = _ - private[nsc] def setErrorHandler(e: String => Unit) = _errorFn = e - def errorFn(msg: String) = _errorFn(msg) - /** Will be called after this Setting is set for any extra work. */ private var _postSetHook: this.type => Unit = (x: this.type) => () def postSetHook() = { _postSetHook(this) ; this } @@ -467,8 +460,7 @@ class MutableSettings(val errorFn: String => Unit) extends AbsSettings with Scal extends Setting(name, descr) { type T = List[String] protected var v: List[String] = Nil - // def appendToValue(str: String) { value ++= List(str) } - def appendToValue(str: String) { value = value ++ List(str) } // ++= List(str) } + def appendToValue(str: String) { value ++= List(str) } def tryToSet(args: List[String]) = { val (strings, rest) = args span (x => !x.startsWith("-")) diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala new file mode 100644 index 0000000000..0de60672ac --- /dev/null +++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala @@ -0,0 +1,162 @@ +/* NSC -- new Scala compiler + * Copyright 2005-2010 LAMP/EPFL + * @author Martin Odersky + */ +// $Id$ + +package scala.tools.nsc +package settings + +import io.AbstractFile +import util.{ ClassPath, SourceFile, CommandLineParser } +import annotation.elidable +import scala.tools.util.{ PathResolver, StringOps } +import scala.collection.mutable.{ HashSet, ListBuffer } +import scala.collection.immutable.TreeSet +import interpreter.{ returning } + +trait ScalaSettings extends AbsScalaSettings with StandardScalaSettings { + self: MutableSettings => + + import PathResolver.{ Defaults, Environment } + + /** Set of settings */ + protected lazy val allSettings = HashSet[Setting]() + + /** Disable a setting */ + def disable(s: Setting) = allSettings -= s + + /** + * Temporary Settings + */ + val suppressVTWarn = BooleanSetting ("-Ysuppress-vt-typer-warnings", "Suppress warnings from the typer when testing the virtual class encoding, NOT FOR FINAL!") + + /** + * Standard settings + */ + // argfiles is only for the help message + val argfiles = BooleanSetting ("@", "A text file containing compiler arguments (options and source files)") + val classpath = PathSetting ("-classpath", "path", "Specify where to find user class files", ".") . + withAbbreviation ("-cp") + val d = OutputSetting (outputDirs, ".") + val defines = DefinesSetting() + val optimise = BooleanSetting ("-optimise", "Generates faster bytecode by applying optimisations to the program") . + withAbbreviation("-optimize") . + withPostSetHook(_ => List(inline, Xcloselim, Xdce) foreach (_.value = true)) + + /** + * -X "Advanced" settings + */ + val Xhelp = BooleanSetting ("-X", "Print a synopsis of advanced options") + val assemname = StringSetting ("-Xassem-name", "file", "Name of the output assembly (only relevant with -target:msil)", "").dependsOn(target, "msil") + val assemrefs = StringSetting ("-Xassem-path", "path", "List of assemblies referenced by the program (only relevant with -target:msil)", ".").dependsOn(target, "msil") + val assemextdirs = StringSetting ("-Xassem-extdirs", "dirs", "List of directories containing assemblies, defaults to `lib'", Defaults.scalaLibDir.path).dependsOn(target, "msil") + val sourcedir = StringSetting ("-Xsourcedir", "directory", "When -target:msil, the source folder structure is mirrored in output directory.", ".").dependsOn(target, "msil") + val checkInit = BooleanSetting ("-Xcheckinit", "Add runtime checks on field accessors. Uninitialized accesses result in an exception being thrown.") + val noassertions = BooleanSetting ("-Xdisable-assertions", "Generate no assertions and assumptions") + val elideLevel = IntSetting ("-Xelide-level", "Generate calls to @elidable-marked methods only method priority is greater than argument.", + elidable.ASSERTION, None, elidable.byName.get(_)) + val Xexperimental = BooleanSetting ("-Xexperimental", "Enable experimental extensions") + val noForwarders = BooleanSetting ("-Xno-forwarders", "Do not generate static forwarders in mirror classes") + val future = BooleanSetting ("-Xfuture", "Turn on future language features") + val genPhaseGraph = StringSetting ("-Xgenerate-phase-graph", "file", "Generate the phase graphs (outputs .dot files) to fileX.dot", "") + val XlogImplicits = BooleanSetting ("-Xlog-implicits", "Show more info on why some implicits are not applicable") + val Xmigration28 = BooleanSetting ("-Xmigration", "Warn about constructs whose behavior may have changed between 2.7 and 2.8") + val nouescape = BooleanSetting ("-Xno-uescape", "Disables handling of \\u unicode escapes") + val Xnojline = BooleanSetting ("-Xnojline", "Do not use JLine for editing") + val plugin = MultiStringSetting("-Xplugin", "file", "Load a plugin from a file") + val disable = MultiStringSetting("-Xplugin-disable", "plugin", "Disable a plugin") + val showPlugins = BooleanSetting ("-Xplugin-list", "Print a synopsis of loaded plugins") + val require = MultiStringSetting("-Xplugin-require", "plugin", "Abort unless a plugin is available") + val pluginsDir = StringSetting ("-Xpluginsdir", "path", "Path to search compiler plugins", Defaults.scalaPluginPath) + val Xprint = PhasesSetting ("-Xprint", "Print out program after") + val writeICode = BooleanSetting ("-Xprint-icode", "Log internal icode to *.icode files") + val Xprintpos = BooleanSetting ("-Xprint-pos", "Print tree positions (as offsets)") + val printtypes = BooleanSetting ("-Xprint-types", "Print tree types (debugging option)") + val prompt = BooleanSetting ("-Xprompt", "Display a prompt after each error (debugging option)") + val resident = BooleanSetting ("-Xresident", "Compiler stays resident, files to compile are read from standard input") + val script = StringSetting ("-Xscript", "object", "Compile as a script, wrapping the code into object.main()", "") + val Xshowcls = StringSetting ("-Xshow-class", "class", "Show class info", "") + val Xshowobj = StringSetting ("-Xshow-object", "object", "Show object info", "") + val showPhases = BooleanSetting ("-Xshow-phases", "Print a synopsis of compiler phases") + val sourceReader = StringSetting ("-Xsource-reader", "classname", "Specify a custom method for reading source files", "scala.tools.nsc.io.SourceReader") + + /** Compatibility stubs for options whose value name did + * not previously match the option name. + */ + def XO = optimise + def debuginfo = g + def dependenciesFile = dependencyfile + def nowarnings = nowarn + def outdir = d + def printLate = print + + /** + * -Y "Private" settings + */ + val Yhelp = BooleanSetting ("-Y", "Print a synopsis of private options") + val browse = PhasesSetting ("-Ybrowse", "Browse the abstract syntax tree after") + val check = PhasesSetting ("-Ycheck", "Check the tree at the end of") + val Xcloselim = BooleanSetting ("-Yclosure-elim", "Perform closure elimination") + val Ycompacttrees = BooleanSetting ("-Ycompact-trees", "Use compact tree printer when displaying trees") + val noCompletion = BooleanSetting ("-Yno-completion", "Disable tab-completion in the REPL") + val Xdce = BooleanSetting ("-Ydead-code", "Perform dead code elimination") + val debug = BooleanSetting ("-Ydebug", "Output debugging messages") + val Xdetach = BooleanSetting ("-Ydetach", "Perform detaching of remote closures") + // val doc = BooleanSetting ("-Ydoc", "Generate documentation") + val inline = BooleanSetting ("-Yinline", "Perform inlining when possible") + val Xlinearizer = ChoiceSetting ("-Ylinearizer", "Linearizer to use", List("normal", "dfs", "rpo", "dump"), "rpo") . + withHelpSyntax("-Ylinearizer:") + val log = PhasesSetting ("-Ylog", "Log operations in") + val Ylogcp = BooleanSetting ("-Ylog-classpath", "Output information about what classpath is being applied.") + val Ynogenericsig = BooleanSetting ("-Yno-generic-signatures", "Suppress generation of generic signatures for Java") + val noimports = BooleanSetting ("-Yno-imports", "Compile without any implicit imports") + val nopredefs = BooleanSetting ("-Yno-predefs", "Compile without any implicit predefined values") + val Yrecursion = IntSetting ("-Yrecursion", "Recursion depth used when locking symbols", 0, Some(0, Int.MaxValue), (_: String) => None) + val selfInAnnots = BooleanSetting ("-Yself-in-annots", "Include a \"self\" identifier inside of annotations") + val Xshowtrees = BooleanSetting ("-Yshow-trees", "Show detailed trees when used in connection with -print:phase") + val skip = PhasesSetting ("-Yskip", "Skip") + val Xsqueeze = ChoiceSetting ("-Ysqueeze", "if on, creates compact code in matching", List("on","off"), "on") . + withHelpSyntax("-Ysqueeze:") + val Ystatistics = BooleanSetting ("-Ystatistics", "Print compiler statistics") + val stop = PhasesSetting ("-Ystop", "Stop after phase") + val refinementMethodDispatch = + ChoiceSetting ("-Ystruct-dispatch", "Selects dispatch method for structural refinement method calls", + List("no-cache", "mono-cache", "poly-cache", "invoke-dynamic"), "poly-cache") . + withHelpSyntax("-Ystruct-dispatch:") + val specialize = BooleanSetting ("-Yspecialize", "Specialize generic code on types.") + val Yrangepos = BooleanSetting ("-Yrangepos", "Use range positions for syntax trees.") + val Yidedebug = BooleanSetting ("-Yide-debug", "Generate, validate and output trees using the interactive compiler.") + val Ybuilderdebug = ChoiceSetting ("-Ybuilder-debug", "Compile using the specified build manager", List("none", "refined", "simple"), "none") . + withHelpSyntax("-Ybuilder-debug:") + val Ybuildmanagerdebug = + BooleanSetting ("-Ybuild-manager-debug", "Generate debug information for the Refined Build Manager compiler.") + val Ytyperdebug = BooleanSetting ("-Ytyper-debug", "Trace all type assignements") + val Ypmatdebug = BooleanSetting ("-Ypmat-debug", "Trace all pattern matcher activity.") + val Yrepldebug = BooleanSetting ("-Yrepl-debug", "Trace all repl activity.") + val Ypmatnaive = BooleanSetting ("-Ypmat-naive", "Desugar matches as naively as possible..") + val Ytailrec = BooleanSetting ("-Ytailrecommend", "Alert methods which would be tail-recursive if private or final.") + val Yjenkins = BooleanSetting ("-Yjenkins-hashCodes", "Use jenkins hash algorithm for case class generated hashCodes.") + + // Warnings + val Ywarnfatal = BooleanSetting ("-Yfatal-warnings", "Fail the compilation if there are any warnings.") + val Xwarninit = BooleanSetting ("-Xwarninit", "Warn about possible changes in initialization semantics") + val Xchecknull = BooleanSetting ("-Xcheck-null", "Emit warning on selection of nullable reference") + val Xwarndeadcode = BooleanSetting ("-Ywarn-dead-code", "Emit warnings for dead code") + val YwarnShadow = BooleanSetting ("-Ywarn-shadowing", "Emit warnings about possible variable shadowing.") + val YwarnCatches = BooleanSetting ("-Ywarn-catches", "Emit warnings about catch blocks which catch everything.") + val Xwarnings = BooleanSetting ("-Xstrict-warnings", "Emit warnings about lots of things.") . + withPostSetHook(_ => + List(YwarnShadow, YwarnCatches, Xwarndeadcode, Xwarninit) foreach (_.value = true) + ) + /** + * "fsc-specific" settings. + */ + val fscShutdown = BooleanSetting ("-shutdown", "Shutdown the fsc daemon") + + /** + * -P "Plugin" settings + */ + val pluginOptions = MultiStringSetting("-P", "plugin:opt", "Pass an option to a plugin") . + withHelpSyntax("-P::") +} diff --git a/src/compiler/scala/tools/nsc/settings/ScalacSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalacSettings.scala deleted file mode 100644 index 60c996f02d..0000000000 --- a/src/compiler/scala/tools/nsc/settings/ScalacSettings.scala +++ /dev/null @@ -1,185 +0,0 @@ -/* NSC -- new Scala compiler - * Copyright 2005-2010 LAMP/EPFL - * @author Martin Odersky - */ -// $Id$ - -package scala.tools.nsc -package settings - -import io.AbstractFile -import util.{ ClassPath, SourceFile, CommandLineParser } -import annotation.elidable -import scala.tools.util.{ PathResolver, StringOps } -import scala.collection.mutable.ListBuffer -import scala.collection.immutable.TreeSet -import interpreter.{ returning } - -trait ScalacSettings extends AbsScalacSettings with StandardScalaSettings { - self: MutableSettings => - - import PathResolver.{ Defaults, Environment } - - /** Set of settings */ - protected var allSettings = Set[Setting]() - - /** Disable a setting */ - def disable(s: Setting) = allSettings -= s - - /** - * Temporary Settings - */ - val suppressVTWarn = BooleanSetting ("-Ysuppress-vt-typer-warnings", "Suppress warnings from the typer when testing the virtual class encoding, NOT FOR FINAL!") - def appendToClasspath(entry: String) = { - val oldClasspath = classpath.value - classpath.value = ClassPath.join(classpath.value, entry) - - if (Ylogcp.value) - Console.println("Updated classpath from '%s' to '%s'".format(oldClasspath, classpath.value)) - } - - /** - * Classpath related settings - */ - - val classpath = PathSetting ("-classpath", "path", "Specify where to find user class files", ".") withAbbreviation ("-cp") - val bootclasspath = PathSetting ("-bootclasspath", "path", "Override location of bootstrap class files", Defaults.scalaBootClassPath) - val extdirs = PathSetting ("-extdirs", "dirs", "Override location of installed extensions", Defaults.scalaExtDirs) - val javabootclasspath = PathSetting ("-javabootclasspath", "path", "Override java boot classpath.", Defaults.javaBootClassPath) - val javaextdirs = PathSetting ("-javaextdirs", "path", "Override java extdirs classpath.", Defaults.javaExtDirs) - /** This one is most likely temporary, but so helpful while I try to get an iron grip on the classpath. */ - val javaignorecp = BooleanSetting ("-javaignorecp", "scala will not use java's -classpath no matter what.") - - val d = OutputSetting (outputDirs, ".") - val sourcepath = StringSetting ("-sourcepath", "path", "Specify where to find input source files", "") - val Ylogcp = BooleanSetting ("-Ylog-classpath", "Output information about what classpath is being applied.") - - /** - * Standard settings - */ - // argfiles is only for the help message - val argfiles = BooleanSetting ("@", "A text file containing compiler arguments (options and source files)") - val defines = DefinesSetting() - val dependencyfile = StringSetting ("-dependencyfile", "file", "Specify the file in which dependencies are tracked", ".scala_dependencies") - val deprecation = BooleanSetting ("-deprecation", "Output source locations where deprecated APIs are used") - val encoding = StringSetting ("-encoding", "encoding", "Specify character encoding used by source files", Properties.sourceEncoding) - val explaintypes = BooleanSetting ("-explaintypes", "Explain type errors in more detail") - val g = ChoiceSetting ("-g", "Specify level of generated debugging info", List("none", "source", "line", "vars", "notailcalls"), "vars") - val help = BooleanSetting ("-help", "Print a synopsis of standard options") - val make = ChoiceSetting ("-make", "Specify recompilation detection strategy", List("all", "changed", "immediate", "transitive", "transitivenocp"), "all") . - withHelpSyntax("-make:") - val nowarn = BooleanSetting ("-nowarn", "Generate no warnings") - val optimise = BooleanSetting ("-optimise", "Generates faster bytecode by applying optimisations to the program").withAbbreviation("-optimize") . - withPostSetHook(_ => List(inline, Xcloselim, Xdce) foreach (_.value = true)) - val print = BooleanSetting ("-print", "Print program with all Scala-specific features removed") - val target = ChoiceSetting ("-target", "Specify for which target object files should be built", List("jvm-1.5", "msil"), "jvm-1.5") - val unchecked = BooleanSetting ("-unchecked", "Enable detailed unchecked warnings") - val uniqid = BooleanSetting ("-uniqid", "Print identifiers with unique names for debugging") - val verbose = BooleanSetting ("-verbose", "Output messages about what the compiler is doing") - val version = BooleanSetting ("-version", "Print product version and exit") - - /** - * -X "Advanced" settings - */ - val Xhelp = BooleanSetting ("-X", "Print a synopsis of advanced options") - val assemname = StringSetting ("-Xassem-name", "file", "Name of the output assembly (only relevant with -target:msil)", "").dependsOn(target, "msil") - val assemrefs = StringSetting ("-Xassem-path", "path", "List of assemblies referenced by the program (only relevant with -target:msil)", ".").dependsOn(target, "msil") - val assemextdirs = StringSetting ("-Xassem-extdirs", "dirs", "List of directories containing assemblies, defaults to `lib'", Defaults.scalaLibDir.path).dependsOn(target, "msil") - val sourcedir = StringSetting ("-Xsourcedir", "directory", "When -target:msil, the source folder structure is mirrored in output directory.", ".").dependsOn(target, "msil") - val checkInit = BooleanSetting ("-Xcheckinit", "Add runtime checks on field accessors. Uninitialized accesses result in an exception being thrown.") - val noassertions = BooleanSetting ("-Xdisable-assertions", "Generate no assertions and assumptions") - val elideLevel = IntSetting ("-Xelide-level", "Generate calls to @elidable-marked methods only method priority is greater than argument.", - elidable.ASSERTION, None, elidable.byName.get(_)) - val Xexperimental = BooleanSetting ("-Xexperimental", "Enable experimental extensions") - val noForwarders = BooleanSetting ("-Xno-forwarders", "Do not generate static forwarders in mirror classes") - val future = BooleanSetting ("-Xfuture", "Turn on future language features") - val genPhaseGraph = StringSetting ("-Xgenerate-phase-graph", "file", "Generate the phase graphs (outputs .dot files) to fileX.dot", "") - val XlogImplicits = BooleanSetting ("-Xlog-implicits", "Show more info on why some implicits are not applicable") - val Xmigration28 = BooleanSetting ("-Xmigration", "Warn about constructs whose behavior may have changed between 2.7 and 2.8") - val nouescape = BooleanSetting ("-Xno-uescape", "Disables handling of \\u unicode escapes") - val Xnojline = BooleanSetting ("-Xnojline", "Do not use JLine for editing") - val plugin = MultiStringSetting("-Xplugin", "file", "Load a plugin from a file") - val disable = MultiStringSetting("-Xplugin-disable", "plugin", "Disable a plugin") - val showPlugins = BooleanSetting ("-Xplugin-list", "Print a synopsis of loaded plugins") - val require = MultiStringSetting("-Xplugin-require", "plugin", "Abort unless a plugin is available") - val pluginsDir = StringSetting ("-Xpluginsdir", "path", "Path to search compiler plugins", Defaults.scalaPluginPath) - val Xprint = PhasesSetting ("-Xprint", "Print out program after") - val writeICode = BooleanSetting ("-Xprint-icode", "Log internal icode to *.icode files") - val Xprintpos = BooleanSetting ("-Xprint-pos", "Print tree positions (as offsets)") - val printtypes = BooleanSetting ("-Xprint-types", "Print tree types (debugging option)") - val prompt = BooleanSetting ("-Xprompt", "Display a prompt after each error (debugging option)") - val resident = BooleanSetting ("-Xresident", "Compiler stays resident, files to compile are read from standard input") - val script = StringSetting ("-Xscript", "object", "Compile as a script, wrapping the code into object.main()", "") - val Xshowcls = StringSetting ("-Xshow-class", "class", "Show class info", "") - val Xshowobj = StringSetting ("-Xshow-object", "object", "Show object info", "") - val showPhases = BooleanSetting ("-Xshow-phases", "Print a synopsis of compiler phases") - val sourceReader = StringSetting ("-Xsource-reader", "classname", "Specify a custom method for reading source files", "scala.tools.nsc.io.SourceReader") - - /** - * -Y "Private" settings - */ - val Yhelp = BooleanSetting ("-Y", "Print a synopsis of private options") - val browse = PhasesSetting ("-Ybrowse", "Browse the abstract syntax tree after") - val check = PhasesSetting ("-Ycheck", "Check the tree at the end of") - val Xcloselim = BooleanSetting ("-Yclosure-elim", "Perform closure elimination") - val Ycompacttrees = BooleanSetting ("-Ycompact-trees", "Use compact tree printer when displaying trees") - val noCompletion = BooleanSetting ("-Yno-completion", "Disable tab-completion in the REPL") - val Xdce = BooleanSetting ("-Ydead-code", "Perform dead code elimination") - val debug = BooleanSetting ("-Ydebug", "Output debugging messages") - val Xdetach = BooleanSetting ("-Ydetach", "Perform detaching of remote closures") - // val doc = BooleanSetting ("-Ydoc", "Generate documentation") - val inline = BooleanSetting ("-Yinline", "Perform inlining when possible") - val Xlinearizer = ChoiceSetting ("-Ylinearizer", "Linearizer to use", List("normal", "dfs", "rpo", "dump"), "rpo") . - withHelpSyntax("-Ylinearizer:") - val log = PhasesSetting ("-Ylog", "Log operations in") - val Ynogenericsig = BooleanSetting ("-Yno-generic-signatures", "Suppress generation of generic signatures for Java") - val noimports = BooleanSetting ("-Yno-imports", "Compile without any implicit imports") - val nopredefs = BooleanSetting ("-Yno-predefs", "Compile without any implicit predefined values") - val Yrecursion = IntSetting ("-Yrecursion", "Recursion depth used when locking symbols", 0, Some(0, Int.MaxValue), (_: String) => None) - val selfInAnnots = BooleanSetting ("-Yself-in-annots", "Include a \"self\" identifier inside of annotations") - val Xshowtrees = BooleanSetting ("-Yshow-trees", "Show detailed trees when used in connection with -print:phase") - val skip = PhasesSetting ("-Yskip", "Skip") - val Xsqueeze = ChoiceSetting ("-Ysqueeze", "if on, creates compact code in matching", List("on","off"), "on") . - withHelpSyntax("-Ysqueeze:") - val Ystatistics = BooleanSetting ("-Ystatistics", "Print compiler statistics") - val stop = PhasesSetting ("-Ystop", "Stop after phase") - val refinementMethodDispatch = - ChoiceSetting ("-Ystruct-dispatch", "Selects dispatch method for structural refinement method calls", - List("no-cache", "mono-cache", "poly-cache", "invoke-dynamic"), "poly-cache") . - withHelpSyntax("-Ystruct-dispatch:") - val specialize = BooleanSetting ("-Yspecialize", "Specialize generic code on types.") - val Yrangepos = BooleanSetting ("-Yrangepos", "Use range positions for syntax trees.") - val Yidedebug = BooleanSetting ("-Yide-debug", "Generate, validate and output trees using the interactive compiler.") - val Ybuilderdebug = ChoiceSetting ("-Ybuilder-debug", "Compile using the specified build manager", List("none", "refined", "simple"), "none") . - withHelpSyntax("-Ybuilder-debug:") - val Ybuildmanagerdebug = - BooleanSetting ("-Ybuild-manager-debug", "Generate debug information for the Refined Build Manager compiler.") - val Ytyperdebug = BooleanSetting ("-Ytyper-debug", "Trace all type assignements") - val Ypmatdebug = BooleanSetting ("-Ypmat-debug", "Trace all pattern matcher activity.") - val Yrepldebug = BooleanSetting ("-Yrepl-debug", "Trace all repl activity.") - val Ypmatnaive = BooleanSetting ("-Ypmat-naive", "Desugar matches as naively as possible..") - val Ytailrec = BooleanSetting ("-Ytailrecommend", "Alert methods which would be tail-recursive if private or final.") - val Yjenkins = BooleanSetting ("-Yjenkins-hashCodes", "Use jenkins hash algorithm for case class generated hashCodes.") - - // Warnings - val Ywarnfatal = BooleanSetting ("-Yfatal-warnings", "Fail the compilation if there are any warnings.") - val Xwarninit = BooleanSetting ("-Xwarninit", "Warn about possible changes in initialization semantics") - val Xchecknull = BooleanSetting ("-Xcheck-null", "Emit warning on selection of nullable reference") - val Xwarndeadcode = BooleanSetting ("-Ywarn-dead-code", "Emit warnings for dead code") - val YwarnShadow = BooleanSetting ("-Ywarn-shadowing", "Emit warnings about possible variable shadowing.") - val YwarnCatches = BooleanSetting ("-Ywarn-catches", "Emit warnings about catch blocks which catch everything.") - val Xwarnings = BooleanSetting ("-Xstrict-warnings", "Emit warnings about lots of things.") . - withPostSetHook(_ => - List(YwarnShadow, YwarnCatches, Xwarndeadcode, Xwarninit) foreach (_.value = true) - ) - /** - * "fsc-specific" settings. - */ - val fscShutdown = BooleanSetting ("-shutdown", "Shutdown the fsc daemon") - - /** - * -P "Plugin" settings - */ - val pluginOptions = MultiStringSetting("-P", "plugin:opt", "Pass an option to a plugin") . - withHelpSyntax("-P::") -} diff --git a/src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala index 6ad82454e5..74e69b82e6 100644 --- a/src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/StandardScalaSettings.scala @@ -6,55 +6,50 @@ package scala.tools.nsc package settings +import scala.tools.util.PathResolver.Defaults + /** Settings which aren't behind a -X, -Y, or -P option. - * Wherever possible, the val and the option have identical. - * names. + * When possible, the val and the option have identical names. + * The abstract settings are commented as to why they are as yet + * implemented in MutableSettings rather than mutation-generically. */ trait StandardScalaSettings { - self: AbsScalacSettings => + self: AbsScalaSettings => /** Path related settings. + * !!! javaignorecp is temporary while I try to get an iron grip on the classpath. */ - val bootclasspath: PathSetting - val classpath: PathSetting - val d: OutputSetting - val extdirs: PathSetting - val g: ChoiceSetting - val javabootclasspath: PathSetting - val javaextdirs: PathSetting - val javaignorecp: BooleanSetting - val sourcepath: StringSetting + val bootclasspath = PathSetting ("-bootclasspath", "path", "Override location of bootstrap class files", Defaults.scalaBootClassPath) + val classpath: PathSetting // is mutated directly in various places (thus inspiring this very effort) + val d: OutputSetting // depends on mutable OutputDirs class + val extdirs = PathSetting ("-extdirs", "dirs", "Override location of installed extensions", Defaults.scalaExtDirs) + val javabootclasspath = PathSetting ("-javabootclasspath", "path", "Override java boot classpath.", Defaults.javaBootClassPath) + val javaextdirs = PathSetting ("-javaextdirs", "path", "Override java extdirs classpath.", Defaults.javaExtDirs) + val javaignorecp = BooleanSetting ("-javaignorecp", "scala will not use java's -classpath no matter what.") + val sourcepath = StringSetting ("-sourcepath", "path", "Specify where to find input source files", "") /** Other settings. */ - val dependencyfile: StringSetting - val deprecation: BooleanSetting - val encoding: StringSetting - val explaintypes: BooleanSetting - val help: BooleanSetting - val make: ChoiceSetting - val nowarn: BooleanSetting - val optimise: BooleanSetting - val print: BooleanSetting - val target: ChoiceSetting - val unchecked: BooleanSetting - val uniqid: BooleanSetting - val verbose: BooleanSetting - val version: BooleanSetting + val dependencyfile = StringSetting ("-dependencyfile", "file", "Specify the file in which dependencies are tracked", ".scala_dependencies") + val deprecation = BooleanSetting ("-deprecation", "Output source locations where deprecated APIs are used") + val encoding = StringSetting ("-encoding", "encoding", "Specify character encoding used by source files", Properties.sourceEncoding) + val explaintypes = BooleanSetting ("-explaintypes", "Explain type errors in more detail") + val g = ChoiceSetting ("-g", "Specify level of generated debugging info", List("none", "source", "line", "vars", "notailcalls"), "vars") + val help = BooleanSetting ("-help", "Print a synopsis of standard options") + val make = ChoiceSetting ("-make", "Specify recompilation detection strategy", List("all", "changed", "immediate", "transitive", "transitivenocp"), "all") . + withHelpSyntax("-make:") + val nowarn = BooleanSetting ("-nowarn", "Generate no warnings") + val optimise: BooleanSetting // depends on post hook which mutates other settings + val print = BooleanSetting ("-print", "Print program with all Scala-specific features removed") + val target = ChoiceSetting ("-target", "Specify for which target object files should be built", List("jvm-1.5", "msil"), "jvm-1.5") + val unchecked = BooleanSetting ("-unchecked", "Enable detailed unchecked warnings") + val uniqid = BooleanSetting ("-uniqid", "Print identifiers with unique names for debugging") + val verbose = BooleanSetting ("-verbose", "Output messages about what the compiler is doing") + val version = BooleanSetting ("-version", "Print product version and exit") /** These are @ and -Dkey=val style settings, which don't * nicely map to identifiers. */ - val argfiles: BooleanSetting - val defines: DefinesSetting - - /** Compatibility stubs for options whose value name did - * not previously match the option name. - */ - def XO = optimise - def debuginfo = g - def dependenciesFile = dependencyfile - def nowarnings = nowarn - def outdir = d - def printLate = print + val argfiles: BooleanSetting // exists only to echo help message, should be done differently + val defines: DefinesSetting // not entirely clear that DefinesSetting makes sense as a Setting } -- cgit v1.2.3