comparison gen/classes.cpp @ 169:2df270e1ba59 trunk

[svn r185] Fixed broken nested classes with data members, did DMD change the class layout? tango.text.Regex now compiles. Commented some of the *very* verbose logging for -vv option.
author lindquist
date Tue, 06 May 2008 03:07:21 +0200
parents a8cd9bc1021a
children db9890b3fb64
comparison
equal deleted inserted replaced
168:08cfde5f70d3 169:2df270e1ba59
767 if (newexp->thisexp) 767 if (newexp->thisexp)
768 { 768 {
769 Logger::println("Resolving outer class"); 769 Logger::println("Resolving outer class");
770 LOG_SCOPE; 770 LOG_SCOPE;
771 DValue* thisval = newexp->thisexp->toElem(gIR); 771 DValue* thisval = newexp->thisexp->toElem(gIR);
772 size_t idx = 2; 772 size_t idx = 2 + gIR->irDsymbol[tc->sym->vthis].irField->index;
773 //idx += gIR->irDsymbol[tc->sym].irStruct->interfaces.size(); 773 llvm::Value* src = thisval->getRVal();
774 llvm::Value* dst = thisval->getRVal(); 774 llvm::Value* dst = DtoGEPi(mem,0,idx,"tmp");
775 llvm::Value* src = DtoGEPi(mem,0,idx,"tmp");
776 Logger::cout() << "dst: " << *dst << "\nsrc: " << *src << '\n'; 775 Logger::cout() << "dst: " << *dst << "\nsrc: " << *src << '\n';
777 DtoStore(dst, src); 776 DtoStore(src, dst);
778 } 777 }
779 // set the context for nested classes 778 // set the context for nested classes
780 else if (tc->sym->isNested()) 779 else if (tc->sym->isNested())
781 { 780 {
782 Logger::println("Resolving nested context"); 781 Logger::println("Resolving nested context");
1108 //for (unsigned i=0; i<cd->fields.dim; ++i) { 1107 //for (unsigned i=0; i<cd->fields.dim; ++i) {
1109 //VarDeclaration* vd = (VarDeclaration*)cd->fields.data[i]; 1108 //VarDeclaration* vd = (VarDeclaration*)cd->fields.data[i];
1110 VarDeclaration* vd = i->second.var; 1109 VarDeclaration* vd = i->second.var;
1111 assert(vd); 1110 assert(vd);
1112 Type* vdtype = DtoDType(vd->type); 1111 Type* vdtype = DtoDType(vd->type);
1113 Logger::println("found %u type %s", vd->offset, vdtype->toChars()); 1112 //Logger::println("found %u type %s", vd->offset, vdtype->toChars());
1114 assert(gIR->irDsymbol[vd].irField->index >= 0); 1113 assert(gIR->irDsymbol[vd].irField->index >= 0);
1115 if (os == vd->offset && vdtype == t) { 1114 if (os == vd->offset && vdtype == t) {
1115 Logger::println("found %s %s", vdtype->toChars(), vd->toChars());
1116 idxs.push_back(gIR->irDsymbol[vd].irField->index + dataoffset); 1116 idxs.push_back(gIR->irDsymbol[vd].irField->index + dataoffset);
1117 Logger::cout() << "indexing: " << *ptr << '\n'; 1117 //Logger::cout() << "indexing: " << *ptr << '\n';
1118 ptr = DtoGEP(ptr, idxs, "tmp"); 1118 ptr = DtoGEP(ptr, idxs, "tmp");
1119 if (ptr->getType() != llt) 1119 if (ptr->getType() != llt)
1120 ptr = gIR->ir->CreateBitCast(ptr, llt, "tmp"); 1120 ptr = gIR->ir->CreateBitCast(ptr, llt, "tmp");
1121 Logger::cout() << "indexing: " << *ptr << '\n'; 1121 //Logger::cout() << "indexing: " << *ptr << '\n';
1122 if (gIR->irDsymbol[vd].irField->indexOffset) 1122 if (gIR->irDsymbol[vd].irField->indexOffset)
1123 ptr = new llvm::GetElementPtrInst(ptr, DtoConstUint(gIR->irDsymbol[vd].irField->indexOffset), "tmp", gIR->scopebb()); 1123 ptr = new llvm::GetElementPtrInst(ptr, DtoConstUint(gIR->irDsymbol[vd].irField->indexOffset), "tmp", gIR->scopebb());
1124 Logger::cout() << "indexing: " << *ptr << '\n'; 1124 //Logger::cout() << "indexing: " << *ptr << '\n';
1125 return ptr; 1125 return ptr;
1126 } 1126 }
1127 else if (vdtype->ty == Tstruct && (vd->offset + vdtype->size()) > os) { 1127 else if (vdtype->ty == Tstruct && (vd->offset + vdtype->size()) > os) {
1128 TypeStruct* ts = (TypeStruct*)vdtype; 1128 TypeStruct* ts = (TypeStruct*)vdtype;
1129 StructDeclaration* ssd = ts->sym; 1129 StructDeclaration* ssd = ts->sym;