aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Contexts.scala
blob: 873bbf3779d8eaf68142659357affbfad52008de (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package dotty.tools.dotc
package core

import Decorators._
import Periods._
import Names._
import Phases._
import Types._
import SubTypers._

object Contexts {

  val NoContext: Context = null

  abstract class Context extends Periods {
    val underlying: Context
    val root: RootContext
    val period: Period
    def constraints: Constraints
    def subTyper: SubTyper
    def names: NameTable
    def phase: Phase = ???
    def stableInterval: Interval = ???
    def erasedTypes: Boolean = ???
  }

  abstract class SubContext(val underlying: Context) extends Context {
    val root: RootContext = underlying.root
    val period: Period = underlying.period
    val constraints = underlying.constraints
    def names: NameTable = root.names
    lazy val subTyper =
      if (constraints eq underlying.constraints) underlying.subTyper
      else new SubTyper(this)
  }

  class RootContext extends Context
                       with Symbols
                       with Denotations
                       with DenotationTransformers
                       with Types {

    val underlying: Context = throw new UnsupportedOperationException("RootContext.underlying")
    def subTyper: SubTyper = ???

    val root: RootContext = this
    val period = periodOf(NoRunId, NoPhaseId)
    val names: NameTable = new NameTable
    val variance = 1

    var lastPhaseId: Int = NoPhaseId
    lazy val definitions = new Definitions()(this)

    val constraints: Constraints = Map()
  }

  private final val initialUniquesCapacity = 4096
}