Merge branch 'master' of https://github.com/water111/jak-project into w/type-pass-2

This commit is contained in:
water
2021-06-26 13:04:33 -04:00
66 changed files with 2021 additions and 1119 deletions
+11 -9
View File
@@ -1846,7 +1846,8 @@ void FunctionCallElement::update_from_stack(const Env& env,
function_type = tp_type.typespec();
}
bool swap_function = tp_type.kind == TP_Type::Kind::NON_VIRTUAL_METHOD && true;
bool swap_function =
tp_type.kind == TP_Type::Kind::NON_VIRTUAL_METHOD && all_pop_vars.size() >= 2;
if (tp_type.kind == TP_Type::Kind::NON_VIRTUAL_METHOD) {
// this is a hack to make some weird macro for calling res-lump methods work
if (env.dts->ts.tc(TypeSpec("res-lump"), tp_type.method_from_type())) {
@@ -2058,7 +2059,12 @@ void FunctionCallElement::update_from_stack(const Env& env,
"type. Got {} instead.",
tp_type.print()));
}
}
auto type_source_form = match_result.maps.forms.at(type_source);
// if the type is the exact type of the argument, we want to build it into a method call
if (type_source_form->to_string(env) == first_arg_type.base_type() && name != "new") {
if (env.dts->ts.should_use_virtual_methods(tp_type.method_from_type(),
tp_type.method_id())) {
throw std::runtime_error(fmt::format(
@@ -2066,12 +2072,6 @@ void FunctionCallElement::update_from_stack(const Env& env,
":final in the deftype to disable virtual method calls",
tp_type.method_from_type().print(), tp_type.method_id()));
}
}
auto type_source_form = match_result.maps.forms.at(type_source);
// if the type is the exact type of the argument, we want to build it into a method call
if (type_source_form->to_string(env) == first_arg_type.base_type() && name != "new") {
auto method_op = pool.alloc_single_element_form<ConstantTokenElement>(nullptr, name);
auto gop = GenericOperator::make_function(method_op);
@@ -3391,10 +3391,12 @@ void ArrayFieldAccess::update_with_val(Form* new_val,
if (m_expected_stride == 1) {
// reg0 is idx
auto reg0_matcher =
Matcher::match_or({Matcher::cast("int", Matcher::any(0)), Matcher::any(0)});
Matcher::match_or({Matcher::cast("int", Matcher::any(0)),
Matcher::cast("uint", Matcher::any(0)), Matcher::any(0)});
// reg1 is base
auto reg1_matcher =
Matcher::match_or({Matcher::cast("int", Matcher::any(1)), Matcher::any(1)});
Matcher::match_or({Matcher::cast("int", Matcher::any(1)),
Matcher::cast("uint", Matcher::any(1)), Matcher::any(1)});
auto matcher = Matcher::fixed_op(FixedOperatorKind::ADDITION, {reg0_matcher, reg1_matcher});
auto match_result = match(matcher, new_val);
if (!match_result.matched) {