diff options
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 */ }); } |
