mirror of
https://github.com/open-goal/jak-project
synced 2026-07-10 07:07:04 -04:00
Smarter send-event detection and fix touching-list bugs (#1320)
This commit is contained in:
@@ -2419,20 +2419,26 @@ void SetFormFormElement::push_to_stack(const Env& env, FormPool& pool, FormStack
|
||||
}
|
||||
}
|
||||
|
||||
const static std::pair<FixedOperatorKind, FixedOperatorKind> in_place_ops[] = {
|
||||
{FixedOperatorKind::ADDITION, FixedOperatorKind::ADDITION_IN_PLACE},
|
||||
{FixedOperatorKind::ADDITION_PTR, FixedOperatorKind::ADDITION_PTR_IN_PLACE},
|
||||
{FixedOperatorKind::LOGAND, FixedOperatorKind::LOGAND_IN_PLACE},
|
||||
{FixedOperatorKind::LOGIOR, FixedOperatorKind::LOGIOR_IN_PLACE},
|
||||
{FixedOperatorKind::LOGCLEAR, FixedOperatorKind::LOGCLEAR_IN_PLACE}};
|
||||
typedef struct {
|
||||
FixedOperatorKind kind;
|
||||
FixedOperatorKind inplace_kind;
|
||||
int inplace_arg;
|
||||
} InplaceOpInfo;
|
||||
|
||||
const static InplaceOpInfo in_place_ops[] = {
|
||||
{FixedOperatorKind::ADDITION, FixedOperatorKind::ADDITION_IN_PLACE, 0},
|
||||
{FixedOperatorKind::ADDITION_PTR, FixedOperatorKind::ADDITION_PTR_IN_PLACE, 0},
|
||||
{FixedOperatorKind::LOGAND, FixedOperatorKind::LOGAND_IN_PLACE, 0},
|
||||
{FixedOperatorKind::LOGIOR, FixedOperatorKind::LOGIOR_IN_PLACE, 0},
|
||||
{FixedOperatorKind::LOGCLEAR, FixedOperatorKind::LOGCLEAR_IN_PLACE, 0}};
|
||||
|
||||
typedef struct {
|
||||
std::string orig_name;
|
||||
int inplace_arg;
|
||||
std::string inplace_name;
|
||||
int inplace_arg;
|
||||
} InplaceCallInfo;
|
||||
|
||||
const static InplaceCallInfo in_place_calls[] = {{"seek", 0, "seek!"}, {"seekl", 0, "seekl!"}};
|
||||
const static InplaceCallInfo in_place_calls[] = {{"seek", "seek!", 0}, {"seekl", "seekl!", 0}};
|
||||
|
||||
auto src_as_generic = m_src->try_as_element<GenericElement>();
|
||||
if (src_as_generic) {
|
||||
@@ -2446,35 +2452,37 @@ void SetFormFormElement::push_to_stack(const Env& env, FormPool& pool, FormStack
|
||||
auto src_form_in_func = src_as_generic->elts().at(call_info.inplace_arg)->to_form(env);
|
||||
|
||||
if (dst_form == src_form_in_func) {
|
||||
const auto& inplace_name = call_info.inplace_name;
|
||||
auto new_func_op = GenericOperator::make_function(
|
||||
pool.alloc_single_element_form<ConstantTokenElement>(nullptr,
|
||||
call_info.inplace_name));
|
||||
GenericElement* inplace_call = nullptr;
|
||||
|
||||
if (funcname == "seek" || funcname == "seekl") {
|
||||
inplace_call = pool.alloc_single_element_form<GenericElement>(
|
||||
nullptr,
|
||||
GenericOperator::make_function(
|
||||
pool.alloc_single_element_form<ConstantTokenElement>(
|
||||
nullptr, inplace_name)),
|
||||
nullptr, new_func_op,
|
||||
std::vector<Form*>{m_dst, src_as_generic->elts().at(1),
|
||||
src_as_generic->elts().at(2)})
|
||||
->try_as_element<GenericElement>();
|
||||
}
|
||||
if (inplace_call) {
|
||||
stack.push_form_element(inplace_call, true);
|
||||
return;
|
||||
}
|
||||
ASSERT_MSG(
|
||||
inplace_call,
|
||||
fmt::format(
|
||||
"Somehow, no appropriate inplace call was generated for (set! {}) -> {}",
|
||||
call_info.orig_name, call_info.inplace_name));
|
||||
stack.push_form_element(inplace_call, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (auto& op_pair : in_place_ops) {
|
||||
if (src_as_generic->op().is_fixed(op_pair.first)) {
|
||||
for (const auto& op_info : in_place_ops) {
|
||||
if (src_as_generic->op().is_fixed(op_info.kind)) {
|
||||
auto dst_form = m_dst->to_form(env);
|
||||
auto add_form_0 = src_as_generic->elts().at(0)->to_form(env);
|
||||
auto add_form_0 = src_as_generic->elts().at(op_info.inplace_arg)->to_form(env);
|
||||
|
||||
if (dst_form == add_form_0) {
|
||||
src_as_generic->op() = GenericOperator::make_fixed(op_pair.second);
|
||||
src_as_generic->op() = GenericOperator::make_fixed(op_info.inplace_kind);
|
||||
stack.push_form_element(src_as_generic, true);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user