# HG changeset patch # User mjsousa # Date 1419588567 0 # Node ID bc90dd4bbf4feade05079d3983f527a8123dc5ae # Parent 8aee27d46208d5f0ce30f75b3250e0bb3bb03de5 Change dsymbtable_c -> use design pattern used by C++ standard library (STL) diff -r 8aee27d46208 -r bc90dd4bbf4f absyntax_utils/absyntax_utils.cc --- a/absyntax_utils/absyntax_utils.cc Fri Dec 26 09:57:02 2014 +0000 +++ b/absyntax_utils/absyntax_utils.cc Fri Dec 26 10:09:27 2014 +0000 @@ -104,8 +104,7 @@ /* A symbol table with all globally declared functions... */ -function_declaration_c null_symbol1(NULL,NULL,NULL,NULL); -dsymtable_c function_symtable; +dsymtable_c function_symtable; /* A symbol table with all globally declared functions block types... */ symtable_c function_block_type_symtable; diff -r 8aee27d46208 -r bc90dd4bbf4f absyntax_utils/absyntax_utils.hh --- a/absyntax_utils/absyntax_utils.hh Fri Dec 26 09:57:02 2014 +0000 +++ b/absyntax_utils/absyntax_utils.hh Fri Dec 26 10:09:27 2014 +0000 @@ -56,8 +56,7 @@ int compare_identifiers(symbol_c *ident1, symbol_c *ident2); /* A symbol table with all globally declared functions... */ -extern function_declaration_c null_symbol1; -typedef dsymtable_c function_symtable_t; +typedef dsymtable_c function_symtable_t; extern function_symtable_t function_symtable; /* A symbol table with all globally declared functions block types... */ diff -r 8aee27d46208 -r bc90dd4bbf4f stage3/fill_candidate_datatypes.cc --- a/stage3/fill_candidate_datatypes.cc Fri Dec 26 09:57:02 2014 +0000 +++ b/stage3/fill_candidate_datatypes.cc Fri Dec 26 10:09:27 2014 +0000 @@ -90,8 +90,7 @@ */ /* NOTE: we do not store any NULL values in this symbol table, so we can safely use NULL and the null value. */ -symbol_c null_enumvalue_symbol; /* cannot be static, so it may be used in the template!! */ -typedef dsymtable_c enumerated_value_symtable_t; +typedef dsymtable_c enumerated_value_symtable_t; static enumerated_value_symtable_t global_enumerated_value_symtable; @@ -1052,8 +1051,8 @@ enumerated_type = symbol->type; } else { - symbol_c *global_enumerated_type = global_enumerated_value_symtable.find_value (symbol->value); - symbol_c * local_enumerated_type = local_enumerated_value_symtable.find_value (symbol->value); + symbol_c *global_enumerated_type = global_enumerated_value_symtable.find (symbol->value)->second; + symbol_c * local_enumerated_type = local_enumerated_value_symtable.find (symbol->value)->second; int global_multiplicity = global_enumerated_value_symtable.count(symbol->value); int local_multiplicity = local_enumerated_value_symtable.count(symbol->value); diff -r 8aee27d46208 -r bc90dd4bbf4f util/dsymtable.cc --- a/util/dsymtable.cc Fri Dec 26 09:57:02 2014 +0000 +++ b/util/dsymtable.cc Fri Dec 26 10:09:27 2014 +0000 @@ -38,22 +38,22 @@ /* clear all entries... */ -template -void dsymtable_c::reset(void) { +template +void dsymtable_c::reset(void) { _base.clear(); } -template -void dsymtable_c::insert(const char *identifier_str, value_t new_value) { +template +void dsymtable_c::insert(const char *identifier_str, value_t new_value) { // std::cout << "store_identifier(" << identifier_str << "): \n"; std::pair new_element(identifier_str, new_value); /* iterator res = */ _base.insert(new_element); } -template -void dsymtable_c::insert(const symbol_c *symbol, value_t new_value) { +template +void dsymtable_c::insert(const symbol_c *symbol, value_t new_value) { const token_c *name = dynamic_cast(symbol); if (name == NULL) ERROR; @@ -62,8 +62,8 @@ #if 0 -template -void dsymtable_c::insert_noduplicate(const char *identifier_str, value_t new_value) { +template +void dsymtable_c::insert_noduplicate(const char *identifier_str, value_t new_value) { if (find_value(identifier_str) != null_value) /* already present in the set! */ ERROR; @@ -74,8 +74,8 @@ } -template -void dsymtable_c::insert_noduplicate(const symbol_c *symbol, value_t new_value) { +template +void dsymtable_c::insert_noduplicate(const symbol_c *symbol, value_t new_value) { const token_c *name = dynamic_cast(symbol); if (name == NULL) ERROR; @@ -86,20 +86,8 @@ -/* returns null_value if not found! */ -template -value_type dsymtable_c::find_value(const char *identifier_str) { - iterator i = _base.find(identifier_str); - - if (i == _base.end()) - return null_value; - else - return i->second; -} - - -template -const char * dsymtable_c::symbol_to_string(const symbol_c *symbol) { +template +const char * dsymtable_c::symbol_to_string(const symbol_c *symbol) { const token_c *name = dynamic_cast(symbol); if (name == NULL) ERROR; @@ -108,8 +96,8 @@ /* debuging function... */ -template -void dsymtable_c::print(void) { +template +void dsymtable_c::print(void) { for(iterator i = _base.begin(); i != _base.end(); i++) diff -r 8aee27d46208 -r bc90dd4bbf4f util/dsymtable.hh --- a/util/dsymtable.hh Fri Dec 26 09:57:02 2014 +0000 +++ b/util/dsymtable.hh Fri Dec 26 10:09:27 2014 +0000 @@ -44,7 +44,7 @@ -template class dsymtable_c { +template class dsymtable_c { /* Case insensitive string compare copied from * "The C++ Programming Language" - 3rd Edition * by Bjarne Stroustrup, ISBN 0201889544. @@ -92,11 +92,6 @@ int count(const char *identifier_str) {return _base.count(identifier_str);} int count(const symbol_c *symbol) {return count(symbol_to_string(symbol));} - /* Search for an entry. Will return end_value() if not found */ - value_t end_value(void) {return null_value;} - value_t find_value(const char *identifier_str); - value_t find_value(const symbol_c *symbol) {return find_value(symbol_to_string(symbol));} - /* Search for an entry associated with identifier_str. Will return end() if not found */ iterator find(const char *identifier_str) {return _base.find(identifier_str);} iterator find(const symbol_c *symbol) {return find(symbol_to_string(symbol));}