mirror of
https://github.com/open-goal/jak-project
synced 2026-07-08 22:45:00 -04:00
decomp: finish target-racer | target-tube (#1042)
* decomp: finish `target-racer` target-racing-turn-anim was the `cond` issue here * decomp: finish `target-tube` target-tube-turn-anim was the issue here
This commit is contained in:
@@ -3583,66 +3583,59 @@ FormElement* sc_to_handle_get_proc(ShortCircuitElement* elt,
|
||||
|
||||
void ShortCircuitElement::push_to_stack(const Env& env, FormPool& pool, FormStack& stack) {
|
||||
mark_popped();
|
||||
if (!used_as_value.value_or(false)) {
|
||||
throw std::runtime_error(
|
||||
"ShortCircuitElement::push_to_stack not implemented for result not used case.");
|
||||
|
||||
if (already_rewritten) {
|
||||
stack.push_form_element(this, true);
|
||||
} else {
|
||||
if (already_rewritten) {
|
||||
stack.push_form_element(this, true);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// the first condition is special
|
||||
auto first_condition = entries.front().condition;
|
||||
// lets evaluate in on the parent stack...
|
||||
for (auto x : first_condition->elts()) {
|
||||
x->push_to_stack(env, pool, stack);
|
||||
}
|
||||
// the first condition is special
|
||||
auto first_condition = entries.front().condition;
|
||||
// lets evaluate in on the parent stack...
|
||||
for (auto x : first_condition->elts()) {
|
||||
x->push_to_stack(env, pool, stack);
|
||||
}
|
||||
|
||||
for (int i = 0; i < int(entries.size()); i++) {
|
||||
auto& entry = entries.at(i);
|
||||
if (entry.condition == first_condition) {
|
||||
entry.condition->clear();
|
||||
entry.condition->push_back(stack.pop_back(pool));
|
||||
for (int i = 0; i < int(entries.size()); i++) {
|
||||
auto& entry = entries.at(i);
|
||||
if (entry.condition == first_condition) {
|
||||
entry.condition->clear();
|
||||
entry.condition->push_back(stack.pop_back(pool));
|
||||
} else {
|
||||
FormStack temp_stack(false);
|
||||
for (auto& elt : entry.condition->elts()) {
|
||||
elt->push_to_stack(env, pool, temp_stack);
|
||||
}
|
||||
|
||||
std::vector<FormElement*> new_entries;
|
||||
if (i == int(entries.size()) - 1) {
|
||||
new_entries = rewrite_to_get_var(temp_stack, pool, final_result, env);
|
||||
} else {
|
||||
FormStack temp_stack(false);
|
||||
for (auto& elt : entry.condition->elts()) {
|
||||
elt->push_to_stack(env, pool, temp_stack);
|
||||
}
|
||||
new_entries = temp_stack.rewrite(pool, env);
|
||||
}
|
||||
|
||||
std::vector<FormElement*> new_entries;
|
||||
if (i == int(entries.size()) - 1) {
|
||||
new_entries = rewrite_to_get_var(temp_stack, pool, final_result, env);
|
||||
} else {
|
||||
new_entries = temp_stack.rewrite(pool, env);
|
||||
}
|
||||
|
||||
entry.condition->clear();
|
||||
for (auto e : new_entries) {
|
||||
if (dynamic_cast<EmptyElement*>(e)) {
|
||||
continue;
|
||||
}
|
||||
entry.condition->push_back(e);
|
||||
}
|
||||
if (entry.condition->elts().empty()) {
|
||||
entry.condition->push_back(pool.alloc_element<EmptyElement>());
|
||||
entry.condition->clear();
|
||||
for (auto e : new_entries) {
|
||||
if (dynamic_cast<EmptyElement*>(e)) {
|
||||
continue;
|
||||
}
|
||||
entry.condition->push_back(e);
|
||||
}
|
||||
if (entry.condition->elts().empty()) {
|
||||
entry.condition->push_back(pool.alloc_element<EmptyElement>());
|
||||
}
|
||||
}
|
||||
|
||||
FormElement* to_push = this;
|
||||
auto as_handle_get = sc_to_handle_get_proc(this, env, pool, stack);
|
||||
if (as_handle_get) {
|
||||
to_push = as_handle_get;
|
||||
}
|
||||
|
||||
assert(used_as_value.has_value());
|
||||
stack.push_value_to_reg(final_result, pool.alloc_single_form(nullptr, to_push), true,
|
||||
env.get_variable_type(final_result, false));
|
||||
already_rewritten = true;
|
||||
}
|
||||
|
||||
FormElement* to_push = this;
|
||||
auto as_handle_get = sc_to_handle_get_proc(this, env, pool, stack);
|
||||
if (as_handle_get) {
|
||||
to_push = as_handle_get;
|
||||
}
|
||||
|
||||
assert(used_as_value.has_value());
|
||||
stack.push_value_to_reg(final_result, pool.alloc_single_form(nullptr, to_push), true,
|
||||
env.get_variable_type(final_result, false));
|
||||
already_rewritten = true;
|
||||
}
|
||||
|
||||
void ShortCircuitElement::update_from_stack(const Env& env,
|
||||
|
||||
Reference in New Issue
Block a user