| 304 | } |
| 305 | |
| 306 | bool DescriptorDatabaseBuilder::addSymbol(size_t fileIndex, |
| 307 | size_t packageIndex, |
| 308 | const FullyQualifiedName& name, |
| 309 | ExceptionTracker& exceptionTracker) { |
| 310 | if (_symbolIndexByName.find(name) != _symbolIndexByName.end()) { |
| 311 | exceptionTracker.onError(Error(STRING_FORMAT("Symbol '{}' already exist", name))); |
| 312 | return false; |
| 313 | } |
| 314 | |
| 315 | auto symbolIndex = _symbols.size(); |
| 316 | auto& symbol = _symbols.emplace_back(); |
| 317 | symbol.fullName = name; |
| 318 | symbol.fileIndex = fileIndex; |
| 319 | |
| 320 | _symbolIndexByName[name] = symbolIndex; |
| 321 | |
| 322 | // Append our new message type inside the package |
| 323 | _packages[packageIndex].symbolIndexes.emplace_back(symbolIndex); |
| 324 | |
| 325 | return true; |
| 326 | } |
| 327 | |
| 328 | size_t DescriptorDatabaseBuilder::getOrCreatePackageIndex(const FullyQualifiedName& name) { |
| 329 | const auto& it = _packageIndexByName.find(name); |