diff ast/Exp.d @ 59:1d6f4ad38a91 new_gen

Make most of the tests pass again Still have two bugs, one is that type conversion has been diabled for return statements, the other is at line ~540 of CodeGen.d, were the following error is emitted: Can't find an implicit conversion between { i32 } and i32
author Anders Halager <halager@gmail.com>
date Tue, 29 Apr 2008 00:31:56 +0200
parents fc62c5296a1c
children 2451f0904bf6
line wrap: on
line diff
--- a/ast/Exp.d	Mon Apr 28 21:51:39 2008 +0200
+++ b/ast/Exp.d	Tue Apr 29 00:31:56 2008 +0200
@@ -54,7 +54,7 @@
     override DType type()
     {
         DFunction f = cast(DFunction)exp.type();
-        assert(f, "Can only call functions");
+        assert(f !is null, "Can only call functions");
         return f.return_type;
     }
 
@@ -65,6 +65,11 @@
 
     Exp simplify()
     {
+        DFunction func_t = cast(DFunction)exp.type();
+        assert(func_t !is null, "Calling on something that isn't a function");
+        if (cast(DStruct)func_t.return_type is null)
+            return this;
+
         auto call = cast(Identifier)exp;
         FuncDecl f = env.parentFunction;
         auto i = new Identifier("temp.var");
@@ -224,7 +229,6 @@
     }
     Exp simplify()
     {
-        child.simplify;
         target = target.simplify;
         return this;
     }
@@ -280,7 +284,7 @@
 
     override DType type()
     {
-        if (myType)
+        if (myType !is null)
             return myType;
         myType = env.find(this).type;
         return myType;