Skip to content

Commit 4ebaa73

Browse files
committed
Add Attributes data class
1 parent e8a39f0 commit 4ebaa73

File tree

7 files changed

+20
-13
lines changed

7 files changed

+20
-13
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ import java.nio.charset.StandardCharsets
1010
object AttributePickler:
1111

1212
def pickleAttributes(
13-
scala2StandardLibrary: Boolean,
13+
attributes: Attributes,
1414
pickler: TastyPickler,
1515
buf: TastyBuffer
1616
): Unit =
17-
if scala2StandardLibrary then // or any other attribute is set
17+
if attributes.scala2StandardLibrary then // or any other attribute is set
1818
pickler.newSection(AttributesSection, buf)
1919
// Pickle attributes
20-
if scala2StandardLibrary then buf.writeNat(TastyFormat.SCALA2STANDARDLIBRARYattr)
20+
if attributes.scala2StandardLibrary then buf.writeNat(TastyFormat.SCALA2STANDARDLIBRARYattr)
2121

2222
end pickleAttributes
2323

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import java.nio.charset.StandardCharsets
1010
class AttributeUnpickler(reader: TastyReader):
1111
import reader._
1212

13-
lazy val scala2StandardLibrary = {
13+
lazy val attributes = {
1414
var scala2StandardLibrary = false
1515
while (!isAtEnd) {
1616
readNat() match
@@ -19,7 +19,9 @@ class AttributeUnpickler(reader: TastyReader):
1919
case attribute =>
2020
assert(false, "Unexpected attribute value: " + attribute)
2121
}
22-
scala2StandardLibrary
22+
Attributes(
23+
scala2StandardLibrary,
24+
)
2325
}
2426

2527
end AttributeUnpickler
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package dotty.tools.dotc.core.tasty
2+
3+
class Attributes(
4+
val scala2StandardLibrary: Boolean,
5+
)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class ScratchData:
1010
val pickledIndices = new mutable.BitSet
1111

1212
val commentBuffer = new TastyBuffer(5000)
13-
val attributeBuffer = new TastyBuffer(128)
13+
val attributeBuffer = new TastyBuffer(32)
1414

1515
def reset() =
1616
assert(delta ne delta1)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,9 @@ class TastyPrinter(bytes: Array[Byte]) {
230230

231231
def unpickle(reader: TastyReader, tastyName: NameTable): String = {
232232
sb.append(s" ${reader.endAddr.index - reader.currentAddr.index}")
233-
val attributeUnpickler = new AttributeUnpickler(reader)
233+
val attributes = new AttributeUnpickler(reader).attributes
234234
sb.append(s" attributes bytes:\n")
235-
if attributeUnpickler.scala2StandardLibrary then
235+
if attributes.scala2StandardLibrary then
236236
sb.append(" SCALA2STANDARDLIBRARYattr\n")
237237
sb.result
238238
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class TreeUnpickler(reader: TastyReader,
100100
private var withCaptureChecks: Boolean = false
101101

102102
private val unpicklingScala2Library =
103-
attributeUnpicklerOpt.exists(_.scala2StandardLibrary)
103+
attributeUnpicklerOpt.exists(_.attributes.scala2StandardLibrary)
104104

105105
private def registerSym(addr: Addr, sym: Symbol) =
106106
symAtAddr(addr) = sym

compiler/src/dotty/tools/dotc/transform/Pickler.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ class Pickler extends Phase {
108108
pickler, treePkl.buf.addrOfTree, treePkl.docString, tree,
109109
scratch.commentBuffer)
110110

111-
AttributePickler.pickleAttributes(
112-
ctx.settings.YcompileScala2Library.value,
113-
pickler,
114-
scratch.attributeBuffer)
111+
val attributes = Attributes(
112+
scala2StandardLibrary = ctx.settings.YcompileScala2Library.value,
113+
)
114+
AttributePickler.pickleAttributes(attributes, pickler, scratch.attributeBuffer)
115115

116116
val pickled = pickler.assembleParts()
117117

0 commit comments

Comments
 (0)