diff ast/Decl.d @ 129:ed815b31479b

Added a Symbol
author Anders Halager <halager@gmail.com>
date Sat, 21 Jun 2008 20:41:18 +0200
parents c3b24e7e8cf8
children 2be29b296081
line wrap: on
line diff
--- a/ast/Decl.d	Sat Jun 21 17:32:27 2008 +0200
+++ b/ast/Decl.d	Sat Jun 21 20:41:18 2008 +0200
@@ -8,6 +8,7 @@
 import tango.io.Stdout;
 
 import sema.Scope,
+       sema.Symbol,
        sema.DType,
        basic.SmallArray,
        basic.Attribute;
@@ -15,6 +16,7 @@
 enum DeclType
 {
     VarDecl,
+    DummyDecl,
     ImportDecl,
     FuncDecl,
     StructDecl,
@@ -31,13 +33,27 @@
     {
     }
 
-    DType type() { return null; }
+    DType type()
+    {
+        if (sym !is null)
+            return sym.type;
+        return null;
+    }
 
     DeclType declType;
     Scope env;
+    Symbol sym;
     Attribute att;
 }
 
+class DummyDecl : Decl
+{
+    this()
+    {
+        super(DeclType.DummyDecl);
+    }
+}
+
 class VarDecl : Decl
 {
     this(Identifier type, Identifier identifier,
@@ -55,7 +71,7 @@
 
     override DType type()
     {
-        return env.find(identifier).type;
+        return env.findType(varType);
     }
 
     Identifier varType, identifier;
@@ -109,7 +125,8 @@
 
     void simplify()
     {
-        if(auto t = cast(DFunction)env.find(identifier).type)
+        /*
+        if(auto t = env.find(identifier).type.asFunction())
         {
             if(auto s = cast(DStruct)t.returnType)
             {
@@ -131,6 +148,7 @@
                 myType = null;
             }
         }
+        */
 
         foreach (funcArg; funcArgs)
             funcArg.simplify();