mirror of
https://github.com/open-goal/jak-project
synced 2026-09-06 03:08:29 -04:00
[decompiler] Handle find-parent-method (#3018)
This change adds a few new features: - Decompiler automatically knows the type of `find-parent-method` use in jak 1 and jak2 when used in a method or virtual state handler. - Decompiler inserts a call to `call-parent-method` or `find-parent-state` - Removed most casts related to these functions There are still a few minor issues around this: - There are still some casts needed when using `post` methods, as `post` is just a `function`, and needs a cast to `(function none)` or similar. It didn't seem easy to change the type of `post`, so I'm not going to worry about it for this PR. It only shows up in like 3 places in jak 2. (and 0 in jak 1) - If "call the handler if it's not #f" logic should probably be another macro. Fixes #805
This commit is contained in:
@@ -276,7 +276,7 @@ bool Matcher::do_match(Form* input, MatchResult::Maps* maps_out, const Env* cons
|
||||
} else if (m_kind == Kind::VAR_NAME) {
|
||||
return env && env->get_variable_name_name_only(result) == m_str;
|
||||
} else if (m_reg_out_id != -1) {
|
||||
if (m_kind == Kind::SAME_VAR && maps_out->regs.size() > m_reg_out_id &&
|
||||
if (m_kind == Kind::SAME_VAR && (int)maps_out->regs.size() > m_reg_out_id &&
|
||||
maps_out->regs.at(m_reg_out_id)) {
|
||||
return env && env->get_variable_name_name_only(result) ==
|
||||
env->get_variable_name_name_only(*maps_out->regs.at(m_reg_out_id));
|
||||
@@ -695,7 +695,7 @@ bool Matcher::do_match(Form* input, MatchResult::Maps* maps_out, const Env* cons
|
||||
if (as_let) {
|
||||
// fail if we have wrong number of entries/body elts or recursive marker
|
||||
if ((m_entry_matchers.size() != as_let->entries().size()) ||
|
||||
(m_sub_matchers.size() != as_let->body()->size()) ||
|
||||
((int)m_sub_matchers.size() != as_let->body()->size()) ||
|
||||
(as_let->is_star() != m_let_is_star)) {
|
||||
return false;
|
||||
}
|
||||
@@ -706,7 +706,7 @@ bool Matcher::do_match(Form* input, MatchResult::Maps* maps_out, const Env* cons
|
||||
}
|
||||
}
|
||||
// now match body
|
||||
for (int i = 0; i < m_sub_matchers.size(); ++i) {
|
||||
for (int i = 0; i < (int)m_sub_matchers.size(); ++i) {
|
||||
Form fake;
|
||||
fake.elts().push_back(as_let->body()->elts().at(i));
|
||||
if (!m_sub_matchers.at(i).do_match(&fake, maps_out, env)) {
|
||||
@@ -908,7 +908,7 @@ bool LetEntryMatcher::do_match(const LetElement::Entry& input,
|
||||
case Kind::ANY:
|
||||
case Kind::NAME:
|
||||
if (m_reg_out_id != -1) {
|
||||
if (m_kind == Kind::NAME && maps_out->regs.size() > m_reg_out_id &&
|
||||
if (m_kind == Kind::NAME && (int)maps_out->regs.size() > m_reg_out_id &&
|
||||
maps_out->regs.at(m_reg_out_id)) {
|
||||
return env && env->get_variable_name_name_only(input.dest) ==
|
||||
env->get_variable_name_name_only(*maps_out->regs.at(m_reg_out_id));
|
||||
|
||||
Reference in New Issue
Block a user