mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-05 01:20:51 +03:00
[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.
This commit is contained in:
parent
88d497a936
commit
93a632c7c2
5 changed files with 54 additions and 13 deletions
|
@ -769,12 +769,11 @@ DValue* DtoNewClass(TypeClass* tc, NewExp* newexp)
|
|||
Logger::println("Resolving outer class");
|
||||
LOG_SCOPE;
|
||||
DValue* thisval = newexp->thisexp->toElem(gIR);
|
||||
size_t idx = 2;
|
||||
//idx += gIR->irDsymbol[tc->sym].irStruct->interfaces.size();
|
||||
llvm::Value* dst = thisval->getRVal();
|
||||
llvm::Value* src = DtoGEPi(mem,0,idx,"tmp");
|
||||
size_t idx = 2 + gIR->irDsymbol[tc->sym->vthis].irField->index;
|
||||
llvm::Value* src = thisval->getRVal();
|
||||
llvm::Value* dst = DtoGEPi(mem,0,idx,"tmp");
|
||||
Logger::cout() << "dst: " << *dst << "\nsrc: " << *src << '\n';
|
||||
DtoStore(dst, src);
|
||||
DtoStore(src, dst);
|
||||
}
|
||||
// set the context for nested classes
|
||||
else if (tc->sym->isNested())
|
||||
|
@ -1110,18 +1109,19 @@ llvm::Value* DtoIndexClass(llvm::Value* ptr, ClassDeclaration* cd, Type* t, unsi
|
|||
VarDeclaration* vd = i->second.var;
|
||||
assert(vd);
|
||||
Type* vdtype = DtoDType(vd->type);
|
||||
Logger::println("found %u type %s", vd->offset, vdtype->toChars());
|
||||
//Logger::println("found %u type %s", vd->offset, vdtype->toChars());
|
||||
assert(gIR->irDsymbol[vd].irField->index >= 0);
|
||||
if (os == vd->offset && vdtype == t) {
|
||||
Logger::println("found %s %s", vdtype->toChars(), vd->toChars());
|
||||
idxs.push_back(gIR->irDsymbol[vd].irField->index + dataoffset);
|
||||
Logger::cout() << "indexing: " << *ptr << '\n';
|
||||
//Logger::cout() << "indexing: " << *ptr << '\n';
|
||||
ptr = DtoGEP(ptr, idxs, "tmp");
|
||||
if (ptr->getType() != llt)
|
||||
ptr = gIR->ir->CreateBitCast(ptr, llt, "tmp");
|
||||
Logger::cout() << "indexing: " << *ptr << '\n';
|
||||
//Logger::cout() << "indexing: " << *ptr << '\n';
|
||||
if (gIR->irDsymbol[vd].irField->indexOffset)
|
||||
ptr = new llvm::GetElementPtrInst(ptr, DtoConstUint(gIR->irDsymbol[vd].irField->indexOffset), "tmp", gIR->scopebb());
|
||||
Logger::cout() << "indexing: " << *ptr << '\n';
|
||||
//Logger::cout() << "indexing: " << *ptr << '\n';
|
||||
return ptr;
|
||||
}
|
||||
else if (vdtype->ty == Tstruct && (vd->offset + vdtype->size()) > os) {
|
||||
|
|
|
@ -122,7 +122,7 @@ llvm::Value* DtoIndexStruct(llvm::Value* ptr, StructDeclaration* sd, Type* t, un
|
|||
for (unsigned i=0; i<sd->fields.dim; ++i) {
|
||||
VarDeclaration* vd = (VarDeclaration*)sd->fields.data[i];
|
||||
Type* vdtype = DtoDType(vd->type);
|
||||
Logger::println("found %u type %s", vd->offset, vdtype->toChars());
|
||||
//Logger::println("found %u type %s", vd->offset, vdtype->toChars());
|
||||
assert(gIR->irDsymbol[vd].irField->index >= 0);
|
||||
if (os == vd->offset && vdtype == t) {
|
||||
idxs.push_back(gIR->irDsymbol[vd].irField->index);
|
||||
|
|
|
@ -541,6 +541,8 @@ DValue* AssignExp::toElem(IRState* p)
|
|||
|
||||
p->exps.pop_back();
|
||||
|
||||
Logger::println("performing assignment");
|
||||
|
||||
DImValue* im = r->isIm();
|
||||
if (!im || !im->inPlace()) {
|
||||
Logger::println("assignment not inplace");
|
||||
|
@ -1007,7 +1009,7 @@ DValue* CallExp::toElem(IRState* p)
|
|||
|
||||
// this arguments
|
||||
if (dfn && dfn->vthis) {
|
||||
Logger::cout() << "This Call func val:" << *funcval << '\n';
|
||||
Logger::cout() << "This Call" << '\n';// func val:" << *funcval << '\n';
|
||||
if (dfn->vthis->getType() != argiter->get()) {
|
||||
//Logger::cout() << "value: " << *dfn->vthis << " totype: " << *argiter->get() << '\n';
|
||||
llargs[j] = DtoBitCast(dfn->vthis, argiter->get());
|
||||
|
@ -1155,7 +1157,7 @@ DValue* CallExp::toElem(IRState* p)
|
|||
}
|
||||
}
|
||||
|
||||
#if 1
|
||||
#if 0
|
||||
Logger::println("%d params passed", n);
|
||||
for (int i=0; i<llargs.size(); ++i) {
|
||||
assert(llargs[i]);
|
||||
|
@ -1168,7 +1170,7 @@ DValue* CallExp::toElem(IRState* p)
|
|||
if (llfnty->getReturnType() != llvm::Type::VoidTy)
|
||||
varname = "tmp";
|
||||
|
||||
Logger::cout() << "Calling: " << *funcval << '\n';
|
||||
//Logger::cout() << "Calling: " << *funcval << '\n';
|
||||
|
||||
// call the function
|
||||
llvm::CallInst* call = new llvm::CallInst(funcval, llargs.begin(), llargs.end(), varname, p->scopebb());
|
||||
|
@ -1894,6 +1896,7 @@ DValue* NewExp::toElem(IRState* p)
|
|||
Type* ntype = DtoDType(newtype);
|
||||
|
||||
if (ntype->ty == Tclass) {
|
||||
Logger::println("new class");
|
||||
return DtoNewClass((TypeClass*)ntype, this);
|
||||
}
|
||||
|
||||
|
|
|
@ -750,6 +750,7 @@ tangotests/a.d
|
|||
tangotests/aa1.d
|
||||
tangotests/b.d
|
||||
tangotests/c.d
|
||||
tangotests/classes1.d
|
||||
tangotests/constructors.d
|
||||
tangotests/d.d
|
||||
tangotests/e.d
|
||||
|
|
37
tangotests/classes1.d
Normal file
37
tangotests/classes1.d
Normal file
|
@ -0,0 +1,37 @@
|
|||
module tangotests.classes1;
|
||||
|
||||
class Outer
|
||||
{
|
||||
int data;
|
||||
|
||||
class Inner
|
||||
{
|
||||
long data;
|
||||
|
||||
this(long d)
|
||||
{
|
||||
data = d*2;
|
||||
}
|
||||
}
|
||||
|
||||
void func()
|
||||
{
|
||||
auto i = new Inner(data);
|
||||
data += (i.data/4);
|
||||
}
|
||||
|
||||
this(int d)
|
||||
{
|
||||
data = d;
|
||||
}
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
scope c = new Outer(100);
|
||||
c.func();
|
||||
int d = c.data;
|
||||
printf("150 = %d\n", d);
|
||||
}
|
||||
|
||||
extern(C) int printf(char*, ...);
|
Loading…
Add table
Add a link
Reference in a new issue