aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/pickling/TastyBuffer.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-02-10 12:39:15 +0100
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-03-18 11:09:43 +0100
commit1c5f3b75f7e70e8608d6be442087857bd4a6b2cc (patch)
tree26a197f56bfbd0a0ffa819cf68a730abd88a6260 /src/dotty/tools/dotc/core/pickling/TastyBuffer.scala
parent41922c14bf1a45a3dcf7afca7719e0be84c2c29a (diff)
downloaddotty-1c5f3b75f7e70e8608d6be442087857bd4a6b2cc.tar.gz
dotty-1c5f3b75f7e70e8608d6be442087857bd4a6b2cc.tar.bz2
dotty-1c5f3b75f7e70e8608d6be442087857bd4a6b2cc.zip
Add TASTY readers and printers for TASTy info.
So far printing is the only reader, ie. deserializer. Numerous bugfixes to make first tests work.
Diffstat (limited to 'src/dotty/tools/dotc/core/pickling/TastyBuffer.scala')
-rw-r--r--src/dotty/tools/dotc/core/pickling/TastyBuffer.scala20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/dotty/tools/dotc/core/pickling/TastyBuffer.scala b/src/dotty/tools/dotc/core/pickling/TastyBuffer.scala
index f6a7a17b4..0e44dbd76 100644
--- a/src/dotty/tools/dotc/core/pickling/TastyBuffer.scala
+++ b/src/dotty/tools/dotc/core/pickling/TastyBuffer.scala
@@ -12,9 +12,9 @@ object TastyBuffer {
if (nat < 128) 1 else natSize(nat >>> 7) + 1
/** An address pointing to an index in a Tasty buffer's byte array */
- class Addr(val index: Int) extends AnyVal {
- def -(delta: Int): Addr = new Addr(this.index - delta)
- def +(delta: Int): Addr = new Addr(this.index + delta)
+ case class Addr(val index: Int) extends AnyVal {
+ def -(delta: Int): Addr = Addr(this.index - delta)
+ def +(delta: Int): Addr = Addr(this.index + delta)
def relativeTo(base: Addr): Addr = this - base.index - AddrWidth
}
@@ -49,7 +49,7 @@ class TastyBuffer(initialSize: Int) {
/** Write the first `n` bytes of `data`. */
def writeBytes(data: Array[Byte], n: Int): Unit = {
- while (bytes.length < length + data.length) bytes = dble(bytes)
+ while (bytes.length < length + n) bytes = dble(bytes)
Array.copy(data, 0, bytes, length, n)
length += n
}
@@ -71,11 +71,11 @@ class TastyBuffer(initialSize: Int) {
def writeNatPrefix(x: Long): Unit = {
val y = x >>> 7
if (y != 0L) writeNatPrefix(y)
- writeByte(((x & 0x7f) | 0x80).toInt)
+ writeByte((x & 0x7f).toInt)
}
val y = x >>> 7
if (y != 0L) writeNatPrefix(y)
- writeByte((x & 0x7f).toInt)
+ writeByte(((x & 0x7f) | 0x80).toInt)
}
/** Write the `nbytes` least significant bytes of `x` in big endian format */
@@ -119,14 +119,14 @@ class TastyBuffer(initialSize: Int) {
var idx = at.index
do {
b = bytes(idx)
- x = (x << 7) + (b & 0x7f)
+ x = (x << 7) | (b & 0x7f)
idx += 1
- } while ((b & 0x80) != 0L)
+ } while ((b & 0x80) == 0)
x
}
/** The address (represented as a natural number) at address `at` */
- def getAddr(at: Addr) = new Addr(getNat(at))
+ def getAddr(at: Addr) = Addr(getNat(at))
/** The smallest address equal to or following `at` which points to a non-zero byte */
final def skipZeroes(at: Addr): Addr =
@@ -139,7 +139,7 @@ class TastyBuffer(initialSize: Int) {
}
/** The address referring to the end of data written so far */
- def currentAddr: Addr = new Addr(length)
+ def currentAddr: Addr = Addr(length)
/** Reserve `AddrWidth` bytes to write an address into */
def reserveAddr(): Addr = {