Move storage of final vtbl from BaseClass to IrInterface: BaseClass instances are shared!

Always use the target's irstruct interfaceMap when building the const initializer.
Tango helloworld works again.
This commit is contained in:
Christian Kamm
2008-11-30 11:25:40 +01:00
parent dcf3c96f65
commit f14d97d786
3 changed files with 7 additions and 4 deletions

View File

@@ -154,6 +154,8 @@ struct UnionDeclaration : StructDeclaration
UnionDeclaration *isUnionDeclaration() { return this; }
};
// warning: two classes with the same base class share the same
// BaseClass instance.
struct BaseClass
{
Type *type; // (before semantic processing)

View File

@@ -66,7 +66,7 @@ static void add_interface(ClassDeclaration* target, BaseClass* b, int newinstanc
}
// build the interface vtable
b->fillVtbl(target, &b->vtbl, newinstance);
b->fillVtbl(target, &iri->vtblDecls, newinstance);
// add the vtable type
assert(inter->type->ir.type);
@@ -493,8 +493,8 @@ static size_t init_class_initializer(std::vector<LLConstant*>& inits, ClassDecla
lastsize = var->type->size();
}
// if it's a class, and it implements interfaces, add the vtables
IrStruct* irstruct = cd->ir.irStruct;
// if it's a class, and it implements interfaces, add the vtables - as found in the target class!
IrStruct* irstruct = target->ir.irStruct;
size_t nvtbls = cd->vtblInterfaces->dim;
for(size_t i=0; i<nvtbls; i++)
@@ -592,7 +592,7 @@ static void init_class_interface_vtbl_initializers(ClassDeclaration* cd)
Logger::println("interface %s", iri->decl->toChars());
// build vtable intializer for this interface implementation
Array& arr = iri->base->vtbl;
Array& arr = iri->vtblDecls;
size_t narr = arr.dim;
if (narr > 0)

View File

@@ -164,6 +164,7 @@ struct IrInterface : IrBase
LLConstant* vtblInit;
LLGlobalVariable* vtbl;
Array vtblDecls; // array of FuncDecls that make up the vtbl
const LLStructType* infoTy;
LLConstant* infoInit;