Skip to content

Commit

Permalink
Add -Yprint-tasty compiler flag
Browse files Browse the repository at this point in the history
This flag provides a simple way to print the generated TASTy. Unlike
`Printers.pickling`, this can be used on a release version of the
compiler.
  • Loading branch information
nicolasstucki committed Jun 16, 2023
1 parent 916d4e7 commit d4a6ab6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ private sealed trait YSettings:
val YprintDebugOwners: Setting[Boolean] = BooleanSetting("-Yprint-debug-owners", "When printing trees, print owners of definitions.")
val YprintLevel: Setting[Boolean] = BooleanSetting("-Yprint-level", "print nesting levels of symbols and type variables.")
val YshowPrintErrors: Setting[Boolean] = BooleanSetting("-Yshow-print-errors", "Don't suppress exceptions thrown during tree printing.")
val YprintTasty: Setting[Boolean] = BooleanSetting("-Yprint-tasty", "Prints the generated TASTY to stdout.")
val YtestPickler: Setting[Boolean] = BooleanSetting("-Ytest-pickler", "Self-test for pickling functionality; should be used with -Ystop-after:pickler.")
val YcheckReentrant: Setting[Boolean] = BooleanSetting("-Ycheck-reentrant", "Check that compiled program does not contain vars that can be accessed from a global root.")
val YdropComments: Setting[Boolean] = BooleanSetting("-Ydrop-docs", "Drop documentation when scanning source files.", aliases = List("-Ydrop-comments"))
Expand Down
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/transform/Pickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@ class Pickler extends Phase {
}

// println(i"rawBytes = \n$rawBytes%\n%") // DEBUG
if pickling ne noPrinter then
if ctx.settings.YprintTasty.value || pickling != noPrinter then
println(i"**** pickled info of $cls")
println(TastyPrinter.showContents(pickled, ctx.settings.color.value == "never"))
println(i"**** end of pickled info of $cls")
pickled
}
}
Expand Down

0 comments on commit d4a6ab6

Please sign in to comment.