Skip to content

Commit 43c0784

Browse files
committed
Populate addresses of symbols and types after pickler
To allow other phases to generate their info.
1 parent ccead6d commit 43c0784

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/dotty/tools/dotc/CompilationUnit.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package dotty.tools
22
package dotc
33

4+
import dotty.tools.dotc.core.Types.Type
45
import dotty.tools.dotc.core.pickling.{TastyBuffer, TastyPickler}
56
import util.SourceFile
67
import ast.{tpd, untpd}
78
import TastyBuffer._
9+
import dotty.tools.dotc.core.Symbols._
810

911
class CompilationUnit(val source: SourceFile) {
1012

@@ -19,4 +21,8 @@ class CompilationUnit(val source: SourceFile) {
1921
lazy val pickled: TastyPickler = new TastyPickler()
2022

2123
var addrOfTree: tpd.Tree => Option[Addr] = (_ => None)
24+
25+
var addrOfSym: Symbol => Option[Addr] = (_ => None)
26+
27+
var addrOfType: Type => Option[Addr] = (_ => None)
2228
}

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,22 @@ class TreePickler(pickler: TastyPickler) {
1919

2020
private val symRefs = new mutable.HashMap[Symbol, Addr]
2121
private val forwardSymRefs = new mutable.HashMap[Symbol, List[Addr]]
22-
private val pickledTypes = new java.util.IdentityHashMap[Type, Any] // Value type is really Addr, but that's not compatible with null
22+
private val pickledTypes = new mutable.HashMap[Type, Addr]
2323

2424
private def withLength(op: => Unit) = {
2525
val lengthAddr = reserveRef(relative = true)
2626
op
2727
fillRef(lengthAddr, currentAddr, relative = true)
2828
}
29-
29+
30+
def addrOfSym(sym: Symbol): Option[Addr] = {
31+
symRefs.get(sym)
32+
}
33+
34+
def addrOfType(tp: Type): Option[Addr] = {
35+
pickledTypes.get(tp)
36+
}
37+
3038
private var makeSymbolicRefsTo: Symbol = NoSymbol
3139

3240
/** All references to members of class `sym` are pickled

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ class Pickler extends Phase {
3636
val treePkl = new TreePickler(pickler)
3737
treePkl.pickle(tree :: Nil)
3838
unit.addrOfTree = treePkl.buf.addrOfTree
39+
unit.addrOfSym = treePkl.addrOfSym
40+
unit.addrOfType = treePkl.addrOfType
3941
if (tree.pos.exists)
4042
new PositionPickler(pickler, treePkl.buf.addrOfTree).picklePositions(tree :: Nil, tree.pos)
4143

0 commit comments

Comments
 (0)