diff sema/AstAction.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 57b0b4464a0b
children dc9bf56b7ace
line wrap: on
line diff
--- a/sema/AstAction.d	Thu Jul 24 12:27:34 2008 +0200
+++ b/sema/AstAction.d	Thu Jul 24 20:31:24 2008 +0200
@@ -27,14 +27,16 @@
     }
     private SourceManager sm;
 
-    private Identifier handleType(Id type)
+    private IdentifierTypeExp handleType(Id type)
     {
-        if(auto t = cast(PointerId)type)
-            return new PointerIdentifier(handleType(t.id));
-        if(auto t = cast(StaticArrayId)type)
-            return new StaticArrayIdentifier(handleType(t.id), cast(IntegerLit)t.number);
-        else
-            return identifierFromTok(type.tok);
+        if(auto t = cast(PointerTypeId)type)
+            return new PointerTypeExp(handleType(t.id));
+        if(auto t = cast(StaticArrayTypeId)type)
+            return new StaticArrayTypeExp(handleType(t.id), cast(IntegerLit)t.number);
+        if(auto t = cast(FunctionTypeId)type)
+            return new FunctionTypeExp(handleType(t.id), cast(VarDecl[])t.decls);
+        
+        return new IdentifierTypeExp(type.tok.location, sm.getText(type.tok.asRange));
     }
 
     private Identifier identifierFromTok(Token t)
@@ -139,7 +141,7 @@
 
     DeclT actOnStartOfFunctionDef(ref Id type, ref Id name, Attribute att)
     {
-        auto res = new FuncDecl(identifierFromTok(type.tok), identifierFromTok(name.tok));
+        auto res = new FuncDecl(handleType(type), identifierFromTok(name.tok));
         res.att = att;
         return res;
     }
@@ -150,7 +152,7 @@
         if(name)
             fd.addParam(handleType(type), identifierFromTok(name.tok));
         else
-            fd.addParam(identifierFromTok(type.tok));
+            fd.addParam(handleType(type));
     }
 
     DeclT actOnEndOfFunction(DeclT func, StmtT stmts)