diff options
author | Martin Odersky <odersky@gmail.com> | 2015-04-28 10:23:03 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-04-28 12:07:29 +0200 |
commit | 014ad9bc44ae8abaac5ec40c8993f09fa289eff3 (patch) | |
tree | 9a74de3bfd62e2447b302fda51e3803e9a2ce8e1 /src/dotty/tools/dotc/transform/Pickler.scala | |
parent | 512689c11348144023e7b55298cc5d9be3203eb0 (diff) | |
download | dotty-014ad9bc44ae8abaac5ec40c8993f09fa289eff3.tar.gz dotty-014ad9bc44ae8abaac5ec40c8993f09fa289eff3.tar.bz2 dotty-014ad9bc44ae8abaac5ec40c8993f09fa289eff3.zip |
Maintain source files in pickled info
So far: Only one source file is recorded. Should evaluate
whether more are needed. Will programs composed from several
source files be pickled? They will certainly be generated after
inlining, but maybe all that happens after pickling?
Diffstat (limited to 'src/dotty/tools/dotc/transform/Pickler.scala')
-rw-r--r-- | src/dotty/tools/dotc/transform/Pickler.scala | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/transform/Pickler.scala b/src/dotty/tools/dotc/transform/Pickler.scala index c09ba6889..d30c876bd 100644 --- a/src/dotty/tools/dotc/transform/Pickler.scala +++ b/src/dotty/tools/dotc/transform/Pickler.scala @@ -11,6 +11,7 @@ import Periods._ import Phases._ import Symbols._ import Flags.Module +import util.SourceFile import collection.mutable /** This phase pickles trees */ @@ -47,6 +48,8 @@ class Pickler extends Phase { treePkl.pickle(tree :: Nil) unit.addrOfTree = treePkl.buf.addrOfTree unit.addrOfSym = treePkl.addrOfSym + if (unit.source.exists) + pickleSourcefile(pickler, unit.source) if (tree.pos.exists) new PositionPickler(pickler, treePkl.buf.addrOfTree).picklePositions(tree :: Nil, tree.pos) @@ -62,6 +65,12 @@ class Pickler extends Phase { } } + private def pickleSourcefile(pickler: TastyPickler, source: SourceFile): Unit = { + val buf = new TastyBuffer(10) + pickler.newSection("Sourcefile", buf) + buf.writeNat(pickler.nameBuffer.nameIndex(source.file.path).index) + } + override def runOn(units: List[CompilationUnit])(implicit ctx: Context): List[CompilationUnit] = { val result = super.runOn(units) if (ctx.settings.YtestPickler.value) @@ -80,16 +89,16 @@ class Pickler extends Phase { } pickling.println("************* entered toplevel ***********") for ((cls, unpickler) <- unpicklers) { - val unpickled = unpickler.body(readPositions = false) - testSame(i"$unpickled%\n%", beforePickling(cls), cls) + val (unpickled, source) = unpickler.body(readPositions = false) + testSame(i"$unpickled%\n%", beforePickling(cls), cls, source) } } - private def testSame(unpickled: String, previous: String, cls: ClassSymbol)(implicit ctx: Context) = + private def testSame(unpickled: String, previous: String, cls: ClassSymbol, source: SourceFile)(implicit ctx: Context) = if (previous != unpickled) { output("before-pickling.txt", previous) output("after-pickling.txt", unpickled) - ctx.error(s"""pickling difference for ${cls.fullName}, for details: + ctx.error(s"""pickling difference for ${cls.fullName} in $source, for details: | | diff before-pickling.txt after-pickling.txt""".stripMargin) } |