| 28 | } |
| 29 | |
| 30 | void AstWalker::walk(AstNode *node) |
| 31 | { |
| 32 | if (!node) |
| 33 | { |
| 34 | return; |
| 35 | } |
| 36 | |
| 37 | // Process the node top-down. |
| 38 | dispatch<top_down>(node); |
| 39 | |
| 40 | for (auto i : *node) |
| 41 | { |
| 42 | walk(i); |
| 43 | } |
| 44 | |
| 45 | // Process this node bottom-up. |
| 46 | dispatch<bottom_up>(node); |
| 47 | } |
| 48 | |
| 49 | template <typename D> |
| 50 | void AstWalker::dispatch(AstNode *node) |