forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor TASTy Attributes (scala#19091)
We generalize the internal encoding of `Attributes` to be a list of tags. Then we add add helper methods to have simpler ways to interact with this abstraction using booleans. This implies that the pickling/unpickling can be agnostic of the semantics of each tag. Therefore reducing the number of places that need to be updated when we add a new tag. Useful for scala#19074, scala#19033, and scala#18948.
- Loading branch information
Showing
14 changed files
with
134 additions
and
62 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,32 @@ | ||
package dotty.tools.dotc.core.tasty | ||
|
||
import dotty.tools.tasty.TastyFormat | ||
|
||
class Attributes( | ||
val scala2StandardLibrary: Boolean, | ||
val explicitNulls: Boolean, | ||
) | ||
val booleanTags: List[Int], | ||
val stringTagValues: List[(Int, String)], | ||
) { | ||
def scala2StandardLibrary: Boolean = | ||
booleanTags.contains(TastyFormat.SCALA2STANDARDLIBRARYattr) | ||
def explicitNulls: Boolean = | ||
booleanTags.contains(TastyFormat.EXPLICITNULLSattr) | ||
def sourceFile: Option[String] = | ||
stringTagValues.find(_._1 == TastyFormat.SOURCEFILEattr).map(_._2) | ||
} | ||
|
||
object Attributes: | ||
def apply( | ||
sourceFile: String, | ||
scala2StandardLibrary: Boolean, | ||
explicitNulls: Boolean, | ||
): Attributes = | ||
val booleanTags = List.newBuilder[Int] | ||
if scala2StandardLibrary then booleanTags += TastyFormat.SCALA2STANDARDLIBRARYattr | ||
if explicitNulls then booleanTags += TastyFormat.EXPLICITNULLSattr | ||
|
||
val stringTagValues = List( | ||
(TastyFormat.SOURCEFILEattr, sourceFile) | ||
) | ||
|
||
new Attributes(booleanTags.result(), stringTagValues) | ||
end apply |
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
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
Oops, something went wrong.