| 71 | } |
| 72 | |
| 73 | void ResolveSymbols::createFastLookup() { |
| 74 | UHDM::Serializer& s = m_compileDesign->getSerializer(); |
| 75 | Library* lib = m_fileData->getLibrary(); |
| 76 | const std::string_view libName = lib->getName(); |
| 77 | |
| 78 | // std::string fileName = "FILE: " + m_fileData->getFileName() + " " + |
| 79 | // m_fileData->getChunkFileName () + "\n"; std::cout << fileName; |
| 80 | |
| 81 | VObjectTypeUnorderedSet types = { |
| 82 | VObjectType::paModule_declaration, VObjectType::paPackage_declaration, |
| 83 | VObjectType::paConfig_declaration, VObjectType::paUdp_declaration, |
| 84 | VObjectType::paInterface_declaration, VObjectType::paProgram_declaration, |
| 85 | VObjectType::paClass_declaration}; |
| 86 | |
| 87 | VObjectTypeUnorderedSet stopPoints = { |
| 88 | VObjectType::paModule_declaration, VObjectType::paPackage_declaration, |
| 89 | VObjectType::paProgram_declaration, VObjectType::paClass_declaration}; |
| 90 | |
| 91 | std::vector<NodeId> objects = |
| 92 | m_fileData->sl_collect_all(m_fileData->getRootNode(), types, stopPoints); |
| 93 | |
| 94 | for (auto object : objects) { |
| 95 | VObjectType type = m_fileData->Type(object); |
| 96 | NodeId stId = m_fileData->sl_collect(object, VObjectType::slStringConst, |
| 97 | VObjectType::paAttr_spec); |
| 98 | if (stId) { |
| 99 | const std::string_view name = SymName(stId); |
| 100 | m_fileData->insertObjectLookup(name, object, m_errorContainer); |
| 101 | const std::string fullName = StrCat(libName, "@", name); |
| 102 | |
| 103 | switch (type) { |
| 104 | case VObjectType::paPackage_declaration: { |
| 105 | // Package names are not prefixed by Library names! |
| 106 | const std::string_view pkgname = name; |
| 107 | Package* pdef = new Package(pkgname, lib, m_fileData, object); |
| 108 | UHDM::package* pack = s.MakePackage(); |
| 109 | pack->VpiName(pdef->getName()); |
| 110 | pdef->setUhdmInstance(pack); |
| 111 | m_fileData->populateCoreMembers(object, object, pack); |
| 112 | m_fileData->addPackageDefinition(pkgname, pdef); |
| 113 | |
| 114 | VObjectTypeUnorderedSet subtypes = {VObjectType::paClass_declaration}; |
| 115 | std::vector<NodeId> subobjects = |
| 116 | m_fileData->sl_collect_all(object, subtypes, subtypes); |
| 117 | for (auto subobject : subobjects) { |
| 118 | NodeId stId = |
| 119 | m_fileData->sl_collect(subobject, VObjectType::slStringConst, |
| 120 | VObjectType::paAttr_spec); |
| 121 | if (stId) { |
| 122 | const std::string_view name = SymName(stId); |
| 123 | const std::string fullSubName = StrCat(pkgname, "::", name); |
| 124 | m_fileData->insertObjectLookup(fullSubName, subobject, |
| 125 | m_errorContainer); |
| 126 | |
| 127 | ClassDefinition* def = |
| 128 | new ClassDefinition(name, lib, pdef, m_fileData, subobject, |
| 129 | nullptr, s.MakeClass_defn()); |
| 130 | m_fileData->addClassDefinition(fullSubName, def); |
no test coverage detected