aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/pickling/TastyUnpickler.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty/tools/dotc/core/pickling/TastyUnpickler.scala')
-rw-r--r--src/dotty/tools/dotc/core/pickling/TastyUnpickler.scala32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/dotty/tools/dotc/core/pickling/TastyUnpickler.scala b/src/dotty/tools/dotc/core/pickling/TastyUnpickler.scala
index b5e978afa..5fbb85768 100644
--- a/src/dotty/tools/dotc/core/pickling/TastyUnpickler.scala
+++ b/src/dotty/tools/dotc/core/pickling/TastyUnpickler.scala
@@ -7,9 +7,9 @@ import PickleFormat._
import Names.{Name, termName}
import java.util.UUID
-object TastyUnpickler {
+object TastyUnpickler {
class UnpickleException(msg: String) extends Exception(msg)
-
+
abstract class SectionUnpickler[R](val name: String) {
def unpickle(reader: TastyReader, tastyName: TastyName.Table): R
}
@@ -19,28 +19,28 @@ import TastyUnpickler._
class TastyUnpickler(reader: TastyReader) {
import reader._
-
+
def this(bytes: Array[Byte]) = this(new TastyReader(bytes))
-
+
private val sectionReader = new mutable.HashMap[String, TastyReader]
val tastyName = new TastyName.Table
-
- def check(cond: Boolean, msg: => String) =
+
+ def check(cond: Boolean, msg: => String) =
if (!cond) throw new UnpickleException(msg)
-
+
def readString(): String = {
val TastyName.Simple(name) = tastyName(readNameRef())
name.toString
}
-
+
def readName(): TastyName = {
import TastyName._
- val tag = readByte()
+ val tag = readByte()
val length = readNat()
val start = currentAddr
val end = start + length
val result = tag match {
- case UTF8 =>
+ case UTF8 =>
goto(end)
Simple(termName(bytes, start.index, length))
case QUALIFIED =>
@@ -64,21 +64,21 @@ class TastyUnpickler(reader: TastyReader) {
assert(currentAddr == end, s"bad name $result $start $currentAddr $end")
result
}
-
+
private def readHeader(): UUID = {
for (i <- 0 until header.length)
check(readByte() == header(i), "not a TASTy file")
val major = readNat()
val minor = readNat()
- check(major == MajorVersion && minor <= MinorVersion,
+ check(major == MajorVersion && minor <= MinorVersion,
s"""TASTy signature has wrong version.
| expected: $MajorVersion.$MinorVersion
| found : $major.$minor""".stripMargin)
new UUID(readUncompressedLong(), readUncompressedLong())
}
-
+
val uuid = readHeader()
-
+
locally {
until(readEnd()) { tastyName.add(readName()) }
while (!isAtEnd) {
@@ -88,8 +88,8 @@ class TastyUnpickler(reader: TastyReader) {
goto(secEnd)
}
}
-
- def unpickle[R](sec: SectionUnpickler[R]): Option[R] =
+
+ def unpickle[R](sec: SectionUnpickler[R]): Option[R] =
for (reader <- sectionReader.get(sec.name)) yield
sec.unpickle(reader, tastyName)
}