Skip to content

Commit fbad1dc

Browse files
committed
Export pickler and pickled addresses so that other phases can pickle their info
1 parent c413eec commit fbad1dc

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/dotty/tools/dotc/CompilationUnit.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package dotty.tools
22
package dotc
33

4+
import dotty.tools.dotc.core.pickling.{TastyBuffer, TastyPickler}
45
import util.SourceFile
56
import ast.{tpd, untpd}
7+
import TastyBuffer._
68

79
class CompilationUnit(val source: SourceFile) {
810

@@ -14,5 +16,7 @@ class CompilationUnit(val source: SourceFile) {
1416

1517
def isJava = source.file.name.endsWith(".java")
1618

17-
var pickled: Array[Byte] = Array()
19+
lazy val pickled: TastyPickler = new TastyPickler()
20+
21+
var addrOfTree: tpd.Tree => Option[Addr] = (_ => None)
1822
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ 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 = new TastyPickler
35+
val pickler = unit.pickled
3636
val treePkl = new TreePickler(pickler)
3737
treePkl.pickle(tree :: Nil)
38+
unit.addrOfTree = treePkl.buf.addrOfTree
3839
if (tree.pos.exists)
3940
new PositionPickler(pickler, treePkl.buf.addrOfTree).picklePositions(tree :: Nil, tree.pos)
4041

41-
unit.pickled = pickler.assembleParts()
4242
def rawBytes = // not needed right now, but useful to print raw format.
43-
unit.pickled.iterator.grouped(10).toList.zipWithIndex.map {
43+
unit.pickled.assembleParts().iterator.grouped(10).toList.zipWithIndex.map {
4444
case (row, i) => s"${i}0: ${row.mkString(" ")}"
4545
}
4646
// println(i"rawBytes = \n$rawBytes%\n%") // DEBUG
47-
if (pickling ne noPrinter) new TastyPrinter(unit.pickled).printContents()
47+
if (pickling ne noPrinter) new TastyPrinter(pickler.assembleParts()).printContents()
4848
}
4949
}
5050

@@ -60,7 +60,7 @@ class Pickler extends Phase {
6060
ctx.definitions.init
6161
val unpicklers =
6262
for (unit <- units) yield {
63-
val unpickler = new DottyUnpickler(unit.pickled)
63+
val unpickler = new DottyUnpickler(unit.pickled.assembleParts())
6464
unpickler.enter(roots = Set())
6565
unpickler
6666
}

0 commit comments

Comments
 (0)