@@ -72,14 +72,14 @@ object Phases {
72
72
override def lastPhaseId (implicit ctx : Context ) = id
73
73
}
74
74
75
- def phasePlan = this .phasesPlan
76
- def setPhasePlan (phasess : List [List [Phase ]]) = this .phasesPlan = phasess
75
+ final def phasePlan = this .phasesPlan
76
+ final def setPhasePlan (phasess : List [List [Phase ]]) = this .phasesPlan = phasess
77
77
78
78
/** Squash TreeTransform's beloning to same sublist to a single TreeTransformer
79
79
* Each TreeTransform gets own period,
80
80
* whereas a combined TreeTransformer gets period equal to union of periods of it's TreeTransforms
81
81
*/
82
- def squashPhases (phasess : List [List [Phase ]],
82
+ final def squashPhases (phasess : List [List [Phase ]],
83
83
phasesToSkip : List [String ], stopBeforePhases : List [String ], stopAfterPhases : List [String ], YCheckAfter : List [String ]): List [Phase ] = {
84
84
val squashedPhases = ListBuffer [Phase ]()
85
85
var prevPhases : Set [Class [_ <: Phase ]] = Set .empty
@@ -139,7 +139,7 @@ object Phases {
139
139
* The list should never contain NoPhase.
140
140
* if squashing is enabled, phases in same subgroup will be squashed to single phase.
141
141
*/
142
- def usePhases (phasess : List [Phase ], squash : Boolean = true ) = {
142
+ final def usePhases (phasess : List [Phase ], squash : Boolean = true ) = {
143
143
144
144
val flatPhases = collection.mutable.ListBuffer [Phase ]()
145
145
@@ -149,6 +149,7 @@ object Phases {
149
149
})
150
150
151
151
phases = (NoPhase :: flatPhases.toList ::: new TerminalPhase :: Nil ).toArray
152
+ setSpecificPhases()
152
153
var phasesAfter : Set [Class [_ <: Phase ]] = Set .empty
153
154
nextDenotTransformerId = new Array [Int ](phases.length)
154
155
denotTransformers = new Array [DenotTransformer ](phases.length)
@@ -211,54 +212,53 @@ object Phases {
211
212
config.println(s " nextDenotTransformerId = ${nextDenotTransformerId.deep}" )
212
213
}
213
214
214
- def phaseOfClass (pclass : Class [_]) = phases.find(pclass.isInstance).getOrElse(NoPhase )
215
-
216
- private val cachedPhases = collection.mutable.Set [PhaseCache ]()
217
- private def cleanPhaseCache = cachedPhases.foreach(_.myPhase = NoPhase )
218
-
219
- /** A cache to compute the phase with given name, which
220
- * stores the phase as soon as phaseNamed returns something
221
- * different from NoPhase.
222
- */
223
- private class PhaseCache (pclass : Class [_ <: Phase ]) {
224
- var myPhase : Phase = NoPhase
225
- def phase = {
226
- if (myPhase eq NoPhase ) myPhase = phaseOfClass(pclass)
227
- myPhase
228
- }
229
- cachedPhases += this
215
+ private [this ] var myTyperPhase : Phase = _
216
+ private [this ] var myPicklerPhase : Phase = _
217
+ private [this ] var myRefChecksPhase : Phase = _
218
+ private [this ] var myPatmatPhase : Phase = _
219
+ private [this ] var myElimRepeatedPhase : Phase = _
220
+ private [this ] var myExtensionMethodsPhase : Phase = _
221
+ private [this ] var myExplicitOuterPhase : Phase = _
222
+ private [this ] var myGettersPhase : Phase = _
223
+ private [this ] var myErasurePhase : Phase = _
224
+ private [this ] var myElimErasedValueTypePhase : Phase = _
225
+ private [this ] var myLambdaLiftPhase : Phase = _
226
+ private [this ] var myFlattenPhase : Phase = _
227
+ private [this ] var myGenBCodePhase : Phase = _
228
+
229
+ final def typerPhase = myTyperPhase
230
+ final def picklerPhase = myPicklerPhase
231
+ final def refchecksPhase = myRefChecksPhase
232
+ final def patmatPhase = myPatmatPhase
233
+ final def elimRepeatedPhase = myElimRepeatedPhase
234
+ final def extensionMethodsPhase = myExtensionMethodsPhase
235
+ final def explicitOuterPhase = myExplicitOuterPhase
236
+ final def gettersPhase = myGettersPhase
237
+ final def erasurePhase = myErasurePhase
238
+ final def elimErasedValueTypePhase = myElimErasedValueTypePhase
239
+ final def lambdaLiftPhase = myLambdaLiftPhase
240
+ final def flattenPhase = myFlattenPhase
241
+ final def genBCodePhase = myGenBCodePhase
242
+
243
+ private def setSpecificPhases () = {
244
+ def phaseOfClass (pclass : Class [_]) = phases.find(pclass.isInstance).getOrElse(NoPhase )
245
+
246
+ myTyperPhase = phaseOfClass(classOf [FrontEnd ])
247
+ myPicklerPhase = phaseOfClass(classOf [Pickler ])
248
+ myRefChecksPhase = phaseOfClass(classOf [RefChecks ])
249
+ myElimRepeatedPhase = phaseOfClass(classOf [ElimRepeated ])
250
+ myExtensionMethodsPhase = phaseOfClass(classOf [ExtensionMethods ])
251
+ myErasurePhase = phaseOfClass(classOf [Erasure ])
252
+ myElimErasedValueTypePhase = phaseOfClass(classOf [ElimErasedValueType ])
253
+ myPatmatPhase = phaseOfClass(classOf [PatternMatcher ])
254
+ myLambdaLiftPhase = phaseOfClass(classOf [LambdaLift ])
255
+ myFlattenPhase = phaseOfClass(classOf [Flatten ])
256
+ myExplicitOuterPhase = phaseOfClass(classOf [ExplicitOuter ])
257
+ myGettersPhase = phaseOfClass(classOf [Getters ])
258
+ myGenBCodePhase = phaseOfClass(classOf [GenBCode ])
230
259
}
231
260
232
- private val typerCache = new PhaseCache (classOf [FrontEnd ])
233
- private val picklerCache = new PhaseCache (classOf [Pickler ])
234
-
235
- private val refChecksCache = new PhaseCache (classOf [RefChecks ])
236
- private val elimRepeatedCache = new PhaseCache (classOf [ElimRepeated ])
237
- private val extensionMethodsCache = new PhaseCache (classOf [ExtensionMethods ])
238
- private val erasureCache = new PhaseCache (classOf [Erasure ])
239
- private val elimErasedValueTypeCache = new PhaseCache (classOf [ElimErasedValueType ])
240
- private val patmatCache = new PhaseCache (classOf [PatternMatcher ])
241
- private val lambdaLiftCache = new PhaseCache (classOf [LambdaLift ])
242
- private val flattenCache = new PhaseCache (classOf [Flatten ])
243
- private val explicitOuterCache = new PhaseCache (classOf [ExplicitOuter ])
244
- private val gettersCache = new PhaseCache (classOf [Getters ])
245
- private val genBCodeCache = new PhaseCache (classOf [GenBCode ])
246
-
247
- def typerPhase = typerCache.phase
248
- def picklerPhase = picklerCache.phase
249
- def refchecksPhase = refChecksCache.phase
250
- def elimRepeatedPhase = elimRepeatedCache.phase
251
- def extensionMethodsPhase = extensionMethodsCache.phase
252
- def erasurePhase = erasureCache.phase
253
- def elimErasedValueTypePhase = elimErasedValueTypeCache.phase
254
- def patmatPhase = patmatCache.phase
255
- def lambdaLiftPhase = lambdaLiftCache.phase
256
- def flattenPhase = flattenCache.phase
257
- def explicitOuterPhase = explicitOuterCache.phase
258
- def gettersPhase = gettersCache.phase
259
- def genBCodePhase = genBCodeCache.phase
260
-
261
- def isAfterTyper (phase : Phase ): Boolean = phase.id > typerPhase.id
261
+ final def isAfterTyper (phase : Phase ): Boolean = phase.id > typerPhase.id
262
262
}
263
263
264
264
trait Phase extends DotClass {
0 commit comments