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/core/pickling/DottyUnpickler.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/core/pickling/DottyUnpickler.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/pickling/DottyUnpickler.scala | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/pickling/DottyUnpickler.scala b/src/dotty/tools/dotc/core/pickling/DottyUnpickler.scala index 6e7bd9210..2d8f571ec 100644 --- a/src/dotty/tools/dotc/core/pickling/DottyUnpickler.scala +++ b/src/dotty/tools/dotc/core/pickling/DottyUnpickler.scala @@ -7,6 +7,7 @@ import Contexts._, SymDenotations._ import dotty.tools.dotc.ast.tpd import TastyUnpickler._, TastyBuffer._ import util.Positions._ +import util.{SourceFile, NoSource} import PositionUnpickler._ object DottyUnpickler { @@ -30,14 +31,20 @@ class DottyUnpickler(bytes: Array[Byte]) extends ClassfileParser.Embedded { def enter(roots: Set[SymDenotation])(implicit ctx: Context): Unit = treeUnpickler.enterTopLevel(roots) - /** The unpickled trees + /** The unpickled trees, and the source file they come from * @param readPositions if true, trees get decorated with position information. */ - def body(readPositions: Boolean = false)(implicit ctx: Context): List[Tree] = { + def body(readPositions: Boolean = false)(implicit ctx: Context): (List[Tree], SourceFile) = { + val source = unpickler.unpickle(new SourceFileUnpickler).getOrElse(NoSource) if (readPositions) - for ((totalRange, positions) <- unpickler.unpickle(new PositionsSectionUnpickler())) + for ((totalRange, positions) <- unpickler.unpickle(new PositionsSectionUnpickler)) treeUnpickler.usePositions(totalRange, positions) - treeUnpickler.unpickle() + (treeUnpickler.unpickle(), source) + } + + private class SourceFileUnpickler extends SectionUnpickler[SourceFile]("Sourcefile") { + def unpickle(reader: TastyReader, tastyName: TastyName.Table) = + new SourceFile(tastyName(reader.readNameRef()).toString, Seq()) } private class TreeSectionUnpickler extends SectionUnpickler[TreeUnpickler]("ASTs") { |