24 ordered_map<const IR::MAU::Table *, unsigned> tableToIDs;
25 ordered_map<unsigned, const IR::MAU::Table *> idToTables;
28 profile_t init_apply(
const IR::Node *root)
override {
32 return Inspector::init_apply(root);
35 bool preorder(
const IR::MAU::Table *tbl)
override {
36 BUG_CHECK(tableToIDs.count(tbl) == 0,
"Table %1% already assigned ID %2%", tbl->name,
38 BUG_CHECK(idToTables.count(lastID) == 0,
"ID %1% already assigned to table %2%", lastID,
39 idToTables.at(lastID));
40 tableToIDs[tbl] = lastID;
41 idToTables[lastID] = tbl;
47 const ordered_map<const IR::MAU::Table *, unsigned> &getTableToIDs()
const {
51 const ordered_map<unsigned, const IR::MAU::Table *> &getIDsToTables()
const {
55 unsigned getIDForTable(
const IR::MAU::Table *tbl)
const {
56 BUG_CHECK(tableToIDs.count(tbl),
"No ID assigned to table %1%", tbl->name);
57 return tableToIDs.at(tbl);
60 const IR::MAU::Table *getTableForID(
unsigned id)
const {
61 BUG_CHECK(idToTables.count(
id),
"ID %1% not assigned to any table",
id);
62 return idToTables.at(
id);