Mercurial > projects > ldc
changeset 307:7ade5e035beb trunk
[svn r328] Fixed an issue with interfaces where the vtable type of a interface implemented could be invalid. Fixes several tango modules like, FileStream, ServerSocket
and most tina cluster modules :)
author | lindquist |
---|---|
date | Sat, 28 Jun 2008 03:45:18 +0200 |
parents | 0baca2feb554 |
children | 6b62e8cdf970 |
files | gen/classes.cpp ir/irstruct.cpp ir/irstruct.h |
diffstat | 3 files changed, 14 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/gen/classes.cpp Fri Jun 27 23:58:22 2008 +0200 +++ b/gen/classes.cpp Sat Jun 28 03:45:18 2008 +0200 @@ -39,7 +39,7 @@ if (target->ir.irStruct->interfaceMap.find(bc->base) == target->ir.irStruct->interfaceMap.end()) { Logger::println("adding interface '%s'", bc->base->toPrettyChars()); - IrInterface* iri = new IrInterface(bc, NULL); + IrInterface* iri = new IrInterface(bc); // add to map target->ir.irStruct->interfaceMap.insert(std::make_pair(bc->base, iri)); @@ -242,16 +242,14 @@ // set vtbl type TypeClass* itc = (TypeClass*)id->type; - const LLType* ivtblTy = getPtrToType(itc->ir.vtblType->get()); - fieldtypes.push_back(ivtblTy); + const LLType* ivtblTy = itc->ir.vtblType->get(); + assert(ivtblTy); + Logger::cout() << "interface vtbl type: " << *ivtblTy << '\n'; + fieldtypes.push_back(getPtrToType(ivtblTy)); // fix the interface vtable type - #if OPAQUE_VTBLS - iri->vtblTy = isaArray(itc->ir.vtblType->get()); - #else - iri->vtblTy = isaStruct(itc->ir.vtblType->get()); - #endif - assert(iri->vtblTy); + assert(iri->vtblTy == NULL); + iri->vtblTy = new llvm::PATypeHolder(ivtblTy); // set index iri->index = interIdx++; @@ -421,7 +419,7 @@ nam.append("6__vtblZ"); assert(iri->vtblTy); - iri->vtbl = new llvm::GlobalVariable(iri->vtblTy, true, _linkage, 0, nam, gIR->module); + iri->vtbl = new llvm::GlobalVariable(iri->vtblTy->get(), true, _linkage, 0, nam, gIR->module); LLConstant* idxs[2] = {DtoConstUint(0), DtoConstUint(idx)}; iri->info = llvm::ConstantExpr::getGetElementPtr(irstruct->interfaceInfos, idxs, 2); idx++;
--- a/ir/irstruct.cpp Fri Jun 27 23:58:22 2008 +0200 +++ b/ir/irstruct.cpp Sat Jun 28 03:45:18 2008 +0200 @@ -4,15 +4,11 @@ #include "ir/irstruct.h" #include "gen/irstate.h" -#if OPAQUE_VTBLS -IrInterface::IrInterface(BaseClass* b, const llvm::ArrayType* vt) -#else -IrInterface::IrInterface(BaseClass* b, const llvm::StructType* vt) -#endif +IrInterface::IrInterface(BaseClass* b) { base = b; decl = b->base; - vtblTy = vt; + vtblTy = NULL; vtblInit = NULL; vtbl = NULL; infoTy = NULL; @@ -24,6 +20,7 @@ IrInterface::~IrInterface() { + delete vtblTy; } //////////////////////////////////////////////////////////////////////////////
--- a/ir/irstruct.h Fri Jun 27 23:58:22 2008 +0200 +++ b/ir/irstruct.h Sat Jun 28 03:45:18 2008 +0200 @@ -11,13 +11,8 @@ BaseClass* base; ClassDeclaration* decl; -#if OPAQUE_VTBLS - const LLArrayType* vtblTy; - LLConstantArray* vtblInit; -#else - const LLStructType* vtblTy; - LLConstantStruct* vtblInit; -#endif + llvm::PATypeHolder* vtblTy; + LLConstant* vtblInit; LLGlobalVariable* vtbl; const LLStructType* infoTy; @@ -26,11 +21,7 @@ int index; -#if OPAQUE_VTBLS - IrInterface(BaseClass* b, const LLArrayType* vt); -#else - IrInterface(BaseClass* b, const LLStructType* vt); -#endif + IrInterface(BaseClass* b); ~IrInterface(); };