File tree 3 files changed +9
-1
lines changed
compiler/src/dotty/tools/dotc
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 {
43
43
val rewrite = OptionSetting [Rewrites ](" -rewrite" , " When used in conjunction with -language:Scala2 rewrites sources to migrate to new syntax" )
44
44
val silentWarnings = BooleanSetting (" -nowarn" , " Silence all warnings." )
45
45
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." )
46
47
47
48
/** -X "Advanced" settings
48
49
*/
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ class TastyPrinter(bytes: Array[Byte])(implicit ctx: Context) {
29
29
def printContents (): Unit = {
30
30
println(" Names:" )
31
31
printNames()
32
+ println()
32
33
println(" Trees:" )
33
34
unpickle(new TreeSectionUnpickler )
34
35
unpickle(new PositionSectionUnpickler )
@@ -111,7 +112,7 @@ class TastyPrinter(bytes: Array[Byte])(implicit ctx: Context) {
111
112
val positions = new PositionUnpickler (reader).positions
112
113
println(s " position bytes: " )
113
114
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}" )
115
116
}
116
117
}
117
118
}
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package decompiler
3
3
4
4
import dotty .tools .dotc .core .Contexts ._
5
5
import dotty .tools .dotc .core .Phases .Phase
6
+ import dotty .tools .dotc .core .tasty .TastyPrinter
6
7
7
8
/** Phase that prints the trees in all loaded compilation units.
8
9
*
@@ -26,5 +27,10 @@ class DecompilationPrinter extends Phase {
26
27
27
28
println(unit.tpdTree.show)
28
29
println(line)
30
+
31
+ if (ctx.settings.printTasty.value) {
32
+ new TastyPrinter (unit.pickled.head._2).printContents()
33
+ println(line)
34
+ }
29
35
}
30
36
}
You can’t perform that action at this time.
0 commit comments