mirror of
https://github.com/open-goal/jak-project
synced 2026-07-09 23:01:56 -04:00
[Decompiler] Expressions (Part 3) (#213)
* before inserting bonus instruction * first part of refactor for return values * find parent method working
This commit is contained in:
+42
-2
@@ -344,8 +344,8 @@ void BranchElement::collect_vars(VariableSet& vars) const {
|
||||
goos::Object ReturnElement::to_form(const Env& env) const {
|
||||
std::vector<goos::Object> forms;
|
||||
forms.push_back(pretty_print::to_symbol("return"));
|
||||
forms.push_back(pretty_print::build_list(return_code->to_form(env)));
|
||||
forms.push_back(pretty_print::build_list(dead_code->to_form(env)));
|
||||
forms.push_back(return_code->to_form(env));
|
||||
forms.push_back(dead_code->to_form(env));
|
||||
return pretty_print::build_list(forms);
|
||||
}
|
||||
|
||||
@@ -820,6 +820,26 @@ void GenericOperator::apply_form(const std::function<void(Form*)>& f) {
|
||||
}
|
||||
}
|
||||
|
||||
bool GenericOperator::operator==(const GenericOperator& other) const {
|
||||
if (m_kind != other.m_kind) {
|
||||
return false;
|
||||
}
|
||||
switch (m_kind) {
|
||||
case Kind::FIXED_OPERATOR:
|
||||
return m_fixed_kind == other.m_fixed_kind;
|
||||
case Kind::CONDITION_OPERATOR:
|
||||
return m_condition_kind == other.m_condition_kind;
|
||||
case Kind::FUNCTION_EXPR:
|
||||
return false;
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
bool GenericOperator::operator!=(const GenericOperator& other) const {
|
||||
return !((*this) == other);
|
||||
}
|
||||
|
||||
std::string fixed_operator_to_string(FixedOperatorKind kind) {
|
||||
switch (kind) {
|
||||
case FixedOperatorKind::GPR_TO_FPR:
|
||||
@@ -1034,4 +1054,24 @@ void DerefElement::collect_vars(VariableSet& vars) const {
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////
|
||||
// DynamicMethodAccess
|
||||
/////////////////////////////
|
||||
|
||||
DynamicMethodAccess::DynamicMethodAccess(Variable source) : m_source(source) {}
|
||||
|
||||
goos::Object DynamicMethodAccess::to_form(const Env& env) const {
|
||||
return pretty_print::build_list("dyn-method-access", m_source.to_string(&env));
|
||||
}
|
||||
|
||||
void DynamicMethodAccess::apply(const std::function<void(FormElement*)>& f) {
|
||||
f(this);
|
||||
}
|
||||
|
||||
void DynamicMethodAccess::apply_form(const std::function<void(Form*)>&) {}
|
||||
|
||||
void DynamicMethodAccess::collect_vars(VariableSet& vars) const {
|
||||
vars.insert(m_source);
|
||||
}
|
||||
|
||||
} // namespace decompiler
|
||||
|
||||
Reference in New Issue
Block a user