diff sema/Visitor.d @ 144:6e6355fb5f0f

- Parsing nested attributes. - Creating classes and interfaces in AST. - Updated AstPrinter to print attributes, classes and interfaces.
author Anders Johnsen <skabet@gmail.com>
date Mon, 21 Jul 2008 17:41:40 +0200
parents d76cc5cad4fc
children 393a1f47a6d2
line wrap: on
line diff
--- a/sema/Visitor.d	Mon Jul 21 01:05:20 2008 +0200
+++ b/sema/Visitor.d	Mon Jul 21 17:41:40 2008 +0200
@@ -45,6 +45,10 @@
                 return visitImportDecl(cast(ImportDecl)decl);
             case DeclType.StructDecl:
                 return visitStructDecl(cast(StructDecl)decl);
+            case DeclType.ClassDecl:
+                return visitClassDecl(cast(ClassDecl)decl);
+            case DeclType.InterfaceDecl:
+                return visitInterfaceDecl(cast(InterfaceDecl)decl);
             default:
                 throw new Exception("Unknown declaration type");
         }
@@ -169,6 +173,38 @@
             return DeclT.init;
     }
 
+    DeclT visitClassDecl(ClassDecl s)
+    {
+        visitExp(s.identifier);
+
+        foreach (arg; s.decls)
+            visitDecl(arg);
+
+        foreach (arg; s.baseClasses)
+            visitExp(arg);
+
+        static if (is(DeclT == void))
+            return;
+        else
+            return DeclT.init;
+    }
+
+    DeclT visitInterfaceDecl(InterfaceDecl s)
+    {
+        visitExp(s.identifier);
+
+        foreach (arg; s.decls)
+            visitDecl(arg);
+
+        foreach (arg; s.baseClasses)
+            visitExp(arg);
+
+        static if (is(DeclT == void))
+            return;
+        else
+            return DeclT.init;
+    }
+
     // Statements:
     StmtT visitReturnStmt(ReturnStmt s)
     {