diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-03-09 14:02:19 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-03-09 14:02:19 -0500 |
| commit | 955f047e069497be4cbeffa3e0309360aeb1efa7 (patch) | |
| tree | 20b59546bb79c75d368739959d15c28317e913bd /types.c | |
| parent | 0921f3723bf7fe7539aa7a5dfdbd921f445777af (diff) | |
First pass at lambdas/closures
Diffstat (limited to 'types.c')
| -rw-r--r-- | types.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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; |
