Mercurial > projects > ldc
comparison 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 |
comparison
equal
deleted
inserted
replaced
270:d9d5d59873d8 | 271:1e6e2b5d5bfe |
---|---|
1241 const LLType* st = cinfo->type->ir.type->get(); | 1241 const LLType* st = cinfo->type->ir.type->get(); |
1242 | 1242 |
1243 cd->ir.irStruct->classInfo = new llvm::GlobalVariable(st, true, DtoLinkage(cd), NULL, gname, gIR->module); | 1243 cd->ir.irStruct->classInfo = new llvm::GlobalVariable(st, true, DtoLinkage(cd), NULL, gname, gIR->module); |
1244 } | 1244 } |
1245 | 1245 |
1246 static LLConstant* build_offti_entry(VarDeclaration* vd) | 1246 static LLConstant* build_offti_entry(ClassDeclaration* cd, VarDeclaration* vd) |
1247 { | 1247 { |
1248 std::vector<const LLType*> types; | 1248 std::vector<const LLType*> types; |
1249 std::vector<LLConstant*> inits; | 1249 std::vector<LLConstant*> inits; |
1250 | 1250 |
1251 types.push_back(DtoSize_t()); | 1251 types.push_back(DtoSize_t()); |
1252 | 1252 |
1253 size_t offset = vd->offset; // TODO might not be the true offset | 1253 assert(vd->ir.irField); |
1254 // dmd only accounts for the vtable, not classinfo or monitor | 1254 assert(vd->ir.irField->index >= 0); |
1255 if (global.params.is64bit) | 1255 size_t offset = gTargetData->getStructLayout(isaStruct(cd->type->ir.type->get()))->getElementOffset(vd->ir.irField->index+2); |
1256 offset += 8; | |
1257 else | |
1258 offset += 4; | |
1259 inits.push_back(DtoConstSize_t(offset)); | 1256 inits.push_back(DtoConstSize_t(offset)); |
1260 | 1257 |
1261 vd->type->getTypeInfo(NULL); | 1258 vd->type->getTypeInfo(NULL); |
1262 assert(vd->type->vtinfo); | 1259 assert(vd->type->vtinfo); |
1263 DtoForceDeclareDsymbol(vd->type->vtinfo); | 1260 DtoForceDeclareDsymbol(vd->type->vtinfo); |
1286 for (size_t i = 0; i < cd2->members->dim; i++) | 1283 for (size_t i = 0; i < cd2->members->dim; i++) |
1287 { | 1284 { |
1288 Dsymbol *sm = (Dsymbol *)cd2->members->data[i]; | 1285 Dsymbol *sm = (Dsymbol *)cd2->members->data[i]; |
1289 if (VarDeclaration* vd = sm->isVarDeclaration()) // is this enough? | 1286 if (VarDeclaration* vd = sm->isVarDeclaration()) // is this enough? |
1290 { | 1287 { |
1291 LLConstant* c = build_offti_entry(vd); | 1288 LLConstant* c = build_offti_entry(cd, vd); |
1292 assert(c); | 1289 assert(c); |
1293 arrayInits.push_back(c); | 1290 arrayInits.push_back(c); |
1294 } | 1291 } |
1295 } | 1292 } |
1296 } | 1293 } |