summaryrefslogtreecommitdiff
path: root/scope.h
diff options
context:
space:
mode:
authorCarson Fleming <cflems@cflems.net>2026-03-26 19:46:35 -0700
committerCarson Fleming <cflems@cflems.net>2026-03-26 19:46:35 -0700
commit28157efe6ef65394d8930a79200b9243ee919f47 (patch)
tree5dd492ae8d27e99d066b88e76f5304fad270ee11 /scope.h
parent2e4f713ede25fb6147571858779fde542144c76f (diff)
downloadccc-28157efe6ef65394d8930a79200b9243ee919f47.tar.gz
mostly there except need to implement one more hash map
Diffstat (limited to 'scope.h')
-rw-r--r--scope.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/scope.h b/scope.h
new file mode 100644
index 0000000..b469476
--- /dev/null
+++ b/scope.h
@@ -0,0 +1,46 @@
+#ifndef VARS_H
+#define VARS_H
+
+struct storage_location {
+ enum {
+ REGISTER,
+ JMP_LABEL,
+ BP_OFFSET,
+ } type;
+ union {
+ long long offset;
+ const char* label;
+ };
+};
+
+struct type_def {
+ const char* name;
+ unsigned long long size;
+};
+
+struct var_def {
+ const char* name;
+ struct storage_location loc;
+};
+
+struct scope {
+ struct type_def* types;
+ struct var_def* vars;
+ struct scope* next_out;
+ unsigned long long bp_offset;
+};
+
+void scope_push(struct scope** p_scope);
+void scope_pop(struct scope** p_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);
+
+#endif \ No newline at end of file