Skip to content

Commit

Permalink
Give attribute a semantic kind
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstucki committed Oct 25, 2023
1 parent 7026f2a commit d248207
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import dotty.tools.tasty.TastyBuffer
import dotty.tools.tasty.TastyFormat.AttributesSection

import java.nio.charset.StandardCharsets
import dotty.tools.tasty.TastyFormat

object AttributePickler:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class AttributeUnpickler(reader: TastyReader):
private[tasty] lazy val attributes: List[String] = {
val attributesBuilder = List.newBuilder[String]
while (!isAtEnd) {
val kind = readNat()
assert(kind == TastyFormat.FLAGattr, "Malformed attribute kind")
val length = readNat()
val bytes = readBytes(length)
val attribute = new String(bytes, StandardCharsets.UTF_8)
Expand Down
7 changes: 6 additions & 1 deletion tasty/src/dotty/tools/tasty/TastyFormat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ Standard Section: "Comments" Comment*
Standard Section: "Attributes" Attribute*
```none
Attribute = UTF8 // attributes match the regex [a-zA-Z0-9]+
Attribute = FLAGattr UTF8 // attributes match the regex [a-zA-Z0-9]+
```
**************************************************************************************/
Expand Down Expand Up @@ -606,6 +606,11 @@ object TastyFormat {
final val firstNatASTTreeTag = IDENT
final val firstLengthTreeTag = PACKAGE


// Attribute tags

final val FLAGattr = 1

/** Useful for debugging */
def isLegalTag(tag: Int): Boolean =
firstSimpleTreeTag <= tag && tag <= SPLITCLAUSE ||
Expand Down

0 comments on commit d248207

Please sign in to comment.