Skip to content

Commit 361a680

Browse files
committed
Use Nats to pickle line sizes in TASTy
1 parent c7106ef commit 361a680

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

compiler/src/dotty/tools/dotc/core/tasty/PositionPickler.scala

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,18 @@ class PositionPickler(
3434

3535
def picklePositions(source: SourceFile, roots: List[Tree], warnings: mutable.ListBuffer[String]): Unit = {
3636
/** Pickle the number of lines followed by the length of each line */
37-
def pickleLineOffsetts(): Unit = {
37+
def pickleLineOffsets(): Unit = {
3838
val content = source.content()
39-
buf.writeInt(content.count(_ == '\n') + 1) // number of lines
39+
buf.writeNat(content.count(_ == '\n') + 1) // number of lines
4040
var lastIndex = content.indexOf('\n', 0)
41-
buf.writeInt(lastIndex) // size of first line
41+
buf.writeNat(lastIndex) // size of first line
4242
while lastIndex != -1 do
4343
val nextIndex = content.indexOf('\n', lastIndex + 1)
4444
val end = if nextIndex != -1 then nextIndex else content.length
45-
buf.writeInt(end - lastIndex - 1) // size of the next line
45+
buf.writeNat(end - lastIndex - 1) // size of the next line
4646
lastIndex = nextIndex
4747
}
48-
pickleLineOffsetts()
48+
pickleLineOffsets()
4949

5050
var lastIndex = 0
5151
var lastSpan = Span(0, 0)

compiler/src/dotty/tools/dotc/core/tasty/PositionUnpickler.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ class PositionUnpickler(reader: TastyReader, nameAtRef: NameRef => TermName) {
2222

2323
def ensureDefined(): Unit = {
2424
if (!isDefined) {
25-
val lines = readInt()
25+
val lines = readNat()
2626
myLineSizes = new Array[Int](lines)
2727
var i = 0
2828
while i < lines do
29-
myLineSizes(i) += readInt()
29+
myLineSizes(i) += readNat()
3030
i += 1
3131

3232
mySpans = util.HashMap[Addr, Span]()

tasty/src/dotty/tools/tasty/TastyFormat.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ Note: Tree tags are grouped into 5 categories that determine what follows, and t
230230
231231
Standard-Section: "Positions" LinesSizes Assoc*
232232
233-
LinesSizes = Int Int* // Number of lines followed by the size of each line not counting the trailing `\n`
233+
LinesSizes = Nat Nat* // Number of lines followed by the size of each line not counting the trailing `\n`
234234
235235
Assoc = Header offset_Delta? offset_Delta? point_Delta?
236236
| SOURCE nameref_Int

0 commit comments

Comments
 (0)