This commit is contained in:
water
2023-09-23 13:31:53 -04:00
parent 518bf8b29a
commit 69caa163c9
78 changed files with 261 additions and 308 deletions
+17
View File
@@ -3896,6 +3896,7 @@ void FunctionCallElement::update_from_stack(const Env& env,
{
const auto& guessed_name = env.func->guessed_name;
if (guessed_name.kind == FunctionName::FunctionKind::METHOD) {
// detect stuff like: ((find-parent-method...) arg...)
auto mr_find_parent =
match(Matcher::func(Matcher::symbol("find-parent-method"),
{Matcher::symbol(env.func->method_of_type),
@@ -3908,6 +3909,22 @@ void FunctionCallElement::update_from_stack(const Env& env,
GenericOperator::make_function(pool.form<ConstantTokenElement>("call-parent-method")),
arg_forms);
}
} else if (guessed_name.kind == FunctionName::FunctionKind::V_STATE && arg_forms.size() == 2) {
// here, simply detect (find-parent-method...)
//
auto mr_find_parent = match(Matcher::symbol("find-parent-method"), unstacked.at(0));
if (mr_find_parent.matched) {
auto state_info =
env.dts->ts.lookup_method(guessed_name.type_name, guessed_name.state_name);
if (arg_forms.at(0)->to_string(env) == guessed_name.type_name &&
arg_forms.at(1)->to_string(env) == std::to_string(state_info.id)) {
new_form = pool.alloc_element<GenericElement>(
GenericOperator::make_function(pool.form<ConstantTokenElement>("find-parent-state")));
} else {
printf("BAD match [%s] [%s]\n", arg_forms.at(0)->to_string(env).c_str(),
arg_forms.at(1)->to_string(env).c_str());
}
}
}
}