mirror of
https://github.com/open-goal/jak-project
synced 2026-07-07 14:13:45 -04:00
misc small improvements (#217)
This commit is contained in:
@@ -5,11 +5,13 @@ namespace decompiler {
|
||||
std::string FormStack::StackEntry::print(const Env& env) const {
|
||||
if (destination.has_value()) {
|
||||
assert(source && !elt);
|
||||
return fmt::format("d: {} s: {} | {} <- {}", active, sequence_point,
|
||||
destination.value().reg().to_charp(), source->to_string(env));
|
||||
return fmt::format("d: {} s: {} | {} <- {} f: {}", active, sequence_point,
|
||||
destination.value().reg().to_charp(), source->to_string(env),
|
||||
non_seq_source.has_value());
|
||||
} else {
|
||||
assert(elt && !source);
|
||||
return fmt::format("d: {} s: {} | {}", active, sequence_point, elt->to_string(env));
|
||||
return fmt::format("d: {} s: {} | {} f: {}", active, sequence_point, elt->to_string(env),
|
||||
non_seq_source.has_value());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +33,18 @@ void FormStack::push_value_to_reg(Variable var, Form* value, bool sequence_point
|
||||
m_stack.push_back(entry);
|
||||
}
|
||||
|
||||
void FormStack::push_non_seq_reg_to_reg(const Variable& dst,
|
||||
const Variable& src,
|
||||
Form* src_as_form) {
|
||||
StackEntry entry;
|
||||
entry.active = true;
|
||||
entry.sequence_point = false;
|
||||
entry.destination = dst;
|
||||
entry.non_seq_source = src;
|
||||
entry.source = src_as_form;
|
||||
m_stack.push_back(entry);
|
||||
}
|
||||
|
||||
bool FormStack::is_single_expression() {
|
||||
int count = 0;
|
||||
for (auto& e : m_stack) {
|
||||
@@ -56,6 +70,13 @@ Form* FormStack::pop_reg(Register reg) {
|
||||
if (entry.destination->reg() == reg) {
|
||||
entry.active = false;
|
||||
assert(entry.source);
|
||||
if (entry.non_seq_source.has_value()) {
|
||||
assert(entry.sequence_point == false);
|
||||
auto result = pop_reg(entry.non_seq_source->reg());
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return entry.source;
|
||||
} else {
|
||||
// we didn't match
|
||||
|
||||
Reference in New Issue
Block a user