Skip to content
Snippets Groups Projects
Commit 185932ff authored by Clemens Paumgarten's avatar Clemens Paumgarten
Browse files

Merge branch 'develop' of git.uibk.ac.at:csaw2672/compiler-construction into ir

parents 188808c1 bd4c53fe
No related branches found
No related tags found
No related merge requests found
...@@ -397,6 +397,7 @@ mcc_ast_new_statement_list(struct mcc_ast_statement *statement) ...@@ -397,6 +397,7 @@ mcc_ast_new_statement_list(struct mcc_ast_statement *statement)
assert(list); assert(list);
list->statement = statement; list->statement = statement;
list->next = NULL;
return list; return list;
} }
...@@ -409,6 +410,7 @@ void mcc_ast_delete_statement_list( ...@@ -409,6 +410,7 @@ void mcc_ast_delete_statement_list(
mcc_ast_delete_statement_list(statement_list->next); mcc_ast_delete_statement_list(statement_list->next);
} }
mcc_ast_delete_statement(statement_list->statement); mcc_ast_delete_statement(statement_list->statement);
free(statement_list);
} }
struct mcc_ast_statement * struct mcc_ast_statement *
......
...@@ -20,6 +20,7 @@ struct mcc_symbol *mcc_symbol_new_symbol_variable(char* variable_name, enum mcc_ ...@@ -20,6 +20,7 @@ struct mcc_symbol *mcc_symbol_new_symbol_variable(char* variable_name, enum mcc_
symbol -> variable_name = variable_name; symbol -> variable_name = variable_name;
symbol -> data_type = data_type; symbol -> data_type = data_type;
symbol -> symbol_type = MCC_SYMBOL_TYPE_VARIABLE; symbol -> symbol_type = MCC_SYMBOL_TYPE_VARIABLE;
symbol -> func_arguments = NULL;
return symbol; return symbol;
} }
...@@ -32,6 +33,7 @@ struct mcc_symbol *mcc_symbol_new_symbol_array(char* variable_name, enum mcc_ast ...@@ -32,6 +33,7 @@ struct mcc_symbol *mcc_symbol_new_symbol_array(char* variable_name, enum mcc_ast
symbol -> variable_name = variable_name; symbol -> variable_name = variable_name;
symbol -> data_type = data_type; symbol -> data_type = data_type;
symbol -> array_size = array_size; symbol -> array_size = array_size;
symbol -> func_arguments = NULL;
return symbol; return symbol;
} }
...@@ -68,7 +70,7 @@ void mcc_symbol_delete_symbol(void *symbol) { ...@@ -68,7 +70,7 @@ void mcc_symbol_delete_symbol(void *symbol) {
struct mcc_symbol *s = (struct mcc_symbol *) symbol; struct mcc_symbol *s = (struct mcc_symbol *) symbol;
if (s != NULL) { if (s != NULL) {
if (s -> func_arguments) { if (s -> func_arguments != NULL) {
mcc_delete_array(s ->func_arguments, NULL); mcc_delete_array(s ->func_arguments, NULL);
} }
} }
...@@ -81,7 +83,7 @@ struct mcc_symbol_table *mcc_symbol_table_new_table( ...@@ -81,7 +83,7 @@ struct mcc_symbol_table *mcc_symbol_table_new_table(
struct mcc_symbol_table *table = malloc(sizeof(*table)); struct mcc_symbol_table *table = malloc(sizeof(*table));
table ->inner_tables = mcc_create_dynamic_array(MCC_SYMBOL_TABLE_CHILDREN_SIZE); table -> inner_tables = mcc_create_dynamic_array(MCC_SYMBOL_TABLE_CHILDREN_SIZE);
table -> symbols = mcc_create_dynamic_array(MCC_SYMBOL_TABLE_SYMBOL_SIZE); table -> symbols = mcc_create_dynamic_array(MCC_SYMBOL_TABLE_SYMBOL_SIZE);
table -> parent = parent; table -> parent = parent;
...@@ -89,12 +91,13 @@ struct mcc_symbol_table *mcc_symbol_table_new_table( ...@@ -89,12 +91,13 @@ struct mcc_symbol_table *mcc_symbol_table_new_table(
} }
void mcc_symbol_table_delete_table(void *table) { void mcc_symbol_table_delete_table(void *table) {
struct mcc_symbol_table *st = (struct mcc_symbol_table *) table;
// Delete symbols // Delete symbols
assert(table); assert(table);
struct mcc_symbol_table *st = (struct mcc_symbol_table *) table;
mcc_delete_array(st -> symbols, mcc_symbol_delete_symbol); mcc_delete_array(st -> symbols, mcc_symbol_delete_symbol);
mcc_delete_array(st ->inner_tables, mcc_symbol_table_delete_table); mcc_delete_array(st -> inner_tables, mcc_symbol_table_delete_table);
free(table); free(table);
} }
...@@ -123,7 +126,6 @@ int mcc_symbol_table_insert_symbol(struct mcc_symbol_table *table, struct mcc_sy ...@@ -123,7 +126,6 @@ int mcc_symbol_table_insert_symbol(struct mcc_symbol_table *table, struct mcc_sy
assert(symbol); assert(symbol);
return mcc_add_to_array(table -> symbols, symbol); return mcc_add_to_array(table -> symbols, symbol);
} }
struct mcc_symbol *mcc_symbol_table_get_symbol(struct mcc_symbol_table *symbol_table, char *symbol_name, bool propagate) { struct mcc_symbol *mcc_symbol_table_get_symbol(struct mcc_symbol_table *symbol_table, char *symbol_name, bool propagate) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment