mirror of
https://github.com/open-goal/jak-project
synced 2026-09-09 12:14:10 -04:00
fix some rare enum detection bugs (#2808)
This commit is contained in:
@@ -745,7 +745,7 @@ TP_Type SimpleExpression::get_type_int2(const TypeState& input,
|
||||
|
||||
// allow shifting stuff for setting bitfields
|
||||
if (m_kind == Kind::LEFT_SHIFT) {
|
||||
return TP_Type::make_from_ts("int");
|
||||
return TP_Type::make_from_ts(TypeSpec("int"));
|
||||
}
|
||||
|
||||
throw std::runtime_error(fmt::format("Cannot get_type_int2: {}, args {} and {}",
|
||||
|
||||
@@ -4658,8 +4658,8 @@ FormElement* try_make_nonzero_logtest(Form* in, FormPool& pool) {
|
||||
`(nonzero? (logand ,a ,b))
|
||||
)
|
||||
*/
|
||||
auto logand_matcher = Matcher::op(GenericOpMatcher::fixed(FixedOperatorKind::LOGAND),
|
||||
{Matcher::any(0), Matcher::any(1)});
|
||||
auto static const logand_matcher = Matcher::op(GenericOpMatcher::fixed(FixedOperatorKind::LOGAND),
|
||||
{Matcher::any(0), Matcher::any(1)});
|
||||
auto mr_logand = match(logand_matcher, in);
|
||||
if (mr_logand.matched) {
|
||||
return pool.alloc_element<GenericElement>(
|
||||
@@ -4744,13 +4744,25 @@ FormElement* try_make_logtest_cpad_macro(Form* in, FormPool& pool) {
|
||||
`(logtest? (cpad-hold ,pad-idx) (pad-buttons ,@buttons))
|
||||
)
|
||||
*/
|
||||
auto cpad_matcher = Matcher::op(
|
||||
auto static const cpad_matcher = Matcher::op(
|
||||
GenericOpMatcher::fixed(FixedOperatorKind::LOGTEST),
|
||||
{Matcher::deref(Matcher::symbol("*cpad-list*"), false,
|
||||
{DerefTokenMatcher::string("cpads"), DerefTokenMatcher::any_expr_or_int(0),
|
||||
DerefTokenMatcher::any_string(2), DerefTokenMatcher::integer(0)}),
|
||||
Matcher::op_with_rest(GenericOpMatcher::func(Matcher::constant_token("pad-buttons")), {})});
|
||||
auto static const cpad_matcher_inv = Matcher::op(
|
||||
GenericOpMatcher::fixed(FixedOperatorKind::LOGTEST),
|
||||
{Matcher::op_with_rest(GenericOpMatcher::func(Matcher::constant_token("pad-buttons")), {}),
|
||||
Matcher::deref(Matcher::symbol("*cpad-list*"), false,
|
||||
{DerefTokenMatcher::string("cpads"), DerefTokenMatcher::any_expr_or_int(0),
|
||||
DerefTokenMatcher::any_string(2), DerefTokenMatcher::integer(0)})});
|
||||
|
||||
bool inv_match = false;
|
||||
auto mr = match(cpad_matcher, in);
|
||||
if (!mr.matched) {
|
||||
mr = match(cpad_matcher_inv, in);
|
||||
inv_match = true;
|
||||
}
|
||||
if (mr.matched) {
|
||||
enum { ABS, REL, NIL } t = NIL;
|
||||
if (mr.maps.strings.at(2) == "button0-abs") {
|
||||
@@ -4761,8 +4773,8 @@ FormElement* try_make_logtest_cpad_macro(Form* in, FormPool& pool) {
|
||||
|
||||
if (t != NIL) {
|
||||
auto logtest_elt = dynamic_cast<GenericElement*>(in->at(0));
|
||||
if (logtest_elt != nullptr) {
|
||||
auto buttons_form = logtest_elt->elts().at(1);
|
||||
if (logtest_elt) {
|
||||
auto buttons_form = logtest_elt->elts().at(inv_match ? 0 : 1);
|
||||
std::vector<Form*> v;
|
||||
v.push_back(mr.int_or_form_to_form(pool, 0));
|
||||
GenericElement* butts =
|
||||
@@ -4916,7 +4928,14 @@ FormElement* ConditionElement::make_equal_check_generic(const Env& env,
|
||||
return pool.alloc_element<GenericElement>(GenericOperator::make_fixed(FixedOperatorKind::EQ),
|
||||
forms_with_cast);
|
||||
} else {
|
||||
{
|
||||
nice_constant =
|
||||
try_make_constant_for_compare(source_forms.at(0), source_types.at(1), pool, env);
|
||||
if (nice_constant) {
|
||||
auto forms_with_cast = source_forms;
|
||||
forms_with_cast.at(0) = nice_constant;
|
||||
return pool.alloc_element<GenericElement>(
|
||||
GenericOperator::make_fixed(FixedOperatorKind::EQ), forms_with_cast);
|
||||
} else {
|
||||
// (= (ja-group)
|
||||
// (-> self draw art-group data 7)
|
||||
// )
|
||||
|
||||
@@ -3456,13 +3456,13 @@
|
||||
(x 14)
|
||||
(square 15)
|
||||
;; only 16 buttons are mapped to hardware, the rest are 'actions' or something else
|
||||
(l-analog-down 16)
|
||||
(l-analog-up 16)
|
||||
(l-analog-right 17)
|
||||
(l-analog-up 18)
|
||||
(l-analog-down 18)
|
||||
(l-analog-left 19)
|
||||
(r-analog-down 20)
|
||||
(r-analog-up 20)
|
||||
(r-analog-right 21)
|
||||
(r-analog-up 22)
|
||||
(r-analog-down 22)
|
||||
(r-analog-left 23)
|
||||
(confirm 24)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user