| 191 | } |
| 192 | |
| 193 | void CompileDesign::collectObjects_(Design::FileIdDesignContentMap& all_files, |
| 194 | Design* design, bool finalCollection) { |
| 195 | typedef std::map<std::string, std::vector<Package*>> FileNamePackageMap; |
| 196 | FileNamePackageMap fileNamePackageMap; |
| 197 | SymbolTable* symbols = m_compiler->getSymbolTable(); |
| 198 | ErrorContainer* errors = m_compiler->getErrorContainer(); |
| 199 | // Collect all packages and module definitions |
| 200 | for (const auto& file : all_files) { |
| 201 | const FileContent* fC = file.second; |
| 202 | Library* lib = fC->getLibrary(); |
| 203 | for (const auto& mod : fC->getModuleDefinitions()) { |
| 204 | ModuleDefinition* existing = design->getModuleDefinition(mod.first); |
| 205 | if (existing) { |
| 206 | const FileContent* oldFC = existing->getFileContents()[0]; |
| 207 | const FileContent* oldParentFile = oldFC->getParent(); |
| 208 | |
| 209 | ModuleDefinition* newM = mod.second; |
| 210 | const FileContent* newFC = newM->getFileContents()[0]; |
| 211 | const FileContent* newParentFile = newFC->getParent(); |
| 212 | |
| 213 | if (oldParentFile && (oldParentFile == newParentFile)) { |
| 214 | // Recombine splitted module |
| 215 | existing->addFileContent(mod.second->getFileContents()[0], |
| 216 | mod.second->getNodeIds()[0]); |
| 217 | for (auto classdef : mod.second->getClassDefinitions()) { |
| 218 | existing->addClassDefinition(classdef.first, classdef.second); |
| 219 | classdef.second->setContainer(existing); |
| 220 | } |
| 221 | } else { |
| 222 | design->addModuleDefinition(mod.first, mod.second); |
| 223 | if (finalCollection) lib->addModuleDefinition(mod.second); |
| 224 | } |
| 225 | } else { |
| 226 | design->addModuleDefinition(mod.first, mod.second); |
| 227 | if (finalCollection) lib->addModuleDefinition(mod.second); |
| 228 | } |
| 229 | } |
| 230 | for (const auto& prog : fC->getProgramDefinitions()) { |
| 231 | design->addProgramDefinition(prog.first, prog.second); |
| 232 | } |
| 233 | for (auto pack : fC->getPackageDefinitions()) { |
| 234 | Package* existing = design->getPackage(pack.first); |
| 235 | if (existing) { |
| 236 | const FileContent* oldFC = existing->getFileContents()[0]; |
| 237 | const FileContent* oldParentFile = oldFC->getParent(); |
| 238 | Package* newP = pack.second; |
| 239 | const FileContent* newFC = newP->getFileContents()[0]; |
| 240 | const FileContent* newParentFile = newFC->getParent(); |
| 241 | NodeId newNodeId = newP->getNodeIds()[0]; |
| 242 | if (!finalCollection && |
| 243 | ((oldParentFile != newParentFile) || |
| 244 | ((oldParentFile == nullptr) && (newParentFile == nullptr)))) { |
| 245 | NodeId oldNodeId = existing->getNodeIds()[0]; |
| 246 | uint32_t oldLine = oldFC->Line(oldNodeId); |
| 247 | uint32_t newLine = newFC->Line(newNodeId); |
| 248 | if ((oldFC->getFileId() != newFC->getFileId()) || |
| 249 | (oldLine != newLine)) { |
| 250 | Location loc1(oldFC->getFileId(), oldLine, oldFC->Column(oldNodeId), |
nothing calls this directly
no test coverage detected