Mercurial > projects > ldc
diff gen/toir.cpp @ 705:5a2983f97498
Fixed weird struct problem from downs, see mini/compile_structs1.d
Rewrote DtoIndexStruct/Class , the old implementation were way too complex for what we really need now - since the DotVar changes.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Tue, 14 Oct 2008 15:35:49 +0200 |
parents | 43165a082535 |
children | 30b42a283c8e |
line wrap: on
line diff
--- a/gen/toir.cpp Tue Oct 14 13:21:14 2008 +0200 +++ b/gen/toir.cpp Tue Oct 14 15:35:49 2008 +0200 @@ -500,18 +500,7 @@ Type* e2type = e2->type->toBasetype(); if (e1type != e2type) { - /*if (llvmFieldIndex) { - assert(e1type->ty == Tpointer && e1next && e1next->ty == Tstruct); - Logger::println("add to AddrExp of struct"); - assert(r->isConst()); - llvm::ConstantInt* cofs = llvm::cast<llvm::ConstantInt>(r->isConst()->c); - - TypeStruct* ts = (TypeStruct*)e1next; - DStructIndexVector offsets; - LLValue* v = DtoIndexStruct(l->getRVal(), ts->sym, t->next, cofs->getZExtValue(), offsets); - return new DFieldValue(type, v); - } - else*/ if (e1type->ty == Tpointer) { + if (e1type->ty == Tpointer) { Logger::println("add to pointer"); if (r->isConst()) { llvm::ConstantInt* cofs = llvm::cast<llvm::ConstantInt>(r->isConst()->c); @@ -943,34 +932,21 @@ if (VarDeclaration* vd = var->isVarDeclaration()) { LLValue* arrptr; + // indexing struct pointer if (e1type->ty == Tpointer) { assert(e1type->next->ty == Tstruct); TypeStruct* ts = (TypeStruct*)e1type->next; - Logger::println("Struct member offset:%d", vd->offset); - - LLValue* src = l->getRVal(); - - DStructIndexVector vdoffsets; - arrptr = DtoIndexStruct(src, ts->sym, vd->type, vd->offset, vdoffsets); + arrptr = DtoIndexStruct(l->getRVal(), ts->sym, vd); } - // happens for tuples + // indexing normal struct else if (e1type->ty == Tstruct) { TypeStruct* ts = (TypeStruct*)e1type; - Logger::println("Struct member offset:%d", vd->offset); - - LLValue* src = l->getRVal(); - - DStructIndexVector vdoffsets; - arrptr = DtoIndexStruct(src, ts->sym, vd->type, vd->offset, vdoffsets); + arrptr = DtoIndexStruct(l->getRVal(), ts->sym, vd); } + // indexing class else if (e1type->ty == Tclass) { TypeClass* tc = (TypeClass*)e1type; - Logger::println("Class member offset: %d", vd->offset); - - LLValue* src = l->getRVal(); - - DStructIndexVector vdoffsets; - arrptr = DtoIndexClass(src, tc->sym, vd->type, vd->offset, vdoffsets); + arrptr = DtoIndexClass(l->getRVal(), tc->sym, vd); } else assert(0); @@ -1343,6 +1319,11 @@ if (rv->getType() != lv->getType()) { rv = DtoBitCast(rv, lv->getType()); } + if (Logger::enabled()) + { + Logger::cout() << "lv: " << *lv << '\n'; + Logger::cout() << "rv: " << *rv << '\n'; + } eval = p->ir->CreateICmp(cmpop, lv, rv, "tmp"); } else if (t->iscomplex())