17#ifndef FRONTENDS_COMMON_PROGRAMMAP_H_
18#define FRONTENDS_COMMON_PROGRAMMAP_H_
30 const IR::P4Program *fake =
new IR::P4Program();
31 const IR::P4Program *program =
nullptr;
33 explicit ProgramMap(std::string_view kind) : mapKind(kind) {}
38 bool checkMap(
const IR::Node *node)
const {
39 if (node == program) {
41 LOG2(mapKind <<
" is up-to-date");
44 LOG2(
"Program has changed from " << dbp(program) <<
" to " << dbp(node));
48 void validateMap(
const IR::Node *node)
const {
49 if (node ==
nullptr || !node->
is<IR::P4Program>() || program ==
nullptr)
return;
51 BUG(
"Invalid map %1%: computed for %2%, used for %3%", mapKind, dbp(program),
54 void updateMap(
const IR::Node *node) {
55 if (node ==
nullptr || !node->
is<IR::P4Program>())
return;
56 program = node->
to<IR::P4Program>();
57 LOG2(mapKind <<
" updated to " << dbp(node));
Definition stringify.h:31
Definition programMap.h:28
Definition applyOptionsPragmas.cpp:24
T * to() noexcept
Definition rtti.h:226
bool is() const noexcept
Definition rtti.h:216