File tree Expand file tree Collapse file tree 4 files changed +9
-9
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 4 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ class ScalaSettings extends Settings.SettingGroup {
4747 val fromTasty = BooleanSetting (" -from-tasty" , " Compile classes from tasty in classpath. The arguments are used as class names." )
4848
4949 /** Decompiler settings */
50- val printTasty = BooleanSetting (" -print-tasty" , " Prints the raw tasty when decompiling ." )
50+ val printTasty = BooleanSetting (" -print-tasty" , " Prints the raw tasty." )
5151 val printLines = BooleanSetting (" -print-lines" , " Show source code line numbers." )
5252
5353 /** Plugin-related setting */
Original file line number Diff line number Diff line change @@ -39,14 +39,12 @@ class DecompilationPrinter extends Phase {
3939 val pageWidth = ctx.settings.pageWidth.value
4040 val printLines = ctx.settings.printLines.value
4141
42- out.println(s " /** Decompiled from $unit */ " )
43- val printer = new DecompilerPrinter (ctx)
44- out.println(printer.toText(unit.tpdTree).mkString(pageWidth, printLines))
45-
4642 if (ctx.settings.printTasty.value) {
47- out.println(" /*" )
4843 new TastyPrinter (unit.pickled.head._2).printContents()
49- out.println(" */" )
44+ } else {
45+ out.println(s " /** Decompiled from $unit */ " )
46+ val printer = new DecompilerPrinter (ctx)
47+ out.println(printer.toText(unit.tpdTree).mkString(pageWidth, printLines))
5048 }
5149 }
5250}
Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ case "$1" in
8585 -repl) PROG_NAME=" $ReplMain " && shift ;;
8686 -compile) PROG_NAME=" $CompilerMain " && shift ;;
8787 -decompile) PROG_NAME=" $DecompilerMain " && shift ;;
88+ -print-tasty) PROG_NAME=" $DecompilerMain " && shift ;;
8889 -run) PROG_NAME=" $ReplMain " && shift ;;
8990 -bootcp) bootcp=true && shift ;;
9091 -nobootcp) unset bootcp && shift ;;
Original file line number Diff line number Diff line change @@ -658,18 +658,19 @@ object Build {
658658 val dottyCompiler = jars(" dotty-compiler" )
659659 val args0 : List [String ] = spaceDelimited(" <arg>" ).parsed.toList
660660 val decompile = args0.contains(" -decompile" )
661+ val printTasty = args0.contains(" -print-tasty" )
661662 val debugFromTasty = args0.contains(" -Ythrough-tasty" )
662663 val args = args0.filter(arg => arg != " -repl" && arg != " -decompile" &&
663664 arg != " -with-compiler" && arg != " -Ythrough-tasty" )
664665
665666 val main =
666667 if (repl) " dotty.tools.repl.Main"
667- else if (decompile) " dotty.tools.dotc.decompiler.Main"
668+ else if (decompile || printTasty ) " dotty.tools.dotc.decompiler.Main"
668669 else if (debugFromTasty) " dotty.tools.dotc.fromtasty.Debug"
669670 else " dotty.tools.dotc.Main"
670671
671672 var extraClasspath = dottyLib
672- if (decompile && ! args.contains(" -classpath" )) extraClasspath += " :."
673+ if (( decompile || printTasty) && ! args.contains(" -classpath" )) extraClasspath += " :."
673674 if (args0.contains(" -with-compiler" )) extraClasspath += s " : $dottyCompiler"
674675
675676 val fullArgs = main :: insertClasspathInArgs(args, extraClasspath)
You can’t perform that action at this time.
0 commit comments