comparison gen/classes.cpp @ 275:665b81613475 trunk

[svn r296] Removed: the 'suite' dir, it never took off! Fixed: foreach statement, key-type checks were buggy. Fixed: setting LLVMDC versions on the command line is now an error. Fixed: array compare runtime had incorrect param attrs on call. Fixed: index expressions on dynamic array slices w/o storage was broken. Fixed: scope classes had incorrect finalization in some cases. Fixed: when outputting !ClassInfoS !OffsetTypeInfoS, static class members were trying to be included, crashing the compiler. Fixed: calling LLVMDC with -inline but not any -O option caused assertion failure. Changed: the runtime now uses a single interface to "get" to !TypeInfoS, part of eliminating duplicate !TypeInfo codegen.
author lindquist
date Thu, 19 Jun 2008 17:30:32 +0200
parents 1e6e2b5d5bfe
children 70c370e97944
comparison
equal deleted inserted replaced
274:9f228c1e5311 275:665b81613475
445 // classinfo 445 // classinfo
446 DtoDeclareClassInfo(cd); 446 DtoDeclareClassInfo(cd);
447 447
448 // typeinfo 448 // typeinfo
449 if (needs_definition) 449 if (needs_definition)
450 cd->type->getTypeInfo(NULL); 450 DtoTypeInfoOf(cd->type, false);
451 } 451 }
452 452
453 ////////////////////////////////////////////////////////////////////////////////////////// 453 //////////////////////////////////////////////////////////////////////////////////////////
454 454
455 void DtoConstInitClass(ClassDeclaration* cd) 455 void DtoConstInitClass(ClassDeclaration* cd)
1253 assert(vd->ir.irField); 1253 assert(vd->ir.irField);
1254 assert(vd->ir.irField->index >= 0); 1254 assert(vd->ir.irField->index >= 0);
1255 size_t offset = gTargetData->getStructLayout(isaStruct(cd->type->ir.type->get()))->getElementOffset(vd->ir.irField->index+2); 1255 size_t offset = gTargetData->getStructLayout(isaStruct(cd->type->ir.type->get()))->getElementOffset(vd->ir.irField->index+2);
1256 inits.push_back(DtoConstSize_t(offset)); 1256 inits.push_back(DtoConstSize_t(offset));
1257 1257
1258 vd->type->getTypeInfo(NULL); 1258 LLConstant* c = DtoTypeInfoOf(vd->type, true);
1259 assert(vd->type->vtinfo); 1259 const LLType* tiTy = c->getType();
1260 DtoForceDeclareDsymbol(vd->type->vtinfo);
1261 LLConstant* c = isaConstant(vd->type->vtinfo->ir.getIrValue());
1262
1263 const LLType* tiTy = getPtrToType(Type::typeinfo->type->ir.type->get());
1264 //Logger::cout() << "tiTy = " << *tiTy << '\n'; 1260 //Logger::cout() << "tiTy = " << *tiTy << '\n';
1265 1261
1266 types.push_back(tiTy); 1262 types.push_back(tiTy);
1267 inits.push_back(llvm::ConstantExpr::getBitCast(c, tiTy)); 1263 inits.push_back(c);
1268 1264
1269 const llvm::StructType* sTy = llvm::StructType::get(types); 1265 const llvm::StructType* sTy = llvm::StructType::get(types);
1270 return llvm::ConstantStruct::get(sTy, inits); 1266 return llvm::ConstantStruct::get(sTy, inits);
1271 } 1267 }
1272 1268
1283 for (size_t i = 0; i < cd2->members->dim; i++) 1279 for (size_t i = 0; i < cd2->members->dim; i++)
1284 { 1280 {
1285 Dsymbol *sm = (Dsymbol *)cd2->members->data[i]; 1281 Dsymbol *sm = (Dsymbol *)cd2->members->data[i];
1286 if (VarDeclaration* vd = sm->isVarDeclaration()) // is this enough? 1282 if (VarDeclaration* vd = sm->isVarDeclaration()) // is this enough?
1287 { 1283 {
1288 LLConstant* c = build_offti_entry(cd, vd); 1284 if (!vd->isDataseg()) // static members dont have an offset!
1289 assert(c); 1285 {
1290 arrayInits.push_back(c); 1286 LLConstant* c = build_offti_entry(cd, vd);
1287 assert(c);
1288 arrayInits.push_back(c);
1289 }
1291 } 1290 }
1292 } 1291 }
1293 } 1292 }
1294 } 1293 }
1295 1294
1387 if (cd2->members) 1386 if (cd2->members)
1388 { 1387 {
1389 for (size_t i = 0; i < cd2->members->dim; i++) 1388 for (size_t i = 0; i < cd2->members->dim; i++)
1390 { 1389 {
1391 Dsymbol *sm = (Dsymbol *)cd2->members->data[i]; 1390 Dsymbol *sm = (Dsymbol *)cd2->members->data[i];
1392 if (sm->isVarDeclaration()) // is this enough? 1391 if (sm->isVarDeclaration() && !sm->isVarDeclaration()->isDataseg()) // is this enough?
1393 hasOffTi = true; 1392 hasOffTi = true;
1394 //printf("sm = %s %s\n", sm->kind(), sm->toChars()); 1393 //printf("sm = %s %s\n", sm->kind(), sm->toChars());
1395 if (sm->hasPointers()) 1394 if (sm->hasPointers())
1396 goto L2; 1395 goto L2;
1397 } 1396 }