| 268 | } |
| 269 | |
| 270 | bool DesignElaboration::identifyTopModules_() { |
| 271 | FileSystem* const fileSystem = FileSystem::getInstance(); |
| 272 | m_topLevelModules.clear(); |
| 273 | bool modulePresent = false; |
| 274 | bool toplevelModuleFound = false; |
| 275 | SymbolTable* st = m_compileDesign->getCompiler()->getSymbolTable(); |
| 276 | auto& userTopList = m_compileDesign->getCompiler() |
| 277 | ->getCommandLineParser() |
| 278 | ->getTopLevelModules(); |
| 279 | auto all_files = |
| 280 | m_compileDesign->getCompiler()->getDesign()->getAllFileContents(); |
| 281 | typedef std::multimap<std::string, |
| 282 | std::pair<const DesignElement*, const FileContent*>> |
| 283 | ModuleMultiMap; |
| 284 | ModuleMultiMap all_modules; |
| 285 | for (auto file : all_files) { |
| 286 | if (m_compileDesign->getCompiler()->isLibraryFile(file.first)) continue; |
| 287 | for (const DesignElement* element : file.second->getDesignElements()) { |
| 288 | const std::string_view elemName = st->getSymbol(element->m_name); |
| 289 | if (element->m_type == DesignElement::Module) { |
| 290 | if (element->m_parent) { |
| 291 | // This is a nested element |
| 292 | continue; |
| 293 | } |
| 294 | const std::string_view libName = file.second->getLibrary()->getName(); |
| 295 | std::string topname = StrCat(libName, "@", elemName); |
| 296 | |
| 297 | if (!file.second->getParent()) { |
| 298 | // Files that have parent are splited files (When a module is too |
| 299 | // large it is splited) |
| 300 | all_modules.emplace(topname, std::make_pair(element, file.second)); |
| 301 | } |
| 302 | |
| 303 | modulePresent = true; |
| 304 | bool used = false; |
| 305 | for (auto file1 : all_files) { |
| 306 | if (file1.second->getReferencedObjects().find(elemName) != |
| 307 | file1.second->getReferencedObjects().end()) { |
| 308 | if (m_compileDesign->getCompiler()->isLibraryFile(file1.first)) |
| 309 | continue; |
| 310 | used = true; |
| 311 | break; |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | if (!used) { |
| 316 | bool isTop = true; |
| 317 | |
| 318 | if (!m_toplevelConfigModules.empty()) { |
| 319 | isTop = false; |
| 320 | if (m_toplevelConfigModules.find(topname) != |
| 321 | m_toplevelConfigModules.end()) { |
| 322 | isTop = true; |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | if (isTop) { |
| 327 | SymbolId topid = st->registerSymbol(topname); |
nothing calls this directly
no test coverage detected