diff options
| -rw-r--r-- | scope.c | 19 | ||||
| -rw-r--r-- | test/fibonacci2.c | 8 |
2 files changed, 15 insertions, 12 deletions
@@ -12,10 +12,6 @@ static void scope_init(struct scope* scope) { scope->var_cap = DEFAULT_SIZE; } -static void type_destroy(struct type_def* type) { - free(type->key.name); -} - static void var_destroy(struct var_def* var) { free(var->name); } @@ -23,7 +19,6 @@ static void var_destroy(struct var_def* var) { void scope_destroy(struct scope* scope) { for (unsigned long long i = 0; i < scope->type_cap; i++) { if (scope->types[i] != NULL) { - type_destroy(scope->types[i]); free(scope->types[i]); } } @@ -164,7 +159,7 @@ void scope_install_default_types(struct ast* ast) { /* TODO: don't let people make void variables */ ast->void_type = scope_define_type(ast->root_scope, (struct type_def) { .key = { - .name = strdup("void"), + .name = "void", .how_long = 0, .marked_signed = false, .marked_unsigned = false, @@ -176,7 +171,7 @@ void scope_install_default_types(struct ast* ast) { ast->char_type = scope_define_type(ast->root_scope, (struct type_def) { .key = { - .name = strdup("char"), + .name = "char", .how_long = 0, .marked_signed = false, .marked_unsigned = false, @@ -188,7 +183,7 @@ void scope_install_default_types(struct ast* ast) { scope_define_type(ast->root_scope, (struct type_def) { .key = { - .name = strdup("short"), + .name = "short", .how_long = 0, .marked_signed = false, .marked_unsigned = false, @@ -200,7 +195,7 @@ void scope_install_default_types(struct ast* ast) { scope_define_type(ast->root_scope, (struct type_def) { .key = { - .name = strdup("int"), + .name = "int", .how_long = 0, .marked_signed = false, .marked_unsigned = false, @@ -212,7 +207,7 @@ void scope_install_default_types(struct ast* ast) { ast->integral_type = scope_define_type(ast->root_scope, (struct type_def) { .key = { - .name = strdup("int"), + .name = "int", .how_long = 1, .marked_signed = false, .marked_unsigned = false, @@ -225,7 +220,7 @@ void scope_install_default_types(struct ast* ast) { scope_define_type(ast->root_scope, (struct type_def) { .key = { - .name = strdup("float"), + .name = "float", .how_long = 0, .marked_signed = false, .marked_unsigned = false, @@ -237,7 +232,7 @@ void scope_install_default_types(struct ast* ast) { ast->decimal_type = scope_define_type(ast->root_scope, (struct type_def) { .key = { - .name = strdup("double"), + .name = "double", .how_long = 0, .marked_signed = false, .marked_unsigned = false, diff --git a/test/fibonacci2.c b/test/fibonacci2.c new file mode 100644 index 0000000..b8adb9a --- /dev/null +++ b/test/fibonacci2.c @@ -0,0 +1,8 @@ +int main (int argc, char** argv) { + int n = argc; + int result = 1; + for (; n; n = n - 1) { + result = result * n; + } + return result; +} |
