Mercurial > projects > ldc
diff gen/classes.cpp @ 271:1e6e2b5d5bfe trunk
[svn r292] Fixed: string switch was broken in several ways.
Fixed: TypeInfo_Typedef.next was incorrect (return base of base instead of just base).
Fixed: ClassInfo offset type info (offTi) had invalid offsets.
author | lindquist |
---|---|
date | Wed, 18 Jun 2008 21:31:05 +0200 |
parents | 23d0d9855cad |
children | 665b81613475 |
line wrap: on
line diff
--- a/gen/classes.cpp Mon Jun 16 16:01:19 2008 +0200 +++ b/gen/classes.cpp Wed Jun 18 21:31:05 2008 +0200 @@ -1243,19 +1243,16 @@ cd->ir.irStruct->classInfo = new llvm::GlobalVariable(st, true, DtoLinkage(cd), NULL, gname, gIR->module); } -static LLConstant* build_offti_entry(VarDeclaration* vd) +static LLConstant* build_offti_entry(ClassDeclaration* cd, VarDeclaration* vd) { std::vector<const LLType*> types; std::vector<LLConstant*> inits; types.push_back(DtoSize_t()); - size_t offset = vd->offset; // TODO might not be the true offset - // dmd only accounts for the vtable, not classinfo or monitor - if (global.params.is64bit) - offset += 8; - else - offset += 4; + assert(vd->ir.irField); + assert(vd->ir.irField->index >= 0); + size_t offset = gTargetData->getStructLayout(isaStruct(cd->type->ir.type->get()))->getElementOffset(vd->ir.irField->index+2); inits.push_back(DtoConstSize_t(offset)); vd->type->getTypeInfo(NULL); @@ -1288,7 +1285,7 @@ Dsymbol *sm = (Dsymbol *)cd2->members->data[i]; if (VarDeclaration* vd = sm->isVarDeclaration()) // is this enough? { - LLConstant* c = build_offti_entry(vd); + LLConstant* c = build_offti_entry(cd, vd); assert(c); arrayInits.push_back(c); }