aboutsummaryrefslogtreecommitdiff
path: root/types.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-01-02 20:29:55 -0500
committerBruce Hill <bruce@bruce-hill.com>2025-01-02 20:29:55 -0500
commitb025cf269d2e07e179be4a0e34d936862dc640c2 (patch)
tree6bcce81829436a08dbe4f0101044c0cd07811525 /types.c
parent500e4e1bd74b45476c4df0f4f9da72fbada9bb18 (diff)
Use `holding` blocks for mutexed data instead of lambdas
Diffstat (limited to 'types.c')
-rw-r--r--types.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/types.c b/types.c
index 92a3c270..cee1db9b 100644
--- a/types.c
+++ b/types.c
@@ -85,6 +85,13 @@ CORD type_to_cord(type_t *t) {
else
return "(Unknown optional type)";
}
+ case MutexedType: {
+ type_t *opt = Match(t, MutexedType)->type;
+ if (opt)
+ return CORD_all("mutexed ", type_to_cord(opt));
+ else
+ return "(Unknown optional type)";
+ }
case TypeInfoType: {
return CORD_all("Type$info(", Match(t, TypeInfoType)->name, ")");
}
@@ -246,6 +253,7 @@ PUREFUNC bool has_heap_memory(type_t *t)
case SetType: return true;
case PointerType: return true;
case OptionalType: return has_heap_memory(Match(t, OptionalType)->type);
+ case MutexedType: return true;
case BigIntType: return true;
case StructType: {
for (arg_t *field = Match(t, StructType)->fields; field; field = field->next) {
@@ -270,6 +278,7 @@ PUREFUNC bool has_stack_memory(type_t *t)
switch (t->tag) {
case PointerType: return Match(t, PointerType)->is_stack;
case OptionalType: return has_stack_memory(Match(t, OptionalType)->type);
+ case MutexedType: return has_stack_memory(Match(t, MutexedType)->type);
default: return false;
}
}
@@ -498,6 +507,7 @@ PUREFUNC size_t type_size(type_t *t)
case FunctionType: return sizeof(void*);
case ClosureType: return sizeof(struct {void *fn, *userdata;});
case PointerType: return sizeof(void*);
+ case MutexedType: return sizeof(MutexedData_t);
case OptionalType: {
type_t *nonnull = Match(t, OptionalType)->type;
switch (nonnull->tag) {
@@ -582,6 +592,7 @@ PUREFUNC size_t type_align(type_t *t)
case FunctionType: return __alignof__(void*);
case ClosureType: return __alignof__(struct {void *fn, *userdata;});
case PointerType: return __alignof__(void*);
+ case MutexedType: return __alignof__(MutexedData_t);
case OptionalType: {
type_t *nonnull = Match(t, OptionalType)->type;
switch (nonnull->tag) {