mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-03-14 16:11:49 +01:00
Automated merge with http://hg.dsource.org/projects/ldc
This commit is contained in:
@@ -57,7 +57,7 @@ static void LLVM_AddBaseClassInterfaces(ClassDeclaration* target, BaseClasses* b
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void LLVM_AddBaseClassData(BaseClasses* bcs)
|
||||
static void LLVM_AddBaseClassData(IrStruct* irstruct, BaseClasses* bcs)
|
||||
{
|
||||
// add base class data members first
|
||||
for (int j=0; j<bcs->dim; j++)
|
||||
@@ -69,7 +69,7 @@ static void LLVM_AddBaseClassData(BaseClasses* bcs)
|
||||
continue;
|
||||
|
||||
// recursively add baseclass data
|
||||
LLVM_AddBaseClassData(&bc->base->baseclasses);
|
||||
LLVM_AddBaseClassData(irstruct, &bc->base->baseclasses);
|
||||
|
||||
Array* arr = &bc->base->fields;
|
||||
if (arr->dim == 0)
|
||||
@@ -80,7 +80,9 @@ static void LLVM_AddBaseClassData(BaseClasses* bcs)
|
||||
|
||||
for (int k=0; k < arr->dim; k++) {
|
||||
VarDeclaration* v = (VarDeclaration*)(arr->data[k]);
|
||||
v->toObjFile(0); // TODO: multiobj
|
||||
Logger::println("Adding field: %s %s", v->type->toChars(), v->toChars());
|
||||
// init fields, used to happen in VarDeclaration::toObjFile
|
||||
irstruct->addField(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -143,9 +145,19 @@ void DtoResolveClass(ClassDeclaration* cd)
|
||||
fieldtypes.push_back(getVoidPtrType());
|
||||
|
||||
// add base class data fields first
|
||||
LLVM_AddBaseClassData(&cd->baseclasses);
|
||||
LLVM_AddBaseClassData(irstruct, &cd->baseclasses);
|
||||
|
||||
// then add own members, if any
|
||||
// add own fields
|
||||
Array* fields = &cd->fields;
|
||||
for (int k=0; k < fields->dim; k++)
|
||||
{
|
||||
VarDeclaration* v = (VarDeclaration*)fields->data[k];
|
||||
Logger::println("Adding field: %s %s", v->type->toChars(), v->toChars());
|
||||
// init fields, used to happen in VarDeclaration::toObjFile
|
||||
irstruct->addField(v);
|
||||
}
|
||||
|
||||
// then add other members of us, if any
|
||||
if(cd->members) {
|
||||
for (int k=0; k < cd->members->dim; k++) {
|
||||
Dsymbol* dsym = (Dsymbol*)(cd->members->data[k]);
|
||||
|
||||
@@ -92,7 +92,7 @@ void DtoResolveStruct(StructDeclaration* sd)
|
||||
TypeStruct* ts = (TypeStruct*)sd->type->toBasetype();
|
||||
|
||||
// this struct is a forward declaration
|
||||
// didn't even know had those ...
|
||||
// didn't even know D had those ...
|
||||
if (sd->sizeok != 1)
|
||||
{
|
||||
sd->ir.irStruct = new IrStruct(ts);
|
||||
@@ -102,10 +102,21 @@ void DtoResolveStruct(StructDeclaration* sd)
|
||||
|
||||
bool ispacked = (ts->alignsize() == 1);
|
||||
|
||||
// create the IrStruct
|
||||
IrStruct* irstruct = new IrStruct(ts);
|
||||
sd->ir.irStruct = irstruct;
|
||||
gIR->structs.push_back(irstruct);
|
||||
|
||||
// add fields
|
||||
Array* fields = &sd->fields;
|
||||
for (int k=0; k < fields->dim; k++)
|
||||
{
|
||||
VarDeclaration* v = (VarDeclaration*)fields->data[k];
|
||||
Logger::println("Adding field: %s %s", v->type->toChars(), v->toChars());
|
||||
// init fields, used to happen in VarDeclaration::toObjFile
|
||||
irstruct->addField(v);
|
||||
}
|
||||
|
||||
irstruct->packed = ispacked;
|
||||
|
||||
bool thisModule = false;
|
||||
|
||||
@@ -991,19 +991,10 @@ void VarDeclaration::toObjFile(int multiobj)
|
||||
else
|
||||
gIR->constInitList.push_back(this);
|
||||
}
|
||||
|
||||
// inside aggregate declaration. declare a field.
|
||||
else
|
||||
{
|
||||
Logger::println("Aggregate var declaration: '%s' offset=%d", toChars(), offset);
|
||||
|
||||
const LLType* _type = DtoType(type);
|
||||
this->ir.irField = new IrField(this);
|
||||
|
||||
// add the field in the IRStruct
|
||||
gIR->topstruct()->offsets.insert(std::make_pair(offset, IrStruct::Offset(this, _type)));
|
||||
assert(ir.irField != 0);
|
||||
}
|
||||
|
||||
Logger::println("VarDeclaration::toObjFile is done");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user