Skip to content

Implement decompiler on Tasty #4579

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 7 commits into from
May 31, 2018
Merged

Conversation

nicolasstucki
Copy link
Contributor

@nicolasstucki nicolasstucki commented May 24, 2018

The implementation of the decompiler must:

  • print compilable code
  • print precise types
  • print resolved implicits
  • resugar code that cannot be written in source

It does NOT need:

  • pretty printing (line wrapping, small types, ...), this is something that can be done trough another tool or another custom printer

@nicolasstucki nicolasstucki force-pushed the tasty-decompiler branch 16 times, most recently from 95fb46b to 2204b3b Compare May 28, 2018 11:16
@nicolasstucki nicolasstucki changed the title Reformat QuoteCompiler and implement decompiler on Tasty Implement decompiler on Tasty May 28, 2018
@nicolasstucki nicolasstucki requested a review from liufengyun May 28, 2018 12:53
@nicolasstucki
Copy link
Contributor Author

Rebased

@allanrenucci
Copy link
Contributor

Should we remove DecompilerPrinter? We could simplify the implementation of RefinedPrinter

@nicolasstucki
Copy link
Contributor Author

nicolasstucki commented May 28, 2018

The idea is to remove the DecompilerPrinter and merge the code with ReplPrinter

@nicolasstucki nicolasstucki force-pushed the tasty-decompiler branch 2 times, most recently from e67a67d to fe9b1a7 Compare May 29, 2018 08:06
if (ctx.settings.printTasty.value) {
new TastyPrinter(unit.pickled.head._2).printContents()
} else {
val unit = ctx.compilationUnit
Copy link
Contributor

Choose a reason for hiding this comment

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

unit is no longer accessible in L40, the CI failed because of this.

Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

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

Otherwise, LGTM


case Type.TypeLambda(paramNames, paramBounds, resType) =>
???
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems ??? in the above means they should never be reached. Maybe use a "|" pattern to combine them in one case (the variable patterns are not used, can be underscore), and add a note.

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 add a better way to handle unreachable patterns.

this += lineBreak()
printCases(cases, lineBreak())
}
this += lineBreak() += "}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have a test for partial functions?

Another tricky issue is extractors with implicits. Maybe add a TODO to support later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not yet, I will add it later. The idea is to start testing all the files in test/pos and test/run.

@nicolasstucki
Copy link
Contributor Author

@liufengyun I fixed the issues from the comments and repeated args. You should review the last 3 commits.

@liufengyun
Copy link
Contributor

LGTM

@liufengyun liufengyun merged commit 1a7144a into scala:master May 31, 2018
@liufengyun liufengyun deleted the tasty-decompiler branch May 31, 2018 08:04
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