@@ -31,6 +31,7 @@ import config.{Settings, ScalaSettings, Platform, JavaPlatform}
31
31
import language .implicitConversions
32
32
import DenotTransformers .DenotTransformer
33
33
import util .Property .Key
34
+ import util .Store
34
35
import xsbti .AnalysisCallback
35
36
36
37
object Contexts {
@@ -157,13 +158,6 @@ object Contexts {
157
158
protected def runInfo_= (runInfo : RunInfo ) = _runInfo = runInfo
158
159
def runInfo : RunInfo = _runInfo
159
160
160
- /** An optional diagostics buffer than is used by some checking code
161
- * to provide more information in the buffer if it exists.
162
- */
163
- private [this ] var _diagnostics : Option [StringBuilder ] = _
164
- protected def diagnostics_= (diagnostics : Option [StringBuilder ]) = _diagnostics = diagnostics
165
- def diagnostics : Option [StringBuilder ] = _diagnostics
166
-
167
161
/** The current bounds in force for type parameters appearing in a GADT */
168
162
private [this ] var _gadt : GADTMap = _
169
163
protected def gadt_= (gadt : GADTMap ) = _gadt = gadt
@@ -174,6 +168,11 @@ object Contexts {
174
168
protected def freshNames_= (freshNames : FreshNameCreator ) = _freshNames = freshNames
175
169
def freshNames : FreshNameCreator = _freshNames
176
170
171
+ /** A store that can be used by sub-components */
172
+ private var _store : Store = _
173
+ protected def store_= (store : Store ) = _store = store
174
+ def store : Store = _store
175
+
177
176
/** A map in which more contextual properties can be stored */
178
177
private [this ] var _moreProperties : Map [Key [Any ], Any ] = _
179
178
protected def moreProperties_= (moreProperties : Map [Key [Any ], Any ]) = _moreProperties = moreProperties
@@ -300,13 +299,6 @@ object Contexts {
300
299
def isNonEmptyScopeContext : Boolean =
301
300
(this .scope ne outer.scope) && ! this .scope.isEmpty
302
301
303
- /** Leave message in diagnostics buffer if it exists */
304
- def diagnose (str : => String ) =
305
- for (sb <- diagnostics) {
306
- sb.setLength(0 )
307
- sb.append(str)
308
- }
309
-
310
302
/** The next outer context whose tree is a template or package definition
311
303
* Note: Currently unused
312
304
def enclTemplate: Context = {
@@ -406,7 +398,6 @@ object Contexts {
406
398
.withSettings(sstate)
407
399
// tree is not preserved in condensed
408
400
.withRunInfo(runInfo)
409
- .withDiagnostics(diagnostics)
410
401
.withMoreProperties(moreProperties)
411
402
_condensed
412
403
}
@@ -474,12 +465,12 @@ object Contexts {
474
465
def setImportInfo (importInfo : ImportInfo ): this .type = { this .importInfo = importInfo; this }
475
466
def setImplicits (implicits : ContextualImplicits ): this .type = { this .implicitsCache = implicits; this }
476
467
def setRunInfo (runInfo : RunInfo ): this .type = { this .runInfo = runInfo; this }
477
- def setDiagnostics (diagnostics : Option [StringBuilder ]): this .type = { this .diagnostics = diagnostics; this }
478
468
def setGadt (gadt : GADTMap ): this .type = { this .gadt = gadt; this }
479
469
def setFreshGADTBounds : this .type = setGadt(new GADTMap (gadt.bounds))
480
470
def setTypeComparerFn (tcfn : Context => TypeComparer ): this .type = { this .typeComparer = tcfn(this ); this }
481
471
def setSearchHistory (searchHistory : SearchHistory ): this .type = { this .searchHistory = searchHistory; this }
482
472
def setFreshNames (freshNames : FreshNameCreator ): this .type = { this .freshNames = freshNames; this }
473
+ def setStore (store : Store ): this .type = { this .store = store; this }
483
474
def setMoreProperties (moreProperties : Map [Key [Any ], Any ]): this .type = { this .moreProperties = moreProperties; this }
484
475
485
476
def setProperty [T ](key : Key [T ], value : T ): this .type =
@@ -488,13 +479,21 @@ object Contexts {
488
479
def dropProperty (key : Key [_]): this .type =
489
480
setMoreProperties(moreProperties - key)
490
481
482
+ def addLocation [T ](initial : T ): Store .Location [T ] = {
483
+ val (loc, store1) = store.newLocation(initial)
484
+ setStore(store1)
485
+ loc
486
+ }
487
+
488
+ def updateStore [T ](loc : Store .Location [T ], value : T ): this .type =
489
+ setStore(store.updated(loc, value))
490
+
491
491
def setPhase (pid : PhaseId ): this .type = setPeriod(Period (runId, pid))
492
492
def setPhase (phase : Phase ): this .type = setPeriod(Period (runId, phase.start, phase.end))
493
493
494
494
def setSetting [T ](setting : Setting [T ], value : T ): this .type =
495
495
setSettings(setting.updateIn(sstate, value))
496
496
497
-
498
497
def setDebug = setSetting(base.settings.debug, true )
499
498
}
500
499
@@ -527,9 +526,9 @@ object Contexts {
527
526
tree = untpd.EmptyTree
528
527
typeAssigner = TypeAssigner
529
528
runInfo = new RunInfo (this )
530
- diagnostics = None
531
529
freshNames = new FreshNameCreator .Default
532
530
moreProperties = Map .empty
531
+ store = Store .empty
533
532
typeComparer = new TypeComparer (this )
534
533
searchHistory = new SearchHistory (0 , Map ())
535
534
gadt = EmptyGADTMap
@@ -643,7 +642,7 @@ object Contexts {
643
642
private [core] var phasesPlan : List [List [Phase ]] = _
644
643
645
644
/** Phases by id */
646
- private [core ] var phases : Array [Phase ] = _
645
+ private [dotc ] var phases : Array [Phase ] = _
647
646
648
647
/** Phases with consecutive Transforms grouped into a single phase, Empty array if squashing is disabled */
649
648
private [core] var squashedPhases : Array [Phase ] = Array .empty[Phase ]
0 commit comments