mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-03-03 11:03:14 +01:00
Fixed class default initializers and type generation. Bug #260 is fixed.
This commit is contained in:
@@ -205,7 +205,11 @@ void DtoInitClass(TypeClass* tc, LLValue* dst)
|
||||
|
||||
// copy the rest from the static initializer
|
||||
LLValue* dstarr = DtoGEPi(dst,0,2,"tmp");
|
||||
LLValue* srcarr = DtoGEPi(tc->sym->ir.irStruct->getInitSymbol(),0,2,"tmp");
|
||||
|
||||
// init symbols might not have valid types
|
||||
LLValue* initsym = tc->sym->ir.irStruct->getInitSymbol();
|
||||
initsym = DtoBitCast(initsym, DtoType(tc));
|
||||
LLValue* srcarr = DtoGEPi(initsym,0,2,"tmp");
|
||||
|
||||
DtoMemCpy(dstarr, srcarr, DtoConstSize_t(n));
|
||||
}
|
||||
|
||||
@@ -44,13 +44,13 @@ void DtoResolveStruct(StructDeclaration* sd)
|
||||
IrStruct* irstruct = new IrStruct(sd);
|
||||
sd->ir.irStruct = irstruct;
|
||||
|
||||
// emit the initZ symbol
|
||||
LLGlobalVariable* initZ = irstruct->getInitSymbol();
|
||||
|
||||
// perform definition
|
||||
bool needs_def = mustDefineSymbol(sd);
|
||||
if (needs_def)
|
||||
{
|
||||
// emit the initZ symbol
|
||||
LLGlobalVariable* initZ = irstruct->getInitSymbol();
|
||||
|
||||
// set initZ initializer
|
||||
initZ->setInitializer(irstruct->getDefaultInit());
|
||||
}
|
||||
|
||||
@@ -217,7 +217,9 @@ DValue* VarExp::toElem(IRState* p)
|
||||
assert(ts->sym);
|
||||
ts->sym->codegen(Type::sir);
|
||||
|
||||
return new DVarValue(type, ts->sym->ir.irStruct->getInitSymbol());
|
||||
LLValue* initsym = ts->sym->ir.irStruct->getInitSymbol();
|
||||
initsym = DtoBitCast(initsym, DtoType(ts->pointerTo()));
|
||||
return new DVarValue(type, initsym);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1645,7 +1647,7 @@ DValue* NewExp::toElem(IRState* p)
|
||||
else {
|
||||
assert(ts->sym);
|
||||
ts->sym->codegen(Type::sir);
|
||||
DtoAggrCopy(mem,ts->sym->ir.irStruct->getInitSymbol());
|
||||
DtoAggrCopy(mem, ts->sym->ir.irStruct->getInitSymbol());
|
||||
}
|
||||
return new DImValue(type, mem);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user