nixd
Loading...
Searching...
No Matches
Public Member Functions | List of all members
nixt::RecursiveASTVisitor< Derived > Struct Template Reference

A CRTP base class for traversing nix::Expr * nodes. More...

#include <Visitor.h>

Public Member Functions

bool shouldTraversePostOrder ()
 
bool visitExpr (const nix::Expr *)
 
Derived & getDerived ()
 
bool traverseExpr (const nix::Expr *E)
 

Detailed Description

template<class Derived>
struct nixt::RecursiveASTVisitor< Derived >

A CRTP base class for traversing nix::Expr * nodes.

Usage:

struct MyVisitor : public RecursiveASTVisitor<MyVisitor> {
// This can be omitted.
bool traverseExpr(const nix::Expr *E) {
// Do something before/after traversing children.
}
// return `true` to traverse post-order, otherwise pre-order (default).
bool shouldTraversePostOrder() { return true; }
// sreturn `true` if we should continue traversing.
bool visitExprInt(const nix::ExprInt *E) { return true; }
bool visitExprFloat(const nix::ExprFloat *E) { return true; }
} V;
V.traverseExpr(Root); // call traverseExpr() on Root.
A CRTP base class for traversing nix::Expr * nodes.
Definition Visitor.h:48
bool traverseExpr(const nix::Expr *E)
Definition Visitor.h:65
Note
This is based on dynamic_cast, so it is not very efficient.

visit*() methods are called once for each node.traverse*() methods are automatically generated describing relations between nodes. Usually you should always write custom visit*() methods, and only write traverse*() methods when you need to do something special.

Definition at line 48 of file Visitor.h.

Member Function Documentation

◆ getDerived()

template<class Derived >
Derived & nixt::RecursiveASTVisitor< Derived >::getDerived ( )
inline

Definition at line 63 of file Visitor.h.

◆ shouldTraversePostOrder()

template<class Derived >
bool nixt::RecursiveASTVisitor< Derived >::shouldTraversePostOrder ( )
inline

Definition at line 50 of file Visitor.h.

◆ traverseExpr()

template<class Derived >
bool nixt::RecursiveASTVisitor< Derived >::traverseExpr ( const nix::Expr * E)
inline

Definition at line 65 of file Visitor.h.

Referenced by nixt::parentMap().

◆ visitExpr()

template<class Derived >
bool nixt::RecursiveASTVisitor< Derived >::visitExpr ( const nix::Expr * )
inline

Definition at line 52 of file Visitor.h.


The documentation for this struct was generated from the following file: