Skip to content

Commit

Permalink
Symbol destroy 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
limdongjin committed Apr 5, 2019
1 parent facf2b6 commit 857c335
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 24 deletions.
2 changes: 1 addition & 1 deletion assemble.c
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ error_handling_pass1or2(Statement *stmt, FILE *fp1, FILE *fp2, FILE *fp3, char *
if(rm_file_name3) remove(rm_file_name3);

if(line_num != -1 && stmt && stmt->raw_input) {
fprintf(stderr, "[ERROR] Line %d: %s \n", line_num + 5, stmt->raw_input);
fprintf(stderr, "[ERROR] Line %d: %s \n", line_num, stmt->raw_input);
}

return true;
Expand Down
1 change: 1 addition & 0 deletions state.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ bool destroy_state(State **state_store){
destroy_histories(&((*state_store)->histories_state));
destroy_memories(&((*state_store)->memories_state));
destroy_opcode_table(&(*state_store)->opcode_table_state);
destroy_symbol_table(&((*state_store)->symbol_table_state));

free(*state_store);

Expand Down
4 changes: 0 additions & 4 deletions state.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ void print_histories_state(State* state_store, char* last_command);
*/
bool assemble_file(State *state_store, char *asm_file_name);

/* PASS1 */

/* PASS2 */

bool assemble_pass1(State *state_store, char *asm_file_name);

bool assemble_pass2(State *state_store, char *asm_file_name);
Expand Down
44 changes: 25 additions & 19 deletions symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,30 @@ SymbolTable* construct_symbol_table(){
table->size = 40;
return table;
}

bool destroy_symbol_table(SymbolTable** table){
SymNode *cur;
SymNode *next;
SymLinkedList** list;
int i, j;

list = (*table)->list;
for(i=0;i<(*table)->size;i++){
cur = list[i]->head;

for(j=0;j<list[i]->size+1;j++){
next = cur->next;
free(cur->data);
free(cur);
cur = next;
}
free(list[i]);
}
free(*table);

return true;
}

SymNode* construct_symbol_node(){
SymNode* node = (SymNode*)malloc(sizeof(SymNode));

Expand Down Expand Up @@ -112,22 +136,4 @@ int symbol_comparator(const void *a, const void *b){
if(!right) return 0;

return -1*strcmp(left->label, right->label);
}

/*
* BUFFER 0036
CLOOP 0006
ENDFIL 001A
EOF 002D
EXIT 1056
FIRST 0000
INPUT 105C
LENGTH 0033
OUTPUT 1076
RDREC 1036
RETADR 0030
RLOOP 1040
WLOOP 1062
WRREC 105D
*
* */
}
2 changes: 2 additions & 0 deletions symbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ typedef struct symbol_table {

SymbolTable* construct_symbol_table();
//SymLinkedList* construct_symbol_linked_list();
bool destroy_symbol_table(SymbolTable** table);

SymNode* construct_symbol_node();
Symbol* construct_symbol();
bool insert_symbol(SymbolTable* table, Symbol* symbol);
Expand Down

0 comments on commit 857c335

Please sign in to comment.