Skip to content

Use relative paths in position pickler #7518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/core/Contexts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ object Contexts {
}

/** Sourcefile with given path name, memoized */
def getSource(path: SourceFile.PathName): SourceFile = base.sourceNamed.get(path) match {
def getSource(path: TermName): SourceFile = base.sourceNamed.get(path) match {
case Some(source) =>
source
case None =>
Expand Down Expand Up @@ -685,7 +685,7 @@ object Contexts {

/** Sources that were loaded */
val sources: mutable.HashMap[AbstractFile, SourceFile] = new mutable.HashMap[AbstractFile, SourceFile]
val sourceNamed: mutable.HashMap[SourceFile.PathName, SourceFile] = new mutable.HashMap[SourceFile.PathName, SourceFile]
val sourceNamed: mutable.HashMap[TermName, SourceFile] = new mutable.HashMap[TermName, SourceFile]

// Types state
/** A table for hash consing unique types */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class PositionPickler(pickler: TastyPickler, addrOfTree: untpd.Tree => Addr) {

def pickleSource(source: SourceFile): Unit = {
buf.writeInt(SOURCE)
buf.writeInt(pickler.nameBuffer.nameIndex(source.pathName).index)
buf.writeInt(pickler.nameBuffer.nameIndex(source.path.toTermName).index)
}

/** True if x's position shouldn't be reconstructed automatically from its initial span
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/transform/Pickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class Pickler extends Phase {
pickled.iterator.grouped(10).toList.zipWithIndex.map {
case (row, i) => s"${i}0: ${row.mkString(" ")}"
}

// println(i"rawBytes = \n$rawBytes%\n%") // DEBUG
if (pickling ne noPrinter) {
println(i"**** pickled info of $cls")
Expand Down
6 changes: 0 additions & 6 deletions compiler/src/dotty/tools/dotc/util/SourceFile.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ import java.io.IOException
import scala.internal.Chars._
import Spans._
import scala.io.Codec
import core.Names.TermName
import core.Contexts.Context
import scala.annotation.internal.sharable
import core.Decorators.PreNamedString
import java.util.concurrent.atomic.AtomicInteger
import scala.collection.mutable

Expand Down Expand Up @@ -59,8 +57,6 @@ class SourceFile(val file: AbstractFile, computeContent: => Array[Char]) extends
override def path: String = file.path
override def jfile: Optional[JFile] = Optional.ofNullable(file.file)

def pathName: PathName = file.absolutePath.toTermName

override def equals(that: Any): Boolean =
(this `eq` that.asInstanceOf[AnyRef]) || {
that match {
Expand Down Expand Up @@ -202,8 +198,6 @@ object SourceFile {

implicit def fromContext(implicit ctx: Context): SourceFile = ctx.source

type PathName = TermName

def fromId(id: Int): SourceFile = sourceOfChunk(id >> ChunkSizeLog)

def virtual(name: String, content: String) = new SourceFile(new VirtualFile(name, content.getBytes), scala.io.Codec.UTF8)
Expand Down