aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/SymTransformers.scala
blob: ec2e4d3578dfb6f7f418645e5bd075af5c26203b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package dotty.tools.dotc.core

import Periods._, Denotations._, Contexts._
import java.lang.AssertionError

trait DenotationTransformers { self: RootContext =>

  import DenotationTransformers._

  def lastPhaseId: PhaseId

  private val nxTransformer =
    Array.fill[DenotationTransformer](lastPhaseId + 1)(NoTransformer)

  object NoTransformer extends DenotationTransformer {
    val phaseId = lastPhaseId + 1
    def transform(enot: Denotation): Denotation =
      throw new AssertionError("NoTransformer.transform")
  }

  def install(pid: PhaseId, trans: DenotationTransformer): Unit = {
    if ((pid > NoPhaseId) && (nxTransformer(pid).phaseId > pid)) {
      nxTransformer(pid) = trans
      install(pid - 1, trans)
    }
  }

  def nextTransformer(i: Int) = nxTransformer(i)
}

object DenotationTransformers {

  abstract class DenotationTransformer {
    val phaseId: PhaseId
    def transform(denot: Denotation): Denotation
  }


}