blob: 131f72c658878a2d11ea28e0d10a25b239363053 (
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
package dotty.tools.dotc
package core
import Decorators._
import Periods._
import Names._
import Phases._
import Types._
import Symbols._
import SubTypers._
import collection.mutable
import collection.immutable.BitSet
object Contexts {
val NoContext: Context = null
abstract class Context extends Periods with Substituters with TypeOps {
implicit val ctx: Context = this
val underlying: Context
val root: RootContext
val period: Period
def constraints: Constraints
def subTyper: SubTyper
def names: NameTable
def phase: Phase = ???
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 Transformers {
val underlying: Context = throw new UnsupportedOperationException("RootContext.underlying")
def subTyper: SubTyper = ???
val root: RootContext = this
val period = Nowhere
val names: NameTable = new NameTable
val variance = 1
var lastPhaseId: Int = NoPhaseId
lazy val definitions = new Definitions()(this)
val constraints: Constraints = Map()
// Symbols state
/** A map from a superclass id to the class that has it */
private[core] var classOfId = Array.ofDim[ClassSymbol](InitialSuperIdsSize)
/** A map from a superclass to its superclass id */
private[core] val superIdOfClass = new mutable.HashMap[ClassSymbol, Int]
/** The last allocate superclass id */
private[core] var lastSuperId = -1
/** Allocate and return next free superclass id */
private[core] def nextSuperId: Int = { lastSuperId += 1; lastSuperId }
// SymDenotations state
private[core] val uniqueBits = new util.HashSet[BitSet]("superbits", 1024)
// Types state
private[core] val uniques = new util.HashSet[Type]("uniques", initialUniquesCapacity) {
override def hash(x: Type): Int = x.hash
}
// TypeOps state
private[core] var volatileRecursions: Int = 0
private[core] val pendingVolatiles = new mutable.HashSet[Type]
}
/** Initial size of superId table */
private final val InitialSuperIdsSize = 4096
/** Initial capacity of uniques HashMap */
private[core] final val initialUniquesCapacity = 50000
/** How many recursive calls to isVolatile are performed before
* logging starts.
*/
private[core] final val LogVolatileThreshold = 50
}
|