File tree Expand file tree Collapse file tree 3 files changed +17
-10
lines changed
compiler/src/dotty/tools/dotc/core/tasty
tasty/src/dotty/tools/tasty Expand file tree Collapse file tree 3 files changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -10,15 +10,18 @@ import java.nio.charset.StandardCharsets
10
10
class AttributeUnpickler(reader: TastyReader):
11
11
import reader._
12
12
13
- lazy val attributes = {
13
+ lazy val attributeTags: List[Int] =
14
+ val listBuilder = List.newBuilder[Int]
15
+ while !isAtEnd do listBuilder += readNat()
16
+ listBuilder.result()
17
+
18
+ lazy val attributes: Attributes = {
14
19
var scala2StandardLibrary = false
15
- while (!isAtEnd) {
16
- readNat() match
17
- case TastyFormat.SCALA2STANDARDLIBRARYattr =>
18
- scala2StandardLibrary = true
20
+ for attributeTag <- attributeTags do
21
+ attributeTag match
22
+ case TastyFormat.SCALA2STANDARDLIBRARYattr => scala2StandardLibrary = true
19
23
case attribute =>
20
24
assert(false, "Unexpected attribute value: " + attribute)
21
- }
22
25
Attributes(
23
26
scala2StandardLibrary,
24
27
)
Original file line number Diff line number Diff line change @@ -225,15 +225,15 @@ class TastyPrinter(bytes: Array[Byte]) {
225
225
}
226
226
227
227
class AttributesSectionUnpickler extends SectionUnpickler[String](AttributesSection) {
228
-
228
+ import dotty.tools.tasty.TastyFormat.attributeTagToString
229
229
private val sb: StringBuilder = new StringBuilder
230
230
231
231
def unpickle(reader: TastyReader, tastyName: NameTable): String = {
232
232
sb.append(s" ${reader.endAddr.index - reader.currentAddr.index}")
233
- val attributes = new AttributeUnpickler(reader).attributes
233
+ val attributeTags = new AttributeUnpickler(reader).attributeTags
234
234
sb.append(s" attributes bytes:\n")
235
- if attributes.scala2StandardLibrary then
236
- sb.append(" SCALA2STANDARDLIBRARYattr \n")
235
+ for attributeTag <- attributeTags do
236
+ sb.append(" ").append(attributeTagToString(attributeTag)).append(" \n")
237
237
sb.result
238
238
}
239
239
}
Original file line number Diff line number Diff line change @@ -824,6 +824,10 @@ object TastyFormat {
824
824
case HOLE => "HOLE"
825
825
}
826
826
827
+ def attributeTagToString(tag: Int): String = tag match {
828
+ case SCALA2STANDARDLIBRARYattr => "SCALA2STANDARDLIBRARYattr"
829
+ }
830
+
827
831
/** @return If non-negative, the number of leading references (represented as nats) of a length/trees entry.
828
832
* If negative, minus the number of leading non-reference trees.
829
833
*/
You can’t perform that action at this time.
0 commit comments