feat: finish implementing analyzer
This commit is contained in:
@@ -164,15 +164,31 @@ fzl_an_res_t analyze_call(fzl_analyzer_t *analyzer, fzl_node_t *call_node)
|
||||
return (fzl_an_res_t){.error = true};
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < sym.node->fn.args_count; i++)
|
||||
size_t start_i = is_method ? 1 : 0;
|
||||
for (size_t i = start_i; i < sym.node->fn.args_count; i++)
|
||||
{
|
||||
fzl_an_res_t req = analyze_common(analyzer, sym.node->fn.args[i]);
|
||||
fzl_node_t *arg = sym.node->fn.args[i];
|
||||
fzl_type_t req_type = an_toktotype(arg->var.type);
|
||||
char *req_classname = NULL;
|
||||
if (req_type == FZL_TYPE_OBJECT)
|
||||
req_classname = arg->var.type->value;
|
||||
|
||||
fzl_an_res_t got = analyze_common(analyzer, call_node->call.args[i]);
|
||||
if (!an_is_compatible(req.type, got.type, req.classname, got.classname))
|
||||
if (got.error)
|
||||
{
|
||||
if (tmp_method_name != NULL)
|
||||
{
|
||||
free(tmp_method_name);
|
||||
tmp_method_name = NULL;
|
||||
}
|
||||
return (fzl_an_res_t){.error = true};
|
||||
}
|
||||
|
||||
if (!an_is_compatible(req_type, got.type, req_classname, got.classname))
|
||||
{
|
||||
snprintf(call_problem, sizeof(call_problem),
|
||||
"expect argument %zu to be %s, got '%s'", i + 1,
|
||||
an_typetostr(req.type, req.classname),
|
||||
an_typetostr(req_type, req_classname),
|
||||
an_typetostr(got.type, got.classname));
|
||||
an_push_error(analyzer, call_node->token, call_problem);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user