# HG changeset patch # User Mario de Sousa # Date 1352395910 0 # Node ID 5dc33058e0415eb293c39fb9d360f2614de7aeb6 # Parent f637ac331a68e1f1bb23195482a047ff7d44a02c Fix counting bug in dsymbtable_c diff -r f637ac331a68 -r 5dc33058e041 stage4/generate_c/generate_c_il.cc --- a/stage4/generate_c/generate_c_il.cc Thu Nov 08 17:31:29 2012 +0000 +++ b/stage4/generate_c/generate_c_il.cc Thu Nov 08 17:31:50 2012 +0000 @@ -847,8 +847,8 @@ } /* Check whether we are calling an overloaded function! */ - /* (fdecl_mutiplicity==2) => calling overloaded function */ - int fdecl_mutiplicity = function_symtable.multiplicity(symbol->function_name); + /* (fdecl_mutiplicity > 1) => calling overloaded function */ + int fdecl_mutiplicity = function_symtable.count(symbol->function_name); if (fdecl_mutiplicity == 0) ERROR; this->implicit_variable_result.accept(*this); @@ -868,7 +868,7 @@ fbname->accept(*this); s4o.print("_"); function_name->accept(*this); - if (fdecl_mutiplicity == 2) { + if (fdecl_mutiplicity > 1) { /* function being called is overloaded! */ s4o.print("__"); print_function_parameter_data_types_c overloaded_func_suf(&s4o); @@ -879,7 +879,7 @@ else { if (function_name != NULL) { function_name->accept(*this); - if (fdecl_mutiplicity == 2) { + if (fdecl_mutiplicity > 1) { /* function being called is overloaded! */ s4o.print("__"); print_function_parameter_data_types_c overloaded_func_suf(&s4o); @@ -1234,8 +1234,8 @@ } /* Check whether we are calling an overloaded function! */ - /* (fdecl_mutiplicity==2) => calling overloaded function */ - int fdecl_mutiplicity = function_symtable.multiplicity(symbol->function_name); + /* (fdecl_mutiplicity > 1) => calling overloaded function */ + int fdecl_mutiplicity = function_symtable.count(symbol->function_name); if (fdecl_mutiplicity == 0) ERROR; if (fdecl_mutiplicity == 1) /* function being called is NOT overloaded! */ @@ -1258,7 +1258,7 @@ fbname->accept(*this); s4o.print("_"); function_name->accept(*this); - if (fdecl_mutiplicity == 2) { + if (fdecl_mutiplicity > 1) { /* function being called is overloaded! */ s4o.print("__"); print_function_parameter_data_types_c overloaded_func_suf(&s4o); @@ -1269,7 +1269,7 @@ else { if (function_name != NULL) { function_name->accept(*this); - if (fdecl_mutiplicity == 2) { + if (fdecl_mutiplicity > 1) { /* function being called is overloaded! */ s4o.print("__"); print_function_parameter_data_types_c overloaded_func_suf(&s4o); diff -r f637ac331a68 -r 5dc33058e041 stage4/generate_c/generate_c_inlinefcall.cc --- a/stage4/generate_c/generate_c_inlinefcall.cc Thu Nov 08 17:31:29 2012 +0000 +++ b/stage4/generate_c/generate_c_inlinefcall.cc Thu Nov 08 17:31:50 2012 +0000 @@ -527,8 +527,8 @@ } /* Check whether we are calling an overloaded function! */ - /* (fdecl_mutiplicity==2) => calling overloaded function */ - int fdecl_mutiplicity = function_symtable.multiplicity(symbol->function_name); + /* (fdecl_mutiplicity > 1) => calling overloaded function */ + int fdecl_mutiplicity = function_symtable.count(symbol->function_name); if (fdecl_mutiplicity == 0) ERROR; if (fdecl_mutiplicity == 1) /* function being called is NOT overloaded! */ @@ -684,8 +684,8 @@ } /* Check whether we are calling an overloaded function! */ - /* (fdecl_mutiplicity==2) => calling overloaded function */ - int fdecl_mutiplicity = function_symtable.multiplicity(symbol->function_name); + /* (fdecl_mutiplicity > 1) => calling overloaded function */ + int fdecl_mutiplicity = function_symtable.count(symbol->function_name); if (fdecl_mutiplicity == 0) ERROR; if (fdecl_mutiplicity == 1) /* function being called is NOT overloaded! */ @@ -846,8 +846,8 @@ } /* Check whether we are calling an overloaded function! */ - /* (fdecl_mutiplicity==2) => calling overloaded function */ - int fdecl_mutiplicity = function_symtable.multiplicity(symbol->function_name); + /* (fdecl_mutiplicity > 1) => calling overloaded function */ + int fdecl_mutiplicity = function_symtable.count(symbol->function_name); if (fdecl_mutiplicity == 0) ERROR; if (fdecl_mutiplicity == 1) /* function being called is NOT overloaded! */ diff -r f637ac331a68 -r 5dc33058e041 stage4/generate_c/generate_c_st.cc --- a/stage4/generate_c/generate_c_st.cc Thu Nov 08 17:31:29 2012 +0000 +++ b/stage4/generate_c/generate_c_st.cc Thu Nov 08 17:31:50 2012 +0000 @@ -711,8 +711,8 @@ } /* Check whether we are calling an overloaded function! */ - /* (fdecl_mutiplicity==2) => calling overloaded function */ - int fdecl_mutiplicity = function_symtable.multiplicity(symbol->function_name); + /* (fdecl_mutiplicity > 1) => calling overloaded function */ + int fdecl_mutiplicity = function_symtable.count(symbol->function_name); if (fdecl_mutiplicity == 0) ERROR; if (has_output_params) { @@ -721,7 +721,7 @@ fbname->accept(*this); s4o.print("_"); function_name->accept(*this); - if (fdecl_mutiplicity == 2) { + if (fdecl_mutiplicity > 1) { /* function being called is overloaded! */ s4o.print("__"); print_function_parameter_data_types_c overloaded_func_suf(&s4o); @@ -731,7 +731,7 @@ } else { function_name->accept(*this); - if (fdecl_mutiplicity == 2) { + if (fdecl_mutiplicity > 1) { /* function being called is overloaded! */ s4o.print("__"); print_function_parameter_data_types_c overloaded_func_suf(&s4o); diff -r f637ac331a68 -r 5dc33058e041 util/dsymtable.cc --- a/util/dsymtable.cc Thu Nov 08 17:31:29 2012 +0000 +++ b/util/dsymtable.cc Thu Nov 08 17:31:50 2012 +0000 @@ -37,9 +37,6 @@ - - - /* clear all entries... */ template void dsymtable_c::reset(void) { @@ -88,26 +85,6 @@ -/* Determine how many entries are associated to key identifier_str */ -/* returns: - * 0: if no entry is found - * 1: if 1 entry is found - * 2: if more than 1 entry is found - */ -template -int dsymtable_c::multiplicity(const char *identifier_str) { - iterator lower = _base.lower_bound(identifier_str); - if (lower == _base.end()) return 0; - - iterator upper = _base.upper_bound(identifier_str); - iterator second = lower; - second++; - - if (second == upper) return 1; - - return 2; -} - /* returns null_value if not found! */ template diff -r f637ac331a68 -r 5dc33058e041 util/dsymtable.hh --- a/util/dsymtable.hh Thu Nov 08 17:31:29 2012 +0000 +++ b/util/dsymtable.hh Thu Nov 08 17:31:50 2012 +0000 @@ -77,26 +77,23 @@ typedef typename base_t::const_reverse_iterator const_reverse_iterator; private: - void reset(void); /* clear all entries... */ const char *symbol_to_string(const symbol_c *symbol); public: dsymtable_c(void) {}; + void reset(void); /* clear all entries... */ + void insert(const char *identifier_str, value_t value); void insert(const symbol_c *symbol, value_t value); /* Determine how many entries are associated to key identifier_str */ - /* returns: - * 0: if no entry is found - * 1: if 1 entry is found - * 2: if more than 1 entry is found - */ - int multiplicity(const char *identifier_str); - int multiplicity(const symbol_c *symbol) {return multiplicity(symbol_to_string(symbol));} + /* returns: 0 if no entry is found, 1 if 1 entry is found, ..., n if n entries are found */ + 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 end_value(void) {return _base.end(); 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));}