From 955f047e069497be4cbeffa3e0309360aeb1efa7 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 9 Mar 2024 14:02:19 -0500 Subject: First pass at lambdas/closures --- types.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'types.c') diff --git a/types.c b/types.c index e1f3026d..0b08cf95 100644 --- a/types.c +++ b/types.c @@ -27,6 +27,9 @@ CORD type_to_cord(type_t *t) { auto table = Match(t, TableType); return CORD_asprintf("{%r=>%r}", type_to_cord(table->key_type), type_to_cord(table->value_type)); } + case ClosureType: { + return CORD_all("~", type_to_cord(Match(t, ClosureType)->fn)); + } case FunctionType: { CORD c = "func("; auto fn = Match(t, FunctionType); @@ -440,7 +443,7 @@ size_t type_align(type_t *t) case ArrayType: return __alignof__(array_t); case TableType: return __alignof__(table_t); case FunctionType: return __alignof__(void*); - case ClosureType: return __alignof__(void*); + case ClosureType: return __alignof__(struct {void *fn, *userdata;}); case PointerType: return __alignof__(void*); case StructType: { size_t align = 0; -- cgit v1.2.3