TSymbolTableLevel* TSymbolTableLevel::clone() const { TSymbolTableLevel *symTableLevel = new TSymbolTableLevel(); symTableLevel->anonId = anonId; symTableLevel->thisLevel = thisLevel; std::vector<bool> containerCopied(anonId, false); tLevel::const_iterator iter; for (iter = level.begin(); iter != level.end(); ++iter) { const TAnonMember* anon = iter->second->getAsAnonMember(); if (anon) { // Insert all the anonymous members of this same container at once, // avoid inserting the other members in the future, once this has been done, // allowing them to all be part of the same new container. if (! containerCopied[anon->getAnonId()]) { TVariable* container = anon->getAnonContainer().clone(); container->changeName(NewPoolTString("")); // insert the whole container symTableLevel->insert(*container, false); containerCopied[anon->getAnonId()] = true; } } else symTableLevel->insert(*iter->second->clone(), false); } return symTableLevel; }
TSymbolTableLevel* TSymbolTableLevel::clone(TStructureMap& remapper) { TSymbolTableLevel *symTableLevel = new TSymbolTableLevel(); symTableLevel->anonId = anonId; tLevel::iterator iter; for (iter = level.begin(); iter != level.end(); ++iter) symTableLevel->insert(*iter->second->clone(remapper)); return symTableLevel; }