|
|
|
@@ -13,6 +13,7 @@ void print_symbol_table(void); |
|
|
|
void print_symbols(void); |
|
|
|
void print_bindings(node_t *root); |
|
|
|
void destroy_symbol_table(void); |
|
|
|
void tlhash_insert_symbol(tlhash_t *tab, symbol_t *symbol); |
|
|
|
void find_globals(void); |
|
|
|
void bind_names(symbol_t *function, node_t *root); |
|
|
|
void destroy_symtab(void); |
|
|
|
@@ -141,6 +142,11 @@ destroy_symbol_table ( void ) |
|
|
|
destroy_symtab(); |
|
|
|
} |
|
|
|
|
|
|
|
// Helper function |
|
|
|
void tlhash_insert_symbol(tlhash_t *tab, symbol_t *symbol) |
|
|
|
{ |
|
|
|
tlhash_insert(tab, symbol->name, strlen(symbol->name), symbol); |
|
|
|
} |
|
|
|
|
|
|
|
void |
|
|
|
find_globals ( void ) |
|
|
|
@@ -174,7 +180,7 @@ find_globals ( void ) |
|
|
|
parameter_symbol->node = parameter; |
|
|
|
parameter_symbol->seq = j; |
|
|
|
|
|
|
|
tlhash_insert(symbol->locals, parameter_symbol->name, strlen(parameter_symbol->name), parameter_symbol); |
|
|
|
tlhash_insert_symbol(symbol->locals, parameter_symbol); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// The node should be a variable or a function. |
|
|
|
@@ -182,13 +188,17 @@ find_globals ( void ) |
|
|
|
exit(1); |
|
|
|
} |
|
|
|
|
|
|
|
tlhash_insert(global_names, symbol->name, strlen(symbol->name), symbol); |
|
|
|
tlhash_insert_symbol(global_names, symbol); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void |
|
|
|
bind_names ( symbol_t *function, node_t *root ) |
|
|
|
{ |
|
|
|
// Go through variable list, add to local scope |
|
|
|
// Go through rest of function |
|
|
|
// Replace variable references with pointers to the symbol table |
|
|
|
// put strings in the symbol table, and increment root->data = stringc |
|
|
|
} |
|
|
|
|
|
|
|
void |
|
|
|
|