[decomp] Small fixes (#541)

* fix a few bugs

* fix local vars missing in top level

* more small fixes

* support missing inline array access case

* one more fix
This commit is contained in:
water111
2021-05-30 19:57:11 -04:00
committed by GitHub
parent c910a22c1b
commit b1a76b2291
32 changed files with 298 additions and 117 deletions
+8 -4
View File
@@ -1725,7 +1725,7 @@ void StoreArrayAccess::push_to_stack(const Env& env, FormPool& pool, FormStack&
auto fr = pool.alloc_element<SetFormFormElement>(
form_out, make_optional_cast(m_src_cast_type, expr_form, pool, env));
fr->mark_popped();
stack.push_form_element(fr, true);
fr->push_to_stack(env, pool, stack);
}
///////////////////
@@ -2178,6 +2178,8 @@ void CondWithElseElement::push_to_stack(const Env& env, FormPool& pool, FormStac
// check all to see if they write the value.
std::vector<SetVarElement*> dest_sets;
std::vector<TypeSpec> source_types; // only explicit accesses that aren't move-eliminated
int empty_count = 0;
for (auto form : write_output_forms) {
auto last_in_body = dynamic_cast<SetVarElement*>(form->elts().back());
if (last_in_body) {
@@ -2191,9 +2193,11 @@ void CondWithElseElement::push_to_stack(const Env& env, FormPool& pool, FormStac
}
last_var = last_in_body->dst();
}
// For now, I am fine with letting this fail. For example, if the set is eliminated by a
// coloring move. If this makes really ugly code later on, we could use this to disable
// write as set.
empty_count++;
}
if (empty_count > 0 && env.aggressively_reject_cond_to_value_rewrite) {
rewrite_as_set = false;
}
if (!last_var.has_value()) {