aboutsummaryrefslogtreecommitdiff
path: root/src/debug.c
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2024-08-14 18:51:28 +0300
committerKimplul <kimi.h.kuparinen@gmail.com>2024-08-14 18:51:28 +0300
commit852ff838af56ef3668ff94c27b0140869dcb7359 (patch)
treefbb51f25484832aeb4acc24ca0e9fb16a0831b7d /src/debug.c
parent085817c69d145400eac84e09704f48ede2bece68 (diff)
downloadek-852ff838af56ef3668ff94c27b0140869dcb7359.tar.gz
ek-852ff838af56ef3668ff94c27b0140869dcb7359.zip
allow adding traits to pointers
+ Should be enough to fairly easily use pointers in standard containers. Note that this just uses the pointer value itself, and doesn't care about the underlying type at all. So for example a sorted vector of pointers is sorted by the address, not by some comparison function that the underlying type may have defined. For that you will need a wrapper struct or something.
Diffstat (limited to 'src/debug.c')
-rw-r--r--src/debug.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/debug.c b/src/debug.c
index 47e53f2..92d85d2 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -218,6 +218,22 @@ void internal_warn(const char *fmt, ...)
va_end(args);
}
+static void _type_str(FILE *fp, struct type *type);
+
+static void _type_list_str(FILE *fp, struct type *types)
+{
+ if (!types)
+ return;
+
+ _type_str(fp, types);
+
+ types = types->n;
+ foreach_type(t, types) {
+ fprintf(fp, ", ");
+ _type_str(fp, t);
+ }
+}
+
/**
* Workhorse for type_str().
*
@@ -263,6 +279,15 @@ static void _type_str(FILE *fp, struct type *type)
break;
}
+ case TYPE_CALLABLE: {
+ fputc('(', fp);
+ _type_list_str(fp, callable_ptypes(type));
+ fprintf(fp, " => ");
+ _type_str(fp, callable_rtype(type));
+ fputc(')', fp);
+ break;
+ }
+
default:
if (is_primitive(type))
fprintf(fp, "%s", primitive_str(type));