mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-08-02 20:40:05 +02:00
Merge dmd v2.055
This commit is contained in:
128
dmd2/class.c
128
dmd2/class.c
@@ -232,11 +232,11 @@ Dsymbol *ClassDeclaration::syntaxCopy(Dsymbol *s)
|
||||
cd->storage_class |= storage_class;
|
||||
|
||||
cd->baseclasses->setDim(this->baseclasses->dim);
|
||||
for (int i = 0; i < cd->baseclasses->dim; i++)
|
||||
for (size_t i = 0; i < cd->baseclasses->dim; i++)
|
||||
{
|
||||
BaseClass *b = (BaseClass *)this->baseclasses->data[i];
|
||||
BaseClass *b = this->baseclasses->tdata()[i];
|
||||
BaseClass *b2 = new BaseClass(b->type->syntaxCopy(), b->protection);
|
||||
cd->baseclasses->data[i] = b2;
|
||||
cd->baseclasses->tdata()[i] = b2;
|
||||
}
|
||||
|
||||
ScopeDsymbol::syntaxCopy(cd);
|
||||
@@ -244,9 +244,7 @@ Dsymbol *ClassDeclaration::syntaxCopy(Dsymbol *s)
|
||||
}
|
||||
|
||||
void ClassDeclaration::semantic(Scope *sc)
|
||||
{ int i;
|
||||
unsigned offset;
|
||||
|
||||
{
|
||||
//printf("ClassDeclaration::semantic(%s), type = %p, sizeok = %d, this = %p\n", toChars(), type, sizeok, this);
|
||||
//printf("\tparent = %p, '%s'\n", sc->parent, sc->parent ? sc->parent->toChars() : "");
|
||||
//printf("sc->stc = %x\n", sc->stc);
|
||||
@@ -300,8 +298,8 @@ void ClassDeclaration::semantic(Scope *sc)
|
||||
error("cannot create C++ classes");
|
||||
|
||||
// Expand any tuples in baseclasses[]
|
||||
for (i = 0; i < baseclasses->dim; )
|
||||
{ BaseClass *b = (BaseClass *)baseclasses->data[i];
|
||||
for (size_t i = 0; i < baseclasses->dim; )
|
||||
{ BaseClass *b = baseclasses->tdata()[i];
|
||||
//printf("test1 %s %s\n", toChars(), b->type->toChars());
|
||||
b->type = b->type->semantic(loc, sc);
|
||||
//printf("test2\n");
|
||||
@@ -328,7 +326,7 @@ void ClassDeclaration::semantic(Scope *sc)
|
||||
BaseClass *b;
|
||||
Type *tb;
|
||||
|
||||
b = (BaseClass *)baseclasses->data[0];
|
||||
b = baseclasses->tdata()[0];
|
||||
//b->type = b->type->semantic(loc, sc);
|
||||
tb = b->type->toBasetype();
|
||||
if (tb->ty != Tclass)
|
||||
@@ -392,12 +390,12 @@ void ClassDeclaration::semantic(Scope *sc)
|
||||
|
||||
// Treat the remaining entries in baseclasses as interfaces
|
||||
// Check for errors, handle forward references
|
||||
for (i = (baseClass ? 1 : 0); i < baseclasses->dim; )
|
||||
for (size_t i = (baseClass ? 1 : 0); i < baseclasses->dim; )
|
||||
{ TypeClass *tc;
|
||||
BaseClass *b;
|
||||
Type *tb;
|
||||
|
||||
b = (BaseClass *)baseclasses->data[i];
|
||||
b = baseclasses->tdata()[i];
|
||||
b->type = b->type->semantic(loc, sc);
|
||||
tb = b->type->toBasetype();
|
||||
if (tb->ty == Tclass)
|
||||
@@ -426,7 +424,7 @@ void ClassDeclaration::semantic(Scope *sc)
|
||||
// Check for duplicate interfaces
|
||||
for (size_t j = (baseClass ? 1 : 0); j < i; j++)
|
||||
{
|
||||
BaseClass *b2 = (BaseClass *)baseclasses->data[j];
|
||||
BaseClass *b2 = baseclasses->tdata()[j];
|
||||
if (b2->base == tc->sym)
|
||||
error("inherits from duplicate interface %s", b2->base->toChars());
|
||||
}
|
||||
@@ -480,7 +478,7 @@ void ClassDeclaration::semantic(Scope *sc)
|
||||
}
|
||||
|
||||
interfaces_dim = baseclasses->dim;
|
||||
interfaces = (BaseClass **)baseclasses->data;
|
||||
interfaces = baseclasses->tdata();
|
||||
|
||||
|
||||
if (baseClass)
|
||||
@@ -493,7 +491,7 @@ void ClassDeclaration::semantic(Scope *sc)
|
||||
|
||||
// Copy vtbl[] from base class
|
||||
vtbl.setDim(baseClass->vtbl.dim);
|
||||
memcpy(vtbl.data, baseClass->vtbl.data, sizeof(void *) * vtbl.dim);
|
||||
memcpy(vtbl.tdata(), baseClass->vtbl.tdata(), sizeof(void *) * vtbl.dim);
|
||||
|
||||
// Inherit properties from base class
|
||||
com = baseClass->isCOMclass();
|
||||
@@ -515,9 +513,9 @@ void ClassDeclaration::semantic(Scope *sc)
|
||||
{
|
||||
interfaceSemantic(sc);
|
||||
|
||||
for (i = 0; i < members->dim; i++)
|
||||
for (size_t i = 0; i < members->dim; i++)
|
||||
{
|
||||
Dsymbol *s = (Dsymbol *)members->data[i];
|
||||
Dsymbol *s = members->tdata()[i];
|
||||
s->addMember(sc, this, 1);
|
||||
}
|
||||
|
||||
@@ -561,9 +559,9 @@ void ClassDeclaration::semantic(Scope *sc)
|
||||
if (ad)
|
||||
t = ad->handle;
|
||||
else if (fd)
|
||||
{ AggregateDeclaration *ad = fd->isMember2();
|
||||
if (ad)
|
||||
t = ad->handle;
|
||||
{ AggregateDeclaration *ad2 = fd->isMember2();
|
||||
if (ad2)
|
||||
t = ad2->handle;
|
||||
else
|
||||
{
|
||||
t = Type::tvoidptr;
|
||||
@@ -629,14 +627,14 @@ void ClassDeclaration::semantic(Scope *sc)
|
||||
}
|
||||
structsize = sc->offset;
|
||||
Scope scsave = *sc;
|
||||
int members_dim = members->dim;
|
||||
size_t members_dim = members->dim;
|
||||
sizeok = 0;
|
||||
|
||||
/* Set scope so if there are forward references, we still might be able to
|
||||
* resolve individual members like enums.
|
||||
*/
|
||||
for (i = 0; i < members_dim; i++)
|
||||
{ Dsymbol *s = (Dsymbol *)members->data[i];
|
||||
for (size_t i = 0; i < members_dim; i++)
|
||||
{ Dsymbol *s = members->tdata()[i];
|
||||
/* There are problems doing this in the general case because
|
||||
* Scope keeps track of things like 'offset'
|
||||
*/
|
||||
@@ -647,8 +645,8 @@ void ClassDeclaration::semantic(Scope *sc)
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < members_dim; i++)
|
||||
{ Dsymbol *s = (Dsymbol *)members->data[i];
|
||||
for (size_t i = 0; i < members_dim; i++)
|
||||
{ Dsymbol *s = members->tdata()[i];
|
||||
s->semantic(sc);
|
||||
}
|
||||
|
||||
@@ -724,9 +722,9 @@ void ClassDeclaration::semantic(Scope *sc)
|
||||
#endif
|
||||
|
||||
// Allocate instance of each new interface
|
||||
for (i = 0; i < vtblInterfaces->dim; i++)
|
||||
for (size_t i = 0; i < vtblInterfaces->dim; i++)
|
||||
{
|
||||
BaseClass *b = (BaseClass *)vtblInterfaces->data[i];
|
||||
BaseClass *b = vtblInterfaces->tdata()[i];
|
||||
unsigned thissize = PTRSIZE;
|
||||
|
||||
alignmember(structalign, thissize, &sc->offset);
|
||||
@@ -760,7 +758,7 @@ void ClassDeclaration::semantic(Scope *sc)
|
||||
// Fill in base class vtbl[]s
|
||||
for (i = 0; i < vtblInterfaces->dim; i++)
|
||||
{
|
||||
BaseClass *b = (BaseClass *)vtblInterfaces->data[i];
|
||||
BaseClass *b = vtblInterfaces->tdata()[i];
|
||||
|
||||
//b->fillVtbl(this, &b->vtbl, 1);
|
||||
}
|
||||
@@ -783,9 +781,9 @@ void ClassDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||
if (baseclasses->dim)
|
||||
buf->writestring(" : ");
|
||||
}
|
||||
for (int i = 0; i < baseclasses->dim; i++)
|
||||
for (size_t i = 0; i < baseclasses->dim; i++)
|
||||
{
|
||||
BaseClass *b = (BaseClass *)baseclasses->data[i];
|
||||
BaseClass *b = baseclasses->tdata()[i];
|
||||
|
||||
if (i)
|
||||
buf->writeByte(',');
|
||||
@@ -797,9 +795,9 @@ void ClassDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs)
|
||||
buf->writenl();
|
||||
buf->writeByte('{');
|
||||
buf->writenl();
|
||||
for (int i = 0; i < members->dim; i++)
|
||||
for (size_t i = 0; i < members->dim; i++)
|
||||
{
|
||||
Dsymbol *s = (Dsymbol *)members->data[i];
|
||||
Dsymbol *s = members->tdata()[i];
|
||||
|
||||
buf->writestring(" ");
|
||||
s->toCBuffer(buf, hgs);
|
||||
@@ -833,8 +831,8 @@ int ClassDeclaration::isBaseOf2(ClassDeclaration *cd)
|
||||
if (!cd)
|
||||
return 0;
|
||||
//printf("ClassDeclaration::isBaseOf2(this = '%s', cd = '%s')\n", toChars(), cd->toChars());
|
||||
for (int i = 0; i < cd->baseclasses->dim; i++)
|
||||
{ BaseClass *b = (BaseClass *)cd->baseclasses->data[i];
|
||||
for (size_t i = 0; i < cd->baseclasses->dim; i++)
|
||||
{ BaseClass *b = cd->baseclasses->tdata()[i];
|
||||
|
||||
if (b->base == this || isBaseOf2(b->base))
|
||||
return 1;
|
||||
@@ -879,8 +877,8 @@ int ClassDeclaration::isBaseInfoComplete()
|
||||
{
|
||||
if (!baseClass)
|
||||
return ident == Id::Object;
|
||||
for (int i = 0; i < baseclasses->dim; i++)
|
||||
{ BaseClass *b = (BaseClass *)baseclasses->data[i];
|
||||
for (size_t i = 0; i < baseclasses->dim; i++)
|
||||
{ BaseClass *b = baseclasses->tdata()[i];
|
||||
if (!b->base || !b->base->isBaseInfoComplete())
|
||||
return 0;
|
||||
}
|
||||
@@ -911,11 +909,9 @@ Dsymbol *ClassDeclaration::search(Loc loc, Identifier *ident, int flags)
|
||||
{
|
||||
// Search bases classes in depth-first, left to right order
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < baseclasses->dim; i++)
|
||||
for (size_t i = 0; i < baseclasses->dim; i++)
|
||||
{
|
||||
BaseClass *b = (BaseClass *)baseclasses->data[i];
|
||||
BaseClass *b = baseclasses->tdata()[i];
|
||||
|
||||
if (b->base)
|
||||
{
|
||||
@@ -962,9 +958,9 @@ int ClassDeclaration::isFuncHidden(FuncDeclaration *fd)
|
||||
OverloadSet *os = s->isOverloadSet();
|
||||
if (os)
|
||||
{
|
||||
for (int i = 0; i < os->a.dim; i++)
|
||||
{ Dsymbol *s = (Dsymbol *)os->a.data[i];
|
||||
FuncDeclaration *f2 = s->isFuncDeclaration();
|
||||
for (size_t i = 0; i < os->a.dim; i++)
|
||||
{ Dsymbol *s2 = os->a.tdata()[i];
|
||||
FuncDeclaration *f2 = s2->isFuncDeclaration();
|
||||
if (f2 && overloadApply(getModule(), f2, &isf, fd))
|
||||
return 0;
|
||||
}
|
||||
@@ -989,12 +985,12 @@ FuncDeclaration *ClassDeclaration::findFunc(Identifier *ident, TypeFunction *tf)
|
||||
//printf("ClassDeclaration::findFunc(%s, %s) %s\n", ident->toChars(), tf->toChars(), toChars());
|
||||
|
||||
ClassDeclaration *cd = this;
|
||||
Array *vtbl = &cd->vtbl;
|
||||
Dsymbols *vtbl = &cd->vtbl;
|
||||
while (1)
|
||||
{
|
||||
for (size_t i = 0; i < vtbl->dim; i++)
|
||||
{
|
||||
FuncDeclaration *fd = ((Dsymbol*)vtbl->data[i])->isFuncDeclaration();
|
||||
FuncDeclaration *fd = vtbl->tdata()[i]->isFuncDeclaration();
|
||||
if (!fd)
|
||||
continue; // the first entry might be a ClassInfo
|
||||
|
||||
@@ -1069,9 +1065,9 @@ int ClassDeclaration::isAbstract()
|
||||
{
|
||||
if (isabstract)
|
||||
return TRUE;
|
||||
for (int i = 1; i < vtbl.dim; i++)
|
||||
for (size_t i = 1; i < vtbl.dim; i++)
|
||||
{
|
||||
FuncDeclaration *fd = ((Dsymbol *)vtbl.data[i])->isFuncDeclaration();
|
||||
FuncDeclaration *fd = vtbl.tdata()[i]->isFuncDeclaration();
|
||||
|
||||
//printf("\tvtbl[%d] = %p\n", i, fd);
|
||||
if (!fd || fd->isAbstract())
|
||||
@@ -1139,8 +1135,7 @@ Dsymbol *InterfaceDeclaration::syntaxCopy(Dsymbol *s)
|
||||
}
|
||||
|
||||
void InterfaceDeclaration::semantic(Scope *sc)
|
||||
{ int i;
|
||||
|
||||
{
|
||||
//printf("InterfaceDeclaration::semantic(%s), type = %p\n", toChars(), type);
|
||||
if (inuse)
|
||||
return;
|
||||
@@ -1177,8 +1172,8 @@ void InterfaceDeclaration::semantic(Scope *sc)
|
||||
}
|
||||
|
||||
// Expand any tuples in baseclasses[]
|
||||
for (i = 0; i < baseclasses->dim; )
|
||||
{ BaseClass *b = (BaseClass *)baseclasses->data[0];
|
||||
for (size_t i = 0; i < baseclasses->dim; )
|
||||
{ BaseClass *b = baseclasses->tdata()[0];
|
||||
b->type = b->type->semantic(loc, sc);
|
||||
Type *tb = b->type->toBasetype();
|
||||
|
||||
@@ -1201,12 +1196,12 @@ void InterfaceDeclaration::semantic(Scope *sc)
|
||||
cpp = 1;
|
||||
|
||||
// Check for errors, handle forward references
|
||||
for (i = 0; i < baseclasses->dim; )
|
||||
for (size_t i = 0; i < baseclasses->dim; )
|
||||
{ TypeClass *tc;
|
||||
BaseClass *b;
|
||||
Type *tb;
|
||||
|
||||
b = (BaseClass *)baseclasses->data[i];
|
||||
b = baseclasses->tdata()[i];
|
||||
b->type = b->type->semantic(loc, sc);
|
||||
tb = b->type->toBasetype();
|
||||
if (tb->ty == Tclass)
|
||||
@@ -1224,7 +1219,7 @@ void InterfaceDeclaration::semantic(Scope *sc)
|
||||
// Check for duplicate interfaces
|
||||
for (size_t j = 0; j < i; j++)
|
||||
{
|
||||
BaseClass *b2 = (BaseClass *)baseclasses->data[j];
|
||||
BaseClass *b2 = baseclasses->tdata()[j];
|
||||
if (b2->base == tc->sym)
|
||||
error("inherits from duplicate interface %s", b2->base->toChars());
|
||||
}
|
||||
@@ -1260,7 +1255,7 @@ void InterfaceDeclaration::semantic(Scope *sc)
|
||||
}
|
||||
|
||||
interfaces_dim = baseclasses->dim;
|
||||
interfaces = (BaseClass **)baseclasses->data;
|
||||
interfaces = baseclasses->tdata();
|
||||
|
||||
interfaceSemantic(sc);
|
||||
|
||||
@@ -1268,7 +1263,7 @@ void InterfaceDeclaration::semantic(Scope *sc)
|
||||
vtbl.push(this); // leave room at vtbl[0] for classinfo
|
||||
|
||||
// Cat together the vtbl[]'s from base interfaces
|
||||
for (i = 0; i < interfaces_dim; i++)
|
||||
for (size_t i = 0; i < interfaces_dim; i++)
|
||||
{ BaseClass *b = interfaces[i];
|
||||
|
||||
// Skip if b has already appeared
|
||||
@@ -1285,7 +1280,7 @@ void InterfaceDeclaration::semantic(Scope *sc)
|
||||
{
|
||||
vtbl.reserve(d - 1);
|
||||
for (int j = 1; j < d; j++)
|
||||
vtbl.push(b->base->vtbl.data[j]);
|
||||
vtbl.push(b->base->vtbl.tdata()[j]);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1300,9 +1295,9 @@ void InterfaceDeclaration::semantic(Scope *sc)
|
||||
protection = sc->protection;
|
||||
storage_class |= sc->stc & STC_TYPECTOR;
|
||||
|
||||
for (i = 0; i < members->dim; i++)
|
||||
for (size_t i = 0; i < members->dim; i++)
|
||||
{
|
||||
Dsymbol *s = (Dsymbol *)members->data[i];
|
||||
Dsymbol *s = members->tdata()[i];
|
||||
s->addMember(sc, this, 1);
|
||||
}
|
||||
|
||||
@@ -1319,9 +1314,9 @@ void InterfaceDeclaration::semantic(Scope *sc)
|
||||
structalign = sc->structalign;
|
||||
sc->offset = PTRSIZE * 2;
|
||||
inuse++;
|
||||
for (i = 0; i < members->dim; i++)
|
||||
for (size_t i = 0; i < members->dim; i++)
|
||||
{
|
||||
Dsymbol *s = (Dsymbol *)members->data[i];
|
||||
Dsymbol *s = members->tdata()[i];
|
||||
s->semantic(sc);
|
||||
}
|
||||
inuse--;
|
||||
@@ -1414,8 +1409,8 @@ int InterfaceDeclaration::isBaseOf(BaseClass *bc, int *poffset)
|
||||
int InterfaceDeclaration::isBaseInfoComplete()
|
||||
{
|
||||
assert(!baseClass);
|
||||
for (int i = 0; i < baseclasses->dim; i++)
|
||||
{ BaseClass *b = (BaseClass *)baseclasses->data[i];
|
||||
for (size_t i = 0; i < baseclasses->dim; i++)
|
||||
{ BaseClass *b = baseclasses->tdata()[i];
|
||||
if (!b->base || !b->base->isBaseInfoComplete ())
|
||||
return 0;
|
||||
}
|
||||
@@ -1487,10 +1482,9 @@ BaseClass::BaseClass(Type *type, enum PROT protection)
|
||||
* by base classes)
|
||||
*/
|
||||
|
||||
int BaseClass::fillVtbl(ClassDeclaration *cd, Array *vtbl, int newinstance)
|
||||
int BaseClass::fillVtbl(ClassDeclaration *cd, FuncDeclarations *vtbl, int newinstance)
|
||||
{
|
||||
ClassDeclaration *id = base;
|
||||
int j;
|
||||
int result = 0;
|
||||
|
||||
//printf("BaseClass::fillVtbl(this='%s', cd='%s')\n", base->toChars(), cd->toChars());
|
||||
@@ -1498,9 +1492,9 @@ int BaseClass::fillVtbl(ClassDeclaration *cd, Array *vtbl, int newinstance)
|
||||
vtbl->setDim(base->vtbl.dim);
|
||||
|
||||
// first entry is ClassInfo reference
|
||||
for (j = base->vtblOffset(); j < base->vtbl.dim; j++)
|
||||
for (size_t j = base->vtblOffset(); j < base->vtbl.dim; j++)
|
||||
{
|
||||
FuncDeclaration *ifd = ((Dsymbol *)base->vtbl.data[j])->isFuncDeclaration();
|
||||
FuncDeclaration *ifd = base->vtbl.tdata()[j]->isFuncDeclaration();
|
||||
FuncDeclaration *fd;
|
||||
TypeFunction *tf;
|
||||
|
||||
@@ -1537,7 +1531,7 @@ int BaseClass::fillVtbl(ClassDeclaration *cd, Array *vtbl, int newinstance)
|
||||
fd = NULL;
|
||||
}
|
||||
if (vtbl)
|
||||
vtbl->data[j] = fd;
|
||||
vtbl->tdata()[j] = fd;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user