diff sema/Visitor.d @ 172:01c2c49775ef

- Changed Parser to be more clean on type parsing. - Parsing int function(int), and the like, types.(Function pointers) - Fixed a design fault that made Symbol be wrong. Now Symbols are created with a factory with the help of types.
author Anders Johnsen <skabet@gmail.com>
date Thu, 24 Jul 2008 20:31:24 +0200
parents 0f38f1a0f06f
children dc9bf56b7ace
line wrap: on
line diff
--- a/sema/Visitor.d	Thu Jul 24 12:27:34 2008 +0200
+++ b/sema/Visitor.d	Thu Jul 24 20:31:24 2008 +0200
@@ -99,10 +99,14 @@
                 return visitCastExp(cast(CastExp)exp);
             case ExpType.Identifier:
                 return visitIdentifier(cast(Identifier)exp);
-            case ExpType.PointerIdentifier:
-                return visitPointerIdentifier(cast(PointerIdentifier)exp);
-            case ExpType.StaticArrayIdentifier:
-                return visitStaticArrayIdentifier(cast(StaticArrayIdentifier)exp);
+            case ExpType.IdentifierTypeExp:
+                return visitIdentifier(cast(Identifier)exp);
+            case ExpType.PointerTypeExp:
+                return visitPointerTypeExp(cast(PointerTypeExp)exp);
+            case ExpType.StaticArrayTypeExp:
+                return visitStaticArrayTypeExp(cast(StaticArrayTypeExp)exp);
+            case ExpType.FunctionTypeExp:
+                return visitFunctionTypeExp(cast(FunctionTypeExp)exp);
             case ExpType.StringExp:
                 return visitStringExp(cast(StringExp)exp);
             case ExpType.Index:
@@ -387,7 +391,7 @@
             return ExpT.init;
     }
 
-    ExpT visitPointerIdentifier(PointerIdentifier exp)
+    ExpT visitPointerTypeExp(PointerTypeExp exp)
     {
         visitExp(exp.pointerOf);
 
@@ -397,7 +401,7 @@
             return ExpT.init;
     }
 
-    ExpT visitStaticArrayIdentifier(StaticArrayIdentifier exp)
+    ExpT visitStaticArrayTypeExp(StaticArrayTypeExp exp)
     {
         visitExp(exp.arrayOf);
 
@@ -407,6 +411,19 @@
             return ExpT.init;
     }
 
+    ExpT visitFunctionTypeExp(FunctionTypeExp exp)
+    {
+        visitExp(exp.returnType);
+
+        foreach (decl ; exp.decls)
+            visitDecl(decl);
+
+        static if (is(ExpT == void))
+            return;
+        else
+            return ExpT.init;
+    }
+
     ExpT visitIndexExp(IndexExp exp)
     {
         visitExp(exp.target);