diff options
author | Martin Odersky <odersky@gmail.com> | 2016-04-09 11:16:10 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-04-09 11:16:10 +0200 |
commit | 5aa59ac17e6f48719f8b52048e0b86570e9399e3 (patch) | |
tree | 2c15394b99d4abb7e6adb71b63a0a8335c72d76a /src/dotty/tools/dotc/core/tasty | |
parent | f9d27c9f63ed1852b372757aadc517ec02cb17ff (diff) | |
download | dotty-5aa59ac17e6f48719f8b52048e0b86570e9399e3.tar.gz dotty-5aa59ac17e6f48719f8b52048e0b86570e9399e3.tar.bz2 dotty-5aa59ac17e6f48719f8b52048e0b86570e9399e3.zip |
Simplify handling of sourcefiles in Tasty info
Instead of separate source file sections, pickle SourceFile as an
annotation of all toplevel classes.
We represent it like this anyway when reading back Tasty-defined classes.
Diffstat (limited to 'src/dotty/tools/dotc/core/tasty')
-rw-r--r-- | src/dotty/tools/dotc/core/tasty/DottyUnpickler.scala | 19 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/tasty/TastyFormat.scala | 2 |
2 files changed, 4 insertions, 17 deletions
diff --git a/src/dotty/tools/dotc/core/tasty/DottyUnpickler.scala b/src/dotty/tools/dotc/core/tasty/DottyUnpickler.scala index afbf8ae07..0ad5d6966 100644 --- a/src/dotty/tools/dotc/core/tasty/DottyUnpickler.scala +++ b/src/dotty/tools/dotc/core/tasty/DottyUnpickler.scala @@ -6,7 +6,6 @@ package tasty import Contexts._, SymDenotations._, Symbols._ import dotty.tools.dotc.ast.tpd import TastyUnpickler._, TastyBuffer._ -import dotty.tools.dotc.core.tasty.DottyUnpickler.{SourceFileUnpickler, TreeSectionUnpickler, PositionsSectionUnpickler} import util.Positions._ import util.{SourceFile, NoSource} import PositionUnpickler._ @@ -18,13 +17,6 @@ object DottyUnpickler { /** Exception thrown if classfile is corrupted */ class BadSignature(msg: String) extends RuntimeException(msg) - class SourceFileUnpickler extends SectionUnpickler[SourceFile]("Sourcefile") { - def unpickle(reader: TastyReader, tastyName: TastyName.Table) = { - val TastyName.Simple(sourceName) = tastyName(reader.readNameRef()) - new SourceFile(sourceName.toString, Seq()) - } - } - class TreeSectionUnpickler extends SectionUnpickler[TreeUnpickler]("ASTs") { def unpickle(reader: TastyReader, tastyName: TastyName.Table) = new TreeUnpickler(reader, tastyName) @@ -41,27 +33,24 @@ object DottyUnpickler { */ class DottyUnpickler(bytes: Array[Byte]) extends ClassfileParser.Embedded { import tpd._ + import DottyUnpickler._ val unpickler = new TastyUnpickler(bytes) private val treeUnpickler = unpickler.unpickle(new TreeSectionUnpickler).get - private val source = unpickler.unpickle(new SourceFileUnpickler).getOrElse(NoSource) /** Enter all toplevel classes and objects into their scopes * @param roots a set of SymDenotations that should be overwritten by unpickling */ - def enter(roots: Set[SymDenotation])(implicit ctx: Context): Unit = { + def enter(roots: Set[SymDenotation])(implicit ctx: Context): Unit = treeUnpickler.enterTopLevel(roots) - if (source.exists) - for (root <- roots) root.addAnnotation(Annotation.makeSourceFile(source.path)) - } /** 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], SourceFile) = { + def body(readPositions: Boolean = false)(implicit ctx: Context): List[Tree] = { if (readPositions) for ((totalRange, positions) <- unpickler.unpickle(new PositionsSectionUnpickler)) treeUnpickler.usePositions(totalRange, positions) - (treeUnpickler.unpickle(), source) + treeUnpickler.unpickle() } } diff --git a/src/dotty/tools/dotc/core/tasty/TastyFormat.scala b/src/dotty/tools/dotc/core/tasty/TastyFormat.scala index a9f2e753f..ea7e985c9 100644 --- a/src/dotty/tools/dotc/core/tasty/TastyFormat.scala +++ b/src/dotty/tools/dotc/core/tasty/TastyFormat.scala @@ -184,8 +184,6 @@ Note: Tree tags are grouped into 5 categories that determine what follows, and t Category 4 (tags 112-127): tag Nat AST Category 5 (tags 128-255): tag Length <payload> -Standard Section: "Sourcefile" sourcefile_NameRef - Standard Section: "Positions" sourceLength_Nat Assoc* Assoc = addr_Delta offset_Delta offset_Delta? |