Template Class ScopeStack#
Defined in File scope_stack.h
Class Documentation#
-
template<typename T>
class ScopeStack# A scope stack for maintaining hierarchical state during IR visiting.
During IR tree traversal, visitors often need to track scope-local state (e.g., active constraints, variable bindings) that should be automatically cleaned up when leaving a scope. ScopeStack provides this via WithNewScope, which pushes a new element on entry and pops it on exit.
ScopeStack<std::vector<Var>> definitions; definitions.WithNewScope([&]() { definitions.Current().push_back(var); Visit(body); });
- Template Parameters:
T – The element type stored on the stack. Must be default-constructible.
Public Functions
-
inline ScopeStack()#
Construct with one initial scope level.
-
inline auto rbegin() const#
Iterate active scopes from innermost to outermost.
-
inline auto rend() const#