mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-06 10:57:35 +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");
|
Logger::println("Resolving outer class");
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
DValue* thisval = newexp->thisexp->toElem(gIR);
|
DValue* thisval = newexp->thisexp->toElem(gIR);
|
||||||
size_t idx = 2;
|
size_t idx = 2 + gIR->irDsymbol[tc->sym->vthis].irField->index;
|
||||||
//idx += gIR->irDsymbol[tc->sym].irStruct->interfaces.size();
|
llvm::Value* src = thisval->getRVal();
|
||||||
llvm::Value* dst = thisval->getRVal();
|
llvm::Value* dst = DtoGEPi(mem,0,idx,"tmp");
|
||||||
llvm::Value* src = DtoGEPi(mem,0,idx,"tmp");
|
|
||||||
Logger::cout() << "dst: " << *dst << "\nsrc: " << *src << '\n';
|
Logger::cout() << "dst: " << *dst << "\nsrc: " << *src << '\n';
|
||||||
DtoStore(dst, src);
|
DtoStore(src, dst);
|
||||||
}
|
}
|
||||||
// set the context for nested classes
|
// set the context for nested classes
|
||||||
else if (tc->sym->isNested())
|
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;
|
VarDeclaration* vd = i->second.var;
|
||||||
assert(vd);
|
assert(vd);
|
||||||
Type* vdtype = DtoDType(vd->type);
|
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);
|
assert(gIR->irDsymbol[vd].irField->index >= 0);
|
||||||
if (os == vd->offset && vdtype == t) {
|
if (os == vd->offset && vdtype == t) {
|
||||||
|
Logger::println("found %s %s", vdtype->toChars(), vd->toChars());
|
||||||
idxs.push_back(gIR->irDsymbol[vd].irField->index + dataoffset);
|
idxs.push_back(gIR->irDsymbol[vd].irField->index + dataoffset);
|
||||||
Logger::cout() << "indexing: " << *ptr << '\n';
|
//Logger::cout() << "indexing: " << *ptr << '\n';
|
||||||
ptr = DtoGEP(ptr, idxs, "tmp");
|
ptr = DtoGEP(ptr, idxs, "tmp");
|
||||||
if (ptr->getType() != llt)
|
if (ptr->getType() != llt)
|
||||||
ptr = gIR->ir->CreateBitCast(ptr, llt, "tmp");
|
ptr = gIR->ir->CreateBitCast(ptr, llt, "tmp");
|
||||||
Logger::cout() << "indexing: " << *ptr << '\n';
|
//Logger::cout() << "indexing: " << *ptr << '\n';
|
||||||
if (gIR->irDsymbol[vd].irField->indexOffset)
|
if (gIR->irDsymbol[vd].irField->indexOffset)
|
||||||
ptr = new llvm::GetElementPtrInst(ptr, DtoConstUint(gIR->irDsymbol[vd].irField->indexOffset), "tmp", gIR->scopebb());
|
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;
|
return ptr;
|
||||||
}
|
}
|
||||||
else if (vdtype->ty == Tstruct && (vd->offset + vdtype->size()) > os) {
|
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) {
|
for (unsigned i=0; i<sd->fields.dim; ++i) {
|
||||||
VarDeclaration* vd = (VarDeclaration*)sd->fields.data[i];
|
VarDeclaration* vd = (VarDeclaration*)sd->fields.data[i];
|
||||||
Type* vdtype = DtoDType(vd->type);
|
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);
|
assert(gIR->irDsymbol[vd].irField->index >= 0);
|
||||||
if (os == vd->offset && vdtype == t) {
|
if (os == vd->offset && vdtype == t) {
|
||||||
idxs.push_back(gIR->irDsymbol[vd].irField->index);
|
idxs.push_back(gIR->irDsymbol[vd].irField->index);
|
||||||
|
|
|
@ -541,6 +541,8 @@ DValue* AssignExp::toElem(IRState* p)
|
||||||
|
|
||||||
p->exps.pop_back();
|
p->exps.pop_back();
|
||||||
|
|
||||||
|
Logger::println("performing assignment");
|
||||||
|
|
||||||
DImValue* im = r->isIm();
|
DImValue* im = r->isIm();
|
||||||
if (!im || !im->inPlace()) {
|
if (!im || !im->inPlace()) {
|
||||||
Logger::println("assignment not inplace");
|
Logger::println("assignment not inplace");
|
||||||
|
@ -1007,7 +1009,7 @@ DValue* CallExp::toElem(IRState* p)
|
||||||
|
|
||||||
// this arguments
|
// this arguments
|
||||||
if (dfn && dfn->vthis) {
|
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()) {
|
if (dfn->vthis->getType() != argiter->get()) {
|
||||||
//Logger::cout() << "value: " << *dfn->vthis << " totype: " << *argiter->get() << '\n';
|
//Logger::cout() << "value: " << *dfn->vthis << " totype: " << *argiter->get() << '\n';
|
||||||
llargs[j] = DtoBitCast(dfn->vthis, argiter->get());
|
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);
|
Logger::println("%d params passed", n);
|
||||||
for (int i=0; i<llargs.size(); ++i) {
|
for (int i=0; i<llargs.size(); ++i) {
|
||||||
assert(llargs[i]);
|
assert(llargs[i]);
|
||||||
|
@ -1168,7 +1170,7 @@ DValue* CallExp::toElem(IRState* p)
|
||||||
if (llfnty->getReturnType() != llvm::Type::VoidTy)
|
if (llfnty->getReturnType() != llvm::Type::VoidTy)
|
||||||
varname = "tmp";
|
varname = "tmp";
|
||||||
|
|
||||||
Logger::cout() << "Calling: " << *funcval << '\n';
|
//Logger::cout() << "Calling: " << *funcval << '\n';
|
||||||
|
|
||||||
// call the function
|
// call the function
|
||||||
llvm::CallInst* call = new llvm::CallInst(funcval, llargs.begin(), llargs.end(), varname, p->scopebb());
|
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);
|
Type* ntype = DtoDType(newtype);
|
||||||
|
|
||||||
if (ntype->ty == Tclass) {
|
if (ntype->ty == Tclass) {
|
||||||
|
Logger::println("new class");
|
||||||
return DtoNewClass((TypeClass*)ntype, this);
|
return DtoNewClass((TypeClass*)ntype, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -750,6 +750,7 @@ tangotests/a.d
|
||||||
tangotests/aa1.d
|
tangotests/aa1.d
|
||||||
tangotests/b.d
|
tangotests/b.d
|
||||||
tangotests/c.d
|
tangotests/c.d
|
||||||
|
tangotests/classes1.d
|
||||||
tangotests/constructors.d
|
tangotests/constructors.d
|
||||||
tangotests/d.d
|
tangotests/d.d
|
||||||
tangotests/e.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