Skip to content

Commit 5bd83ae

Browse files
committed
Rename in/out to last/current
1 parent fe3930d commit 5bd83ae

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

compiler/src/dotty/tools/dotc/transform/init/Semantic.scala

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -275,51 +275,51 @@ object Semantic {
275275
opaque type CacheStore = mutable.Map[Value, EqHashMap[Tree, Value]]
276276

277277
class Cache {
278-
private val in: CacheStore = mutable.Map.empty
279-
private var out: CacheStore = mutable.Map.empty
278+
private val last: CacheStore = mutable.Map.empty
279+
private var current: CacheStore = mutable.Map.empty
280280
private val stable: CacheStore = mutable.Map.empty
281281
private var changed: Boolean = false
282282

283283
def hasChanged = changed
284284

285285
def contains(value: Value, expr: Tree) =
286-
out.contains(value, expr) || stable.contains(value, expr)
286+
current.contains(value, expr) || stable.contains(value, expr)
287287

288288
def apply(value: Value, expr: Tree) =
289-
if out.contains(value, expr) then out(value)(expr)
289+
if current.contains(value, expr) then current(value)(expr)
290290
else stable(value)(expr)
291291

292-
def assume(value: Value, expr: Tree)(fun: => Result): Result =
292+
def assume(value: Value, expr: Tree, cacheResult: Boolean)(fun: => Result): Result =
293293
val assumeValue =
294-
if in.contains(value, expr) then
295-
in.get(value, expr)
294+
if last.contains(value, expr) then
295+
last.get(value, expr)
296296
else
297-
in.put(value, expr, Hot)
297+
last.put(value, expr, Hot)
298298
Hot
299-
out.put(value, expr, assumeValue)
299+
current.put(value, expr, assumeValue)
300300

301301
val actual = fun
302302
if actual.value != assumeValue then
303303
this.changed = true
304-
in.put(value, expr, actual.value)
305-
out.put(value, expr, actual.value)
304+
last.put(value, expr, actual.value)
305+
current.put(value, expr, actual.value)
306306

307307
actual
308308

309309
def remove(value: Value, expr: Tree) =
310-
out.remove(value, expr)
310+
current.remove(value, expr)
311311

312312
/** Prepare cache for the next iteration
313313
*
314-
* - Commit out cache to stable cache if unchanged.
314+
* - Commit current cache to stable cache if unchanged.
315315
* - Reset changed flag
316-
* - Reset out cache
316+
* - Reset current cache (last cache already synced in `assume`)
317317
*
318-
* Precondition: the out cache reaches fixed point.
318+
* Precondition: the current cache reaches fixed point.
319319
*/
320320
def iterate() = {
321321
if !changed then
322-
out.foreach { (v, m) =>
322+
current.foreach { (v, m) =>
323323
m.iterator.foreach { (e, res) =>
324324
stable.put(v, e, res)
325325
}
@@ -328,7 +328,7 @@ object Semantic {
328328

329329
changed = false
330330

331-
out = mutable.Map.empty
331+
current = mutable.Map.empty
332332
}
333333
}
334334

@@ -834,7 +834,7 @@ object Semantic {
834834
res.errors.foreach(_.issue)
835835

836836
if cache.hasChanged && res.errors.isEmpty then
837-
// discard heap changes and copy cache.out to cache.in
837+
// discard heap changes
838838
heap.restore(heapBefore)
839839
else
840840
pendingTasks = rest
@@ -911,7 +911,7 @@ object Semantic {
911911
*/
912912
def eval(expr: Tree, thisV: Ref, klass: ClassSymbol, cacheResult: Boolean = false): Contextual[Result] = log("evaluating " + expr.show + ", this = " + thisV.show, printer, (_: Result).show) {
913913
if (cache.contains(thisV, expr)) Result(cache(thisV, expr), Errors.empty)
914-
else cache.assume(thisV, expr) { cases(expr, thisV, klass) }
914+
else cache.assume(thisV, expr, cacheResult) { cases(expr, thisV, klass) }
915915
}
916916

917917
/** Evaluate a list of expressions */

0 commit comments

Comments
 (0)