commit 6c959482fdf66e5b3653224109ed29c1958239b2
parent aca00ad93ecd947d601d4d08c320235ed288147b
Author: Drew DeVault <sir@cmpwn.com>
Date: Thu, 24 Dec 2020 16:06:53 -0500
type_eq_type: implement function types
Diffstat:
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/src/type_store.c b/src/type_store.c
@@ -277,8 +277,24 @@ type_eq_type(struct type_store *store,
case TYPE_STORAGE_ALIAS:
case TYPE_STORAGE_ARRAY:
case TYPE_STORAGE_ENUM:
- case TYPE_STORAGE_FUNCTION:
assert(0); // TODO
+ case TYPE_STORAGE_FUNCTION:
+ if (a->func.variadism != b->func.variadism
+ || a->func.flags != b->func.flags
+ || !type_eq_type(store, a->func.result, b->func.result)) {
+ return false;
+ }
+ struct type_func_param *aparam = a->func.params;
+ struct type_func_param *bparam = b->func.params;
+ while (aparam && bparam) {
+ if (!type_eq_type(store, aparam->type, bparam->type)) {
+ return false;
+ }
+
+ aparam = aparam->next;
+ bparam = bparam->next;
+ }
+ return !aparam && !bparam;
case TYPE_STORAGE_POINTER:
return a->pointer.flags == b->pointer.flags &&
type_eq_type(store, a->pointer.referent, b->pointer.referent);