changeset 643:3bd947eb72c2

Added module cmd.ASTStats.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Mon, 14 Jan 2008 14:55:49 +0100
parents be45f982ee3e
children a0643a4d4501
files trunk/src/cmd/ASTStats.d trunk/src/cmd/Statistics.d trunk/src/dil/ast/DefaultVisitor.d
diffstat 3 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trunk/src/cmd/ASTStats.d	Mon Jan 14 14:55:49 2008 +0100
@@ -0,0 +1,22 @@
+/++
+  Author: Aziz Köksal
+  License: GPL3
++/
+module cmd.ASTStats;
+
+import dil.ast.DefaultVisitor;
+import dil.ast.Node;
+
+class ASTStats : DefaultVisitor
+{
+  uint[] table; /// Table for counting nodes.
+
+  uint[] count(Node root)
+  {
+    table = new uint[classNames.length];
+    super.visitN(root);
+    return table;
+  }
+
+  // TODO: add visit methods.
+}
--- a/trunk/src/cmd/Statistics.d	Mon Jan 14 14:18:23 2008 +0100
+++ b/trunk/src/cmd/Statistics.d	Mon Jan 14 14:55:49 2008 +0100
@@ -3,9 +3,11 @@
   License: GPL3
 +/
 module cmd.Statistics;
+
 import dil.File;
 import dil.lexer.Lexer;
 import dil.lexer.Token;
+import cmd.ASTStats;
 import common;
 
 struct Statistics
--- a/trunk/src/dil/ast/DefaultVisitor.d	Mon Jan 14 14:18:23 2008 +0100
+++ b/trunk/src/dil/ast/DefaultVisitor.d	Mon Jan 14 14:55:49 2008 +0100
@@ -4,6 +4,8 @@
 +/
 module dil.ast.DefaultVisitor;
 
+import dil.ast.Visitor;
+
 import dil.ast.Node;
 import dil.ast.Declarations,
        dil.ast.Expressions,