Skip to content

Create dotc -decompiler #3485

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 2 commits into from
Nov 20, 2017
Merged

Conversation

nicolasstucki
Copy link
Contributor

Create infrastructure to support dotp tasty decompiler. The implementation of the decompiler is a tasty compiler that compiles to a text representation of the loaded code (currently with Tree.show).

@nicolasstucki
Copy link
Contributor Author

nicolasstucki commented Nov 16, 2017

Needs rebase on #3436 Done.

@@ -96,6 +96,7 @@ class ScalaSettings extends Settings.SettingGroup {
val YnoPatmatOpt = BooleanSetting("-Yno-patmat-opt", "disable all pattern matching optimizations.")
val YplainPrinter = BooleanSetting("-Yplain-printer", "Pretty-print using a plain printer.")
val YprintSyms = BooleanSetting("-Yprint-syms", "when printing trees print info in symbols instead of corresponding info in trees.")
val YprintNoPrivate = BooleanSetting("-Y-print-no-private", "when printing trees print do not print private/protected members.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should -Yprint, not -Y-print

@nicolasstucki nicolasstucki force-pushed the implement-dotp branch 4 times, most recently from a9e047a to 8b9621b Compare November 19, 2017 16:24
@nicolasstucki nicolasstucki changed the title Create dotp decompiler Create dotc -decompiler Nov 20, 2017
* `dotc -decompile <options|classes>*`
@nicolasstucki
Copy link
Contributor Author

Rebased and squashed

println(line)

val code = unit.tpdTree.show
println(if (ctx.useColors) printing.SyntaxHighlighting(code) else code)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should really be printing.SyntaxHighlighting(code).mkString. We shouldn't assume that the underlying Iterable[Char].toString works as we expect.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will remove the syntax highlighting as it is not compatible with all the output formats of show. I will work on coloring in a separate PR.

@nicolasstucki nicolasstucki merged commit c48f7b0 into scala:master Nov 20, 2017
@allanrenucci allanrenucci deleted the implement-dotp branch December 14, 2017 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants