Mercurial > projects > ldc
diff gen/tollvm.cpp @ 1228:79758fd2f48a
Added Doxygen file.
Completely seperated type and symbol generation. Should fix a lot of bugs, but is not yet 100% complete.
author | Tomas Lindquist Olsen <tomas.l.olsen gmail.com> |
---|---|
date | Wed, 15 Apr 2009 20:06:25 +0200 |
parents | 7e5547d8e59f |
children | 1e699a4e9759 |
line wrap: on
line diff
--- a/gen/tollvm.cpp Mon Apr 13 17:42:36 2009 +0200 +++ b/gen/tollvm.cpp Wed Apr 15 20:06:25 2009 +0200 @@ -23,6 +23,7 @@ #include "gen/llvm-version.h" #include "ir/irtype.h" +#include "ir/irtypeclass.h" bool DtoIsPassedByRef(Type* type) { @@ -52,11 +53,17 @@ const LLType* DtoType(Type* t) { +#if DMDV2 + t = t->mutableOf(); +#endif + if (t->irtype) { return t->irtype->get(); } + IF_LOG Logger::println("Building type: %s", t->toChars()); + assert(t); switch (t->ty) { @@ -86,57 +93,50 @@ case Tdchar: { t->irtype = new IrTypeBasic(t); - return t->irtype->get(); + return t->irtype->buildType(); } // pointers case Tpointer: { t->irtype = new IrTypePointer(t); - return t->irtype->get(); + return t->irtype->buildType(); } // arrays case Tarray: { t->irtype = new IrTypeArray(t); - return t->irtype->get(); + return t->irtype->buildType(); } case Tsarray: { t->irtype = new IrTypeSArray(t); - return t->irtype->get(); + return t->irtype->buildType(); } // aggregates case Tstruct: { - #if DMDV2 - TypeStruct* ts = (TypeStruct*)t->mutableOf(); - #else TypeStruct* ts = (TypeStruct*)t; - #endif - assert(ts->sym); - DtoResolveDsymbol(ts->sym); - return ts->ir.type->get(); + t->irtype = new IrTypeStruct(ts->sym); + return t->irtype->buildType(); } - case Tclass: { - #if DMDV2 - TypeClass* tc = (TypeClass*)t->mutableOf(); - #else TypeClass* tc = (TypeClass*)t; - #endif - assert(tc->sym); - DtoResolveDsymbol(tc->sym); - return getPtrToType(tc->ir.type->get()); + t->irtype = new IrTypeClass(tc->sym); + return t->irtype->buildType(); } // functions case Tfunction: { if (!t->ir.type || *t->ir.type == NULL) { - return DtoFunctionType(t,NULL,NULL); + TypeFunction* tf = (TypeFunction*)t; + if (tf->funcdecl) + return DtoFunctionType(tf->funcdecl); + else + return DtoFunctionType(tf,NULL,NULL); } else { return t->ir.type->get(); @@ -156,6 +156,8 @@ // typedefs // enum + + // FIXME: maybe just call toBasetype first ? case Ttypedef: case Tenum: { @@ -166,15 +168,7 @@ // associative arrays case Taarray: - #if 1 return getVoidPtrType(); - #else - { - TypeAArray* taa = (TypeAArray*)t; - // aa key/val can't be void - return getPtrToType(LLStructType::get(DtoType(taa->key), DtoType(taa->next), 0)); - } - #endif /* Not needed atm as VarDecls for tuples are rewritten as a string of