Skip to content

Decompile while loops and remove empty packages #4250

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 4 commits into from
Apr 5, 2018

Conversation

nicolasstucki
Copy link
Contributor

No description provided.

@nicolasstucki nicolasstucki changed the title Decompile while loops Decompile while loops and remove empty packages Apr 5, 2018
@nicolasstucki nicolasstucki force-pushed the decompile-while-loops branch 2 times, most recently from 0f8fe6f to 2d862bc Compare April 5, 2018 11:31
@nicolasstucki nicolasstucki requested a review from biboudis April 5, 2018 11:32
@nicolasstucki nicolasstucki force-pushed the decompile-while-loops branch from 2d862bc to af822e1 Compare April 5, 2018 11:52
@@ -40,6 +49,12 @@ class DecompilerPrinter(_ctx: Context) extends RefinedPrinter(_ctx) {
decl ~~ typeText(nameIdText(tree)) ~ withEnclosingDef(tree) { toTextTemplate(impl) } ~ ""
}

override protected def toTextTemplate(impl: Template, ofNew: Boolean = false): Text = {
val Template(constr, parents, self, preBody) = impl
val impl1 = Template(constr, parents.filterNot(_.symbol.maybeOwner == defn.ObjectClass), self, preBody)
Copy link
Contributor

Choose a reason for hiding this comment

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

val impl1 = impl.copy(parents = impl1.parents.filterNot(_.symbol.maybeOwner == defn.ObjectClass))

@@ -29,8 +36,10 @@ class DecompilerPrinter(_ctx: Context) extends RefinedPrinter(_ctx) {
case _ => toTextGlobal(stats, "\n")
}
val bodyText =
if (currentPrecedence == TopLevelPrec) "\n" ~ statsText else " {" ~ statsText ~ "}"
keywordStr("package ") ~ toTextPackageId(tree.pid) ~ bodyText
if (tree.pid.symbol.isEmptyPackage) statsText
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this case redundant since you discard it on line 42 if tree.pid.symbol.isEmptyPackage?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The body is the only part that is not discarded

if (tree.pid.symbol.isEmptyPackage) statsText
else if (currentPrecedence == TopLevelPrec) "\n" ~ statsText
else " {" ~ statsText ~ "}"
(keywordStr("package ") ~ toTextPackageId(tree.pid)).provided(!tree.pid.symbol.isEmptyPackage) ~ bodyText
Copy link
Contributor

Choose a reason for hiding this comment

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

tree.pid.symbol same as tree.symbol?

@nicolasstucki nicolasstucki merged commit 62be430 into scala:master Apr 5, 2018
@allanrenucci allanrenucci deleted the decompile-while-loops branch April 5, 2018 19:00
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.

2 participants