# HG changeset patch # User lindquist # Date 1195439986 -3600 # Node ID 182b41f56b7f7f164a079a168edc262981eba1b9 # Parent 4d1e9eb001e0d344a6182203728bca9271a639b5 [svn r109] Fixed support for static array TypeInfo diff -r 4d1e9eb001e0 -r 182b41f56b7f gen/typinf.cpp --- a/gen/typinf.cpp Mon Nov 19 02:58:58 2007 +0100 +++ b/gen/typinf.cpp Mon Nov 19 03:39:46 2007 +0100 @@ -510,22 +510,41 @@ void TypeInfoStaticArrayDeclaration::toDt(dt_t **pdt) { - assert(0 && "TypeInfoStaticArrayDeclaration"); + Logger::println("TypeInfoStaticArrayDeclaration::toDt() %s", toChars()); + LOG_SCOPE; + + // init typeinfo class + ClassDeclaration* base = Type::typeinfostaticarray; + DtoForceConstInitDsymbol(base); - /* - //printf("TypeInfoStaticArrayDeclaration::toDt()\n"); - dtxoff(pdt, Type::typeinfostaticarray->toVtblSymbol(), 0, TYnptr); // vtbl for TypeInfo_StaticArray - dtdword(pdt, 0); // monitor + // get type of typeinfo class + const llvm::StructType* stype = isaStruct(base->type->llvmType->get()); + // initializer vector + std::vector sinits; + // first is always the vtable + sinits.push_back(base->llvmVtbl); + + // value typeinfo assert(tinfo->ty == Tsarray); - TypeSArray *tc = (TypeSArray *)tinfo; - tc->next->getTypeInfo(NULL); - dtxoff(pdt, tc->next->vtinfo->toSymbol(), 0, TYnptr); // TypeInfo for array of type + + // get symbol + assert(tc->next->vtinfo); + DtoForceConstInitDsymbol(tc->next->vtinfo); + llvm::Constant* castbase = isaConstant(tc->next->vtinfo->llvmValue); + castbase = llvm::ConstantExpr::getBitCast(castbase, stype->getElementType(1)); + sinits.push_back(castbase); - dtdword(pdt, tc->dim->toInteger()); // length - */ + // length + sinits.push_back(DtoConstSize_t(tc->dim->toInteger())); + + // create the symbol + llvm::Constant* tiInit = llvm::ConstantStruct::get(stype, sinits); + llvm::GlobalVariable* gvar = new llvm::GlobalVariable(stype,true,llvm::GlobalValue::WeakLinkage,tiInit,toChars(),gIR->module); + + llvmValue = gvar; } /* ========================================================================= */ diff -r 4d1e9eb001e0 -r 182b41f56b7f llvmdc.kdevelop.filelist --- a/llvmdc.kdevelop.filelist Mon Nov 19 02:58:58 2007 +0100 +++ b/llvmdc.kdevelop.filelist Mon Nov 19 03:39:46 2007 +0100 @@ -404,6 +404,7 @@ test/tuple1.d test/typeinfo.d test/typeinfo10.d +test/typeinfo11.d test/typeinfo2.d test/typeinfo3.d test/typeinfo4.d diff -r 4d1e9eb001e0 -r 182b41f56b7f test/typeinfo11.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/typeinfo11.d Mon Nov 19 03:39:46 2007 +0100 @@ -0,0 +1,10 @@ +module typeinfo11; + +void main() +{ + int[4] a; + TypeInfo ti; + ti = typeid(typeof(a)); + assert(ti.next() is typeid(int)); + assert(ti.tsize() == 16); +}