diff options
| author | gingerBill <bill@gingerbill.org> | 2019-10-05 10:22:41 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2019-10-05 10:22:41 +0100 |
| commit | 7fa2d25eea28955c12d8fc6a597e8615562c0ee9 (patch) | |
| tree | 5f0f8e60d3cb70652988ca35884bf8c2e1c3dad8 /src/types.cpp | |
| parent | dae514a2c99875db0dbda56309c7349a68432e19 (diff) | |
Fix #complete switch with pointer case doesn't compile #416
Diffstat (limited to 'src/types.cpp')
| -rw-r--r-- | src/types.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/types.cpp b/src/types.cpp index 94b89d8f5..d8a579510 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -551,8 +551,27 @@ i64 type_offset_of (Type *t, i32 index); gbString type_to_string (Type *type); void init_map_internal_types(Type *type); Type * bit_set_to_int(Type *t); +bool are_types_identical(Type *x, Type *y); +bool type_ptr_set_exists(PtrSet<Type *> *s, Type *t) { + if (ptr_set_exists(s, t)) { + return true; + } + + // TODO(bill, 2019-10-05): This is very slow and it's probably a lot + // faster to cache types correctly + for_array(i, s->entries) { + Type *f = s->entries[i].ptr; + if (are_types_identical(t, f)) { + ptr_set_add(s, t); + return true; + } + } + + return false; +} + Type *base_type(Type *t) { for (;;) { if (t == nullptr) { |