diff options
| author | gingerBill <bill@gingerbill.org> | 2021-07-10 23:51:37 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-07-10 23:51:37 +0100 |
| commit | d9e6ade03007f4ede6471a6ada23b2469e2f052d (patch) | |
| tree | ef13bc1d0b2b547abb3403c1f0e48226910c6ecc /src/types.cpp | |
| parent | 690374d4dec42365fd28cd6f9f1361697fdd7b9f (diff) | |
Add experimental support for a threaded semantic checker to `-threaded-checker`
Diffstat (limited to 'src/types.cpp')
| -rw-r--r-- | src/types.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/types.cpp b/src/types.cpp index 5f6fdbb34..dac2632a9 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -661,6 +661,8 @@ gb_global Type *t_map_header = nullptr; gb_global Type *t_equal_proc = nullptr; gb_global Type *t_hasher_proc = nullptr; +gb_global gbMutex g_type_mutex; + i64 type_size_of (Type *t); i64 type_align_of (Type *t); @@ -674,6 +676,10 @@ bool is_type_pointer(Type *t); bool is_type_slice(Type *t); bool is_type_integer(Type *t); +void init_type_mutex(void) { + gb_mutex_init(&g_type_mutex); +} + bool type_ptr_set_exists(PtrSet<Type *> *s, Type *t) { if (ptr_set_exists(s, t)) { return true; @@ -2727,7 +2733,7 @@ void type_path_print_illegal_cycle(TypePath *tp, isize start_index) { GB_ASSERT(start_index < tp->path.count); Entity *e = tp->path[start_index]; GB_ASSERT(e != nullptr); - error(e->token, "Illegal declaration cycle of `%.*s`", LIT(e->token.string)); + error(e->token, "Illegal type declaration cycle of `%.*s`", LIT(e->token.string)); // NOTE(bill): Print cycle, if it's deep enough for (isize j = start_index; j < tp->path.count; j++) { Entity *e = tp->path[j]; @@ -2844,6 +2850,8 @@ i64 type_align_of_internal(Type *t, TypePath *path) { if (t->failure) { return FAILURE_ALIGNMENT; } + gb_mutex_lock(&g_type_mutex); + defer (gb_mutex_unlock(&g_type_mutex)); t = base_type(t); @@ -3038,6 +3046,9 @@ Array<i64> type_set_offsets_of(Array<Entity *> const &fields, bool is_packed, bo } bool type_set_offsets(Type *t) { + gb_mutex_lock(&g_type_mutex); + defer (gb_mutex_unlock(&g_type_mutex)); + t = base_type(t); if (t->kind == Type_Struct) { if (!t->Struct.are_offsets_set) { @@ -3066,6 +3077,9 @@ i64 type_size_of_internal(Type *t, TypePath *path) { if (t->failure) { return FAILURE_SIZE; } + gb_mutex_lock(&g_type_mutex); + defer (gb_mutex_unlock(&g_type_mutex)); + switch (t->kind) { case Type_Named: { |