diff options
| author | Carson Fleming <cflems@cflems.net> | 2026-07-17 00:38:51 -0400 |
|---|---|---|
| committer | Carson Fleming <cflems@cflems.net> | 2026-07-17 00:38:51 -0400 |
| commit | a5c12fd6f4438fc172f28b722e54908b575c6ce1 (patch) | |
| tree | 5f9b2d48681e02d392567eb8798ba614cb96bfbd /scope.c | |
| parent | 1dfa2971999b4adf36a33866b0b07af07188da08 (diff) | |
| download | ccc-a5c12fd6f4438fc172f28b722e54908b575c6ce1.tar.gz | |
before I do something crazy
Diffstat (limited to 'scope.c')
| -rw-r--r-- | scope.c | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -11,7 +11,7 @@ static void scope_init(struct scope* scope) { scope->var_cap = DEFAULT_SIZE; } -static void scope_destroy(struct scope* scope) { +void scope_destroy(struct scope* scope) { for (unsigned long long i = 0; i < scope->type_cap; i++) { if (scope->types[i] != NULL) free(scope->types[i]); } @@ -113,44 +113,57 @@ void scope_push(struct scope** p_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); } void scope_install_default_types(struct scope* scope) { scope_define_type(scope, (struct type_def) { .name = "void", .sz = 0, + .is_primitive = true, + .is_signed = false, }); scope_define_type(scope, (struct type_def) { .name = "bool", .sz = 1, + .is_primitive = true, + .is_signed = false, }); scope_define_type(scope, (struct type_def) { .name = "char", .sz = 1, + .is_primitive = true, + .is_signed = true, /* implementation defined babyyyyyy */ }); scope_define_type(scope, (struct type_def) { .name = "short", .sz = 2, + .is_primitive = true, + .is_signed = true, }); scope_define_type(scope, (struct type_def) { .name = "int", .sz = 4, + .is_primitive = true, + .is_signed = true, }); scope_define_type(scope, (struct type_def) { .name = "float", .sz = 4, + .is_primitive = true, + .is_signed = true, /* floats can't be unsigned but wtv */ }); scope_define_type(scope, (struct type_def) { .name = "long", .sz = 8, + .is_primitive = true, + .is_signed = true, }); scope_define_type(scope, (struct type_def) { .name = "double", .sz = 8, + .is_primitive = true, + .is_signed = true, /* doubles also can't be unsigned */ }); } |
