P4C
The P4 Compiler
|
Assists visitors in traversing the IR. More...
Public Member Functions | |
ChangeTracker (bool forceClone) | |
bool | busy (const IR::Node *n) const |
bool | done (const IR::Node *n) const |
const IR::Node * | finalResult (const IR::Node *n) const |
bool | finish (const IR::Node *orig, const IR::Node *final) |
const IR::Node * | result (const IR::Node *n) const |
void | revisit_visited () |
bool | shouldVisitOnce (const IR::Node *n) const |
VisitStatus | try_start (const IR::Node *n, bool defaultVisitOnce) |
void | visitAgain (const IR::Node *n) |
void | visitOnce (const IR::Node *n) |
Assists visitors in traversing the IR.
A ChangeTracker object assists visitors traversing the IR by tracking each node. The start
method begins tracking, and finish
ends it. The done
method determines whether the node has been visited, and result
returns the new IR if it changed.
|
inlinenodiscard |
Determine whether
is currently being visited and the visitor has not finished That is, start(@n)
has been invoked, and finish(@n)
has not,
|
inlinenodiscard |
Determine whether
has been visited and the visitor has finished and we don't want to visit
again the next time we see it. That is, start(@n)
has been invoked, followed by finish(@n)
, and the visitOnce field is true.
Produce the final result of visiting
.
nullptr
if finish(@n)
has not been invoked. Mark the process of visiting @orig as finished, with @final being the final state of the node, or nullptr if the node was removed from the tree. done(@orig)
will return true, and result(@orig)
will return the resulting node, if any.
If @final is a new node, that node is marked as finished as well, as if start(@final); finish(@final);
were invoked.
Util::CompilerBug | This method fails if `start(@orig)` has not previously been invoked. |
Produce the result of visiting
.
start(@n)
has been invoked but not finish(@n)
, or start(@n)
has not been invoked.
|
inline |
Forget nodes that have already been visited, allowing them to be visited again.
|
inlinenodiscard |
Return a visitOnce flag for node
|
inlinenodiscard |
Begin tracking
during a visiting pass. Use finish(@n)
to mark
as visited once the pass completes.
VisitStatus::Busy
), or if node was already visited (VisitStatus::Done
), node was never seen before (VisitStatus::New
) or seen, but should be revisited (VisitStatus::Revisit
).