@@ -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,53 +212,52 @@ 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 var myTyperPhase : Phase = _
216
+ private var myPicklerPhase : Phase = _
217
+ private var myRefChecksPhase : Phase = _
218
+ private var myPatmatPhase : Phase = _
219
+ private var myElimRepeatedPhase : Phase = _
220
+ private var myExtensionMethodsPhase : Phase = _
221
+ private var myExplicitOuterPhase : Phase = _
222
+ private var myGettersPhase : Phase = _
223
+ private var myErasurePhase : Phase = _
224
+ private var myElimErasedValueTypePhase : Phase = _
225
+ private var myLambdaLiftPhase : Phase = _
226
+ private var myFlattenPhase : Phase = _
227
+ private var myGenBCodePhase : Phase = _
228
+
229
+ def typerPhase = myTyperPhase
230
+ def picklerPhase = myPicklerPhase
231
+ def refchecksPhase = myRefChecksPhase
232
+ def patmatPhase = myPatmatPhase
233
+ def elimRepeatedPhase = myElimRepeatedPhase
234
+ def extensionMethodsPhase = myExtensionMethodsPhase
235
+ def explicitOuterPhase = myExplicitOuterPhase
236
+ def gettersPhase = myGettersPhase
237
+ def erasurePhase = myErasurePhase
238
+ def elimErasedValueTypePhase = myElimErasedValueTypePhase
239
+ def lambdaLiftPhase = myLambdaLiftPhase
240
+ def flattenPhase = myFlattenPhase
241
+ 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
261
def isAfterTyper (phase : Phase ): Boolean = phase.id > typerPhase.id
262
262
}
263
263
0 commit comments