MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / MoveToNextNode

Method MoveToNextNode

source/opt/tree_iterator.h:198–218  ·  view source on GitHub ↗

Moves the iterator to the next node in the tree. If we are at the end, do nothing, otherwise if our current node has children, use the children iterator and push the current node into the stack. If we reach the end of the local iterator, pop it.

Source from the content-addressed store, hash-verified

196 // current node into the stack.
197 // If we reach the end of the local iterator, pop it.
198 inline void MoveToNextNode() {
199 if (!current_) return;
200 if (parent_iterators_.empty()) {
201 current_ = nullptr;
202 return;
203 }
204 std::pair<NodePtr, NodeIterator>& next_it = parent_iterators_.top();
205 // If we visited all children, the current node is the top of the stack.
206 if (next_it.second == next_it.first->end()) {
207 // Set the new node.
208 current_ = next_it.first;
209 parent_iterators_.pop();
210 return;
211 }
212 // We have more children to visit, set the current node to the first child
213 // and dive to leaf.
214 current_ = *next_it.second;
215 // Update the iterator for the next child (avoid unneeded pop).
216 ++next_it.second;
217 WalkToLeaf();
218 }
219
220 // Moves the iterator to the next node in the tree.
221 // If we are at the end, do nothing, otherwise

Callers

nothing calls this directly

Calls 2

emptyMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected