Skip to content

Commit e47483a

Browse files
committed
Address reviewer comments on #416
1 parent 5597014 commit e47483a

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

src/dotty/tools/dotc/CompilationUnit.scala

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,25 @@ class CompilationUnit(val source: SourceFile) {
1717
var tpdTree: tpd.Tree = tpd.EmptyTree
1818

1919
def isJava = source.file.name.endsWith(".java")
20-
21-
lazy val pickled: TastyPickler = new TastyPickler()
2220

21+
/**
22+
* Pickler used to create TASTY sections.
23+
* Sections: Header, ASTs and Positions are populated by `pickler` phase.
24+
* Subsequent phases can add new sections.
25+
*/
26+
lazy val pickler: TastyPickler = new TastyPickler()
27+
28+
/**
29+
* Addresses in TASTY file of trees, stored by pickling.
30+
* Note that trees are checked for reference equality,
31+
* so one can reliably use this function only dirrectly after `pickler`
32+
*/
2333
var addrOfTree: tpd.Tree => Option[Addr] = (_ => None)
2434

35+
/**
36+
* Addresses in TASTY file of symbols, stored by pickling.
37+
* Note that trees are checked for reference equality,
38+
* so one can reliably use this function only dirrectly after `pickler`
39+
*/
2540
var addrOfSym: Symbol => Option[Addr] = (_ => None)
2641
}

src/dotty/tools/dotc/core/pickling/TreePickler.scala

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -535,12 +535,8 @@ class TreePickler(pickler: TastyPickler) {
535535
withLength { pickleType(ann.symbol.typeRef); pickleTree(ann.tree) }
536536
}
537537

538-
def updateMapWithDeltas[T](mp: collection.mutable.Map[T, Addr]) = {
539-
mp.map{
540-
case (key, addr) => (key, adjusted(addr))
541-
}.foreach(mp += _)
542-
}
543-
538+
def updateMapWithDeltas[T](mp: collection.mutable.Map[T, Addr]) =
539+
for (key <- mp.keysIterator.toBuffer[T]) mp(key) = adjusted(mp(key))
544540

545541
trees.foreach(tree => if (!tree.isEmpty) pickleTree(tree))
546542
assert(forwardSymRefs.isEmpty, i"unresolved symbols: ${forwardSymRefs.keySet.toList}%, %")

src/dotty/tools/dotc/transform/Pickler.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Pickler extends Phase {
3232
pickling.println(i"unpickling in run ${ctx.runId}")
3333
if (ctx.settings.YtestPickler.value) beforePickling(unit) = tree.show
3434

35-
val pickler = unit.pickled
35+
val pickler = unit.pickler
3636
val treePkl = new TreePickler(pickler)
3737
treePkl.pickle(tree :: Nil)
3838
unit.addrOfTree = treePkl.buf.addrOfTree
@@ -41,7 +41,7 @@ class Pickler extends Phase {
4141
new PositionPickler(pickler, treePkl.buf.addrOfTree).picklePositions(tree :: Nil, tree.pos)
4242

4343
def rawBytes = // not needed right now, but useful to print raw format.
44-
unit.pickled.assembleParts().iterator.grouped(10).toList.zipWithIndex.map {
44+
unit.pickler.assembleParts().iterator.grouped(10).toList.zipWithIndex.map {
4545
case (row, i) => s"${i}0: ${row.mkString(" ")}"
4646
}
4747
// println(i"rawBytes = \n$rawBytes%\n%") // DEBUG
@@ -61,7 +61,7 @@ class Pickler extends Phase {
6161
ctx.definitions.init
6262
val unpicklers =
6363
for (unit <- units) yield {
64-
val unpickler = new DottyUnpickler(unit.pickled.assembleParts())
64+
val unpickler = new DottyUnpickler(unit.pickler.assembleParts())
6565
unpickler.enter(roots = Set())
6666
unpickler
6767
}

0 commit comments

Comments
 (0)