Skip to content

Split -print-tasty from -decompile #4595

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ScalaSettings extends Settings.SettingGroup {
val fromTasty = BooleanSetting("-from-tasty", "Compile classes from tasty in classpath. The arguments are used as class names.")

/** Decompiler settings */
val printTasty = BooleanSetting("-print-tasty", "Prints the raw tasty when decompiling.")
val printTasty = BooleanSetting("-print-tasty", "Prints the raw tasty.")
val printLines = BooleanSetting("-print-lines", "Show source code line numbers.")

/** Plugin-related setting */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,12 @@ class DecompilationPrinter extends Phase {
val pageWidth = ctx.settings.pageWidth.value
val printLines = ctx.settings.printLines.value

out.println(s"/** Decompiled from $unit */")
val printer = new DecompilerPrinter(ctx)
out.println(printer.toText(unit.tpdTree).mkString(pageWidth, printLines))

if (ctx.settings.printTasty.value) {
out.println("/*")
new TastyPrinter(unit.pickled.head._2).printContents()
out.println("*/")
} else {
out.println(s"/** Decompiled from $unit */")
val printer = new DecompilerPrinter(ctx)
out.println(printer.toText(unit.tpdTree).mkString(pageWidth, printLines))
}
}
}
1 change: 1 addition & 0 deletions dist/bin/dotc
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ case "$1" in
-repl) PROG_NAME="$ReplMain" && shift ;;
-compile) PROG_NAME="$CompilerMain" && shift ;;
-decompile) PROG_NAME="$DecompilerMain" && shift ;;
-print-tasty) PROG_NAME="$DecompilerMain" && shift ;;
-run) PROG_NAME="$ReplMain" && shift ;;
-bootcp) bootcp=true && shift ;;
-nobootcp) unset bootcp && shift ;;
Expand Down
5 changes: 3 additions & 2 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -658,18 +658,19 @@ object Build {
val dottyCompiler = jars("dotty-compiler")
val args0: List[String] = spaceDelimited("<arg>").parsed.toList
val decompile = args0.contains("-decompile")
val printTasty = args0.contains("-print-tasty")
val debugFromTasty = args0.contains("-Ythrough-tasty")
val args = args0.filter(arg => arg != "-repl" && arg != "-decompile" &&
arg != "-with-compiler" && arg != "-Ythrough-tasty")

val main =
if (repl) "dotty.tools.repl.Main"
else if (decompile) "dotty.tools.dotc.decompiler.Main"
else if (decompile || printTasty) "dotty.tools.dotc.decompiler.Main"
else if (debugFromTasty) "dotty.tools.dotc.fromtasty.Debug"
else "dotty.tools.dotc.Main"

var extraClasspath = dottyLib
if (decompile && !args.contains("-classpath")) extraClasspath += ":."
if ((decompile || printTasty) && !args.contains("-classpath")) extraClasspath += ":."
if (args0.contains("-with-compiler")) extraClasspath += s":$dottyCompiler"

val fullArgs = main :: insertClasspathInArgs(args, extraClasspath)
Expand Down