[decompiler] clean up if/when/cond and recognize define-perm (#472)

* clean up if and when and cond decisions

* recognize define perm
This commit is contained in:
water111
2021-05-12 19:46:17 -04:00
committed by GitHub
parent 3897258753
commit 129ab54fd4
24 changed files with 1304 additions and 1144 deletions
+3 -3
View File
@@ -821,8 +821,8 @@ CondWithElseElement::CondWithElseElement(std::vector<Entry> _entries, Form* _els
goos::Object CondWithElseElement::to_form_internal(const Env& env) const {
// for now we only turn it into an if statement if both cases won't require a begin at the top
// level. I think it is more common to write these as a two-case cond instead of an if with begin.
if (entries.size() == 1 && entries.front().body->is_single_element() &&
else_ir->is_single_element()) {
if (entries.size() == 1 && entries.front().body->is_reasonable_for_if() &&
else_ir->is_reasonable_for_if()) {
std::vector<goos::Object> list;
list.push_back(pretty_print::to_symbol("if"));
list.push_back(entries.front().condition->to_form_as_condition(env));
@@ -1126,7 +1126,7 @@ CondNoElseElement::CondNoElseElement(std::vector<Entry> _entries) : entries(std:
}
goos::Object CondNoElseElement::to_form_internal(const Env& env) const {
if (entries.size() == 1 && entries.front().body->is_single_element()) {
if (entries.size() == 1 && entries.front().body->is_reasonable_for_if()) {
// print as an if statement if we can put the body in a single form.
std::vector<goos::Object> list;
list.push_back(pretty_print::to_symbol("if"));