diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala index c34f6759d148..18254dad2a59 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -43,6 +43,7 @@ class ScalaSettings extends Settings.SettingGroup { val rewrite = OptionSetting[Rewrites]("-rewrite", "When used in conjunction with -language:Scala2 rewrites sources to migrate to new syntax") val silentWarnings = BooleanSetting("-nowarn", "Silence all warnings.") val fromTasty = BooleanSetting("-from-tasty", "Compile classes from tasty in classpath. The arguments are used as class names.") + val printTasty = BooleanSetting("-print-tasty", "Prints the raw tasty when decompiling.") /** -X "Advanced" settings */ diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TastyPrinter.scala b/compiler/src/dotty/tools/dotc/core/tasty/TastyPrinter.scala index a5c87088176c..e74e5166062f 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TastyPrinter.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TastyPrinter.scala @@ -29,6 +29,7 @@ class TastyPrinter(bytes: Array[Byte])(implicit ctx: Context) { def printContents(): Unit = { println("Names:") printNames() + println() println("Trees:") unpickle(new TreeSectionUnpickler) unpickle(new PositionSectionUnpickler) @@ -111,7 +112,7 @@ class TastyPrinter(bytes: Array[Byte])(implicit ctx: Context) { val positions = new PositionUnpickler(reader).positions println(s" position bytes:") val sorted = positions.toSeq.sortBy(_._1.index) - for ((addr, pos) <- sorted) println(s"${addr.index}: ${offsetToInt(pos.start)} .. ${pos.end}") + for ((addr, pos) <- sorted) println(s" ${addr.index}: ${offsetToInt(pos.start)} .. ${pos.end}") } } } diff --git a/compiler/src/dotty/tools/dotc/decompiler/DecompilationPrinter.scala b/compiler/src/dotty/tools/dotc/decompiler/DecompilationPrinter.scala index 9d38fa361730..b189b44133f5 100644 --- a/compiler/src/dotty/tools/dotc/decompiler/DecompilationPrinter.scala +++ b/compiler/src/dotty/tools/dotc/decompiler/DecompilationPrinter.scala @@ -3,6 +3,7 @@ package decompiler import dotty.tools.dotc.core.Contexts._ import dotty.tools.dotc.core.Phases.Phase +import dotty.tools.dotc.core.tasty.TastyPrinter /** Phase that prints the trees in all loaded compilation units. * @@ -26,5 +27,10 @@ class DecompilationPrinter extends Phase { println(unit.tpdTree.show) println(line) + + if (ctx.settings.printTasty.value) { + new TastyPrinter(unit.pickled.head._2).printContents() + println(line) + } } }