Lines Matching defs:Table

158   std::string searchableFieldType(const GenericTable &Table,
177 PrintFatalError(Index.Loc, Twine("In table '") + Table.Name +
186 Twine("In table '") + Table.Name + "' lookup method '" +
191 void emitGenericTable(const GenericTable &Table, raw_ostream &OS);
193 void emitLookupDeclaration(const GenericTable &Table,
195 void emitLookupFunction(const GenericTable &Table, const SearchIndex &Index,
201 parseSearchIndex(GenericTable &Table, const RecordVal *RecVal, StringRef Name,
207 void collectTableEntries(GenericTable &Table,
321 void SearchableTableEmitter::emitLookupFunction(const GenericTable &Table,
326 emitLookupDeclaration(Table, Index, OS);
335 IndexTypeName = Table.CppTypeName;
336 IndexName = Table.Name;
337 IndexRows = Table.Entries;
342 << searchableFieldType(Table, Index, Field, TypeInStaticStruct) << " "
351 Entries.reserve(Table.Entries.size());
352 for (unsigned i = 0; i < Table.Entries.size(); ++i)
353 Entries.emplace_back(Table.Entries[i], i);
407 OS << " auto Table = ArrayRef(" << IndexName << ");\n";
412 OS << "&Table[Idx]";
414 OS << "&" << Table.Name << "[Table[Idx]._index]";
433 OS << " " << searchableFieldType(Table, Index, Field, TypeInTempStruct)
445 Twine("In table '") + Table.Name +
494 OS << " auto Table = ArrayRef(" << IndexName << ");\n";
496 OS << " auto It = std::equal_range(Table.begin(), Table.end(), Key, ";
498 OS << " auto Idx = std::lower_bound(Table.begin(), Table.end(), Key, ";
502 OS << " if (Idx == Table.end()";
514 OS << " return &" << Table.Name << "[Idx->_index];\n";
520 void SearchableTableEmitter::emitLookupDeclaration(const GenericTable &Table,
524 OS << "llvm::iterator_range<const " << Table.CppTypeName << " *> ";
526 OS << "const " << Table.CppTypeName << " *";
530 OS << LS << searchableFieldType(Table, Index, Field, TypeInArgument) << " "
535 void SearchableTableEmitter::emitGenericTable(const GenericTable &Table,
537 emitIfdef((Twine("GET_") + Table.PreprocessorGuard + "_DECL").str(), OS);
540 if (Table.PrimaryKey) {
541 emitLookupDeclaration(Table, *Table.PrimaryKey, OS);
544 for (const auto &Index : Table.Indices) {
545 emitLookupDeclaration(Table, *Index, OS);
551 emitIfdef((Twine("GET_") + Table.PreprocessorGuard + "_IMPL").str(), OS);
554 OS << "constexpr " << Table.CppTypeName << " " << Table.Name << "[] = {\n";
555 for (unsigned i = 0; i < Table.Entries.size(); ++i) {
556 Record *Entry = Table.Entries[i];
560 for (const auto &Field : Table.Fields)
562 << primaryRepresentation(Table.Locs[0], Field,
571 if (Table.PrimaryKey)
572 emitLookupFunction(Table, *Table.PrimaryKey, /*IsPrimary=*/true, OS);
573 for (const auto &Index : Table.Indices)
574 emitLookupFunction(Table, *Index, /*IsPrimary=*/false, OS);
599 GenericTable &Table, const RecordVal *KeyRecVal, StringRef Name,
608 const GenericField *Field = Table.getFieldByName(FieldName);
612 Twine("In table '") + Table.Name +
659 GenericTable &Table, const std::vector<Record *> &Items) {
661 PrintFatalError(Table.Locs,
662 Twine("Table '") + Table.Name + "' has no entries");
665 for (auto &Field : Table.Fields) {
669 "' for table '" + Table.Name +
680 Table.Name + "' entry has incompatible type: " +
687 Table.Entries.push_back(EntryRec); // Add record to table's record list.
692 for (auto &Field : Table.Fields) {
695 "' in table '" + Table.Name + "'. Maybe it is not used?");
706 std::copy(Table.Fields.begin(), Table.Fields.end(),
708 llvm::sort(Table.Entries, [&](Record *LHS, Record *RHS) {
748 auto Table = std::make_unique<GenericTable>();
749 Table->Name = std::string(TableRec->getName());
750 Table->Locs = TableRec->getLoc();
751 Table->PreprocessorGuard = std::string(TableRec->getName());
752 Table->CppTypeName = std::string(TableRec->getValueAsString("CppTypeName"));
756 Table->Fields.emplace_back(FieldName); // Construct a GenericField.
760 if (!parseFieldType(Table->Fields.back(),
763 Twine("Table '") + Table->Name + "' has invalid 'TypeOf_" +
775 Twine("Table FilterClass '") + FilterClass +
794 collectTableEntries(*Table, Definitions);
797 Table->PrimaryKey =
798 parseSearchIndex(*Table, TableRec->getValue("PrimaryKey"),
804 llvm::stable_sort(Table->Entries, [&](Record *LHS, Record *RHS) {
805 return compareBy(LHS, RHS, *Table->PrimaryKey);
809 TableMap.insert(std::pair(TableRec, Table.get()));
810 Tables.emplace_back(std::move(Table));
814 Record *TableRec = IndexRec->getValueAsDef("Table");
817 PrintFatalError(IndexRec->getValue("Table"),
822 GenericTable &Table = *It->second;
823 Table.Indices.push_back(parseSearchIndex(
824 Table, IndexRec->getValue("Key"), IndexRec->getName(),
855 auto Table = std::make_unique<GenericTable>();
856 Table->Name = (Twine(Class->getName()) + "sList").str();
857 Table->Locs = Class->getLoc();
858 Table->PreprocessorGuard = Class->getName().upper();
859 Table->CppTypeName = std::string(Class->getName());
871 Table->Fields.emplace_back(FieldName);
874 collectTableEntries(*Table, Items);
879 (Twine("lookup") + Table->CppTypeName + "By" + Field).str();
880 Table->Indices.push_back(
881 parseSearchIndex(*Table, Class->getValue(Field), Name, {Field},
885 Tables.emplace_back(std::move(Table));
892 for (const auto &Table : Tables)
893 emitGenericTable(*Table, OS);