Skip to content

Commit 9e2dd75

Browse files
committed
Move addrOfTree, addOfSym from CompilationUnit to Pickler.
These only exist if there was a pickler, and they are not unique per CompilationUnit.
1 parent a347632 commit 9e2dd75

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

src/dotty/tools/dotc/CompilationUnit.scala

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,4 @@ class CompilationUnit(val source: SourceFile) {
2424
* Subsequent phases can add new sections.
2525
*/
2626
var picklers: Map[ClassSymbol, TastyPickler] = Map()
27-
28-
/** TODO: I'd prefer we do not put this in CompilationUnit
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 directly after `pickler`
32-
*/
33-
var addrOfTree: tpd.Tree => Option[Addr] = (_ => None)
34-
35-
/** TODO: I'd prefer we do not put this in CompilationUnit
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-
*/
40-
var addrOfSym: Symbol => Option[Addr] = (_ => None)
4127
}

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import PickleFormat._
77
import collection.mutable
88
import TastyBuffer._
99
import java.util.UUID
10+
import core.Symbols.Symbol
11+
import ast.tpd
1012

1113
class TastyPickler {
1214

@@ -51,4 +53,18 @@ class TastyPickler {
5153
assert(all.length == totalSize && all.bytes.length == totalSize, s"totalSize = $totalSize, all.length = ${all.length}, all.bytes.length = ${all.bytes.length}")
5254
all.bytes
5355
}
56+
57+
/**
58+
* Addresses in TASTY file of trees, stored by pickling.
59+
* Note that trees are checked for reference equality,
60+
* so one can reliably use this function only directly after `pickler`
61+
*/
62+
var addrOfTree: tpd.Tree => Option[Addr] = (_ => None)
63+
64+
/**
65+
* Addresses in TASTY file of symbols, stored by pickling.
66+
* Note that trees are checked for reference equality,
67+
* so one can reliably use this function only dirrectly after `pickler`
68+
*/
69+
var addrOfSym: Symbol => Option[Addr] = (_ => None)
5470
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ class Pickler extends Phase {
4646
unit.picklers += (cls -> pickler)
4747
val treePkl = new TreePickler(pickler)
4848
treePkl.pickle(tree :: Nil)
49-
unit.addrOfTree = treePkl.buf.addrOfTree
50-
unit.addrOfSym = treePkl.addrOfSym
49+
pickler.addrOfTree = treePkl.buf.addrOfTree
50+
pickler.addrOfSym = treePkl.addrOfSym
5151
if (unit.source.exists)
5252
pickleSourcefile(pickler, unit.source)
5353
if (tree.pos.exists)

0 commit comments

Comments
 (0)