Checkpoints cannot handle overloaded names

When a field is processed in a class it is added to a list.  This list
will contain the fields from base classes the current class inherits
from.  We check the list of fields we inherited, if we find that the
current field overloads the name of an inherited field we adjust the
inherited field's name to be shown as the fully qualified name in io_src
code.

Fixes #31
This commit is contained in:
Alex Lin 2015-03-25 15:58:33 -05:00
parent 2fa76ce704
commit 3e0abdddc5

View File

@ -28,6 +28,19 @@ ClassValues::~ClassValues() {
void ClassValues::addFieldDescription(FieldDescription * in_fdes) {
field_descripts.push_back(in_fdes) ;
// Test to see if the new field overloads a field of the same name. If it does
// then fully qualify the name of the inherited field (the one already in field_name_to_info).
std::map< std::string , FieldDescription * >::iterator mit = field_name_to_info_map.find(in_fdes->getName()) ;
if ( mit != field_name_to_info_map.end() ) {
// If the matched variable is inherited, qualify it with its container class name.
if ( (*mit).second->isInherited() ) {
(*mit).second->setName( (*mit).second->getContainerClass() + "::" + (*mit).second->getName() ) ;
field_name_to_info_map[(*mit).second->getName()] = (*mit).second ;
field_name_to_info_map.erase(mit) ;
}
}
field_name_to_info_map[in_fdes->getName()] = in_fdes ;
}