@@ -12,13 +12,14 @@ import dotty.tools.dotc.transform.TreeTransforms.{TreeTransformer, TreeTransform
12
12
import dotty .tools .dotc .transform .PostTyperTransformers .PostTyperTransformer
13
13
import dotty .tools .dotc .transform .TreeTransforms
14
14
import TreeTransforms .Separator
15
+ import Periods ._
15
16
16
17
trait Phases {
17
18
self : Context =>
18
19
19
20
import Phases ._
20
21
21
- def phase : Phase = base.phases(period.phaseId )
22
+ def phase : Phase = base.phases(period.firstPhaseId )
22
23
23
24
def phasesStack : List [Phase ] =
24
25
if ((this eq NoContext ) || ! phase.exists) Nil
@@ -66,6 +67,7 @@ object Phases {
66
67
override def lastPhaseId (implicit ctx : Context ) = id
67
68
}
68
69
70
+
69
71
/** Use the following phases in the order they are given.
70
72
* The list should never contain NoPhase.
71
73
* if squashing is enabled, phases in same subgroup will be squashed to single phase.
@@ -112,7 +114,7 @@ object Phases {
112
114
override protected def transformations : Array [TreeTransform ] = transforms.toArray
113
115
}
114
116
squashedPhases += block
115
- block.init(this , phasess(i).head.id)
117
+ block.init(this , phasess(i).head.id, phasess(i).last.id )
116
118
} else squashedPhases += phasess(i).head
117
119
i += 1
118
120
}
@@ -171,7 +173,7 @@ object Phases {
171
173
172
174
def exists : Boolean = true
173
175
174
- private var myId : PhaseId = - 1
176
+ private var myPeriod : Period = Periods . InvalidPeriod
175
177
private var myBase : ContextBase = null
176
178
private var myErasedTypes = false
177
179
private var myFlatClasses = false
@@ -181,32 +183,38 @@ object Phases {
181
183
* is reserved for NoPhase and the first real phase is at position 1.
182
184
* -1 if the phase is not installed in the context.
183
185
*/
184
- def id = myId
186
+ def id = myPeriod.firstPhaseId
187
+
188
+ def period = myPeriod
189
+ def start = myPeriod.firstPhaseId
190
+ def end = myPeriod.lastPhaseId
185
191
186
192
final def erasedTypes = myErasedTypes
187
193
final def flatClasses = myFlatClasses
188
194
final def refChecked = myRefChecked
189
195
190
- protected [Phases ] def init (base : ContextBase , id : Int ): Unit = {
191
- if (id >= FirstPhaseId )
192
- assert(myId == - 1 , s " phase $this has already been used once; cannot be reused " )
196
+ protected [Phases ] def init (base : ContextBase , start : Int , end : Int ): Unit = {
197
+ if (start >= FirstPhaseId )
198
+ assert(myPeriod == Periods . InvalidPeriod , s " phase $this has already been used once; cannot be reused " )
193
199
myBase = base
194
- myId = id
200
+ myPeriod = Period (start, end)
195
201
myErasedTypes = prev.name == erasureName || prev.erasedTypes
196
202
myFlatClasses = prev.name == flattenName || prev.flatClasses
197
203
myRefChecked = prev.name == refChecksName || prev.refChecked
198
204
}
199
205
206
+ protected [Phases ] def init (base : ContextBase , id : Int ): Unit = init(base, id, id)
207
+
200
208
final def <= (that : Phase )(implicit ctx : Context ) =
201
209
exists && id <= that.id
202
210
203
211
final def prev : Phase =
204
- if (id > FirstPhaseId ) myBase.phases(id - 1 ) else myBase.NoPhase
212
+ if (id > FirstPhaseId ) myBase.phases(start - 1 ) else myBase.NoPhase
205
213
206
214
final def next : Phase =
207
- if (hasNext) myBase.phases(id + 1 ) else myBase.NoPhase
215
+ if (hasNext) myBase.phases(end + 1 ) else myBase.NoPhase
208
216
209
- final def hasNext = id >= FirstPhaseId && id + 1 < myBase.phases.length
217
+ final def hasNext = start >= FirstPhaseId && end + 1 < myBase.phases.length
210
218
211
219
final def iterator =
212
220
Iterator .iterate(this )(_.next) takeWhile (_.hasNext)
0 commit comments