comparison src/cmd/ASTStats.d @ 806:bcb74c9b895c

Moved out files in the trunk folder to the root.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Sun, 09 Mar 2008 00:12:19 +0100
parents trunk/src/cmd/ASTStats.d@cf2ad5df025c
children
comparison
equal deleted inserted replaced
805:a3fab8b74a7d 806:bcb74c9b895c
1 /++
2 Author: Aziz Köksal
3 License: GPL3
4 +/
5 module cmd.ASTStats;
6
7 import dil.ast.DefaultVisitor;
8 import dil.ast.Node,
9 dil.ast.Declaration,
10 dil.ast.Statement,
11 dil.ast.Expression,
12 dil.ast.Types;
13
14 /// Counts the nodes in a syntax tree.
15 class ASTStats : DefaultVisitor
16 {
17 uint[] table; /// Table for counting nodes.
18
19 /// Starts counting.
20 uint[] count(Node root)
21 {
22 table = new uint[g_classNames.length];
23 super.visitN(root);
24 return table;
25 }
26
27 // Override dispatch function.
28 override Node dispatch(Node n)
29 {
30 table[n.kind]++;
31 return super.dispatch(n);
32 }
33 }