Mercurial > projects > ldc
comparison gen/classes.cpp @ 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 | 895e1b50cf2a |
children | d59c363fccad |
comparison
equal
deleted
inserted
replaced
306:0baca2feb554 | 307:7ade5e035beb |
---|---|
37 { | 37 { |
38 // don't add twice | 38 // don't add twice |
39 if (target->ir.irStruct->interfaceMap.find(bc->base) == target->ir.irStruct->interfaceMap.end()) | 39 if (target->ir.irStruct->interfaceMap.find(bc->base) == target->ir.irStruct->interfaceMap.end()) |
40 { | 40 { |
41 Logger::println("adding interface '%s'", bc->base->toPrettyChars()); | 41 Logger::println("adding interface '%s'", bc->base->toPrettyChars()); |
42 IrInterface* iri = new IrInterface(bc, NULL); | 42 IrInterface* iri = new IrInterface(bc); |
43 | 43 |
44 // add to map | 44 // add to map |
45 target->ir.irStruct->interfaceMap.insert(std::make_pair(bc->base, iri)); | 45 target->ir.irStruct->interfaceMap.insert(std::make_pair(bc->base, iri)); |
46 // add to ordered list | 46 // add to ordered list |
47 target->ir.irStruct->interfaceVec.push_back(iri); | 47 target->ir.irStruct->interfaceVec.push_back(iri); |
240 IrInterface* iri = *i; | 240 IrInterface* iri = *i; |
241 ClassDeclaration* id = iri->decl; | 241 ClassDeclaration* id = iri->decl; |
242 | 242 |
243 // set vtbl type | 243 // set vtbl type |
244 TypeClass* itc = (TypeClass*)id->type; | 244 TypeClass* itc = (TypeClass*)id->type; |
245 const LLType* ivtblTy = getPtrToType(itc->ir.vtblType->get()); | 245 const LLType* ivtblTy = itc->ir.vtblType->get(); |
246 fieldtypes.push_back(ivtblTy); | 246 assert(ivtblTy); |
247 Logger::cout() << "interface vtbl type: " << *ivtblTy << '\n'; | |
248 fieldtypes.push_back(getPtrToType(ivtblTy)); | |
247 | 249 |
248 // fix the interface vtable type | 250 // fix the interface vtable type |
249 #if OPAQUE_VTBLS | 251 assert(iri->vtblTy == NULL); |
250 iri->vtblTy = isaArray(itc->ir.vtblType->get()); | 252 iri->vtblTy = new llvm::PATypeHolder(ivtblTy); |
251 #else | |
252 iri->vtblTy = isaStruct(itc->ir.vtblType->get()); | |
253 #endif | |
254 assert(iri->vtblTy); | |
255 | 253 |
256 // set index | 254 // set index |
257 iri->index = interIdx++; | 255 iri->index = interIdx++; |
258 } | 256 } |
259 Logger::println("%d interface vtables added", cd->ir.irStruct->interfaceVec.size()); | 257 Logger::println("%d interface vtables added", cd->ir.irStruct->interfaceVec.size()); |
419 nam.append("11__interface"); | 417 nam.append("11__interface"); |
420 nam.append(id->mangle()); | 418 nam.append(id->mangle()); |
421 nam.append("6__vtblZ"); | 419 nam.append("6__vtblZ"); |
422 | 420 |
423 assert(iri->vtblTy); | 421 assert(iri->vtblTy); |
424 iri->vtbl = new llvm::GlobalVariable(iri->vtblTy, true, _linkage, 0, nam, gIR->module); | 422 iri->vtbl = new llvm::GlobalVariable(iri->vtblTy->get(), true, _linkage, 0, nam, gIR->module); |
425 LLConstant* idxs[2] = {DtoConstUint(0), DtoConstUint(idx)}; | 423 LLConstant* idxs[2] = {DtoConstUint(0), DtoConstUint(idx)}; |
426 iri->info = llvm::ConstantExpr::getGetElementPtr(irstruct->interfaceInfos, idxs, 2); | 424 iri->info = llvm::ConstantExpr::getGetElementPtr(irstruct->interfaceInfos, idxs, 2); |
427 idx++; | 425 idx++; |
428 } | 426 } |
429 | 427 |