summaryrefslogtreecommitdiff
path: root/scope.h
diff options
context:
space:
mode:
authorCarson Fleming <cflems@cflems.net>2026-07-17 12:40:59 -0700
committerCarson Fleming <cflems@cflems.net>2026-07-17 12:40:59 -0700
commit424be65858999a894a18e1972fa9649fbc4c1df8 (patch)
treea878fe623546a2e3fcaf204d5977991995b21c3c /scope.h
parent155d1971b7cd56d3206808c36c6b40357bc31cbb (diff)
downloadccc-424be65858999a894a18e1972fa9649fbc4c1df8.tar.gz
improve type system sorta
Diffstat (limited to 'scope.h')
-rw-r--r--scope.h31
1 files changed, 21 insertions, 10 deletions
diff --git a/scope.h b/scope.h
index dfbb2c1..1d3c8ac 100644
--- a/scope.h
+++ b/scope.h
@@ -7,6 +7,8 @@ struct storage_location {
STO_LABEL,
STO_STACK,
STO_IMM,
+ /* I would like to solve functions using the type system
+ * and kill STO_FN and STO_UNRESOLVED in favor of STO_LABEL. */
STO_FN,
STO_UNRESOLVED,
} type;
@@ -19,17 +21,24 @@ struct storage_location {
};
};
+struct type_key {
+ char* name;
+ unsigned char how_long;
+ bool marked_unsigned;
+ bool marked_signed;
+};
+
struct type_def {
- const char* name;
- unsigned long long sz;
- bool is_primitive;
+ struct type_key key;
bool is_signed;
+ bool is_floating;
+ unsigned long long sz;
};
struct var_def {
- const char* name;
+ char* name;
struct storage_location loc;
- unsigned long long sz;
+ const struct type_def* resolved_type;
};
struct scope {
@@ -51,13 +60,15 @@ void scope_destroy(struct scope* scope);
void scope_install_default_types(struct scope* 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);
+ const struct type_def** p_entry,
+ const struct type_key* key);
+const struct type_def* scope_define_type(
+ struct scope* scope,
+ struct type_def type);
bool scope_get_var(
const struct scope* scope,
- struct var_def* p_entry,
+ struct var_def** p_entry,
const char* name);
-void scope_define_var(struct scope* scope, struct var_def var);
+struct var_def* scope_define_var(struct scope* scope, struct var_def var);
#endif \ No newline at end of file