Skip to content

Commit e52fa7e

Browse files
committed
Merge pull request scala#950 from paulp/topic/entering-exiting-phase
Renaming phase time-travel methods.
2 parents 79026e6 + 97ce709 commit e52fa7e

Some content is hidden

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

41 files changed

+183
-184
lines changed

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

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
168168
if (lastPrintedSource == source)
169169
println(": tree is unchanged since " + lastPrintedPhase)
170170
else {
171-
lastPrintedPhase = phase.prev // since we're running inside "afterPhase"
171+
lastPrintedPhase = phase.prev // since we're running inside "exitingPhase"
172172
lastPrintedSource = source
173173
println("")
174174
println(source)
@@ -782,7 +782,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
782782
*/
783783
def afterEachPhase[T](op: => T): List[(Phase, T)] = {
784784
phaseDescriptors.map(_.ownPhase).filterNot(_ eq NoPhase).foldLeft(List[(Phase, T)]()) { (res, ph) =>
785-
val value = afterPhase(ph)(op)
785+
val value = exitingPhase(ph)(op)
786786
if (res.nonEmpty && res.head._2 == value) res
787787
else ((ph, value)) :: res
788788
} reverse
@@ -1051,26 +1051,26 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
10511051
def currentSource: SourceFile = if (currentUnit.exists) currentUnit.source else lastSeenSourceFile
10521052

10531053
// TODO - trim these to the absolute minimum.
1054-
@inline final def afterErasure[T](op: => T): T = afterPhase(currentRun.erasurePhase)(op)
1055-
@inline final def afterExplicitOuter[T](op: => T): T = afterPhase(currentRun.explicitouterPhase)(op)
1056-
@inline final def afterFlatten[T](op: => T): T = afterPhase(currentRun.flattenPhase)(op)
1057-
@inline final def afterIcode[T](op: => T): T = afterPhase(currentRun.icodePhase)(op)
1058-
@inline final def afterMixin[T](op: => T): T = afterPhase(currentRun.mixinPhase)(op)
1059-
@inline final def afterPickler[T](op: => T): T = afterPhase(currentRun.picklerPhase)(op)
1060-
@inline final def afterRefchecks[T](op: => T): T = afterPhase(currentRun.refchecksPhase)(op)
1061-
@inline final def afterSpecialize[T](op: => T): T = afterPhase(currentRun.specializePhase)(op)
1062-
@inline final def afterTyper[T](op: => T): T = afterPhase(currentRun.typerPhase)(op)
1063-
@inline final def afterUncurry[T](op: => T): T = afterPhase(currentRun.uncurryPhase)(op)
1064-
@inline final def beforeErasure[T](op: => T): T = beforePhase(currentRun.erasurePhase)(op)
1065-
@inline final def beforeExplicitOuter[T](op: => T): T = beforePhase(currentRun.explicitouterPhase)(op)
1066-
@inline final def beforeFlatten[T](op: => T): T = beforePhase(currentRun.flattenPhase)(op)
1067-
@inline final def beforeIcode[T](op: => T): T = beforePhase(currentRun.icodePhase)(op)
1068-
@inline final def beforeMixin[T](op: => T): T = beforePhase(currentRun.mixinPhase)(op)
1069-
@inline final def beforePickler[T](op: => T): T = beforePhase(currentRun.picklerPhase)(op)
1070-
@inline final def beforeRefchecks[T](op: => T): T = beforePhase(currentRun.refchecksPhase)(op)
1071-
@inline final def beforeSpecialize[T](op: => T): T = beforePhase(currentRun.specializePhase)(op)
1072-
@inline final def beforeTyper[T](op: => T): T = beforePhase(currentRun.typerPhase)(op)
1073-
@inline final def beforeUncurry[T](op: => T): T = beforePhase(currentRun.uncurryPhase)(op)
1054+
@inline final def exitingErasure[T](op: => T): T = exitingPhase(currentRun.erasurePhase)(op)
1055+
@inline final def exitingExplicitOuter[T](op: => T): T = exitingPhase(currentRun.explicitouterPhase)(op)
1056+
@inline final def exitingFlatten[T](op: => T): T = exitingPhase(currentRun.flattenPhase)(op)
1057+
@inline final def exitingIcode[T](op: => T): T = exitingPhase(currentRun.icodePhase)(op)
1058+
@inline final def exitingMixin[T](op: => T): T = exitingPhase(currentRun.mixinPhase)(op)
1059+
@inline final def exitingPickler[T](op: => T): T = exitingPhase(currentRun.picklerPhase)(op)
1060+
@inline final def exitingRefchecks[T](op: => T): T = exitingPhase(currentRun.refchecksPhase)(op)
1061+
@inline final def exitingSpecialize[T](op: => T): T = exitingPhase(currentRun.specializePhase)(op)
1062+
@inline final def exitingTyper[T](op: => T): T = exitingPhase(currentRun.typerPhase)(op)
1063+
@inline final def exitingUncurry[T](op: => T): T = exitingPhase(currentRun.uncurryPhase)(op)
1064+
@inline final def enteringErasure[T](op: => T): T = enteringPhase(currentRun.erasurePhase)(op)
1065+
@inline final def enteringExplicitOuter[T](op: => T): T = enteringPhase(currentRun.explicitouterPhase)(op)
1066+
@inline final def enteringFlatten[T](op: => T): T = enteringPhase(currentRun.flattenPhase)(op)
1067+
@inline final def enteringIcode[T](op: => T): T = enteringPhase(currentRun.icodePhase)(op)
1068+
@inline final def enteringMixin[T](op: => T): T = enteringPhase(currentRun.mixinPhase)(op)
1069+
@inline final def enteringPickler[T](op: => T): T = enteringPhase(currentRun.picklerPhase)(op)
1070+
@inline final def enteringRefchecks[T](op: => T): T = enteringPhase(currentRun.refchecksPhase)(op)
1071+
@inline final def enteringSpecialize[T](op: => T): T = enteringPhase(currentRun.specializePhase)(op)
1072+
@inline final def enteringTyper[T](op: => T): T = enteringPhase(currentRun.typerPhase)(op)
1073+
@inline final def enteringUncurry[T](op: => T): T = enteringPhase(currentRun.uncurryPhase)(op)
10741074

10751075
def explainContext(c: analyzer.Context): String = (
10761076
if (c == null) "" else (
@@ -1109,7 +1109,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
11091109

11101110
val info1 = formatExplain(
11111111
"while compiling" -> currentSource.path,
1112-
"during phase" -> ( if (globalPhase eq phase) phase else "global=%s, atPhase=%s".format(globalPhase, phase) ),
1112+
"during phase" -> ( if (globalPhase eq phase) phase else "global=%s, enteringPhase=%s".format(globalPhase, phase) ),
11131113
"library version" -> scala.util.Properties.versionString,
11141114
"compiler version" -> Properties.versionString,
11151115
"reconstructed args" -> settings.recreateArgs.mkString(" ")
@@ -1469,7 +1469,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
14691469
lazy val trackers = currentRun.units.toList map (x => SymbolTracker(x))
14701470
def snapshot() = {
14711471
inform("\n[[symbol layout at end of " + phase + "]]")
1472-
afterPhase(phase) {
1472+
exitingPhase(phase) {
14731473
trackers foreach { t =>
14741474
t.snapshot()
14751475
inform(t.show("Heading from " + phase.prev.name + " to " + phase.name))
@@ -1605,7 +1605,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
16051605

16061606
// Reset project
16071607
if (!stopPhase("namer")) {
1608-
atPhase(namerPhase) {
1608+
enteringPhase(namerPhase) {
16091609
resetProjectClasses(RootClass)
16101610
}
16111611
}
@@ -1645,7 +1645,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
16451645
if (firstPhase ne null) { // we might get here during initialization, is a source is newer than the binary
16461646
val maxId = math.max(globalPhase.id, typerPhase.id)
16471647
firstPhase.iterator takeWhile (_.id < maxId) foreach (ph =>
1648-
atPhase(ph)(ph.asInstanceOf[GlobalPhase] applyPhase unit))
1648+
enteringPhase(ph)(ph.asInstanceOf[GlobalPhase] applyPhase unit))
16491649
refreshProgress
16501650
}
16511651
}
@@ -1654,8 +1654,8 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
16541654
* is needed for?)
16551655
*/
16561656
private def resetPackageClass(pclazz: Symbol) {
1657-
atPhase(firstPhase) {
1658-
pclazz.setInfo(atPhase(typerPhase)(pclazz.info))
1657+
enteringPhase(firstPhase) {
1658+
pclazz.setInfo(enteringPhase(typerPhase)(pclazz.info))
16591659
}
16601660
if (!pclazz.isRoot) resetPackageClass(pclazz.owner)
16611661
}
@@ -1703,7 +1703,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
17031703

17041704
def printAllUnits() {
17051705
print("[[syntax trees at end of %25s]]".format(phase))
1706-
afterPhase(phase)(currentRun.units foreach { unit =>
1706+
exitingPhase(phase)(currentRun.units foreach { unit =>
17071707
nodePrinters showUnit unit
17081708
})
17091709
}
@@ -1712,7 +1712,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
17121712
*/
17131713
def showDef(fullName: Name, declsOnly: Boolean, ph: Phase) = {
17141714
val boringOwners = Set[Symbol](definitions.AnyClass, definitions.AnyRefClass, definitions.ObjectClass)
1715-
def phased[T](body: => T): T = afterPhase(ph)(body)
1715+
def phased[T](body: => T): T = exitingPhase(ph)(body)
17161716
def boringMember(sym: Symbol) = boringOwners(sym.owner)
17171717
def symString(sym: Symbol) = if (sym.isTerm) sym.defString else sym.toString
17181718

src/compiler/scala/tools/nsc/SubComponent.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ abstract class SubComponent {
4747
private var ownPhaseCache: WeakReference[Phase] = new WeakReference(null)
4848
private var ownPhaseRunId = global.NoRunId
4949

50-
@inline final def beforeOwnPhase[T](op: => T) = global.beforePhase(ownPhase)(op)
51-
@inline final def afterOwnPhase[T](op: => T) = global.afterPhase(ownPhase)(op)
50+
@inline final def beforeOwnPhase[T](op: => T) = global.enteringPhase(ownPhase)(op)
51+
@inline final def afterOwnPhase[T](op: => T) = global.exitingPhase(ownPhase)(op)
5252

5353
/** The phase corresponding to this subcomponent in the current compiler run */
5454
def ownPhase: Phase = {

src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ abstract class ScalaPrimitives {
565565
import definitions._
566566
val code = getPrimitive(fun)
567567

568-
def elementType = beforeTyper {
568+
def elementType = enteringTyper {
569569
val arrayParent = tpe :: tpe.parents collectFirst {
570570
case TypeRef(_, ArrayClass, elem :: Nil) => elem
571571
}

src/compiler/scala/tools/nsc/backend/icode/TypeKinds.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ trait TypeKinds { self: ICodes =>
139139
* Here we make the adjustment by rewinding to a pre-erasure state and
140140
* sifting through the parents for a class type.
141141
*/
142-
def lub0(tk1: TypeKind, tk2: TypeKind): Type = beforeUncurry {
142+
def lub0(tk1: TypeKind, tk2: TypeKind): Type = enteringUncurry {
143143
import definitions._
144144
val tp = global.lub(List(tk1.toType, tk2.toType))
145145
val (front, rest) = tp.parents span (_.typeSymbol.isTrait)

src/compiler/scala/tools/nsc/backend/jvm/BytecodeWriters.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ trait BytecodeWriters {
2323
import global._
2424

2525
private def outputDirectory(sym: Symbol): AbstractFile = (
26-
settings.outputDirs.outputDirFor(beforeFlatten(sym.sourceFile))
26+
settings.outputDirs.outputDirFor(enteringFlatten(sym.sourceFile))
2727
)
2828
private def getFile(base: AbstractFile, /*cls.getName()*/ clsName: String, suffix: String): AbstractFile = {
2929
var dir = base

src/compiler/scala/tools/nsc/backend/jvm/GenASM.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters {
3333
override def newPhase(p: Phase): Phase = new AsmPhase(p)
3434

3535
private def outputDirectory(sym: Symbol): AbstractFile =
36-
settings.outputDirs outputDirFor beforeFlatten(sym.sourceFile)
36+
settings.outputDirs outputDirFor enteringFlatten(sym.sourceFile)
3737

3838
private def getFile(base: AbstractFile, clsName: String, suffix: String): AbstractFile = {
3939
var dir = base
@@ -81,7 +81,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters {
8181
// At this point it's a module with a main-looking method, so either succeed or warn that it isn't.
8282
hasApproximate && {
8383
// Before erasure so we can identify generic mains.
84-
beforeErasure {
84+
enteringErasure {
8585
val companion = sym.linkedClassOfClass
8686
val companionMain = companion.tpe.member(nme.main)
8787

@@ -311,7 +311,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters {
311311
}
312312

313313
def isTopLevelModule(sym: Symbol): Boolean =
314-
afterPickler { sym.isModuleClass && !sym.isImplClass && !sym.isNestedClass }
314+
exitingPickler { sym.isModuleClass && !sym.isImplClass && !sym.isNestedClass }
315315

316316
def isStaticModule(sym: Symbol): Boolean = {
317317
sym.isModuleClass && !sym.isImplClass && !sym.isLifted
@@ -569,7 +569,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters {
569569
* of inner class all until root class.
570570
*/
571571
def collectInnerClass(s: Symbol): Unit = {
572-
// TODO: some beforeFlatten { ... } which accounts for
572+
// TODO: some enteringFlatten { ... } which accounts for
573573
// being nested in parameterized classes (if we're going to selectively flatten.)
574574
val x = innerClassSymbolFor(s)
575575
if(x ne NoSymbol) {
@@ -671,7 +671,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters {
671671
innerSym.rawname + innerSym.moduleSuffix
672672

673673
// add inner classes which might not have been referenced yet
674-
afterErasure {
674+
exitingErasure {
675675
for (sym <- List(csym, csym.linkedClassOfClass); m <- sym.info.decls.map(innerClassSymbolFor) if m.isClass)
676676
innerClassBuffer += m
677677
}
@@ -867,7 +867,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters {
867867

868868
if (!needsGenericSignature(sym)) { return null }
869869

870-
val memberTpe = beforeErasure(owner.thisType.memberInfo(sym))
870+
val memberTpe = enteringErasure(owner.thisType.memberInfo(sym))
871871

872872
val jsOpt: Option[String] = erasure.javaSig(sym, memberTpe)
873873
if (jsOpt.isEmpty) { return null }
@@ -901,7 +901,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters {
901901
}
902902

903903
if ((settings.check containsName phaseName)) {
904-
val normalizedTpe = beforeErasure(erasure.prepareSigMap(memberTpe))
904+
val normalizedTpe = enteringErasure(erasure.prepareSigMap(memberTpe))
905905
val bytecodeTpe = owner.thisType.memberInfo(sym)
906906
if (!sym.isType && !sym.isConstructor && !(erasure.erasure(sym)(normalizedTpe) =:= bytecodeTpe)) {
907907
getCurrentCUnit().warning(sym.pos,
@@ -1427,7 +1427,7 @@ abstract class GenASM extends SubComponent with BytecodeWriters {
14271427
if (lmoc != NoSymbol) {
14281428
// it must be a top level class (name contains no $s)
14291429
val isCandidateForForwarders = {
1430-
afterPickler { !(lmoc.name.toString contains '$') && lmoc.hasModuleFlag && !lmoc.isImplClass && !lmoc.isNestedClass }
1430+
exitingPickler { !(lmoc.name.toString contains '$') && lmoc.hasModuleFlag && !lmoc.isImplClass && !lmoc.isNestedClass }
14311431
}
14321432
if (isCandidateForForwarders) {
14331433
log("Adding static forwarders from '%s' to implementations in '%s'".format(c.symbol, lmoc))

src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
3838
override def newPhase(p: Phase): Phase = new JvmPhase(p)
3939

4040
private def outputDirectory(sym: Symbol): AbstractFile =
41-
settings.outputDirs outputDirFor beforeFlatten(sym.sourceFile)
41+
settings.outputDirs outputDirFor enteringFlatten(sym.sourceFile)
4242

4343
private def getFile(base: AbstractFile, clsName: String, suffix: String): AbstractFile = {
4444
var dir = base
@@ -85,7 +85,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
8585
// succeed or warn that it isn't.
8686
hasApproximate && {
8787
// Before erasure so we can identify generic mains.
88-
beforeErasure {
88+
enteringErasure {
8989
val companion = sym.linkedClassOfClass
9090
val companionMain = companion.tpe.member(nme.main)
9191

@@ -316,7 +316,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
316316
* of inner class all until root class.
317317
*/
318318
def collectInnerClass(s: Symbol): Unit = {
319-
// TODO: some beforeFlatten { ... } which accounts for
319+
// TODO: some enteringFlatten { ... } which accounts for
320320
// being nested in parameterized classes (if we're going to selectively flatten.)
321321
val x = innerClassSymbolFor(s)
322322
if(x ne NoSymbol) {
@@ -446,7 +446,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
446446

447447
// it must be a top level class (name contains no $s)
448448
def isCandidateForForwarders(sym: Symbol): Boolean =
449-
afterPickler {
449+
exitingPickler {
450450
!(sym.name.toString contains '$') && sym.hasModuleFlag && !sym.isImplClass && !sym.isNestedClass
451451
}
452452

@@ -735,13 +735,13 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
735735
)
736736
def addGenericSignature(jmember: JMember, sym: Symbol, owner: Symbol) {
737737
if (needsGenericSignature(sym)) {
738-
val memberTpe = beforeErasure(owner.thisType.memberInfo(sym))
738+
val memberTpe = enteringErasure(owner.thisType.memberInfo(sym))
739739

740740
erasure.javaSig(sym, memberTpe) foreach { sig =>
741741
// This seems useful enough in the general case.
742742
log(sig)
743743
if (checkSignatures) {
744-
val normalizedTpe = beforeErasure(erasure.prepareSigMap(memberTpe))
744+
val normalizedTpe = enteringErasure(erasure.prepareSigMap(memberTpe))
745745
val bytecodeTpe = owner.thisType.memberInfo(sym)
746746
if (!sym.isType && !sym.isConstructor && !(erasure.erasure(sym)(normalizedTpe) =:= bytecodeTpe)) {
747747
clasz.cunit.warning(sym.pos,
@@ -757,7 +757,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
757757
}
758758
val index = jmember.getConstantPool.addUtf8(sig).toShort
759759
if (settings.verbose.value && settings.debug.value)
760-
beforeErasure(println("add generic sig "+sym+":"+sym.info+" ==> "+sig+" @ "+index))
760+
enteringErasure(println("add generic sig "+sym+":"+sym.info+" ==> "+sig+" @ "+index))
761761

762762
val buf = ByteBuffer.allocate(2)
763763
buf putShort index
@@ -833,7 +833,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
833833
innerSym.rawname + innerSym.moduleSuffix
834834

835835
// add inner classes which might not have been referenced yet
836-
afterErasure {
836+
exitingErasure {
837837
for (sym <- List(clasz.symbol, clasz.symbol.linkedClassOfClass); m <- sym.info.decls.map(innerClassSymbolFor) if m.isClass)
838838
innerClassBuffer += m
839839
}
@@ -1988,7 +1988,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with
19881988
)
19891989

19901990
def isTopLevelModule(sym: Symbol): Boolean =
1991-
afterPickler { sym.isModuleClass && !sym.isImplClass && !sym.isNestedClass }
1991+
exitingPickler { sym.isModuleClass && !sym.isImplClass && !sym.isNestedClass }
19921992

19931993
def isStaticModule(sym: Symbol): Boolean = {
19941994
sym.isModuleClass && !sym.isImplClass && !sym.isLifted

src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,7 @@ abstract class GenMSIL extends SubComponent {
11261126
}
11271127

11281128
// method: implicit view(FunctionX[PType0, PType1, ...,PTypeN, ResType]):DelegateType
1129-
val (isDelegateView, paramType, resType) = beforeTyper {
1129+
val (isDelegateView, paramType, resType) = enteringTyper {
11301130
msym.tpe match {
11311131
case MethodType(params, resultType)
11321132
if (params.length == 1 && msym.name == nme.view_) =>
@@ -1955,7 +1955,7 @@ abstract class GenMSIL extends SubComponent {
19551955
} // createClassMembers0
19561956

19571957
private def isTopLevelModule(sym: Symbol): Boolean =
1958-
beforeRefchecks {
1958+
enteringRefchecks {
19591959
sym.isModuleClass && !sym.isImplClass && !sym.isNestedClass
19601960
}
19611961

src/compiler/scala/tools/nsc/backend/opt/Inliners.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ abstract class Inliners extends SubComponent {
547547

548548
private def isHigherOrderMethod(sym: Symbol) = (
549549
sym.isMethod
550-
&& beforeExplicitOuter(sym.info.paramTypes exists isFunctionType) // was "at erasurePhase.prev"
550+
&& enteringExplicitOuter(sym.info.paramTypes exists isFunctionType) // was "at erasurePhase.prev"
551551
)
552552

553553
/** Should method 'sym' being called in 'receiver' be loaded from disk? */

0 commit comments

Comments
 (0)