Skip to content

Commit 373ded2

Browse files
committed
Remove code from compiler central.
All those old-timey methods whose melodies have become unfashionable.
1 parent 69d850c commit 373ded2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+56
-1146
lines changed

src/compiler/scala/tools/nsc/CompilationUnits.scala

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ trait CompilationUnits { self: Global =>
2626
class CompilationUnit(val source: SourceFile) extends CompilationUnitContextApi {
2727

2828
/** the fresh name creator */
29-
var fresh: FreshNameCreator = new FreshNameCreator.Default
29+
val fresh: FreshNameCreator = new FreshNameCreator.Default
3030

3131
def freshTermName(prefix: String): TermName = newTermName(fresh.newName(prefix))
3232
def freshTypeName(prefix: String): TypeName = newTypeName(fresh.newName(prefix))
@@ -36,16 +36,6 @@ trait CompilationUnits { self: Global =>
3636

3737
def exists = source != NoSourceFile && source != null
3838

39-
// def parseSettings() = {
40-
// val argsmarker = "SCALAC_ARGS"
41-
// if(comments nonEmpty) {
42-
// val pragmas = comments find (_.text.startsWith("//#")) // only parse first one
43-
// pragmas foreach { p =>
44-
// val i = p.text.indexOf(argsmarker)
45-
// if(i > 0)
46-
// }
47-
// }
48-
// }
4939
/** Note: depends now contains toplevel classes.
5040
* To get their sourcefiles, you need to dereference with .sourcefile
5141
*/
@@ -107,18 +97,5 @@ trait CompilationUnits { self: Global =>
10797
lazy val isJava = source.file.name.endsWith(".java")
10898

10999
override def toString() = source.toString()
110-
111-
def clear() {
112-
fresh = new FreshNameCreator.Default
113-
body = EmptyTree
114-
depends.clear()
115-
defined.clear()
116-
synthetics.clear()
117-
toCheck.clear()
118-
checkedFeatures = Set()
119-
icode.clear()
120-
}
121100
}
122101
}
123-
124-

src/compiler/scala/tools/nsc/CompileServer.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ class StandardCompileServer extends SocketServer {
2929
var shutdown = false
3030
var verbose = false
3131

32-
val versionMsg = "Fast " + Properties.versionMsg
33-
3432
val MaxCharge = 0.8
3533

3634
private val runtime = Runtime.getRuntime()

src/compiler/scala/tools/nsc/CompilerCommand.scala

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ class CompilerCommand(arguments: List[String], val settings: Settings) {
1414

1515
type Setting = Settings#Setting
1616

17-
/** file extensions of files that the compiler can process */
18-
lazy val fileEndings = Properties.fileEndings
19-
2017
private val processArgumentsResult =
2118
if (shouldProcessArguments) processArguments
2219
else (true, Nil)
@@ -40,8 +37,6 @@ class CompilerCommand(arguments: List[String], val settings: Settings) {
4037
""".stripMargin.trim + "\n"
4138

4239
def shortUsage = "Usage: %s <options> <source files>" format cmdName
43-
def createUsagePreface(shouldExplain: Boolean) =
44-
if (shouldExplain) shortUsage + "\n" + explainAdvanced else ""
4540

4641
/** Creates a help message for a subset of options based on cond */
4742
def createUsageMsg(cond: Setting => Boolean): String = {

src/compiler/scala/tools/nsc/Global.scala

Lines changed: 9 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
7070
def this(settings: Settings) =
7171
this(settings, new ConsoleReporter(settings))
7272

73-
def mkAttributedQualifier(tpe: Type, termSym: Symbol): Tree = gen.mkAttributedQualifier(tpe, termSym)
74-
7573
def picklerPhase: Phase = if (currentRun.isDefined) currentRun.picklerPhase else NoPhase
7674

7775
// platform specific elements
@@ -265,15 +263,10 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
265263

266264
def informComplete(msg: String): Unit = reporter.withoutTruncating(inform(msg))
267265
def informProgress(msg: String) = if (settings.verbose.value) inform("[" + msg + "]")
268-
def inform[T](msg: String, value: T): T = returning(value)(x => inform(msg + x))
269266
def informTime(msg: String, start: Long) = informProgress(elapsedMessage(msg, start))
270267

271268
def logError(msg: String, t: Throwable): Unit = ()
272269

273-
def logAfterEveryPhase[T](msg: String)(op: => T) {
274-
log("Running operation '%s' after every phase.\n".format(msg) + describeAfterEveryPhase(op))
275-
}
276-
277270
override def shouldLogAtThisPhase = settings.log.isSetByUser && (
278271
(settings.log containsPhase globalPhase) || (settings.log containsPhase phase)
279272
)
@@ -419,8 +412,8 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
419412
}
420413

421414
/** Switch to turn on detailed type logs */
422-
var printTypings = settings.Ytyperdebug.value
423-
var printInfers = settings.Yinferdebug.value
415+
val printTypings = settings.Ytyperdebug.value
416+
val printInfers = settings.Yinferdebug.value
424417

425418
// phaseName = "parser"
426419
object syntaxAnalyzer extends {
@@ -638,13 +631,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
638631
}
639632
}
640633

641-
// phaseName = "SAMPLE PHASE"
642-
object sampleTransform extends {
643-
val global: Global.this.type = Global.this
644-
val runsAfter = List[String]()
645-
val runsRightAfter = None
646-
} with SampleTransform
647-
648634
/** The checkers are for validating the compiler data structures
649635
* at phase boundaries.
650636
*/
@@ -778,48 +764,16 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
778764
/** Returns List of (phase, value) pairs, including only those
779765
* where the value compares unequal to the previous phase's value.
780766
*/
781-
def afterEachPhase[T](op: => T): List[(Phase, T)] = {
767+
def afterEachPhase[T](op: => T): List[(Phase, T)] = { // used in tests
782768
phaseDescriptors.map(_.ownPhase).filterNot(_ eq NoPhase).foldLeft(List[(Phase, T)]()) { (res, ph) =>
783769
val value = exitingPhase(ph)(op)
784770
if (res.nonEmpty && res.head._2 == value) res
785771
else ((ph, value)) :: res
786772
} reverse
787773
}
788774

789-
/** Returns List of ChangeAfterPhase objects, encapsulating those
790-
* phase transitions where the result of the operation gave a different
791-
* list than it had when run during the previous phase.
792-
*/
793-
def changesAfterEachPhase[T](op: => List[T]): List[ChangeAfterPhase[T]] = {
794-
val ops = ((NoPhase, Nil)) :: afterEachPhase(op)
795-
796-
ops sliding 2 map {
797-
case (_, before) :: (ph, after) :: Nil =>
798-
val lost = before filterNot (after contains _)
799-
val gained = after filterNot (before contains _)
800-
ChangeAfterPhase(ph, lost, gained)
801-
case _ => ???
802-
} toList
803-
}
804775
private def numberedPhase(ph: Phase) = "%2d/%s".format(ph.id, ph.name)
805776

806-
case class ChangeAfterPhase[+T](ph: Phase, lost: List[T], gained: List[T]) {
807-
private def mkStr(what: String, xs: List[_]) = (
808-
if (xs.isEmpty) ""
809-
else xs.mkString(what + " after " + numberedPhase(ph) + " {\n ", "\n ", "\n}\n")
810-
)
811-
override def toString = mkStr("Lost", lost) + mkStr("Gained", gained)
812-
}
813-
814-
def describeAfterEachPhase[T](op: => T): List[String] =
815-
afterEachPhase(op) map { case (ph, t) => "[after %-15s] %s".format(numberedPhase(ph), t) }
816-
817-
def describeAfterEveryPhase[T](op: => T): String =
818-
describeAfterEachPhase(op) map (" " + _ + "\n") mkString
819-
820-
def printAfterEachPhase[T](op: => T): Unit =
821-
describeAfterEachPhase(op) foreach (m => println(" " + m))
822-
823777
// ------------ Invalidations ---------------------------------
824778

825779
/** Is given package class a system package class that cannot be invalidated?
@@ -1057,7 +1011,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
10571011
@inline final def exitingPostErasure[T](op: => T): T = exitingPhase(currentRun.posterasurePhase)(op)
10581012
@inline final def exitingExplicitOuter[T](op: => T): T = exitingPhase(currentRun.explicitouterPhase)(op)
10591013
@inline final def exitingFlatten[T](op: => T): T = exitingPhase(currentRun.flattenPhase)(op)
1060-
@inline final def exitingIcode[T](op: => T): T = exitingPhase(currentRun.icodePhase)(op)
10611014
@inline final def exitingMixin[T](op: => T): T = exitingPhase(currentRun.mixinPhase)(op)
10621015
@inline final def exitingPickler[T](op: => T): T = exitingPhase(currentRun.picklerPhase)(op)
10631016
@inline final def exitingRefchecks[T](op: => T): T = exitingPhase(currentRun.refchecksPhase)(op)
@@ -1071,21 +1024,9 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
10711024
@inline final def enteringMixin[T](op: => T): T = enteringPhase(currentRun.mixinPhase)(op)
10721025
@inline final def enteringPickler[T](op: => T): T = enteringPhase(currentRun.picklerPhase)(op)
10731026
@inline final def enteringRefchecks[T](op: => T): T = enteringPhase(currentRun.refchecksPhase)(op)
1074-
@inline final def enteringSpecialize[T](op: => T): T = enteringPhase(currentRun.specializePhase)(op)
10751027
@inline final def enteringTyper[T](op: => T): T = enteringPhase(currentRun.typerPhase)(op)
10761028
@inline final def enteringUncurry[T](op: => T): T = enteringPhase(currentRun.uncurryPhase)(op)
10771029

1078-
def explainContext(c: analyzer.Context): String = (
1079-
if (c == null) "" else (
1080-
"""| context owners: %s
1081-
|
1082-
|Enclosing block or template:
1083-
|%s""".format(
1084-
c.owner.ownerChain.takeWhile(!_.isPackageClass).mkString(" -> "),
1085-
nodePrinters.nodeToString(c.enclClassOrMethod.tree)
1086-
)
1087-
)
1088-
)
10891030
// Owners up to and including the first package class.
10901031
private def ownerChainString(sym: Symbol): String = (
10911032
if (sym == null) ""
@@ -1098,9 +1039,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
10981039
pairs.toList collect { case (k, v) if v != null => "%20s: %s".format(k, v) } mkString "\n"
10991040
)
11001041

1101-
def explainTree(t: Tree): String = formatExplain(
1102-
)
1103-
11041042
/** Don't want to introduce new errors trying to report errors,
11051043
* so swallow exceptions.
11061044
*/
@@ -1158,7 +1096,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
11581096
}
11591097

11601098
def newUnitParser(code: String) = new syntaxAnalyzer.UnitParser(newCompilationUnit(code))
1161-
def newUnitScanner(code: String) = new syntaxAnalyzer.UnitScanner(newCompilationUnit(code))
11621099
def newCompilationUnit(code: String) = new CompilationUnit(newSourceFile(code))
11631100
def newSourceFile(code: String) = new BatchSourceFile("<console>", code)
11641101

@@ -1181,9 +1118,8 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
11811118
val inlinerWarnings = new ConditionalWarning("inliner", settings.YinlinerWarnings)
11821119
val allConditionalWarnings = List(deprecationWarnings0, uncheckedWarnings0, featureWarnings, inlinerWarnings)
11831120

1184-
// for sbt's benefit
1185-
def uncheckedWarnings: List[(Position, String)] = uncheckedWarnings0.warnings.toList
1186-
def deprecationWarnings: List[(Position, String)] = deprecationWarnings0.warnings.toList
1121+
def uncheckedWarnings: List[(Position, String)] = uncheckedWarnings0.warnings.toList // used in sbt
1122+
def deprecationWarnings: List[(Position, String)] = deprecationWarnings0.warnings.toList // used in sbt
11871123

11881124
var reportedFeature = Set[Symbol]()
11891125

@@ -1350,7 +1286,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
13501286
val namerPhase = phaseNamed("namer")
13511287
// val packageobjectsPhase = phaseNamed("packageobjects")
13521288
val typerPhase = phaseNamed("typer")
1353-
val inlineclassesPhase = phaseNamed("inlineclasses")
1289+
// val inlineclassesPhase = phaseNamed("inlineclasses")
13541290
// val superaccessorsPhase = phaseNamed("superaccessors")
13551291
val picklerPhase = phaseNamed("pickler")
13561292
val refchecksPhase = phaseNamed("refchecks")
@@ -1363,7 +1299,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
13631299
val erasurePhase = phaseNamed("erasure")
13641300
val posterasurePhase = phaseNamed("posterasure")
13651301
// val lazyvalsPhase = phaseNamed("lazyvals")
1366-
val lambdaliftPhase = phaseNamed("lambdalift")
1302+
// val lambdaliftPhase = phaseNamed("lambdalift")
13671303
// val constructorsPhase = phaseNamed("constructors")
13681304
val flattenPhase = phaseNamed("flatten")
13691305
val mixinPhase = phaseNamed("mixin")
@@ -1373,12 +1309,10 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
13731309
val inlineExceptionHandlersPhase = phaseNamed("inlineExceptionHandlers")
13741310
val closelimPhase = phaseNamed("closelim")
13751311
val dcePhase = phaseNamed("dce")
1376-
val jvmPhase = phaseNamed("jvm")
1312+
// val jvmPhase = phaseNamed("jvm")
13771313
// val msilPhase = phaseNamed("msil")
13781314

13791315
def runIsAt(ph: Phase) = globalPhase.id == ph.id
1380-
def runIsPast(ph: Phase) = globalPhase.id > ph.id
1381-
// def runIsAtBytecodeGen = (runIsAt(jvmPhase) || runIsAt(msilPhase))
13821316
def runIsAtOptimiz = {
13831317
runIsAt(inlinerPhase) || // listing phases in full for robustness when -Ystop-after has been given.
13841318
runIsAt(inlineExceptionHandlersPhase) ||
@@ -1743,7 +1677,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
17431677
// and forScaladoc default to onlyPresentation, which is the same as defaulting
17441678
// to false except in old code. The downside is that this leaves us calling a
17451679
// deprecated method: but I see no simple way out, so I leave it for now.
1746-
def forJVM = settings.target.value startsWith "jvm"
1680+
// def forJVM = settings.target.value startsWith "jvm"
17471681
override def forMSIL = settings.target.value startsWith "msil"
17481682
def forInteractive = false
17491683
def forScaladoc = false

src/compiler/scala/tools/nsc/ObjectRunner.scala

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ import util.ScalaClassLoader
1111
import util.Exceptional.unwrap
1212

1313
trait CommonRunner {
14-
/** Check whether a class with the specified name
15-
* exists on the specified class path. */
16-
def classExists(urls: List[URL], objectName: String): Boolean =
17-
ScalaClassLoader.classExists(urls, objectName)
18-
1914
/** Run a given object, specified by name, using a
2015
* specified classpath and argument list.
2116
*

src/compiler/scala/tools/nsc/Phases.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ object Phases {
2020
}
2121
val values = new Array[Cell](MaxPhases + 1)
2222
def results = values filterNot (_ == null)
23-
def apply(ph: Phase): T = values(ph.id).value
2423
def update(ph: Phase, value: T): Unit = values(ph.id) = Cell(ph, value)
2524
}
2625
/** A class for recording the elapsed time of each phase in the
@@ -38,7 +37,6 @@ object Phases {
3837
>> ("ms" -> (_.value)) >+ " "
3938
<< ("share" -> (_.value.toDouble * 100 / total formatted "%.2f"))
4039
}
41-
def formatted = "" + table()
4240
}
4341
}
4442

src/compiler/scala/tools/nsc/Properties.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,4 @@ object Properties extends scala.util.PropertiesTrait {
2121

2222
// derived values
2323
def isEmacsShell = propOrEmpty("env.emacs") != ""
24-
def fileEndings = fileEndingString.split("""\|""").toList
2524
}

src/compiler/scala/tools/nsc/ScriptRunner.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ class ScriptRunner extends HasCompileSocket {
4848
case x => x
4949
}
5050

51-
def isScript(settings: Settings) = settings.script.value != ""
52-
5351
/** Choose a jar filename to hold the compiled version of a script. */
5452
private def jarFileFor(scriptFile: String)= File(
5553
if (scriptFile endsWith ".jar") scriptFile

0 commit comments

Comments
 (0)