8#include <nix/nixexpr.hh>
9#include <nix/symbol-table.hh>
54#define NIX_EXPR(EXPR) bool traverse##EXPR(const nix::EXPR *E);
58#define NIX_EXPR(EXPR) \
59 bool visit##EXPR(const nix::EXPR *E) { return getDerived().visitExpr(E); }
63 Derived &
getDerived() {
return *
static_cast<Derived *
>(
this); }
65 bool traverseExpr(
const nix::Expr *E) {
68#define NIX_EXPR(EXPR) \
69 if (auto CE = dynamic_cast<const nix::EXPR *>(E)) { \
70 return getDerived().traverse##EXPR(CE); \
74 assert(
false &&
"We are missing some nix AST Nodes!");
79#define TRY_TO(CALL_EXPR) \
81 if (!getDerived().CALL_EXPR) \
85#define TRY_TO_TRAVERSE(EXPR) TRY_TO(traverseExpr(EXPR))
87#define DEF_TRAVERSE_TYPE(TYPE, CODE) \
88 template <typename Derived> \
89 bool RecursiveASTVisitor<Derived>::traverse##TYPE(const nix::TYPE *T) { \
90 if (!getDerived().shouldTraversePostOrder()) \
91 TRY_TO(visit##TYPE(T)); \
93 if (getDerived().shouldTraversePostOrder()) \
94 TRY_TO(visit##TYPE(T)); \
98#undef DEF_TRAVERSE_TYPE
Nix expressions declaration.
Access EvalCache in nix::EvalState.
A CRTP base class for traversing nix::Expr * nodes.
bool visitExpr(const nix::Expr *)
bool shouldTraversePostOrder()