aboutsummaryrefslogtreecommitdiff
path: root/types.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-03-09 14:02:19 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-03-09 14:02:19 -0500
commit955f047e069497be4cbeffa3e0309360aeb1efa7 (patch)
tree20b59546bb79c75d368739959d15c28317e913bd /types.c
parent0921f3723bf7fe7539aa7a5dfdbd921f445777af (diff)
First pass at lambdas/closures
Diffstat (limited to 'types.c')
-rw-r--r--types.c5
1 files changed, 4 insertions, 1 deletions
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;