| 239 | } |
| 240 | |
| 241 | void AstPrinter::dispatch(AstNode *node, int childIndex) |
| 242 | { |
| 243 | // Print this node. |
| 244 | print(node, childIndex); |
| 245 | |
| 246 | if (node) |
| 247 | { |
| 248 | // Push current depth. |
| 249 | m_depthStack.push(m_depth); |
| 250 | ++m_depth; |
| 251 | |
| 252 | // Dispatch to children. |
| 253 | childIndex = 0; |
| 254 | for (auto i : *node) |
| 255 | { |
| 256 | dispatch(i, childIndex); |
| 257 | ++childIndex; |
| 258 | } |
| 259 | |
| 260 | // Pop depth. |
| 261 | m_depth = m_depthStack.top(); |
| 262 | m_depthStack.pop(); |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | void AstPrinter::print(AstNode *node, int childIndex) |
| 267 | { |