aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKimplul <kimi.h.kuparinen@gmail.com>2025-03-22 16:55:57 +0200
committerKimplul <kimi.h.kuparinen@gmail.com>2025-03-22 16:55:57 +0200
commit0db19dcfafe5b2b3cbebaec9098ec50b9d6b1102 (patch)
tree0314951c6082354bce47f7d2da4c55736dd53705 /include
parent7b5abecd2bef6b7441b0d850f95d451b441a6f76 (diff)
downloadek-0db19dcfafe5b2b3cbebaec9098ec50b9d6b1102.tar.gz
ek-0db19dcfafe5b2b3cbebaec9098ec50b9d6b1102.zip
use new hashmap
Diffstat (limited to 'include')
-rw-r--r--include/ek/scope.h24
1 files changed, 16 insertions, 8 deletions
diff --git a/include/ek/scope.h b/include/ek/scope.h
index 8c56640..d09c086 100644
--- a/include/ek/scope.h
+++ b/include/ek/scope.h
@@ -11,6 +11,7 @@
*/
#include <string.h>
+#include <stdint.h>
#include "ast.h"
#include "debug.h"
@@ -25,13 +26,10 @@ enum scope_flags {
SCOPE_ROOT = (1 << 2)
};
-struct visible_tuple {
- struct ast *def;
-};
-
#define MAP_KEY char *
#define MAP_TYPE struct ast *
#define MAP_CMP(a, b) strcmp((a), (b))
+#define MAP_HASH(a) CONTS_MAP_STR_HASH(a)
#define MAP_NAME visible
#include <conts/map.h>
@@ -50,16 +48,26 @@ static inline int expanded_key_cmp(struct expanded_key a, struct expanded_key b)
return !type_lists_match(a.types, b.types);
}
+static inline size_t expanded_key_hash(struct expanded_key a)
+{
+ return (uintptr_t)a.def;
+}
+
#define MAP_KEY struct expanded_key
#define MAP_TYPE struct ast *
#define MAP_CMP(a, b) expanded_key_cmp((a), (b))
+#define MAP_HASH(a) expanded_key_hash(a)
#define MAP_NAME expanded
#include <conts/map.h>
-#define SPTREE_TYPE struct ast *
-#define SPTREE_CMP(a, b) ((uintptr_t)(a) - (uintptr_t)(b))
-#define SPTREE_NAME exported
-#include <conts/sptree.h>
+/* use map like set, could maybe be added to conts directly with some
+ * convenience wrappers? */
+#define MAP_KEY struct ast *
+#define MAP_TYPE struct ast *
+#define MAP_CMP(a, b) ((uintptr_t)(a) - (uintptr_t)(b))
+#define MAP_HASH(a) ((uintptr_t)(a))
+#define MAP_NAME exported
+#include <conts/map.h>
/**
* Scope.