aboutsummaryrefslogtreecommitdiff
path: root/src/name_canonicalization.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2025-02-18 13:31:34 +0000
committergingerBill <bill@gingerbill.org>2025-02-18 13:31:34 +0000
commit19b59461b04f4b6b63fa24d70e9c9376b3dd3249 (patch)
tree0d88108de7e47e98d3033dfe34f93fb932711fa5 /src/name_canonicalization.cpp
parent721bcf2249fe2f2f6dd462833fede983205d6c5a (diff)
Use `TypeSet` for DeclInfo deps
Diffstat (limited to 'src/name_canonicalization.cpp')
-rw-r--r--src/name_canonicalization.cpp37
1 files changed, 7 insertions, 30 deletions
diff --git a/src/name_canonicalization.cpp b/src/name_canonicalization.cpp
index de35312da..ef0e23f38 100644
--- a/src/name_canonicalization.cpp
+++ b/src/name_canonicalization.cpp
@@ -57,11 +57,10 @@ gb_internal GB_COMPARE_PROC(type_info_pair_cmp) {
return x->hash < y->hash ? -1 : +1;
}
-static constexpr u64 TYPE_SET_TOMBSTONE = ~(u64)(0ull);
-
gb_internal void type_set_init (TypeSet *s, isize capacity);
gb_internal void type_set_destroy(TypeSet *s);
gb_internal Type *type_set_add (TypeSet *s, Type *ptr);
+gb_internal Type *type_set_add (TypeSet *s, TypeInfoPair pair);
gb_internal bool type_set_update (TypeSet *s, Type *ptr); // returns true if it previously existed
gb_internal bool type_set_update (TypeSet *s, TypeInfoPair pair); // returns true if it previously existed
gb_internal bool type_set_exists (TypeSet *s, Type *ptr);
@@ -73,34 +72,6 @@ gb_internal gbAllocator type_set_allocator(void) {
return heap_allocator();
}
-struct TypeSetIterator {
- TypeSet *set;
- usize index;
-
- TypeSetIterator &operator++() noexcept {
- for (;;) {
- ++index;
- if (set->capacity == index) {
- return *this;
- }
- TypeInfoPair key = set->keys[index];
- if (key.hash != 0 && key.hash != TYPE_SET_TOMBSTONE) {
- return *this;
- }
- }
- }
-
- bool operator==(TypeSetIterator const &other) const noexcept {
- return this->set == other.set && this->index == other.index;
- }
-
-
- operator TypeInfoPair *() const {
- return &set->keys[index];
- }
-};
-
-
gb_internal TypeSetIterator begin(TypeSet &set) noexcept {
usize index = 0;
while (index < set.capacity) {
@@ -257,6 +228,12 @@ gb_internal Type *type_set_add(TypeSet *s, Type *ptr) {
return ptr;
}
+gb_internal Type *type_set_add(TypeSet *s, TypeInfoPair pair) {
+ type_set_update(s, pair);
+ return pair.type;
+}
+
+
gb_internal void type_set_remove(TypeSet *s, Type *ptr) {
isize index = type_set__find(s, ptr);