-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The `Attributes` section contains a list of UTF-8 string that represent the attributes.
- Loading branch information
1 parent
982c91b
commit 9481cf9
Showing
8 changed files
with
99 additions
and
12 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
compiler/src/dotty/tools/dotc/core/tasty/AttributePickler.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package dotty.tools.dotc.core.tasty | ||
|
||
import dotty.tools.dotc.ast.{tpd, untpd} | ||
|
||
import dotty.tools.tasty.TastyBuffer | ||
import dotty.tools.tasty.TastyFormat.AttributesSection | ||
|
||
import java.nio.charset.StandardCharsets | ||
|
||
object AttributePickler: | ||
|
||
def pickleAttributes( | ||
attributes: List[String], | ||
pickler: TastyPickler, | ||
buf: TastyBuffer): Unit = | ||
if attributes != Nil then | ||
pickler.newSection(AttributesSection, buf) | ||
for attribute <- attributes do | ||
val bytes = attribute.getBytes(StandardCharsets.UTF_8).nn | ||
val length = bytes.length | ||
buf.writeNat(length) | ||
buf.writeBytes(bytes, length) | ||
end pickleAttributes | ||
|
||
end AttributePickler |
26 changes: 26 additions & 0 deletions
26
compiler/src/dotty/tools/dotc/core/tasty/AttributeUnpickler.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package dotty.tools.dotc | ||
package core.tasty | ||
|
||
import scala.language.unsafeNulls | ||
|
||
import dotty.tools.tasty.{TastyReader, TastyBuffer} | ||
|
||
import java.nio.charset.StandardCharsets | ||
|
||
class AttributeUnpickler(reader: TastyReader): | ||
import reader._ | ||
|
||
private[tasty] lazy val attributes: List[String] = { | ||
val attributesBuilder = List.newBuilder[String] | ||
while (!isAtEnd) { | ||
val length = readNat() | ||
if (length > 0) { | ||
val bytes = readBytes(length) | ||
val attribute = new String(bytes, StandardCharsets.UTF_8) | ||
attributesBuilder += attribute | ||
} | ||
} | ||
attributesBuilder.result() | ||
} | ||
|
||
end AttributeUnpickler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters