File tree Expand file tree Collapse file tree 3 files changed +9
-1
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 3 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ class ScalaSettings extends Settings.SettingGroup {
4343 val rewrite = OptionSetting [Rewrites ](" -rewrite" , " When used in conjunction with -language:Scala2 rewrites sources to migrate to new syntax" )
4444 val silentWarnings = BooleanSetting (" -nowarn" , " Silence all warnings." )
4545 val fromTasty = BooleanSetting (" -from-tasty" , " Compile classes from tasty in classpath. The arguments are used as class names." )
46+ val printTasty = BooleanSetting (" -print-tasty" , " Prints the raw tasty when decompiling." )
4647
4748 /** -X "Advanced" settings
4849 */
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ class TastyPrinter(bytes: Array[Byte])(implicit ctx: Context) {
2929 def printContents (): Unit = {
3030 println(" Names:" )
3131 printNames()
32+ println()
3233 println(" Trees:" )
3334 unpickle(new TreeSectionUnpickler )
3435 unpickle(new PositionSectionUnpickler )
@@ -111,7 +112,7 @@ class TastyPrinter(bytes: Array[Byte])(implicit ctx: Context) {
111112 val positions = new PositionUnpickler (reader).positions
112113 println(s " position bytes: " )
113114 val sorted = positions.toSeq.sortBy(_._1.index)
114- for ((addr, pos) <- sorted) println(s " ${addr.index}: ${offsetToInt(pos.start)} .. ${pos.end}" )
115+ for ((addr, pos) <- sorted) println(s " ${addr.index}: ${offsetToInt(pos.start)} .. ${pos.end}" )
115116 }
116117 }
117118}
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package decompiler
33
44import dotty .tools .dotc .core .Contexts ._
55import dotty .tools .dotc .core .Phases .Phase
6+ import dotty .tools .dotc .core .tasty .TastyPrinter
67
78/** Phase that prints the trees in all loaded compilation units.
89 *
@@ -26,5 +27,10 @@ class DecompilationPrinter extends Phase {
2627
2728 println(unit.tpdTree.show)
2829 println(line)
30+
31+ if (ctx.settings.printTasty.value) {
32+ new TastyPrinter (unit.pickled.head._2).printContents()
33+ println(line)
34+ }
2935 }
3036}
You can’t perform that action at this time.
0 commit comments