summaryrefslogtreecommitdiff
path: root/scope.c
diff options
context:
space:
mode:
authorCarson Fleming <[email protected]>2026-03-26 19:46:35 -0700
committerCarson Fleming <[email protected]>2026-03-26 19:46:35 -0700
commit28157efe6ef65394d8930a79200b9243ee919f47 (patch)
tree5dd492ae8d27e99d066b88e76f5304fad270ee11 /scope.c
parent2e4f713ede25fb6147571858779fde542144c76f (diff)
downloadccc-28157efe6ef65394d8930a79200b9243ee919f47.tar.gz
mostly there except need to implement one more hash map
Diffstat (limited to 'scope.c')
-rw-r--r--scope.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/scope.c b/scope.c
new file mode 100644
index 0000000..076f1a6
--- /dev/null
+++ b/scope.c
@@ -0,0 +1,42 @@
+#include "scope.h"
+#include <stdlib.h>
+
+static void scope_init(struct scope* scope) {}
+
+static void scope_destroy(struct scope* scope) {}
+
+unsigned long long hash_name(const char* name) {
+ unsigned long long hash = 0, i = 0;
+ while (name[i] != 0) hash = (hash << 5) - hash + name[i++];
+ return hash;
+}
+
+void scope_push(struct scope** p_scope) {
+ struct scope* inner_scope = calloc(1, sizeof(struct scope));
+ scope_init(inner_scope);
+ inner_scope->next_out = *p_scope;
+ *p_scope = inner_scope;
+}
+
+void scope_pop(struct scope** p_scope) {
+ struct scope* discarded_scope = *p_scope;
+ *p_scope = (*p_scope)->next_out;
+ scope_destroy(discarded_scope);
+ free(discarded_scope);
+}
+
+bool scope_get_type(
+ const struct scope* scope,
+ struct type_def* p_entry,
+ const char* name
+) {}
+
+void scope_define_type(struct scope* scope, struct type_def type) {}
+
+bool scope_get_var(
+ const struct scope* scope,
+ struct var_def* p_entry,
+ const char* name
+) {}
+
+void scope_define_var(struct scope* scope, struct var_def var) {}