aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Contexts.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-01-10 12:23:23 +0100
committerMartin Odersky <odersky@gmail.com>2013-01-10 12:23:23 +0100
commitf703cd3b404a8a996b8ad100b4a43acb5cdd73a8 (patch)
tree81c35a9d3b90e8c1fa4e57f4f9d8638f47f4a98d /src/dotty/tools/dotc/core/Contexts.scala
parent15927bbb22e4c7d3f4ce45deca282081297a8c41 (diff)
downloaddotty-f703cd3b404a8a996b8ad100b4a43acb5cdd73a8.tar.gz
dotty-f703cd3b404a8a996b8ad100b4a43acb5cdd73a8.tar.bz2
dotty-f703cd3b404a8a996b8ad100b4a43acb5cdd73a8.zip
Refactored Types to move auxiliary operations into Context. Moved per-run state into RootContext.
Diffstat (limited to 'src/dotty/tools/dotc/core/Contexts.scala')
-rw-r--r--src/dotty/tools/dotc/core/Contexts.scala47
1 files changed, 41 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/core/Contexts.scala b/src/dotty/tools/dotc/core/Contexts.scala
index 873bbf377..06f828131 100644
--- a/src/dotty/tools/dotc/core/Contexts.scala
+++ b/src/dotty/tools/dotc/core/Contexts.scala
@@ -6,13 +6,17 @@ 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 {
+ abstract class Context extends Periods with Substituters with TypeOps {
+ implicit val ctx: Context = this
val underlying: Context
val root: RootContext
val period: Period
@@ -35,10 +39,7 @@ object Contexts {
}
class RootContext extends Context
- with Symbols
- with Denotations
- with DenotationTransformers
- with Types {
+ with DenotationTransformers {
val underlying: Context = throw new UnsupportedOperationException("RootContext.underlying")
def subTyper: SubTyper = ???
@@ -52,7 +53,41 @@ object Contexts {
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 }
+
+ // Denotations 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]
}
- private final val initialUniquesCapacity = 4096
+ /** 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
} \ No newline at end of file