diff options
Diffstat (limited to 'scope.c')
| -rw-r--r-- | scope.c | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -1,4 +1,5 @@ #include "scope.h" +#include "ast.h" #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -159,9 +160,9 @@ void scope_pop(struct scope** p_scope) { *p_scope = (*p_scope)->next_out; } -void scope_install_default_types(struct scope* scope) { +void scope_install_default_types(struct ast* ast) { /* TODO: don't let people make void variables */ - scope_define_type(scope, (struct type_def) { + ast->void_type = scope_define_type(ast->root_scope, (struct type_def) { .key = { .name = strdup("void"), .how_long = 0, @@ -173,7 +174,7 @@ void scope_install_default_types(struct scope* scope) { .sz = 0, }); - scope_define_type(scope, (struct type_def) { + ast->char_type = scope_define_type(ast->root_scope, (struct type_def) { .key = { .name = strdup("char"), .how_long = 0, @@ -185,7 +186,7 @@ void scope_install_default_types(struct scope* scope) { .is_floating = false, }); - scope_define_type(scope, (struct type_def) { + scope_define_type(ast->root_scope, (struct type_def) { .key = { .name = strdup("short"), .how_long = 0, @@ -197,7 +198,7 @@ void scope_install_default_types(struct scope* scope) { .is_floating = false, }); - scope_define_type(scope, (struct type_def) { + scope_define_type(ast->root_scope, (struct type_def) { .key = { .name = strdup("int"), .how_long = 0, @@ -209,7 +210,7 @@ void scope_install_default_types(struct scope* scope) { .is_floating = false, }); - scope_define_type(scope, (struct type_def) { + ast->integral_type = scope_define_type(ast->root_scope, (struct type_def) { .key = { .name = strdup("int"), .how_long = 1, @@ -220,8 +221,9 @@ void scope_install_default_types(struct scope* scope) { .is_signed = true, .is_floating = false, }); + ast->string_type = ast->integral_type; /* TODO: support pointers */ - scope_define_type(scope, (struct type_def) { + scope_define_type(ast->root_scope, (struct type_def) { .key = { .name = strdup("float"), .how_long = 0, @@ -233,7 +235,7 @@ void scope_install_default_types(struct scope* scope) { .is_floating = true, }); - scope_define_type(scope, (struct type_def) { + ast->decimal_type = scope_define_type(ast->root_scope, (struct type_def) { .key = { .name = strdup("double"), .how_long = 0, |
