comparison gen/classes.cpp @ 806:96b404ba7eb0

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.
author Christian Kamm <kamm incasoftware de>
date Sun, 30 Nov 2008 11:25:40 +0100
parents 1b23aa1fb1b5
children 69a5e4a6fc0f
comparison
equal deleted inserted replaced
805:1b23aa1fb1b5 806:96b404ba7eb0
64 irstruct->interfaceMap.insert(std::make_pair(bc->base, iri)); 64 irstruct->interfaceMap.insert(std::make_pair(bc->base, iri));
65 } 65 }
66 } 66 }
67 67
68 // build the interface vtable 68 // build the interface vtable
69 b->fillVtbl(target, &b->vtbl, newinstance); 69 b->fillVtbl(target, &iri->vtblDecls, newinstance);
70 70
71 // add the vtable type 71 // add the vtable type
72 assert(inter->type->ir.type); 72 assert(inter->type->ir.type);
73 irstruct->types.push_back( inter->type->ir.type->get() ); 73 irstruct->types.push_back( inter->type->ir.type->get() );
74 // set and increment index 74 // set and increment index
491 491
492 lastoffset = offset; 492 lastoffset = offset;
493 lastsize = var->type->size(); 493 lastsize = var->type->size();
494 } 494 }
495 495
496 // if it's a class, and it implements interfaces, add the vtables 496 // if it's a class, and it implements interfaces, add the vtables - as found in the target class!
497 IrStruct* irstruct = cd->ir.irStruct; 497 IrStruct* irstruct = target->ir.irStruct;
498 498
499 size_t nvtbls = cd->vtblInterfaces->dim; 499 size_t nvtbls = cd->vtblInterfaces->dim;
500 for(size_t i=0; i<nvtbls; i++) 500 for(size_t i=0; i<nvtbls; i++)
501 { 501 {
502 BaseClass* bc = (BaseClass*)cd->vtblInterfaces->data[i]; 502 BaseClass* bc = (BaseClass*)cd->vtblInterfaces->data[i];
590 { 590 {
591 IrInterface* iri = irstruct->interfaceVec[i]; 591 IrInterface* iri = irstruct->interfaceVec[i];
592 Logger::println("interface %s", iri->decl->toChars()); 592 Logger::println("interface %s", iri->decl->toChars());
593 593
594 // build vtable intializer for this interface implementation 594 // build vtable intializer for this interface implementation
595 Array& arr = iri->base->vtbl; 595 Array& arr = iri->vtblDecls;
596 size_t narr = arr.dim; 596 size_t narr = arr.dim;
597 597
598 if (narr > 0) 598 if (narr > 0)
599 { 599 {
600 inits.resize(narr, NULL); 600 inits.resize(narr, NULL);