From 7355b2f7fe6f5dda2aee8feca025350146ccd0f5 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 17 Feb 2024 18:38:29 -0500 Subject: Change things up to use type params for all array and table methods --- builtins/functions.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'builtins/functions.c') diff --git a/builtins/functions.c b/builtins/functions.c index 1b22efdf..93453a3d 100644 --- a/builtins/functions.c +++ b/builtins/functions.c @@ -31,8 +31,8 @@ public void fail(const char *fmt, ...) public uint32_t generic_hash(const void *obj, const TypeInfo *type) { switch (type->tag) { - case PointerInfo: return Pointer__hash(obj, type); - case ArrayInfo: return Array_hash(obj, type); + case PointerInfo: case FunctionInfo: return Pointer__hash(obj, type); + case ArrayInfo: return Array__hash(obj, type); case TableInfo: return Table_hash(obj, type); case CustomInfo: if (!type->CustomInfo.hash) @@ -50,8 +50,8 @@ public uint32_t generic_hash(const void *obj, const TypeInfo *type) public int32_t generic_compare(const void *x, const void *y, const TypeInfo *type) { switch (type->tag) { - case PointerInfo: return Pointer__compare(x, y, type); - case ArrayInfo: return Array_compare(x, y, type); + case PointerInfo: case FunctionInfo: return Pointer__compare(x, y, type); + case ArrayInfo: return Array__compare(x, y, type); case TableInfo: return Table_compare(x, y, type); case CustomInfo: if (!type->CustomInfo.compare) @@ -66,8 +66,8 @@ public int32_t generic_compare(const void *x, const void *y, const TypeInfo *typ public bool generic_equal(const void *x, const void *y, const TypeInfo *type) { switch (type->tag) { - case PointerInfo: return Pointer__equal(x, y, type); - case ArrayInfo: return Array_equal(x, y, type); + case PointerInfo: case FunctionInfo: return Pointer__equal(x, y, type); + case ArrayInfo: return Array__equal(x, y, type); case TableInfo: return Table_equal(x, y, type); case CustomInfo: if (!type->CustomInfo.equal) @@ -83,7 +83,8 @@ public CORD generic_as_str(const void *obj, bool colorize, const TypeInfo *type) { switch (type->tag) { case PointerInfo: return Pointer__cord(obj, colorize, type); - case ArrayInfo: return Array_as_str(obj, colorize, type); + case FunctionInfo: return Func__as_str(obj, colorize, type); + case ArrayInfo: return Array__as_str(obj, colorize, type); case TableInfo: return Table_as_str(obj, colorize, type); case TypeInfoInfo: return Type__as_str(obj, colorize, type); case CustomInfo: -- cgit v1.2.3