Fix pseudo-circular function pointer definitions.

This commit is contained in:
Christoffer Lerno
2023-07-20 12:49:02 +02:00
parent 581ecdb2a8
commit 3f41e58dbd
8 changed files with 79 additions and 35 deletions

View File

@@ -227,6 +227,7 @@ const char *type_to_error_string(Type *type)
return scratch_buffer_copy();
}
case TYPE_FUNC:
if (!type->function.prototype) return type->name;
scratch_buffer_clear();
scratch_buffer_append("fn ");
type_append_func_to_scratch(type->function.prototype);
@@ -1369,6 +1370,15 @@ static inline Type *func_create_new_func_proto(Signature *sig, CallABI abi, uint
return type;
}
Type *type_get_func_alias(const char *name, Signature *signature, Module *module)
{
Type *type = type_new(TYPE_FUNC, name);
type->canonical = type;
type->function.signature = signature;
type->function.module = module;
return type;
}
Type *type_get_func(Signature *signature, CallABI abi)
{
uint32_t hash = hash_function(signature);