| 166 | } |
| 167 | |
| 168 | bool ParseLibraryDef::parseConfigDefinition() { |
| 169 | FileContent* fC = m_fileContent; |
| 170 | if (!fC) return false; |
| 171 | |
| 172 | VObjectTypeUnorderedSet types = {VObjectType::paConfig_declaration}; |
| 173 | std::vector<NodeId> configs = fC->sl_collect_all(fC->getRootNode(), types); |
| 174 | for (auto config : configs) { |
| 175 | NodeId ident = fC->Child(config); |
| 176 | std::string name = |
| 177 | StrCat(fC->getLibrary()->getName(), "@", fC->SymName(ident)); |
| 178 | m_symbolTable->registerSymbol(name); |
| 179 | Config conf(name, fC, config); |
| 180 | |
| 181 | // Design clause |
| 182 | VObjectTypeUnorderedSet designStmt = {VObjectType::paDesign_statement}; |
| 183 | std::vector<NodeId> designs = fC->sl_collect_all(config, designStmt); |
| 184 | if (designs.empty()) { |
| 185 | // TODO: Error |
| 186 | } else if (designs.size() > 1) { |
| 187 | // TODO: Error |
| 188 | } else { |
| 189 | NodeId design = designs[0]; |
| 190 | NodeId libName = fC->Child(design); |
| 191 | NodeId topName = fC->Sibling(libName); |
| 192 | if (!topName) { |
| 193 | conf.setDesignLib(fC->getLibrary()->getName()); |
| 194 | conf.setDesignTop(fC->SymName(libName)); |
| 195 | } else { |
| 196 | conf.setDesignLib(fC->SymName(libName)); |
| 197 | conf.setDesignTop(fC->SymName(topName)); |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | // Default clause |
| 202 | VObjectTypeUnorderedSet defaultStmt = {VObjectType::paDefault_clause}; |
| 203 | std::vector<NodeId> defaults = fC->sl_collect_all(config, defaultStmt); |
| 204 | if (!defaults.empty()) { |
| 205 | NodeId defaultClause = defaults[0]; |
| 206 | NodeId libList = fC->Sibling(defaultClause); |
| 207 | if (fC->Type(libList) == VObjectType::paLiblist_clause) { |
| 208 | NodeId lib = fC->Child(libList); |
| 209 | while (lib) { |
| 210 | conf.addDefaultLib(fC->SymName(lib)); |
| 211 | lib = fC->Sibling(lib); |
| 212 | } |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | // Instance and Cell clauses |
| 217 | VObjectTypeUnorderedSet instanceStmt = {VObjectType::paInst_clause, |
| 218 | VObjectType::paCell_clause}; |
| 219 | std::vector<NodeId> instances = fC->sl_collect_all(config, instanceStmt); |
| 220 | for (auto inst : instances) { |
| 221 | VObjectType type = fC->Type(inst); |
| 222 | NodeId instName = fC->Child(inst); |
| 223 | if (type == VObjectType::paInst_clause) instName = fC->Child(instName); |
| 224 | std::string instNameS; |
| 225 | while (instName) { |
nothing calls this directly
no test coverage detected