diff --git a/src/access.c b/src/access.c index 0e075512dc3a..a2a5e607f1e6 100644 --- a/src/access.c +++ b/src/access.c @@ -85,7 +85,7 @@ enum PROT ClassDeclaration::getAccess(Dsymbol *smember) } for (i = 0; i < baseclasses->dim; i++) - { BaseClass *b = (BaseClass *)baseclasses->data[i]; + { BaseClass *b = baseclasses->tdata()[i]; access = b->base->getAccess(smember); switch (access) @@ -154,7 +154,7 @@ static int accessCheckX( if (cdthis) { for (int i = 0; i < cdthis->baseclasses->dim; i++) - { BaseClass *b = (BaseClass *)cdthis->baseclasses->data[i]; + { BaseClass *b = cdthis->baseclasses->tdata()[i]; enum PROT access; access = b->base->getAccess(smember); @@ -175,7 +175,7 @@ static int accessCheckX( if (cdthis) { for (int i = 0; i < cdthis->baseclasses->dim; i++) - { BaseClass *b = (BaseClass *)cdthis->baseclasses->data[i]; + { BaseClass *b = cdthis->baseclasses->tdata()[i]; if (accessCheckX(smember, sfunc, b->base, cdscope)) return 1; diff --git a/src/aggregate.h b/src/aggregate.h index c30c787e63f8..504e2637b9f3 100644 --- a/src/aggregate.h +++ b/src/aggregate.h @@ -210,8 +210,8 @@ struct ClassDeclaration : AggregateDeclaration #endif FuncDeclaration *staticCtor; FuncDeclaration *staticDtor; - FuncDeclarations vtbl; // Array of FuncDeclaration's making up the vtbl[] - FuncDeclarations vtblFinal; // More FuncDeclaration's that aren't in vtbl[] + Dsymbols vtbl; // Array of FuncDeclaration's making up the vtbl[] + Dsymbols vtblFinal; // More FuncDeclaration's that aren't in vtbl[] BaseClasses *baseclasses; // Array of BaseClass's; first is super, // rest are Interface's diff --git a/src/arrayop.c b/src/arrayop.c index fb89523c5c00..6cbe7ffbb9ca 100644 --- a/src/arrayop.c +++ b/src/arrayop.c @@ -319,7 +319,7 @@ Expression *BinExp::arrayOp(Scope *sc) Parameters *fparams = new Parameters(); Expression *loopbody = buildArrayLoop(fparams); - Parameter *p = (Parameter *)fparams->data[0 /*fparams->dim - 1*/]; + Parameter *p = fparams->tdata()[0 /*fparams->dim - 1*/]; #if DMDV1 // for (size_t i = 0; i < p.length; i++) Initializer *init = new ExpInitializer(0, new IntegerExp(0, 0, Type::tsize_t)); @@ -522,7 +522,7 @@ Expression *AssignExp::buildArrayLoop(Parameters *fparams) ex2 = new CastExp(0, ex2, e1->type->nextOf()); #endif Expression *ex1 = e1->buildArrayLoop(fparams); - Parameter *param = (Parameter *)fparams->data[0]; + Parameter *param = fparams->tdata()[0]; param->storageClass = 0; Expression *e = new AssignExp(0, ex1, ex2); return e; @@ -535,7 +535,7 @@ Expression *Str##AssignExp::buildArrayLoop(Parameters *fparams) \ */ \ Expression *ex2 = e2->buildArrayLoop(fparams); \ Expression *ex1 = e1->buildArrayLoop(fparams); \ - Parameter *param = (Parameter *)fparams->data[0]; \ + Parameter *param = fparams->tdata()[0]; \ param->storageClass = 0; \ Expression *e = new Str##AssignExp(0, ex1, ex2); \ return e; \ diff --git a/src/arraytypes.h b/src/arraytypes.h index e4440085fd27..717b47b0bc33 100644 --- a/src/arraytypes.h +++ b/src/arraytypes.h @@ -54,6 +54,7 @@ struct Symbol; void insert(unsigned index, TYPE *v) { ArrayBase::insert(index, (void *)v); } \ void insert(unsigned index, ArrayOf_##TYPE *a) { ArrayBase::insert(index, (ArrayBase *)a); } \ void append(ArrayOf_##TYPE *a) { ArrayBase::append((ArrayBase *)a); } \ + void push(TYPE *a) { ArrayBase::push((void *)a); } \ ArrayOf_##TYPE *copy() { return (ArrayOf_##TYPE *)ArrayBase::copy(); } \ } diff --git a/src/attrib.c b/src/attrib.c index dd0d1afe003d..1eeb462690b0 100644 --- a/src/attrib.c +++ b/src/attrib.c @@ -55,7 +55,7 @@ int AttribDeclaration::addMember(Scope *sc, ScopeDsymbol *sd, int memnum) if (d) { for (unsigned i = 0; i < d->dim; i++) - { Dsymbol *s = (Dsymbol *)d->data[i]; + { Dsymbol *s = d->tdata()[i]; //printf("\taddMember %s to %s\n", s->toChars(), sd->toChars()); m |= s->addMember(sc, sd, m | memnum); } @@ -86,7 +86,7 @@ void AttribDeclaration::setScopeNewSc(Scope *sc, newsc->structalign = structalign; } for (unsigned i = 0; i < decl->dim; i++) - { Dsymbol *s = (Dsymbol *)decl->data[i]; + { Dsymbol *s = decl->tdata()[i]; s->setScope(newsc); // yes, the only difference from semanticNewSc() } @@ -121,7 +121,7 @@ void AttribDeclaration::semanticNewSc(Scope *sc, newsc->structalign = structalign; } for (unsigned i = 0; i < decl->dim; i++) - { Dsymbol *s = (Dsymbol *)decl->data[i]; + { Dsymbol *s = decl->tdata()[i]; s->semantic(newsc); } @@ -142,7 +142,7 @@ void AttribDeclaration::semantic(Scope *sc) { for (unsigned i = 0; i < d->dim; i++) { - Dsymbol *s = (Dsymbol *)d->data[i]; + Dsymbol *s = d->tdata()[i]; s->semantic(sc); } @@ -156,7 +156,7 @@ void AttribDeclaration::semantic2(Scope *sc) if (d) { for (unsigned i = 0; i < d->dim; i++) - { Dsymbol *s = (Dsymbol *)d->data[i]; + { Dsymbol *s = d->tdata()[i]; s->semantic2(sc); } } @@ -169,7 +169,7 @@ void AttribDeclaration::semantic3(Scope *sc) if (d) { for (unsigned i = 0; i < d->dim; i++) - { Dsymbol *s = (Dsymbol *)d->data[i]; + { Dsymbol *s = d->tdata()[i]; s->semantic3(sc); } } @@ -182,7 +182,7 @@ void AttribDeclaration::inlineScan() if (d) { for (unsigned i = 0; i < d->dim; i++) - { Dsymbol *s = (Dsymbol *)d->data[i]; + { Dsymbol *s = d->tdata()[i]; //printf("AttribDeclaration::inlineScan %s\n", s->toChars()); s->inlineScan(); } @@ -199,7 +199,7 @@ void AttribDeclaration::addComment(unsigned char *comment) if (d) { for (unsigned i = 0; i < d->dim; i++) - { Dsymbol *s = (Dsymbol *)d->data[i]; + { Dsymbol *s = d->tdata()[i]; //printf("AttribDeclaration::addComment %s\n", s->toChars()); s->addComment(comment); } @@ -224,7 +224,7 @@ void AttribDeclaration::emitComment(Scope *sc) if (d) { for (unsigned i = 0; i < d->dim; i++) - { Dsymbol *s = (Dsymbol *)d->data[i]; + { Dsymbol *s = d->tdata()[i]; //printf("AttribDeclaration::emitComment %s\n", s->toChars()); s->emitComment(sc); } @@ -238,7 +238,7 @@ void AttribDeclaration::toObjFile(int multiobj) if (d) { for (unsigned i = 0; i < d->dim; i++) - { Dsymbol *s = (Dsymbol *)d->data[i]; + { Dsymbol *s = d->tdata()[i]; s->toObjFile(multiobj); } } @@ -253,7 +253,7 @@ int AttribDeclaration::cvMember(unsigned char *p) if (d) { for (unsigned i = 0; i < d->dim; i++) - { Dsymbol *s = (Dsymbol *)d->data[i]; + { Dsymbol *s = d->tdata()[i]; n = s->cvMember(p); if (p) p += n; @@ -271,7 +271,7 @@ int AttribDeclaration::hasPointers() { for (size_t i = 0; i < d->dim; i++) { - Dsymbol *s = (Dsymbol *)d->data[i]; + Dsymbol *s = d->tdata()[i]; if (s->hasPointers()) return 1; } @@ -298,7 +298,7 @@ void AttribDeclaration::checkCtorConstInit() if (d) { for (unsigned i = 0; i < d->dim; i++) - { Dsymbol *s = (Dsymbol *)d->data[i]; + { Dsymbol *s = d->tdata()[i]; s->checkCtorConstInit(); } } @@ -314,7 +314,7 @@ void AttribDeclaration::addLocalClass(ClassDeclarations *aclasses) if (d) { for (unsigned i = 0; i < d->dim; i++) - { Dsymbol *s = (Dsymbol *)d->data[i]; + { Dsymbol *s = d->tdata()[i]; s->addLocalClass(aclasses); } } @@ -328,7 +328,7 @@ void AttribDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) if (decl->dim == 0) buf->writestring("{}"); else if (decl->dim == 1) - ((Dsymbol *)decl->data[0])->toCBuffer(buf, hgs); + (decl->tdata()[0])->toCBuffer(buf, hgs); else { buf->writenl(); @@ -336,7 +336,7 @@ void AttribDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) buf->writenl(); for (unsigned i = 0; i < decl->dim; i++) { - Dsymbol *s = (Dsymbol *)decl->data[i]; + Dsymbol *s = decl->tdata()[i]; buf->writestring(" "); s->toCBuffer(buf, hgs); @@ -528,7 +528,7 @@ void LinkDeclaration::semantic3(Scope *sc) sc->linkage = linkage; for (unsigned i = 0; i < decl->dim; i++) { - Dsymbol *s = (Dsymbol *)decl->data[i]; + Dsymbol *s = decl->tdata()[i]; s->semantic3(sc); } @@ -606,7 +606,7 @@ void ProtDeclaration::importAll(Scope *sc) for (int i = 0; i < decl->dim; i++) { - Dsymbol *s = (Dsymbol *)decl->data[i]; + Dsymbol *s = decl->tdata()[i]; s->importAll(newsc); } @@ -765,7 +765,7 @@ void AnonDeclaration::semantic(Scope *sc) for (unsigned i = 0; i < decl->dim; i++) { - Dsymbol *s = (Dsymbol *)decl->data[i]; + Dsymbol *s = decl->tdata()[i]; s->semantic(sc); if (isunion) @@ -817,7 +817,7 @@ void AnonDeclaration::semantic(Scope *sc) //printf("\tadding members of aad to '%s'\n", ad->toChars()); for (unsigned i = 0; i < aad.fields.dim; i++) { - VarDeclaration *v = (VarDeclaration *)aad.fields.data[i]; + VarDeclaration *v = aad.fields.tdata()[i]; v->offset += sc->offset; ad->fields.push(v); @@ -850,7 +850,7 @@ void AnonDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) { for (unsigned i = 0; i < decl->dim; i++) { - Dsymbol *s = (Dsymbol *)decl->data[i]; + Dsymbol *s = decl->tdata()[i]; //buf->writestring(" "); s->toCBuffer(buf, hgs); @@ -896,10 +896,10 @@ void PragmaDeclaration::setScope(Scope *sc) } else { - Expression *e = (Expression *)args->data[0]; + Expression *e = args->tdata()[0]; e = e->semantic(sc); e = e->optimize(WANTvalue | WANTinterpret); - args->data[0] = (void *)e; + args->tdata()[0] = e; if (e->op != TOKstring) { error("string expected, not '%s'", e->toChars()); @@ -928,7 +928,7 @@ void PragmaDeclaration::semantic(Scope *sc) { for (size_t i = 0; i < args->dim; i++) { - Expression *e = (Expression *)args->data[i]; + Expression *e = args->tdata()[i]; e = e->semantic(sc); e = e->optimize(WANTvalue | WANTinterpret); @@ -950,11 +950,11 @@ void PragmaDeclaration::semantic(Scope *sc) error("string expected for library name"); else { - Expression *e = (Expression *)args->data[0]; + Expression *e = args->tdata()[0]; e = e->semantic(sc); e = e->optimize(WANTvalue | WANTinterpret); - args->data[0] = (void *)e; + args->tdata()[0] = e; if (e->op == TOKerror) goto Lnodecl; if (e->op != TOKstring) @@ -982,7 +982,7 @@ void PragmaDeclaration::semantic(Scope *sc) Declaration *d = NULL; StringExp *s = NULL; - e = (Expression *)args->data[0]; + e = args->tdata()[0]; e = e->semantic(sc); if (e->op == TOKvar) { @@ -993,7 +993,7 @@ void PragmaDeclaration::semantic(Scope *sc) if (!d) error("first argument of GNU_asm must be a function or variable declaration"); - e = (Expression *)args->data[1]; + e = args->tdata()[1]; e = e->semantic(sc); e = e->optimize(WANTvalue); if (e->op == TOKstring && ((StringExp *)e)->sz == 1) @@ -1014,10 +1014,10 @@ void PragmaDeclaration::semantic(Scope *sc) error("function name expected for start address"); else { - Expression *e = (Expression *)args->data[0]; + Expression *e = args->tdata()[0]; e = e->semantic(sc); e = e->optimize(WANTvalue | WANTinterpret); - args->data[0] = (void *)e; + args->tdata()[0] = e; Dsymbol *sa = getDsymbol(e); if (!sa || !sa->isFuncDeclaration()) error("function name expected for start address, not '%s'", e->toChars()); @@ -1041,7 +1041,7 @@ void PragmaDeclaration::semantic(Scope *sc) { for (size_t i = 0; i < args->dim; i++) { - Expression *e = (Expression *)args->data[i]; + Expression *e = args->tdata()[i]; e = e->semantic(sc); e = e->optimize(WANTvalue | WANTinterpret); if (i == 0) @@ -1064,7 +1064,7 @@ void PragmaDeclaration::semantic(Scope *sc) { for (unsigned i = 0; i < decl->dim; i++) { - Dsymbol *s = (Dsymbol *)decl->data[i]; + Dsymbol *s = decl->tdata()[i]; s->semantic(sc); } @@ -1093,7 +1093,7 @@ void PragmaDeclaration::toObjFile(int multiobj) { assert(args && args->dim == 1); - Expression *e = (Expression *)args->data[0]; + Expression *e = args->tdata()[0]; assert(e->op == TOKstring); @@ -1112,7 +1112,7 @@ void PragmaDeclaration::toObjFile(int multiobj) * so instead append the library name to the list to be passed * to the linker. */ - global.params.libfiles->push((void *) name); + global.params.libfiles->push(name); #else error("pragma lib not supported"); #endif @@ -1121,7 +1121,7 @@ void PragmaDeclaration::toObjFile(int multiobj) else if (ident == Id::startaddress) { assert(args && args->dim == 1); - Expression *e = (Expression *)args->data[0]; + Expression *e = args->tdata()[0]; Dsymbol *sa = getDsymbol(e); FuncDeclaration *f = sa->isFuncDeclaration(); assert(f); @@ -1193,7 +1193,7 @@ void ConditionalDeclaration::emitComment(Scope *sc) */ Dsymbols *d = decl ? decl : elsedecl; for (unsigned i = 0; i < d->dim; i++) - { Dsymbol *s = (Dsymbol *)d->data[i]; + { Dsymbol *s = d->tdata()[i]; s->emitComment(sc); } } @@ -1217,7 +1217,7 @@ void ConditionalDeclaration::setScope(Scope *sc) { for (unsigned i = 0; i < d->dim; i++) { - Dsymbol *s = (Dsymbol *)d->data[i]; + Dsymbol *s = d->tdata()[i]; s->setScope(sc); } @@ -1233,7 +1233,7 @@ void ConditionalDeclaration::importAll(Scope *sc) { for (unsigned i = 0; i < d->dim; i++) { - Dsymbol *s = (Dsymbol *)d->data[i]; + Dsymbol *s = d->tdata()[i]; s->importAll(sc); } @@ -1259,7 +1259,7 @@ void ConditionalDeclaration::addComment(unsigned char *comment) for (unsigned i = 0; i < d->dim; i++) { Dsymbol *s; - s = (Dsymbol *)d->data[i]; + s = d->tdata()[i]; //printf("ConditionalDeclaration::addComment %s\n", s->toChars()); s->addComment(comment); } @@ -1281,7 +1281,7 @@ void ConditionalDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) { for (unsigned i = 0; i < decl->dim; i++) { - Dsymbol *s = (Dsymbol *)decl->data[i]; + Dsymbol *s = decl->tdata()[i]; buf->writestring(" "); s->toCBuffer(buf, hgs); @@ -1297,7 +1297,7 @@ void ConditionalDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) buf->writenl(); for (unsigned i = 0; i < elsedecl->dim; i++) { - Dsymbol *s = (Dsymbol *)elsedecl->data[i]; + Dsymbol *s = elsedecl->tdata()[i]; buf->writestring(" "); s->toCBuffer(buf, hgs); @@ -1383,7 +1383,7 @@ void StaticIfDeclaration::semantic(Scope *sc) for (unsigned i = 0; i < d->dim; i++) { - Dsymbol *s = (Dsymbol *)d->data[i]; + Dsymbol *s = d->tdata()[i]; s->semantic(sc); } diff --git a/src/backend/cgcv.c b/src/backend/cgcv.c index 68ab29454519..cbc6a0cbba6f 100644 --- a/src/backend/cgcv.c +++ b/src/backend/cgcv.c @@ -238,7 +238,7 @@ void debtyp_check(debtyp_t *d,int linnum) //printf("linnum = %d\n",linnum); //printf(" length = %d\n",d->length); for (i = 0; i < d->length; i++) - c = d->data[i]; + c = d->tdata()[i]; } #define debtyp_check(d) debtyp_check(d,__LINE__); @@ -890,7 +890,7 @@ idx_t cv4_struct(Classsym *s,int flags) descriptor |= 5; if (tyfarfunc(ty)) descriptor++; - vshape->data[4 + n / 2] = descriptor; + vshape->tdata()[4 + n / 2] = descriptor; descriptor <<= 4; n++; } @@ -930,7 +930,7 @@ printf("fwd struct ref\n"); {int i; printf("len = %d, length = %d\n",len,d->length); for (i=0;ilength;i++) - printf("%02x ",d->data[i]); + printf("%02x ",d->tdata()[i]); printf("\n"); } #endif @@ -1250,15 +1250,15 @@ printf("fwd struct ref\n"); if (config.fulltypes == CV4) { db = debtyp_alloc(6); TOWORD(db->data,LF_BITFIELD); - db->data[2] = sf->Swidth; - db->data[3] = sf->Sbit; + db->tdata()[2] = sf->Swidth; + db->tdata()[3] = sf->Sbit; TOWORD(db->data + 4,cv4_symtypidx(sf)); } else { db = debtyp_alloc(8); TOWORD(db->data,LF_BITFIELD); - db->data[6] = sf->Swidth; - db->data[7] = sf->Sbit; + db->tdata()[6] = sf->Swidth; + db->tdata()[7] = sf->Sbit; TOLONG(db->data + 2,cv4_symtypidx(sf)); } typidx = cv_debtyp(db); @@ -1861,7 +1861,7 @@ unsigned cv4_typidx(type *t) TOWORD(d->data,LF_ARRAY); TOWORD(d->data + 2,next); TOWORD(d->data + 4,I32 ? 0x12 : 0x11); // T_LONG : T_SHORT - d->data[6 + u] = 0; // no name + d->tdata()[6 + u] = 0; // no name cv4_storenumeric(d->data + 6,size); } else @@ -1870,7 +1870,7 @@ unsigned cv4_typidx(type *t) TOWORD(d->data,LF_ARRAY); TOLONG(d->data + 2,next); TOLONG(d->data + 6,I32 ? 0x12 : 0x11); // T_LONG : T_SHORT - d->data[10 + u] = 0; // no name + d->tdata()[10 + u] = 0; // no name cv4_storenumeric(d->data + 10,size); } typidx = cv_debtyp(d); @@ -1901,8 +1901,8 @@ unsigned cv4_typidx(type *t) { d = debtyp_alloc(2 + 2 + 1 + 1 + 2 + 2); TOWORD(d->data,LF_PROCEDURE); TOWORD(d->data + 2,next); // return type - d->data[4] = call; - d->data[5] = 0; // reserved + d->tdata()[4] = call; + d->tdata()[5] = 0; // reserved TOWORD(d->data + 6,nparam); TOWORD(d->data + 8,paramidx); } @@ -1910,8 +1910,8 @@ unsigned cv4_typidx(type *t) { d = debtyp_alloc(2 + 4 + 1 + 1 + 2 + 4); TOWORD(d->data,LF_PROCEDURE); TOLONG(d->data + 2,next); // return type - d->data[6] = call; - d->data[7] = 0; // reserved + d->tdata()[6] = call; + d->tdata()[7] = 0; // reserved TOWORD(d->data + 8,nparam); TOLONG(d->data + 10,paramidx); } diff --git a/src/backend/cgobj.c b/src/backend/cgobj.c index 0a24b8614394..a4985039f69c 100644 --- a/src/backend/cgobj.c +++ b/src/backend/cgobj.c @@ -862,8 +862,8 @@ void objlinnum(Srcpos srcpos,targ_size_t offset) ln->i < LINNUMMAX - 6) break; } - TOWORD(&ln->data[ln->i],linnum); - TOOFFSET(&ln->data[ln->i + 2],offset); + TOWORD(&ln->tdata()[ln->i],linnum); + TOOFFSET(&ln->tdata()[ln->i + 2],offset); ln->i += 2 + intsize; } else @@ -1052,12 +1052,12 @@ STATIC void linnum_term() #endif for (u = 0; u < ln->i; ) { - srcpos.Slinnum = *(unsigned short *)&ln->data[u]; + srcpos.Slinnum = *(unsigned short *)&ln->tdata()[u]; u += 2; if (I32) - offset = *(unsigned long *)&ln->data[u]; + offset = *(unsigned long *)&ln->tdata()[u]; else - offset = *(unsigned short *)&ln->data[u]; + offset = *(unsigned short *)&ln->tdata()[u]; objlinnum(srcpos,offset); u += intsize; } @@ -2909,7 +2909,7 @@ L1: ; i = offset - obj.ledata->offset; if (obj.ledata->i <= i) obj.ledata->i = i + 1; - obj.ledata->data[i] = byte; // 1st byte of data + obj.ledata->tdata()[i] = byte; // 1st byte of data } /*********************************** diff --git a/src/backend/dwarf.c b/src/backend/dwarf.c index 67a71665419f..23350158a712 100644 --- a/src/backend/dwarf.c +++ b/src/backend/dwarf.c @@ -548,7 +548,7 @@ void dwarf_initfile(const char *filename) #if 0 && MARS for (int i = 0; i < global.params.imppath->dim; i++) { - linebuf->writeString((char *)global.params.imppath->data[i]); + linebuf->writeString(global.params.imppath->tdata()[i]); linebuf->writeByte(0); } #endif diff --git a/src/builtin.c b/src/builtin.c index 6ec705e676b7..fbd42b3eed73 100644 --- a/src/builtin.c +++ b/src/builtin.c @@ -92,7 +92,7 @@ enum BUILTIN FuncDeclaration::isBuiltin() Expression *eval_builtin(enum BUILTIN builtin, Expressions *arguments) { assert(arguments && arguments->dim); - Expression *arg0 = (Expression *)arguments->data[0]; + Expression *arg0 = arguments->tdata()[0]; Expression *e = NULL; switch (builtin) { diff --git a/src/cast.c b/src/cast.c index de5c658d3c7b..7862bbbe6e55 100644 --- a/src/cast.c +++ b/src/cast.c @@ -424,7 +424,7 @@ MATCH StructLiteralExp::implicitConvTo(Type *t) { m = MATCHconst; for (int i = 0; i < elements->dim; i++) - { Expression *e = (Expression *)elements->data[i]; + { Expression *e = elements->tdata()[i]; Type *te = e->type; te = te->castMod(t->mod); MATCH m2 = e->implicitConvTo(te); @@ -533,7 +533,7 @@ MATCH ArrayLiteralExp::implicitConvTo(Type *t) } for (int i = 0; i < elements->dim; i++) - { Expression *e = (Expression *)elements->data[i]; + { Expression *e = elements->tdata()[i]; MATCH m = (MATCH)e->implicitConvTo(tb->nextOf()); if (m < result) result = m; // remember worst match @@ -554,13 +554,13 @@ MATCH AssocArrayLiteralExp::implicitConvTo(Type *t) if (tb->ty == Taarray && typeb->ty == Taarray) { for (size_t i = 0; i < keys->dim; i++) - { Expression *e = (Expression *)keys->data[i]; + { Expression *e = keys->tdata()[i]; MATCH m = (MATCH)e->implicitConvTo(((TypeAArray *)tb)->index); if (m < result) result = m; // remember worst match if (result == MATCHnomatch) break; // no need to check for worse - e = (Expression *)values->data[i]; + e = values->tdata()[i]; m = (MATCH)e->implicitConvTo(tb->nextOf()); if (m < result) result = m; // remember worst match @@ -595,7 +595,7 @@ MATCH AddrExp::implicitConvTo(Type *t) { OverExp *eo = (OverExp *)e1; FuncDeclaration *f = NULL; for (int i = 0; i < eo->vars->a.dim; i++) - { Dsymbol *s = (Dsymbol *)eo->vars->a.data[i]; + { Dsymbol *s = eo->vars->a.tdata()[i]; FuncDeclaration *f2 = s->isFuncDeclaration(); assert(f2); if (f2->overloadExactMatch(t->nextOf())) @@ -1181,7 +1181,7 @@ Expression *AddrExp::castTo(Scope *sc, Type *t) { OverExp *eo = (OverExp *)e1; FuncDeclaration *f = NULL; for (int i = 0; i < eo->vars->a.dim; i++) - { Dsymbol *s = (Dsymbol *)eo->vars->a.data[i]; + { Dsymbol *s = eo->vars->a.tdata()[i]; FuncDeclaration *f2 = s->isFuncDeclaration(); assert(f2); if (f2->overloadExactMatch(t->nextOf())) @@ -1235,9 +1235,9 @@ Expression *TupleExp::castTo(Scope *sc, Type *t) { TupleExp *e = (TupleExp *)copy(); e->exps = (Expressions *)exps->copy(); for (size_t i = 0; i < e->exps->dim; i++) - { Expression *ex = (Expression *)e->exps->data[i]; + { Expression *ex = e->exps->tdata()[i]; ex = ex->castTo(sc, t); - e->exps->data[i] = (void *)ex; + e->exps->tdata()[i] = ex; } return e; } @@ -1268,9 +1268,9 @@ Expression *ArrayLiteralExp::castTo(Scope *sc, Type *t) e = (ArrayLiteralExp *)copy(); e->elements = (Expressions *)elements->copy(); for (int i = 0; i < elements->dim; i++) - { Expression *ex = (Expression *)elements->data[i]; + { Expression *ex = elements->tdata()[i]; ex = ex->castTo(sc, tb->nextOf()); - e->elements->data[i] = (void *)ex; + e->elements->tdata()[i] = ex; } e->type = t; return e; @@ -1302,13 +1302,13 @@ Expression *AssocArrayLiteralExp::castTo(Scope *sc, Type *t) e->values = (Expressions *)values->copy(); assert(keys->dim == values->dim); for (size_t i = 0; i < keys->dim; i++) - { Expression *ex = (Expression *)values->data[i]; + { Expression *ex = values->tdata()[i]; ex = ex->castTo(sc, tb->nextOf()); - e->values->data[i] = (void *)ex; + e->values->tdata()[i] = ex; - ex = (Expression *)keys->data[i]; + ex = keys->tdata()[i]; ex = ex->castTo(sc, ((TypeAArray *)tb)->index); - e->keys->data[i] = (void *)ex; + e->keys->tdata()[i] = ex; } e->type = t; return e; @@ -1523,7 +1523,7 @@ bool isVoidArrayLiteral(Expression *e, Type *other) while (e->op == TOKarrayliteral && e->type->ty == Tarray && (((ArrayLiteralExp *)e)->elements->dim == 1)) { - e = (Expression *)((ArrayLiteralExp *)e)->elements->data[0]; + e = ((ArrayLiteralExp *)e)->elements->tdata()[0]; if (other->ty == Tsarray || other->ty == Tarray) other = other->nextOf(); else diff --git a/src/class.c b/src/class.c index 14ef9e7014a4..54fd3d42b13d 100644 --- a/src/class.c +++ b/src/class.c @@ -223,9 +223,9 @@ Dsymbol *ClassDeclaration::syntaxCopy(Dsymbol *s) cd->baseclasses->setDim(this->baseclasses->dim); for (int 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); @@ -290,7 +290,7 @@ void ClassDeclaration::semantic(Scope *sc) // Expand any tuples in baseclasses[] for (i = 0; i < baseclasses->dim; ) - { BaseClass *b = (BaseClass *)baseclasses->data[i]; + { BaseClass *b = baseclasses->tdata()[i]; //printf("test1 %s %s\n", toChars(), b->type->toChars()); b->type = b->type->semantic(loc, sc); //printf("test2\n"); @@ -317,7 +317,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) @@ -386,7 +386,7 @@ void ClassDeclaration::semantic(Scope *sc) 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) @@ -415,7 +415,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()); } @@ -469,7 +469,7 @@ void ClassDeclaration::semantic(Scope *sc) } interfaces_dim = baseclasses->dim; - interfaces = (BaseClass **)baseclasses->data; + interfaces = baseclasses->tdata(); if (baseClass) @@ -482,7 +482,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(); @@ -506,7 +506,7 @@ void ClassDeclaration::semantic(Scope *sc) for (i = 0; i < members->dim; i++) { - Dsymbol *s = (Dsymbol *)members->data[i]; + Dsymbol *s = members->tdata()[i]; s->addMember(sc, this, 1); } @@ -625,7 +625,7 @@ void ClassDeclaration::semantic(Scope *sc) * resolve individual members like enums. */ for (i = 0; i < members_dim; i++) - { Dsymbol *s = (Dsymbol *)members->data[i]; + { Dsymbol *s = members->tdata()[i]; /* There are problems doing this in the general case because * Scope keeps track of things like 'offset' */ @@ -637,7 +637,7 @@ void ClassDeclaration::semantic(Scope *sc) } for (i = 0; i < members_dim; i++) - { Dsymbol *s = (Dsymbol *)members->data[i]; + { Dsymbol *s = members->tdata()[i]; s->semantic(sc); } @@ -714,7 +714,7 @@ void ClassDeclaration::semantic(Scope *sc) // Allocate instance of each new interface for (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); @@ -744,7 +744,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); } @@ -763,7 +763,7 @@ void ClassDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) } for (int i = 0; i < baseclasses->dim; i++) { - BaseClass *b = (BaseClass *)baseclasses->data[i]; + BaseClass *b = baseclasses->tdata()[i]; if (i) buf->writeByte(','); @@ -777,7 +777,7 @@ void ClassDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) buf->writenl(); for (int i = 0; i < members->dim; i++) { - Dsymbol *s = (Dsymbol *)members->data[i]; + Dsymbol *s = members->tdata()[i]; buf->writestring(" "); s->toCBuffer(buf, hgs); @@ -812,7 +812,7 @@ int ClassDeclaration::isBaseOf2(ClassDeclaration *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]; + { BaseClass *b = cd->baseclasses->tdata()[i]; if (b->base == this || isBaseOf2(b->base)) return 1; @@ -858,7 +858,7 @@ int ClassDeclaration::isBaseInfoComplete() if (!baseClass) return ident == Id::Object; for (int i = 0; i < baseclasses->dim; i++) - { BaseClass *b = (BaseClass *)baseclasses->data[i]; + { BaseClass *b = baseclasses->tdata()[i]; if (!b->base || !b->base->isBaseInfoComplete()) return 0; } @@ -893,7 +893,7 @@ Dsymbol *ClassDeclaration::search(Loc loc, Identifier *ident, int flags) for (i = 0; i < baseclasses->dim; i++) { - BaseClass *b = (BaseClass *)baseclasses->data[i]; + BaseClass *b = baseclasses->tdata()[i]; if (b->base) { @@ -941,7 +941,7 @@ int ClassDeclaration::isFuncHidden(FuncDeclaration *fd) if (os) { for (int i = 0; i < os->a.dim; i++) - { Dsymbol *s = (Dsymbol *)os->a.data[i]; + { Dsymbol *s = os->a.tdata()[i]; FuncDeclaration *f2 = s->isFuncDeclaration(); if (f2 && overloadApply(f2, &isf, fd)) return 0; @@ -967,12 +967,12 @@ FuncDeclaration *ClassDeclaration::findFunc(Identifier *ident, TypeFunction *tf) //printf("ClassDeclaration::findFunc(%s, %s) %s\n", ident->toChars(), tf->toChars(), toChars()); ClassDeclaration *cd = this; - FuncDeclarations *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 @@ -1049,7 +1049,7 @@ int ClassDeclaration::isAbstract() return TRUE; for (int 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()) @@ -1156,7 +1156,7 @@ void InterfaceDeclaration::semantic(Scope *sc) // Expand any tuples in baseclasses[] for (i = 0; i < baseclasses->dim; ) - { BaseClass *b = (BaseClass *)baseclasses->data[0]; + { BaseClass *b = baseclasses->tdata()[0]; b->type = b->type->semantic(loc, sc); Type *tb = b->type->toBasetype(); @@ -1184,7 +1184,7 @@ void InterfaceDeclaration::semantic(Scope *sc) 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) @@ -1202,7 +1202,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()); } @@ -1238,7 +1238,7 @@ void InterfaceDeclaration::semantic(Scope *sc) } interfaces_dim = baseclasses->dim; - interfaces = (BaseClass **)baseclasses->data; + interfaces = baseclasses->tdata(); interfaceSemantic(sc); @@ -1263,7 +1263,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 @@ -1280,7 +1280,7 @@ void InterfaceDeclaration::semantic(Scope *sc) for (i = 0; i < members->dim; i++) { - Dsymbol *s = (Dsymbol *)members->data[i]; + Dsymbol *s = members->tdata()[i]; s->addMember(sc, this, 1); } @@ -1299,7 +1299,7 @@ void InterfaceDeclaration::semantic(Scope *sc) inuse++; for (i = 0; i < members->dim; i++) { - Dsymbol *s = (Dsymbol *)members->data[i]; + Dsymbol *s = members->tdata()[i]; s->semantic(sc); } inuse--; @@ -1393,7 +1393,7 @@ int InterfaceDeclaration::isBaseInfoComplete() { assert(!baseClass); for (int i = 0; i < baseclasses->dim; i++) - { BaseClass *b = (BaseClass *)baseclasses->data[i]; + { BaseClass *b = baseclasses->tdata()[i]; if (!b->base || !b->base->isBaseInfoComplete ()) return 0; } @@ -1478,7 +1478,7 @@ int BaseClass::fillVtbl(ClassDeclaration *cd, FuncDeclarations *vtbl, int newins // first entry is ClassInfo reference for (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; @@ -1515,7 +1515,7 @@ int BaseClass::fillVtbl(ClassDeclaration *cd, FuncDeclarations *vtbl, int newins fd = NULL; } if (vtbl) - vtbl->data[j] = fd; + vtbl->tdata()[j] = fd; } return result; diff --git a/src/clone.c b/src/clone.c index 9d568f86bf35..0ff7e21ebcf9 100644 --- a/src/clone.c +++ b/src/clone.c @@ -44,7 +44,7 @@ int StructDeclaration::needOpAssign() */ for (size_t i = 0; i < fields.dim; i++) { - Dsymbol *s = (Dsymbol *)fields.data[i]; + Dsymbol *s = fields.tdata()[i]; VarDeclaration *v = s->isVarDeclaration(); assert(v && v->storage_class & STCfield); if (v->storage_class & STCref) @@ -87,7 +87,7 @@ int StructDeclaration::needOpEquals() */ for (size_t i = 0; i < fields.dim; i++) { - Dsymbol *s = (Dsymbol *)fields.data[i]; + Dsymbol *s = fields.tdata()[i]; VarDeclaration *v = s->isVarDeclaration(); assert(v && v->storage_class & STCfield); if (v->storage_class & STCref) @@ -196,7 +196,7 @@ FuncDeclaration *StructDeclaration::buildOpAssign(Scope *sc) //printf("\tmemberwise copy\n"); for (size_t i = 0; i < fields.dim; i++) { - Dsymbol *s = (Dsymbol *)fields.data[i]; + Dsymbol *s = fields.tdata()[i]; VarDeclaration *v = s->isVarDeclaration(); assert(v && v->storage_class & STCfield); // this.v = s.v; @@ -267,7 +267,7 @@ FuncDeclaration *StructDeclaration::buildOpEquals(Scope *sc) //printf("\tmemberwise compare\n"); for (size_t i = 0; i < fields.dim; i++) { - Dsymbol *s = (Dsymbol *)fields.data[i]; + Dsymbol *s = fields.tdata()[i]; VarDeclaration *v = s->isVarDeclaration(); assert(v && v->storage_class & STCfield); if (v->storage_class & STCref) @@ -385,7 +385,7 @@ FuncDeclaration *StructDeclaration::buildPostBlit(Scope *sc) for (size_t i = 0; i < fields.dim; i++) { - Dsymbol *s = (Dsymbol *)fields.data[i]; + Dsymbol *s = fields.tdata()[i]; VarDeclaration *v = s->isVarDeclaration(); assert(v && v->storage_class & STCfield); if (v->storage_class & STCref) @@ -448,12 +448,12 @@ FuncDeclaration *StructDeclaration::buildPostBlit(Scope *sc) return NULL; case 1: - return (FuncDeclaration *)postblits.data[0]; + return postblits.tdata()[0]; default: e = NULL; for (size_t i = 0; i < postblits.dim; i++) - { FuncDeclaration *fd = (FuncDeclaration *)postblits.data[i]; + { FuncDeclaration *fd = postblits.tdata()[i]; stc |= fd->storage_class & STCdisable; Expression *ex = new ThisExp(0); ex = new DotVarExp(0, ex, fd, 0); @@ -487,7 +487,7 @@ FuncDeclaration *AggregateDeclaration::buildDtor(Scope *sc) #if DMDV2 for (size_t i = 0; i < fields.dim; i++) { - Dsymbol *s = (Dsymbol *)fields.data[i]; + Dsymbol *s = fields.tdata()[i]; VarDeclaration *v = s->isVarDeclaration(); assert(v && v->storage_class & STCfield); if (v->storage_class & STCref) @@ -548,12 +548,12 @@ FuncDeclaration *AggregateDeclaration::buildDtor(Scope *sc) return NULL; case 1: - return (FuncDeclaration *)dtors.data[0]; + return dtors.tdata()[0]; default: e = NULL; for (size_t i = 0; i < dtors.dim; i++) - { FuncDeclaration *fd = (FuncDeclaration *)dtors.data[i]; + { FuncDeclaration *fd = dtors.tdata()[i]; Expression *ex = new ThisExp(0); ex = new DotVarExp(0, ex, fd, 0); ex = new CallExp(0, ex); diff --git a/src/cond.c b/src/cond.c index 2131d35ebeae..9e14191363af 100644 --- a/src/cond.c +++ b/src/cond.c @@ -25,13 +25,13 @@ #include "scope.h" #endif -int findCondition(Identifiers *ids, Identifier *ident) +int findCondition(Strings *ids, Identifier *ident) { if (ids) { for (int i = 0; i < ids->dim; i++) { - const char *id = (const char *)ids->data[i]; + const char *id = ids->tdata()[i]; if (strcmp(id, ident->toChars()) == 0) return TRUE; @@ -74,8 +74,8 @@ void DebugCondition::setGlobalLevel(unsigned level) void DebugCondition::addGlobalIdent(const char *ident) { if (!global.params.debugids) - global.params.debugids = new Identifiers(); - global.params.debugids->push((void *)ident); + global.params.debugids = new Strings(); + global.params.debugids->push((char *)ident); } @@ -98,7 +98,7 @@ int DebugCondition::include(Scope *sc, ScopeDsymbol *s) inc = 1; else { if (!mod->debugidsNot) - mod->debugidsNot = new Identifiers(); + mod->debugidsNot = new Strings(); mod->debugidsNot->push(ident->toChars()); } } @@ -168,8 +168,8 @@ void VersionCondition::addGlobalIdent(const char *ident) void VersionCondition::addPredefinedGlobalIdent(const char *ident) { if (!global.params.versionids) - global.params.versionids = new Identifiers(); - global.params.versionids->push((void *)ident); + global.params.versionids = new Strings(); + global.params.versionids->push((char *)ident); } @@ -194,7 +194,7 @@ int VersionCondition::include(Scope *sc, ScopeDsymbol *s) else { if (!mod->versionidsNot) - mod->versionidsNot = new Identifiers(); + mod->versionidsNot = new Strings(); mod->versionidsNot->push(ident->toChars()); } } @@ -322,7 +322,7 @@ int IftypeCondition::include(Scope *sc, ScopeDsymbol *sd) TemplateParameters parameters; parameters.setDim(1); - parameters.data[0] = (void *)&tp; + parameters.tdata()[0] = &tp; Objects dedtypes; dedtypes.setDim(1); @@ -334,7 +334,7 @@ int IftypeCondition::include(Scope *sc, ScopeDsymbol *sd) else { inc = 1; - Type *tded = (Type *)dedtypes.data[0]; + Type *tded = (Type *)dedtypes.tdata()[0]; if (!tded) tded = targ; Dsymbol *s = new AliasDeclaration(loc, id, tded); diff --git a/src/cond.h b/src/cond.h index f547e695e4ce..54928d1563b9 100644 --- a/src/cond.h +++ b/src/cond.h @@ -26,7 +26,7 @@ enum TOK; struct HdrGenState; #endif -int findCondition(Identifiers *ids, Identifier *ident); +int findCondition(Strings *ids, Identifier *ident); struct Condition { diff --git a/src/constfold.c b/src/constfold.c index b2b2088c80a0..8c6f9d58a61b 100644 --- a/src/constfold.c +++ b/src/constfold.c @@ -724,8 +724,8 @@ Expression *Equal(enum TOK op, Type *type, Expression *e1, Expression *e2) else { for (size_t i = 0; i < es1->elements->dim; i++) - { Expression *ee1 = (Expression *)es1->elements->data[i]; - Expression *ee2 = (Expression *)es2->elements->data[i]; + { Expression *ee1 = es1->elements->tdata()[i]; + Expression *ee2 = es2->elements->tdata()[i]; Expression *v = Equal(TOKequal, Type::tint32, ee1, ee2); if (v == EXP_CANT_INTERPRET) @@ -757,7 +757,7 @@ Expression *Equal(enum TOK op, Type *type, Expression *e1, Expression *e2) for (size_t i = 0; i < dim1; i++) { uinteger_t c = es1->charAt(i); - Expression *ee2 = (Expression *)es2->elements->data[i]; + Expression *ee2 = es2->elements->tdata()[i]; if (ee2->isConst() != 1) return EXP_CANT_INTERPRET; cmp = (c == ee2->toInteger()); @@ -783,8 +783,8 @@ Expression *Equal(enum TOK op, Type *type, Expression *e1, Expression *e2) { cmp = 1; for (size_t i = 0; i < es1->elements->dim; i++) - { Expression *ee1 = (Expression *)es1->elements->data[i]; - Expression *ee2 = (Expression *)es2->elements->data[i]; + { Expression *ee1 = es1->elements->tdata()[i]; + Expression *ee2 = es2->elements->tdata()[i]; if (ee1 == ee2) continue; @@ -1158,7 +1158,7 @@ Expression *Cast(Type *type, Type *to, Expression *e1) assert(sd); Expressions *elements = new Expressions; for (size_t i = 0; i < sd->fields.dim; i++) - { Dsymbol *s = (Dsymbol *)sd->fields.data[i]; + { Dsymbol *s = sd->fields.tdata()[i]; VarDeclaration *v = s->isVarDeclaration(); assert(v); @@ -1237,7 +1237,7 @@ Expression *Index(Type *type, Expression *e1, Expression *e2) } else if (e1->op == TOKarrayliteral && !e1->checkSideEffect(2)) { ArrayLiteralExp *ale = (ArrayLiteralExp *)e1; - e = (Expression *)ale->elements->data[i]; + e = ale->elements->tdata()[i]; e->type = type; } } @@ -1251,7 +1251,7 @@ Expression *Index(Type *type, Expression *e1, Expression *e2) { e2->error("array index %ju is out of bounds %s[0 .. %u]", i, e1->toChars(), ale->elements->dim); } else - { e = (Expression *)ale->elements->data[i]; + { e = ale->elements->tdata()[i]; e->type = type; } } @@ -1264,12 +1264,12 @@ Expression *Index(Type *type, Expression *e1, Expression *e2) for (size_t i = ae->keys->dim; i;) { i--; - Expression *ekey = (Expression *)ae->keys->data[i]; + Expression *ekey = ae->keys->tdata()[i]; Expression *ex = Equal(TOKequal, Type::tbool, ekey, e2); if (ex == EXP_CANT_INTERPRET) return ex; if (ex->isBool(TRUE)) - { e = (Expression *)ae->values->data[i]; + { e = ae->values->tdata()[i]; e->type = type; break; } @@ -1330,9 +1330,9 @@ Expression *Slice(Type *type, Expression *e1, Expression *lwr, Expression *upr) { Expressions *elements = new Expressions(); elements->setDim(iupr - ilwr); - memcpy(elements->data, - es1->elements->data + ilwr, - (iupr - ilwr) * sizeof(es1->elements->data[0])); + memcpy(elements->tdata(), + es1->elements->tdata() + ilwr, + (iupr - ilwr) * sizeof(es1->elements->tdata()[0])); e = new ArrayLiteralExp(e1->loc, elements); e->type = type; } @@ -1445,7 +1445,7 @@ Expression *Cat(Type *type, Expression *e1, Expression *e2) void *s = mem.malloc((len + 1) * sz); memcpy((char *)s + sz * es2->elements->dim, es1->string, es1->len * sz); for (int i = 0; i < es2->elements->dim; i++) - { Expression *es2e = (Expression *)es2->elements->data[i]; + { Expression *es2e = es2->elements->tdata()[i]; if (es2e->op != TOKint64) return EXP_CANT_INTERPRET; dinteger_t v = es2e->toInteger(); @@ -1473,7 +1473,7 @@ Expression *Cat(Type *type, Expression *e1, Expression *e2) void *s = mem.malloc((len + 1) * sz); memcpy(s, es1->string, es1->len * sz); for (int i = 0; i < es2->elements->dim; i++) - { Expression *es2e = (Expression *)es2->elements->data[i]; + { Expression *es2e = es2->elements->tdata()[i]; if (es2e->op != TOKint64) return EXP_CANT_INTERPRET; dinteger_t v = es2e->toInteger(); diff --git a/src/cppmangle.c b/src/cppmangle.c index edb477cde3ff..a6ef4c263c93 100644 --- a/src/cppmangle.c +++ b/src/cppmangle.c @@ -69,7 +69,7 @@ int CppMangleState::substitute(OutBuffer *buf, void *p) { for (size_t i = 0; i < components.dim; i++) { - if (p == components.data[i]) + if (p == components.tdata()[i]) { /* Sequence is S_, S0_, .., S9_, SA_, ..., SZ_, S10_, ... */ @@ -88,7 +88,7 @@ int CppMangleState::exist(void *p) { for (size_t i = 0; i < components.dim; i++) { - if (p == components.data[i]) + if (p == components.tdata()[i]) { return 1; } @@ -409,7 +409,7 @@ void Parameter::argsCppMangle(OutBuffer *buf, CppMangleState *cms, Parameters *a if (arguments) { for (size_t i = 0; i < arguments->dim; i++) - { Parameter *arg = (Parameter *)arguments->data[i]; + { Parameter *arg = arguments->tdata()[i]; Type *t = arg->type; if (arg->storageClass & (STCout | STCref)) t = t->referenceTo(); diff --git a/src/declaration.c b/src/declaration.c index f17864c09713..3ba8b5d17113 100644 --- a/src/declaration.c +++ b/src/declaration.c @@ -185,7 +185,7 @@ Type *TupleDeclaration::getType() /* It's only a type tuple if all the Object's are types */ for (size_t i = 0; i < objects->dim; i++) - { Object *o = (Object *)objects->data[i]; + { Object *o = objects->tdata()[i]; if (o->dyncast() != DYNCAST_TYPE) { @@ -196,12 +196,13 @@ Type *TupleDeclaration::getType() /* We know it's a type tuple, so build the TypeTuple */ + Types *types = (Types *)objects; Parameters *args = new Parameters(); args->setDim(objects->dim); OutBuffer buf; int hasdeco = 1; - for (size_t i = 0; i < objects->dim; i++) - { Type *t = (Type *)objects->data[i]; + for (size_t i = 0; i < types->dim; i++) + { Type *t = types->tdata()[i]; //printf("type = %s\n", t->toChars()); #if 0 @@ -212,7 +213,7 @@ Type *TupleDeclaration::getType() #else Parameter *arg = new Parameter(0, t, NULL, NULL); #endif - args->data[i] = (void *)arg; + args->tdata()[i] = arg; if (!t->deco) hasdeco = 0; } @@ -229,7 +230,7 @@ int TupleDeclaration::needThis() { //printf("TupleDeclaration::needThis(%s)\n", toChars()); for (size_t i = 0; i < objects->dim; i++) - { Object *o = (Object *)objects->data[i]; + { Object *o = objects->tdata()[i]; if (o->dyncast() == DYNCAST_EXPRESSION) { Expression *e = (Expression *)o; if (e->op == TOKdsymbol) @@ -862,7 +863,7 @@ void VarDeclaration::semantic(Scope *sc) Expression *einit = ie; if (ie && ie->op == TOKtuple) - { einit = (Expression *)((TupleExp *)ie)->exps->data[i]; + { einit = ((TupleExp *)ie)->exps->tdata()[i]; } Initializer *ti = init; if (einit) @@ -880,7 +881,7 @@ void VarDeclaration::semantic(Scope *sc) } Expression *e = new DsymbolExp(loc, v); - exps->data[i] = e; + exps->tdata()[i] = e; } TupleDeclaration *v2 = new TupleDeclaration(loc, ident, exps); v2->isexp = 1; @@ -1501,7 +1502,7 @@ void VarDeclaration::checkNestedReference(Scope *sc, Loc loc) fdthis->getLevel(loc, fdv); for (int i = 0; i < nestedrefs.dim; i++) - { FuncDeclaration *f = (FuncDeclaration *)nestedrefs.data[i]; + { FuncDeclaration *f = nestedrefs.tdata()[i]; if (f == fdthis) goto L1; } @@ -1510,7 +1511,7 @@ void VarDeclaration::checkNestedReference(Scope *sc, Loc loc) for (int i = 0; i < fdv->closureVars.dim; i++) - { Dsymbol *s = (Dsymbol *)fdv->closureVars.data[i]; + { Dsymbol *s = fdv->closureVars.tdata()[i]; if (s == this) goto L2; } diff --git a/src/declaration.h b/src/declaration.h index e55807470b7a..46905cc11f6f 100644 --- a/src/declaration.h +++ b/src/declaration.h @@ -542,7 +542,7 @@ struct FuncDeclaration : Declaration VarDeclaration *v_argptr; // '_argptr' variable #endif VarDeclaration *v_argsave; // save area for args passed in registers for variadic functions - Dsymbols *parameters; // Array of VarDeclaration's for parameters + VarDeclarations *parameters; // Array of VarDeclaration's for parameters DsymbolTable *labtab; // statement label symbol table Declaration *overnext; // next in overload list Loc endloc; // location of closing curly bracket @@ -580,7 +580,7 @@ struct FuncDeclaration : Declaration int tookAddressOf; // set if someone took the address of // this function - Dsymbols closureVars; // local variables in this function + VarDeclarations closureVars; // local variables in this function // which are referenced by nested // functions #else @@ -599,7 +599,7 @@ struct FuncDeclaration : Declaration void toCBuffer(OutBuffer *buf, HdrGenState *hgs); void bodyToCBuffer(OutBuffer *buf, HdrGenState *hgs); int overrides(FuncDeclaration *fd); - int findVtblIndex(FuncDeclarations *vtbl, int dim); + int findVtblIndex(Dsymbols *vtbl, int dim); int overloadInsert(Dsymbol *s); FuncDeclaration *overloadExactMatch(Type *t); FuncDeclaration *overloadResolve(Loc loc, Expression *ethis, Expressions *arguments, int flags = 0); diff --git a/src/delegatize.c b/src/delegatize.c index 3f5b7257bea0..127523b6e4fe 100644 --- a/src/delegatize.c +++ b/src/delegatize.c @@ -61,7 +61,7 @@ void arrayExpressionScanForNestedRef(Scope *sc, Expressions *a) if (a) { for (int i = 0; i < a->dim; i++) - { Expression *e = (Expression *)a->data[i]; + { Expression *e = a->tdata()[i]; if (e) { diff --git a/src/doc.c b/src/doc.c index defa32a25354..5fe3c26768ba 100644 --- a/src/doc.c +++ b/src/doc.c @@ -226,7 +226,7 @@ void Module::gendocfile() // Override with the ddoc macro files from the command line for (int i = 0; i < global.params.ddocfiles->dim; i++) { - FileName f((char *)global.params.ddocfiles->data[i], 0); + FileName f(global.params.ddocfiles->tdata()[i], 0); File file(&f); file.readv(); // BUG: convert file contents to UTF-8 before use @@ -523,7 +523,7 @@ void ScopeDsymbol::emitMemberComments(Scope *sc) sc = sc->push(this); for (int i = 0; i < members->dim; i++) { - Dsymbol *s = (Dsymbol *)members->data[i]; + Dsymbol *s = members->tdata()[i]; //printf("\ts = '%s'\n", s->toChars()); s->emitComment(sc); } @@ -695,7 +695,7 @@ void EnumDeclaration::emitComment(Scope *sc) { for (int i = 0; i < members->dim; i++) { - Dsymbol *s = (Dsymbol *)members->data[i]; + Dsymbol *s = members->tdata()[i]; s->emitComment(sc); } return; @@ -878,7 +878,7 @@ void FuncDeclaration::toDocBuffer(OutBuffer *buf) buf->writeByte('('); for (int i = 0; i < td->origParameters->dim; i++) { - TemplateParameter *tp = (TemplateParameter *)td->origParameters->data[i]; + TemplateParameter *tp = td->origParameters->tdata()[i]; if (i) buf->writestring(", "); tp->toCBuffer(buf, &hgs); @@ -958,7 +958,7 @@ void ClassDeclaration::toDocBuffer(OutBuffer *buf) } int any = 0; for (int i = 0; i < baseclasses->dim; i++) - { BaseClass *bc = (BaseClass *)baseclasses->data[i]; + { BaseClass *bc = baseclasses->tdata()[i]; if (bc->protection == PROTprivate) continue; @@ -1026,7 +1026,7 @@ DocComment *DocComment::parse(Scope *sc, Dsymbol *s, unsigned char *comment) dc->parseSections(comment); for (int i = 0; i < dc->sections.dim; i++) - { Section *s = (Section *)dc->sections.data[i]; + { Section *s = dc->sections.tdata()[i]; if (icmp("copyright", s->name, s->namelen) == 0) { @@ -1171,7 +1171,7 @@ void DocComment::writeSections(Scope *sc, Dsymbol *s, OutBuffer *buf) { buf->writestring("$(DDOC_SECTIONS \n"); for (int i = 0; i < sections.dim; i++) - { Section *sec = (Section *)sections.data[i]; + { Section *sec = sections.tdata()[i]; if (sec->nooutput) continue; @@ -1748,7 +1748,7 @@ Parameter *isFunctionParameter(Dsymbol *s, unsigned char *p, unsigned len) if (tf->parameters) { for (size_t k = 0; k < tf->parameters->dim; k++) - { Parameter *arg = (Parameter *)tf->parameters->data[k]; + { Parameter *arg = tf->parameters->tdata()[k]; if (arg->ident && cmp(arg->ident->toChars(), p, len) == 0) { diff --git a/src/dsymbol.c b/src/dsymbol.c index 5bf1b46c1061..32a771ff1e9f 100644 --- a/src/dsymbol.c +++ b/src/dsymbol.c @@ -113,7 +113,7 @@ int Dsymbol::oneMembers(Dsymbols *members, Dsymbol **ps) if (members) { for (int i = 0; i < members->dim; i++) - { Dsymbol *sx = (Dsymbol *)members->data[i]; + { Dsymbol *sx = members->tdata()[i]; int x = sx->oneMember(ps); //printf("\t[%d] kind %s = %d, s = %p\n", i, sx->kind(), x, *ps); @@ -666,10 +666,10 @@ Dsymbols *Dsymbol::arraySyntaxCopy(Dsymbols *a) b = (Dsymbols *)a->copy(); for (int i = 0; i < b->dim; i++) { - Dsymbol *s = (Dsymbol *)b->data[i]; + Dsymbol *s = b->tdata()[i]; s = s->syntaxCopy(NULL); - b->data[i] = (void *)s; + b->tdata()[i] = s; } } return b; @@ -767,7 +767,7 @@ Dsymbol *ScopeDsymbol::search(Loc loc, Identifier *ident, int flags) // Look in imported modules for (int i = 0; i < imports->dim; i++) - { ScopeDsymbol *ss = (ScopeDsymbol *)imports->data[i]; + { ScopeDsymbol *ss = imports->tdata()[i]; Dsymbol *s2; // If private import, don't search it @@ -815,11 +815,11 @@ Dsymbol *ScopeDsymbol::search(Loc loc, Identifier *ident, int flags) /* Don't add to a[] if s2 is alias of previous sym */ for (int j = 0; j < a->a.dim; j++) - { Dsymbol *s3 = (Dsymbol *)a->a.data[j]; + { Dsymbol *s3 = a->a.tdata()[j]; if (s2->toAlias() == s3->toAlias()) { if (s3->isDeprecated()) - a->a.data[j] = (void *)s2; + a->a.tdata()[j] = s2; goto Lcontinue; } } @@ -871,7 +871,7 @@ void ScopeDsymbol::importScope(ScopeDsymbol *s, enum PROT protection) for (int i = 0; i < imports->dim; i++) { ScopeDsymbol *ss; - ss = (ScopeDsymbol *) imports->data[i]; + ss = imports->tdata()[i]; if (ss == s) // if already imported { if (protection > prots[i]) @@ -966,7 +966,7 @@ size_t ScopeDsymbol::dim(Dsymbols *members) if (members) { for (size_t i = 0; i < members->dim; i++) - { Dsymbol *s = (Dsymbol *)members->data[i]; + { Dsymbol *s = members->tdata()[i]; AttribDeclaration *a = s->isAttribDeclaration(); if (a) @@ -997,7 +997,7 @@ Dsymbol *ScopeDsymbol::getNth(Dsymbols *members, size_t nth, size_t *pn) size_t n = 0; for (size_t i = 0; i < members->dim; i++) - { Dsymbol *s = (Dsymbol *)members->data[i]; + { Dsymbol *s = members->tdata()[i]; AttribDeclaration *a = s->isAttribDeclaration(); if (a) diff --git a/src/dump.c b/src/dump.c index c443d94e1e75..4fd0d04e70d8 100644 --- a/src/dump.c +++ b/src/dump.c @@ -36,7 +36,7 @@ void dumpExpressions(int i, Expressions *exps) if (exps) { for (size_t j = 0; j < exps->dim; j++) - { Expression *e = (Expression *)exps->data[j]; + { Expression *e = exps->tdata()[j]; indent(i); printf("(\n"); e->dump(i + 2); diff --git a/src/e2ir.c b/src/e2ir.c index 51d537ed19e6..ec3bef09e7e6 100644 --- a/src/e2ir.c +++ b/src/e2ir.c @@ -44,6 +44,7 @@ static char __file__[] = __FILE__; /* for tassert.h */ #include "tassert.h" +typedef ArrayOf(elem) Elems; elem *addressElem(elem *e, Type *t); elem *array_toPtr(Type *t, elem *e); @@ -127,7 +128,7 @@ elem *callfunc(Loc loc, int j = (tf->linkage == LINKd && tf->varargs == 1); for (i = 0; i < arguments->dim ; i++) - { Expression *arg = (Expression *)arguments->data[i]; + { Expression *arg = arguments->tdata()[i]; elem *ea; //printf("\targ[%d]: %s\n", i, arg->toChars()); @@ -1142,7 +1143,7 @@ elem *Dsymbol_toElem(Dsymbol *s, IRState *irs) { for (size_t i = 0; i < decl->dim; i++) { - s = (Dsymbol *)decl->data[i]; + s = decl->tdata()[i]; e = el_combine(e, Dsymbol_toElem(s, irs)); } } @@ -1178,7 +1179,7 @@ elem *Dsymbol_toElem(Dsymbol *s, IRState *irs) // Put vd on list of things needing destruction if (!irs->varsInScope) - irs->varsInScope = new Dsymbols(); + irs->varsInScope = new VarDeclarations(); irs->varsInScope->push(vd); } } @@ -1203,7 +1204,7 @@ elem *Dsymbol_toElem(Dsymbol *s, IRState *irs) { for (size_t i = 0; i < tm->members->dim; i++) { - Dsymbol *sm = (Dsymbol *)tm->members->data[i]; + Dsymbol *sm = tm->members->tdata()[i]; e = el_combine(e, Dsymbol_toElem(sm, irs)); } } @@ -1211,7 +1212,7 @@ elem *Dsymbol_toElem(Dsymbol *s, IRState *irs) else if ((td = s->isTupleDeclaration()) != NULL) { for (size_t i = 0; i < td->objects->dim; i++) - { Object *o = (Object *)td->objects->data[i]; + { Object *o = td->objects->tdata()[i]; if (o->dyncast() == DYNCAST_EXPRESSION) { Expression *eo = (Expression *)o; if (eo->op == TOKdsymbol) @@ -1807,7 +1808,7 @@ elem *NewExp::toElem(IRState *irs) assert(arguments && arguments->dim >= 1); if (arguments->dim == 1) { // Single dimension array allocations - Expression *arg = (Expression *)arguments->data[0]; // gives array length + Expression *arg = arguments->tdata()[0]; // gives array length e = arg->toElem(irs); d_uns64 elemsize = tda->next->size(); @@ -1821,7 +1822,7 @@ elem *NewExp::toElem(IRState *irs) e = el_long(TYsize_t, arguments->dim); for (size_t i = 0; i < arguments->dim; i++) { - Expression *arg = (Expression *)arguments->data[i]; // gives array length + Expression *arg = arguments->tdata()[i]; // gives array length e = el_param(arg->toElem(irs), e); assert(t->ty == Tarray); t = t->nextOf(); @@ -3537,7 +3538,7 @@ elem *CallExp::toElem(IRState *irs) if (fd && fd->ident == Id::alloca && !fd->fbody && fd->linkage == LINKc && arguments && arguments->dim == 1) - { Expression *arg = (Expression *)arguments->data[0]; + { Expression *arg = arguments->tdata()[0]; arg = arg->optimize(WANTvalue); if (arg->isConst() && arg->type->isintegral()) { dinteger_t sz = arg->toInteger(); @@ -4643,7 +4644,7 @@ elem *TupleExp::toElem(IRState *irs) //printf("TupleExp::toElem() %s\n", toChars()); for (size_t i = 0; i < exps->dim; i++) - { Expression *el = (Expression *)exps->data[i]; + { Expression *el = exps->tdata()[i]; elem *ep = el->toElem(irs); e = el_combine(e, ep); @@ -4652,11 +4653,11 @@ elem *TupleExp::toElem(IRState *irs) } #if DMDV2 -elem *tree_insert(Expressions *args, int low, int high) +elem *tree_insert(Elems *args, int low, int high) { assert(low < high); if (low + 1 == high) - return (elem *)args->data[low]; + return args->tdata()[low]; int mid = (low + high) >> 1; return el_param(tree_insert(args, low, mid), tree_insert(args, mid, high)); @@ -4678,7 +4679,7 @@ elem *ArrayLiteralExp::toElem(IRState *irs) * Avoids the whole variadic arg mess. */ dim = elements->dim; - Expressions args; + Elems args; args.setDim(dim); // +1 for number of args parameter e = el_long(TYsize_t, dim); e = el_param(e, type->getTypeInfo(NULL)->toElem(irs)); @@ -4690,7 +4691,7 @@ elem *ArrayLiteralExp::toElem(IRState *irs) targ_size_t sz = tb->nextOf()->size(); // element size ::type *te = tb->nextOf()->toCtype(); // element type for (size_t i = 0; i < dim; i++) - { Expression *el = (Expression *)elements->data[i]; + { Expression *el = elements->tdata()[i]; /* Generate: *(stmp + i * sz) = element[i] */ @@ -4711,20 +4712,20 @@ elem *ArrayLiteralExp::toElem(IRState *irs) eeq->Ejty = eeq->Ety = TYstruct; eeq->ET = te; } - args.data[i] = (void *)eeq; + args.tdata()[i] = eeq; } - e = el_combine(e, el_combines(args.data, dim)); + e = el_combine(e, el_combines((void **)args.tdata(), dim)); e = el_combine(e, el_var(stmp)); } else { - Expressions args; + Elems args; dim = elements->dim; args.setDim(dim + 1); // +1 for number of args parameter e = el_long(TYsize_t, dim); - args.data[dim] = (void *)e; + args.tdata()[dim] = e; for (size_t i = 0; i < dim; i++) - { Expression *el = (Expression *)elements->data[i]; + { Expression *el = elements->tdata()[i]; elem *ep = el->toElem(irs); if (tybasic(ep->Ety) == TYstruct || tybasic(ep->Ety) == TYarray) @@ -4732,14 +4733,14 @@ elem *ArrayLiteralExp::toElem(IRState *irs) ep = el_una(OPstrpar, TYstruct, ep); ep->ET = el->type->toCtype(); } - args.data[dim - (i + 1)] = (void *)ep; + args.tdata()[dim - (i + 1)] = ep; } /* Because the number of parameters can get very large, produce * a balanced binary tree so we don't blow up the stack in * the subsequent tree walking code. */ - e = el_params(args.data, dim + 1); + e = el_params((void **)args.tdata(), dim + 1); e = el_param(e, type->getTypeInfo(NULL)->toElem(irs)); @@ -4784,13 +4785,13 @@ elem *ExpressionsToStaticArray(IRState *irs, Loc loc, Expressions *exps, Type *t symbol *stmp = symbol_genauto(tsarray->toCtype()); targ_size_t szelem = telem->size(); - Voids elems; + Elems elems; elems.setDim(dim); ::type *te = telem->toCtype(); // stmp[] element type for (size_t i = 0; i < dim; i++) - { Expression *el = (Expression *)exps->data[i]; + { Expression *el = exps->tdata()[i]; /* Generate: *(&stmp + i * szelem) = element[i] */ @@ -4811,11 +4812,11 @@ elem *ExpressionsToStaticArray(IRState *irs, Loc loc, Expressions *exps, Type *t eeq->Ejty = eeq->Ety = TYstruct; eeq->ET = te; } - elems.data[i] = (void *)eeq; + elems.tdata()[i] = eeq; } *psym = stmp; - return el_combines(elems.data, dim); + return el_combines((void **)elems.tdata(), dim); } elem *AssocArrayLiteralExp::toElem(IRState *irs) @@ -4853,7 +4854,7 @@ elem *AssocArrayLiteralExp::toElem(IRState *irs) { // call _d_assocarrayliteralT(TypeInfo_AssociativeArray ti, size_t length, ...) e = el_long(TYsize_t, dim); for (size_t i = 0; i < dim; i++) - { Expression *el = (Expression *)keys->data[i]; + { Expression *el = keys->tdata()[i]; for (int j = 0; j < 2; j++) { @@ -4867,7 +4868,7 @@ elem *AssocArrayLiteralExp::toElem(IRState *irs) //printf("[%d] %s\n", i, el->toChars()); //elem_print(ep); e = el_param(ep, e); - el = (Expression *)values->data[i]; + el = values->tdata()[i]; } } @@ -4967,7 +4968,7 @@ elem *StructLiteralExp::toElem(IRState *irs) size_t offset = 0; for (size_t i = 0; i < sd->fields.dim; i++) { - Dsymbol *s = (Dsymbol *)sd->fields.data[i]; + Dsymbol *s = sd->fields.tdata()[i]; VarDeclaration *v = s->isVarDeclaration(); assert(v); @@ -4984,11 +4985,11 @@ elem *StructLiteralExp::toElem(IRState *irs) dim = elements->dim; assert(dim <= sd->fields.dim); for (size_t i = 0; i < dim; i++) - { Expression *el = (Expression *)elements->data[i]; + { Expression *el = elements->tdata()[i]; if (!el) continue; - Dsymbol *s = (Dsymbol *)sd->fields.data[i]; + Dsymbol *s = sd->fields.tdata()[i]; VarDeclaration *v = s->isVarDeclaration(); assert(v); assert(!v->isThisDeclaration()); @@ -5078,7 +5079,7 @@ elem *StructLiteralExp::toElem(IRState *irs) if (sd->isnested) { // Initialize the hidden 'this' pointer assert(sd->fields.dim); - Dsymbol *s = (Dsymbol *)sd->fields.data[sd->fields.dim - 1]; + Dsymbol *s = sd->fields.tdata()[sd->fields.dim - 1]; ThisDeclaration *v = s->isThisDeclaration(); assert(v); @@ -5116,11 +5117,11 @@ elem *appendDtors(IRState *irs, elem *er, size_t starti, size_t endi) for (size_t i = endi; i != starti;) { --i; - VarDeclaration *vd = (VarDeclaration *)irs->varsInScope->data[i]; + VarDeclaration *vd = irs->varsInScope->tdata()[i]; if (vd) { //printf("appending dtor\n"); - irs->varsInScope->data[i] = NULL; + irs->varsInScope->tdata()[i] = NULL; elem *ed = vd->edtor->toElem(irs); edtors = el_combine(edtors, ed); } diff --git a/src/enum.c b/src/enum.c index 42ad8ecb26cc..ce0ff15478dc 100644 --- a/src/enum.c +++ b/src/enum.c @@ -71,7 +71,7 @@ void EnumDeclaration::semantic0(Scope *sc) return; for (int i = 0; i < members->dim; i++) { - EnumMember *em = ((Dsymbol *)members->data[i])->isEnumMember(); + EnumMember *em = (members->tdata()[i])->isEnumMember(); if (em && (em->type || em->value)) return; } @@ -165,7 +165,7 @@ void EnumDeclaration::semantic(Scope *sc) Expression *elast = NULL; for (int i = 0; i < members->dim; i++) { - EnumMember *em = ((Dsymbol *)members->data[i])->isEnumMember(); + EnumMember *em = (members->tdata()[i])->isEnumMember(); Expression *e; if (!em) @@ -329,7 +329,7 @@ void EnumDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) buf->writenl(); for (i = 0; i < members->dim; i++) { - EnumMember *em = ((Dsymbol *)members->data[i])->isEnumMember(); + EnumMember *em = (members->tdata()[i])->isEnumMember(); if (!em) continue; //buf->writestring(" "); diff --git a/src/expression.c b/src/expression.c index 233c06f8f2be..c38784a4084d 100644 --- a/src/expression.c +++ b/src/expression.c @@ -249,10 +249,10 @@ Expressions *arrayExpressionSemantic(Expressions *exps, Scope *sc) if (exps) { for (size_t i = 0; i < exps->dim; i++) - { Expression *e = (Expression *)exps->data[i]; + { Expression *e = exps->tdata()[i]; if (e) { e = e->semantic(sc); - exps->data[i] = (void *)e; + exps->tdata()[i] = e; } } } @@ -270,7 +270,7 @@ int arrayExpressionCanThrow(Expressions *exps, bool mustNotThrow) if (exps) { for (size_t i = 0; i < exps->dim; i++) - { Expression *e = (Expression *)exps->data[i]; + { Expression *e = exps->tdata()[i]; if (e && e->canThrow(mustNotThrow)) return 1; } @@ -289,7 +289,7 @@ void expandTuples(Expressions *exps) if (exps) { for (size_t i = 0; i < exps->dim; i++) - { Expression *arg = (Expression *)exps->data[i]; + { Expression *arg = exps->tdata()[i]; if (!arg) continue; @@ -318,7 +318,7 @@ void expandTuples(Expressions *exps) exps->insert(i, te->exps); // replace with tuple contents if (i == exps->dim) return; // empty tuple, no more arguments - arg = (Expression *)exps->data[i]; + arg = exps->tdata()[i]; } } } @@ -331,7 +331,7 @@ Expressions *arrayExpressionToCommonType(Scope *sc, Expressions *exps, Type **pt */ Type *t0 = NULL; for (size_t i = 0; i < exps->dim; i++) - { Expression *e = (Expression *)exps->data[i]; + { Expression *e = exps->tdata()[i]; if (!e->type) { error("%s has no value", e->toChars()); @@ -343,7 +343,7 @@ Expressions *arrayExpressionToCommonType(Scope *sc, Expressions *exps, Type **pt t0 = e->type; else e = e->implicitCastTo(sc, t0); - exps->data[i] = (void *)e; + exps->tdata()[i] = e; } if (!t0) @@ -370,7 +370,7 @@ Expressions *arrayExpressionToCommonType(Scope *sc, Expressions *exps, Type **pt Expression *e0; int j0; for (size_t i = 0; i < exps->dim; i++) - { Expression *e = (Expression *)exps->data[i]; + { Expression *e = exps->tdata()[i]; e = resolveProperties(sc, e); if (!e->type) @@ -388,7 +388,7 @@ Expressions *arrayExpressionToCommonType(Scope *sc, Expressions *exps, Type **pt condexp.e1 = e0; condexp.e2 = e; condexp.semantic(sc); - exps->data[j0] = (void *)condexp.e1; + exps->tdata()[j0] = condexp.e1; e = condexp.e2; j0 = i; e0 = e; @@ -400,15 +400,15 @@ Expressions *arrayExpressionToCommonType(Scope *sc, Expressions *exps, Type **pt e0 = e; t0 = e->type; } - exps->data[i] = (void *)e; + exps->tdata()[i] = e; } if (t0) { for (size_t i = 0; i < exps->dim; i++) - { Expression *e = (Expression *)exps->data[i]; + { Expression *e = exps->tdata()[i]; e = e->implicitCastTo(sc, t0); - exps->data[i] = (void *)e; + exps->tdata()[i] = e; } } else @@ -432,7 +432,7 @@ void preFunctionParameters(Loc loc, Scope *sc, Expressions *exps) expandTuples(exps); for (size_t i = 0; i < exps->dim; i++) - { Expression *arg = (Expression *)exps->data[i]; + { Expression *arg = exps->tdata()[i]; if (!arg->type) { @@ -445,7 +445,7 @@ void preFunctionParameters(Loc loc, Scope *sc, Expressions *exps) } arg = resolveProperties(sc, arg); - exps->data[i] = (void *) arg; + exps->tdata()[i] = arg; //arg->rvalue(); #if 0 @@ -453,7 +453,7 @@ void preFunctionParameters(Loc loc, Scope *sc, Expressions *exps) { arg = new AddrExp(arg->loc, arg); arg = arg->semantic(sc); - exps->data[i] = (void *) arg; + exps->tdata()[i] = arg; } #endif } @@ -521,7 +521,7 @@ Type *functionParameters(Loc loc, Scope *sc, TypeFunction *tf, Expression *arg; if (i < nargs) - arg = (Expression *)arguments->data[i]; + arg = arguments->tdata()[i]; else arg = NULL; Type *tb; @@ -590,7 +590,7 @@ Type *functionParameters(Loc loc, Scope *sc, TypeFunction *tf, c->type = v->type; for (size_t u = i; u < nargs; u++) - { Expression *a = (Expression *)arguments->data[u]; + { Expression *a = arguments->tdata()[u]; if (tret && !((TypeArray *)tb)->next->equals(a->type)) a = a->toDelegate(sc, tret); @@ -614,7 +614,7 @@ Type *functionParameters(Loc loc, Scope *sc, TypeFunction *tf, Expressions *args = new Expressions(); args->setDim(nargs - i); for (size_t u = i; u < nargs; u++) - args->data[u - i] = arguments->data[u]; + args->tdata()[u - i] = arguments->tdata()[u]; arg = new NewExp(loc, NULL, NULL, p->type, args); break; } @@ -811,7 +811,7 @@ Type *functionParameters(Loc loc, Scope *sc, TypeFunction *tf, } arg = arg->optimize(WANTvalue); L3: - arguments->data[i] = (void *) arg; + arguments->tdata()[i] = arg; if (done) break; } @@ -820,7 +820,7 @@ Type *functionParameters(Loc loc, Scope *sc, TypeFunction *tf, if (tf->linkage == LINKd && tf->varargs == 1) { assert(arguments->dim >= nparams); - Expression *e = createTypeInfoArray(sc, (Expression **)&arguments->data[nparams], + Expression *e = createTypeInfoArray(sc, (Expression **)&arguments->tdata()[nparams], arguments->dim - nparams); arguments->insert(0, e); } @@ -885,7 +885,7 @@ void argsToCBuffer(OutBuffer *buf, Expressions *arguments, HdrGenState *hgs) if (arguments) { for (size_t i = 0; i < arguments->dim; i++) - { Expression *arg = (Expression *)arguments->data[i]; + { Expression *arg = arguments->tdata()[i]; if (arg) { if (i) @@ -906,7 +906,7 @@ void argExpTypesToCBuffer(OutBuffer *buf, Expressions *arguments, HdrGenState *h { OutBuffer argbuf; for (size_t i = 0; i < arguments->dim; i++) - { Expression *arg = (Expression *)arguments->data[i]; + { Expression *arg = arguments->tdata()[i]; if (i) buf->writeByte(','); @@ -1440,11 +1440,11 @@ Expressions *Expression::arraySyntaxCopy(Expressions *exps) a = new Expressions(); a->setDim(exps->dim); for (int i = 0; i < a->dim; i++) - { Expression *e = (Expression *)exps->data[i]; + { Expression *e = exps->tdata()[i]; if (e) e = e->syntaxCopy(); - a->data[i] = e; + a->tdata()[i] = e; } } return a; @@ -3219,7 +3219,7 @@ int ArrayLiteralExp::checkSideEffect(int flag) { int f = 0; for (size_t i = 0; i < elements->dim; i++) - { Expression *e = (Expression *)elements->data[i]; + { Expression *e = elements->tdata()[i]; f |= e->checkSideEffect(2); } @@ -3253,7 +3253,7 @@ void ArrayLiteralExp::toMangleBuffer(OutBuffer *buf) size_t dim = elements ? elements->dim : 0; buf->printf("A%u", dim); for (size_t i = 0; i < dim; i++) - { Expression *e = (Expression *)elements->data[i]; + { Expression *e = elements->tdata()[i]; e->toMangleBuffer(buf); } } @@ -3312,8 +3312,8 @@ int AssocArrayLiteralExp::checkSideEffect(int flag) { int f = 0; for (size_t i = 0; i < keys->dim; i++) - { Expression *key = (Expression *)keys->data[i]; - Expression *value = (Expression *)values->data[i]; + { Expression *key = keys->tdata()[i]; + Expression *value = values->tdata()[i]; f |= key->checkSideEffect(2); f |= value->checkSideEffect(2); @@ -3340,8 +3340,8 @@ void AssocArrayLiteralExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs) { buf->writeByte('['); for (size_t i = 0; i < keys->dim; i++) - { Expression *key = (Expression *)keys->data[i]; - Expression *value = (Expression *)values->data[i]; + { Expression *key = keys->tdata()[i]; + Expression *value = values->tdata()[i]; if (i) buf->writeByte(','); @@ -3357,8 +3357,8 @@ void AssocArrayLiteralExp::toMangleBuffer(OutBuffer *buf) size_t dim = keys->dim; buf->printf("A%u", dim); for (size_t i = 0; i < dim; i++) - { Expression *key = (Expression *)keys->data[i]; - Expression *value = (Expression *)values->data[i]; + { Expression *key = keys->tdata()[i]; + Expression *value = values->tdata()[i]; key->toMangleBuffer(buf); value->toMangleBuffer(buf); @@ -3399,7 +3399,7 @@ Expression *StructLiteralExp::semantic(Scope *sc) expandTuples(elements); size_t offset = 0; for (size_t i = 0; i < elements->dim; i++) - { e = (Expression *)elements->data[i]; + { e = elements->tdata()[i]; if (!e) continue; @@ -3412,7 +3412,7 @@ Expression *StructLiteralExp::semantic(Scope *sc) { error("more initializers than fields of %s", sd->toChars()); return new ErrorExp(); } - Dsymbol *s = (Dsymbol *)sd->fields.data[i]; + Dsymbol *s = sd->fields.tdata()[i]; VarDeclaration *v = s->isVarDeclaration(); assert(v); if (v->offset < offset) @@ -3433,13 +3433,13 @@ Expression *StructLiteralExp::semantic(Scope *sc) e = e->implicitCastTo(sc, telem); - elements->data[i] = (void *)e; + elements->tdata()[i] = e; } /* Fill out remainder of elements[] with default initializers for fields[] */ for (size_t i = elements->dim; i < nfields; i++) - { Dsymbol *s = (Dsymbol *)sd->fields.data[i]; + { Dsymbol *s = sd->fields.tdata()[i]; VarDeclaration *v = s->isVarDeclaration(); assert(v); assert(!v->isThisDeclaration()); @@ -3511,7 +3511,7 @@ Expression *StructLiteralExp::getField(Type *type, unsigned offset) { //printf("\ti = %d\n", i); assert(i < elements->dim); - e = (Expression *)elements->data[i]; + e = elements->tdata()[i]; if (e) { //printf("e = %s, e->type = %s\n", e->toChars(), e->type->toChars()); @@ -3525,7 +3525,7 @@ Expression *StructLiteralExp::getField(Type *type, unsigned offset) Expressions *z = new Expressions; z->setDim(length); for (int q = 0; q < length; ++q) - z->data[q] = e->copy(); + z->tdata()[q] = e->copy(); e = new ArrayLiteralExp(loc, z); e->type = type; } @@ -3552,13 +3552,13 @@ int StructLiteralExp::getFieldIndex(Type *type, unsigned offset) { for (size_t i = 0; i < sd->fields.dim; i++) { - Dsymbol *s = (Dsymbol *)sd->fields.data[i]; + Dsymbol *s = sd->fields.tdata()[i]; VarDeclaration *v = s->isVarDeclaration(); assert(v); if (offset == v->offset && type->size() == v->type->size()) - { Expression *e = (Expression *)elements->data[i]; + { Expression *e = elements->tdata()[i]; if (e) { return i; @@ -3587,7 +3587,7 @@ int StructLiteralExp::checkSideEffect(int flag) { int f = 0; for (size_t i = 0; i < elements->dim; i++) - { Expression *e = (Expression *)elements->data[i]; + { Expression *e = elements->tdata()[i]; if (!e) continue; @@ -3618,7 +3618,7 @@ void StructLiteralExp::toMangleBuffer(OutBuffer *buf) size_t dim = elements ? elements->dim : 0; buf->printf("S%u", dim); for (size_t i = 0; i < dim; i++) - { Expression *e = (Expression *)elements->data[i]; + { Expression *e = elements->tdata()[i]; if (e) e->toMangleBuffer(buf); else @@ -3867,7 +3867,7 @@ Expression *NewExp::semantic(Scope *sc) else if (cd->isAbstract()) { error("cannot create instance of abstract class %s", cd->toChars()); for (int i = 0; i < cd->vtbl.dim; i++) - { FuncDeclaration *fd = ((Dsymbol *)cd->vtbl.data[i])->isFuncDeclaration(); + { FuncDeclaration *fd = cd->vtbl.tdata()[i]->isFuncDeclaration(); if (fd && fd->isAbstract()) error("function %s is abstract", fd->toChars()); } @@ -4097,7 +4097,7 @@ Expression *NewExp::semantic(Scope *sc) goto Lerr; } - Expression *arg = (Expression *)arguments->data[i]; + Expression *arg = arguments->tdata()[i]; arg = resolveProperties(sc, arg); arg = arg->implicitCastTo(sc, Type::tsize_t); arg = arg->optimize(WANTvalue); @@ -4105,7 +4105,7 @@ Expression *NewExp::semantic(Scope *sc) { error("negative array index %s", arg->toChars()); goto Lerr; } - arguments->data[i] = (void *) arg; + arguments->tdata()[i] = arg; tb = ((TypeDArray *)tb)->next->toBasetype(); } } @@ -4585,7 +4585,7 @@ TupleExp::TupleExp(Loc loc, TupleDeclaration *tup) exps->reserve(tup->objects->dim); for (size_t i = 0; i < tup->objects->dim; i++) - { Object *o = (Object *)tup->objects->data[i]; + { Object *o = tup->objects->tdata()[i]; if (o->dyncast() == DYNCAST_EXPRESSION) { Expression *e = (Expression *)o; @@ -4623,8 +4623,8 @@ int TupleExp::equals(Object *o) if (exps->dim != te->exps->dim) return 0; for (size_t i = 0; i < exps->dim; i++) - { Expression *e1 = (Expression *)exps->data[i]; - Expression *e2 = (Expression *)te->exps->data[i]; + { Expression *e1 = exps->tdata()[i]; + Expression *e2 = te->exps->tdata()[i]; if (!e1->equals(e2)) return 0; @@ -4649,20 +4649,20 @@ Expression *TupleExp::semantic(Scope *sc) // Run semantic() on each argument for (size_t i = 0; i < exps->dim; i++) - { Expression *e = (Expression *)exps->data[i]; + { Expression *e = exps->tdata()[i]; e = e->semantic(sc); if (!e->type) { error("%s has no value", e->toChars()); e = new ErrorExp(); } - exps->data[i] = (void *)e; + exps->tdata()[i] = e; } expandTuples(exps); if (0 && exps->dim == 1) { - return (Expression *)exps->data[0]; + return exps->tdata()[0]; } type = new TypeTuple(exps); type = type->semantic(loc, sc); @@ -4681,7 +4681,7 @@ int TupleExp::checkSideEffect(int flag) { int f = 0; for (int i = 0; i < exps->dim; i++) - { Expression *e = (Expression *)exps->data[i]; + { Expression *e = exps->tdata()[i]; f |= e->checkSideEffect(2); } @@ -4700,7 +4700,7 @@ int TupleExp::canThrow(bool mustNotThrow) void TupleExp::checkEscape() { for (size_t i = 0; i < exps->dim; i++) - { Expression *e = (Expression *)exps->data[i]; + { Expression *e = exps->tdata()[i]; e->checkEscape(); } } @@ -4807,7 +4807,7 @@ Expression *DeclarationExp::semantic(Scope *sc) if (ad) { if (ad->decl && ad->decl->dim == 1) - s = (Dsymbol *)ad->decl->data[0]; + s = ad->decl->tdata()[0]; } if (s->isVarDeclaration()) @@ -5010,7 +5010,7 @@ void TraitsExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs) for (int i = 0; i < args->dim; i++) { buf->writeByte(','); - Object *oarg = (Object *)args->data[i]; + Object *oarg = args->tdata()[i]; ObjectToCBuffer(buf, hgs, oarg); } } @@ -5067,8 +5067,8 @@ Expression *IsExp::syntaxCopy() p = new TemplateParameters(); p->setDim(parameters->dim); for (int i = 0; i < p->dim; i++) - { TemplateParameter *tp = (TemplateParameter *)parameters->data[i]; - p->data[i] = (void *)tp->syntaxCopy(); + { TemplateParameter *tp = parameters->tdata()[i]; + p->tdata()[i] = tp->syntaxCopy(); } } @@ -5178,7 +5178,7 @@ Expression *IsExp::semantic(Scope *sc) Parameters *args = new Parameters; args->reserve(cd->baseclasses->dim); for (size_t i = 0; i < cd->baseclasses->dim; i++) - { BaseClass *b = (BaseClass *)cd->baseclasses->data[i]; + { BaseClass *b = cd->baseclasses->tdata()[i]; args->push(new Parameter(STCin, b->type, NULL, NULL)); } tded = new TypeTuple(args); @@ -5275,18 +5275,18 @@ Expression *IsExp::semantic(Scope *sc) } else { - tded = (Type *)dedtypes.data[0]; + tded = (Type *)dedtypes.tdata()[0]; if (!tded) tded = targ; #if DMDV2 Objects tiargs; tiargs.setDim(1); - tiargs.data[0] = (void *)targ; + tiargs.tdata()[0] = targ; /* Declare trailing parameters */ for (int i = 1; i < parameters->dim; i++) - { TemplateParameter *tp = (TemplateParameter *)parameters->data[i]; + { TemplateParameter *tp = parameters->tdata()[i]; Declaration *s = NULL; m = tp->matchArg(sc, &tiargs, i, parameters, &dedtypes, &s); @@ -5294,7 +5294,7 @@ Expression *IsExp::semantic(Scope *sc) goto Lno; s->semantic(sc); #if 0 - Object *o = (Object *)dedtypes.data[i]; + Type *o = dedtypes.tdata()[i]; Dsymbol *s = TemplateDeclaration::declareParameter(loc, sc, tp, o); #endif if (sc->sd) @@ -5379,7 +5379,7 @@ void IsExp::toCBuffer(OutBuffer *buf, HdrGenState *hgs) for (int i = 1; i < parameters->dim; i++) { buf->writeByte(','); - TemplateParameter *tp = (TemplateParameter *)parameters->data[i]; + TemplateParameter *tp = parameters->tdata()[i]; tp->toCBuffer(buf, hgs); } } @@ -6010,10 +6010,10 @@ Expression *DotIdExp::semantic(Scope *sc, int flag) Expressions *exps = new Expressions(); exps->setDim(te->exps->dim); for (int i = 0; i < exps->dim; i++) - { Expression *e = (Expression *)te->exps->data[i]; + { Expression *e = te->exps->tdata()[i]; e = e->semantic(sc); e = new DotIdExp(e->loc, e, Id::offsetof); - exps->data[i] = (void *)e; + exps->tdata()[i] = e; } e = new TupleExp(loc, exps); e = e->semantic(sc); @@ -6280,7 +6280,7 @@ Expression *DotVarExp::semantic(Scope *sc) exps->reserve(tup->objects->dim); for (size_t i = 0; i < tup->objects->dim; i++) - { Object *o = (Object *)tup->objects->data[i]; + { Object *o = tup->objects->tdata()[i]; if (o->dyncast() != DYNCAST_EXPRESSION) { error("%s is not an expression", o->toChars()); @@ -6648,7 +6648,7 @@ CallExp::CallExp(Loc loc, Expression *e, Expression *earg1) Expressions *arguments = new Expressions(); if (earg1) { arguments->setDim(1); - arguments->data[0] = (void *)earg1; + arguments->tdata()[0] = earg1; } this->arguments = arguments; } @@ -6658,8 +6658,8 @@ CallExp::CallExp(Loc loc, Expression *e, Expression *earg1, Expression *earg2) { Expressions *arguments = new Expressions(); arguments->setDim(2); - arguments->data[0] = (void *)earg1; - arguments->data[1] = (void *)earg2; + arguments->tdata()[0] = earg1; + arguments->tdata()[1] = earg2; this->arguments = arguments; } @@ -6688,7 +6688,7 @@ Expression *CallExp::semantic(Scope *sc) #if 0 if (arguments && arguments->dim) { - Expression *earg = (Expression *)arguments->data[0]; + Expression *earg = arguments->tdata()[0]; earg->print(); if (earg->type) earg->type->print(); } @@ -6721,7 +6721,7 @@ Expression *CallExp::semantic(Scope *sc) { error("expected key as argument to aa.remove()"); return new ErrorExp(); } - Expression *key = (Expression *)arguments->data[0]; + Expression *key = arguments->tdata()[0]; key = key->semantic(sc); key = resolveProperties(sc, key); key->rvalue(); @@ -6984,7 +6984,7 @@ Expression *CallExp::semantic(Scope *sc) if (arguments && arguments->dim) { for (int k = 0; k < arguments->dim; k++) - { Expression *checkarg = (Expression *)arguments->data[k]; + { Expression *checkarg = arguments->tdata()[k]; if (checkarg->op == TOKerror) return checkarg; } @@ -7213,7 +7213,7 @@ Expression *CallExp::semantic(Scope *sc) FuncDeclaration *f = NULL; Dsymbol *s = NULL; for (int i = 0; i < eo->vars->a.dim; i++) - { s = (Dsymbol *)eo->vars->a.data[i]; + { s = eo->vars->a.tdata()[i]; FuncDeclaration *f2 = s->isFuncDeclaration(); if (f2) { @@ -7381,7 +7381,7 @@ int CallExp::checkSideEffect(int flag) /* If any of the arguments have side effects, this expression does */ for (size_t i = 0; i < arguments->dim; i++) - { Expression *e = (Expression *)arguments->data[i]; + { Expression *e = arguments->tdata()[i]; if (e->checkSideEffect(2)) return 1; @@ -7409,7 +7409,7 @@ int CallExp::canThrow(bool mustNotThrow) /* If any of the arguments can throw, then this expression can throw */ for (size_t i = 0; i < arguments->dim; i++) - { Expression *e = (Expression *)arguments->data[i]; + { Expression *e = arguments->tdata()[i]; if (e && e->canThrow(mustNotThrow)) return 1; @@ -8323,8 +8323,8 @@ Expression *SliceExp::semantic(Scope *sc) { Expressions *exps = new Expressions; exps->setDim(j2 - j1); for (size_t i = 0; i < j2 - j1; i++) - { Expression *e = (Expression *)te->exps->data[j1 + i]; - exps->data[i] = (void *)e; + { Expression *e = te->exps->tdata()[j1 + i]; + exps->tdata()[i] = e; } e = new TupleExp(loc, exps); } @@ -8534,13 +8534,13 @@ Expression *ArrayExp::semantic(Scope *sc) { error("only one index allowed to index %s", t1->toChars()); goto Lerr; } - e = new IndexExp(loc, e1, (Expression *)arguments->data[0]); + e = new IndexExp(loc, e1, arguments->tdata()[0]); return e->semantic(sc); } // Run semantic() on each argument for (size_t i = 0; i < arguments->dim; i++) - { e = (Expression *)arguments->data[i]; + { e = arguments->tdata()[i]; e = e->semantic(sc); if (!e->type) @@ -8549,7 +8549,7 @@ Expression *ArrayExp::semantic(Scope *sc) } else if (e->type == Type::terror) goto Lerr; - arguments->data[i] = (void *)e; + arguments->tdata()[i] = e; } expandTuples(arguments); @@ -8835,7 +8835,7 @@ Expression *IndexExp::semantic(Scope *sc) { if (e1->op == TOKtuple) - e = (Expression *)te->exps->data[(size_t)index]; + e = te->exps->tdata()[(size_t)index]; else e = new TypeExp(e1->loc, Parameter::getNth(tup->arguments, (size_t)index)->type); } @@ -9089,7 +9089,7 @@ Expression *AssignExp::semantic(Scope *sc) return new ErrorExp(); } - e = new CallExp(loc, e, (Expression *)ae->arguments->data[0], e2); + e = new CallExp(loc, e, ae->arguments->tdata()[0], e2); e = e->semantic(sc); return e; } @@ -9168,9 +9168,9 @@ Expression *AssignExp::semantic(Scope *sc) exps->setDim(dim); for (int i = 0; i < dim; i++) - { Expression *ex1 = (Expression *)tup1->exps->data[i]; - Expression *ex2 = (Expression *)tup2->exps->data[i]; - exps->data[i] = (void *) new AssignExp(loc, ex1, ex2); + { Expression *ex1 = tup1->exps->tdata()[i]; + Expression *ex2 = tup2->exps->tdata()[i]; + exps->tdata()[i] = new AssignExp(loc, ex1, ex2); } Expression *e = new TupleExp(loc, exps); e = e->semantic(sc); @@ -10589,7 +10589,7 @@ Expression *PowExp::semantic(Scope *sc) { importMathChecked = 1; for (int i = 0; i < Module::amodules.dim; i++) - { Module *mi = (Module *)Module::amodules.data[i]; + { Module *mi = Module::amodules.tdata()[i]; //printf("\t[%d] %s\n", i, mi->toChars()); if (mi->ident == Id::math && mi->parent->ident == Id::std && diff --git a/src/func.c b/src/func.c index 5df99990c7c5..79daf6433f4c 100644 --- a/src/func.c +++ b/src/func.c @@ -453,7 +453,7 @@ void FuncDeclaration::semantic(Scope *sc) return; default: - { FuncDeclaration *fdv = (FuncDeclaration *)cd->baseClass->vtbl.data[vi]; + { FuncDeclaration *fdv = (FuncDeclaration *)cd->baseClass->vtbl.tdata()[vi]; // This function is covariant with fdv if (fdv->isFinal()) error("cannot override final function %s", fdv->toPrettyChars()); @@ -480,7 +480,7 @@ void FuncDeclaration::semantic(Scope *sc) ) error("multiple overrides of same function"); } - cd->vtbl.data[vi] = (void *)this; + cd->vtbl.tdata()[vi] = this; vtblIndex = vi; /* Remember which functions this overrides @@ -531,7 +531,7 @@ void FuncDeclaration::semantic(Scope *sc) return; default: - { FuncDeclaration *fdv = (FuncDeclaration *)b->base->vtbl.data[vi]; + { FuncDeclaration *fdv = (FuncDeclaration *)b->base->vtbl.tdata()[vi]; Type *ti = NULL; /* Remember which functions this overrides @@ -809,7 +809,7 @@ void FuncDeclaration::semantic3(Scope *sc) { for (int i = 0; i < fthrows->dim; i++) { - Type *t = (Type *)fthrows->data[i]; + Type *t = fthrows->tdata()[i]; t = t->semantic(loc, sc); if (!t->isClassHandle()) @@ -991,7 +991,7 @@ void FuncDeclaration::semantic3(Scope *sc) if (f->parameters) { for (size_t i = 0; i < f->parameters->dim; i++) - { Parameter *arg = (Parameter *)f->parameters->data[i]; + { Parameter *arg = f->parameters->tdata()[i]; //printf("[%d] arg->type->ty = %d %s\n", i, arg->type->ty, arg->type->toChars()); if (arg->type->ty == Ttuple) @@ -1014,7 +1014,7 @@ void FuncDeclaration::semantic3(Scope *sc) { /* parameters[] has all the tuples removed, as the back end * doesn't know about tuples */ - parameters = new Dsymbols(); + parameters = new VarDeclarations(); parameters->reserve(nparams); for (size_t i = 0; i < nparams; i++) { @@ -1051,7 +1051,7 @@ void FuncDeclaration::semantic3(Scope *sc) if (f->parameters) { for (size_t i = 0; i < f->parameters->dim; i++) - { Parameter *arg = (Parameter *)f->parameters->data[i]; + { Parameter *arg = f->parameters->tdata()[i]; if (!arg->ident) continue; // never used, so ignore @@ -1066,7 +1066,7 @@ void FuncDeclaration::semantic3(Scope *sc) VarDeclaration *v = sc2->search(0, narg->ident, NULL)->isVarDeclaration(); assert(v); Expression *e = new VarExp(v->loc, v); - exps->data[j] = (void *)e; + exps->tdata()[j] = e; } assert(arg->ident); TupleDeclaration *v = new TupleDeclaration(loc, arg->ident, exps); @@ -1228,7 +1228,7 @@ void FuncDeclaration::semantic3(Scope *sc) if (isCtorDeclaration() && cd) { for (int i = 0; i < cd->fields.dim; i++) - { VarDeclaration *v = (VarDeclaration *)cd->fields.data[i]; + { VarDeclaration *v = cd->fields.tdata()[i]; v->ctorinit = 0; } @@ -1265,7 +1265,7 @@ void FuncDeclaration::semantic3(Scope *sc) else { for (int i = 0; i < ad->members->dim; i++) - { Dsymbol *s = (Dsymbol *)ad->members->data[i]; + { Dsymbol *s = ad->members->tdata()[i]; s->checkCtorConstInit(); } @@ -1280,7 +1280,7 @@ void FuncDeclaration::semantic3(Scope *sc) if (!(sc2->callSuper & CSXthis_ctor)) { for (int i = 0; i < cd->fields.dim; i++) - { VarDeclaration *v = (VarDeclaration *)cd->fields.data[i]; + { VarDeclaration *v = cd->fields.tdata()[i]; if (v->ctorinit == 0 && v->isCtorinit() && !v->type->isMutable()) error("missing initializer for final field %s", v->toChars()); @@ -1372,7 +1372,7 @@ void FuncDeclaration::semantic3(Scope *sc) if (parameters) { for (size_t i = 0; i < parameters->dim; i++) { - VarDeclaration *v = (VarDeclaration *)parameters->data[i]; + VarDeclaration *v = parameters->tdata()[i]; if (v->storage_class & STCout) { assert(v->init); @@ -1412,7 +1412,7 @@ void FuncDeclaration::semantic3(Scope *sc) if (parameters && parameters->dim) { int lastNonref = parameters->dim -1; - p = (VarDeclaration *)parameters->data[lastNonref]; + p = parameters->tdata()[lastNonref]; /* The trouble with out and ref parameters is that taking * the address of it doesn't work, because later processing * adds in an extra level of indirection. So we skip over them. @@ -1426,7 +1426,7 @@ void FuncDeclaration::semantic3(Scope *sc) p = v_arguments; break; } - p = (VarDeclaration *)parameters->data[lastNonref]; + p = parameters->tdata()[lastNonref]; } } else @@ -1545,7 +1545,7 @@ void FuncDeclaration::semantic3(Scope *sc) if (parameters) { for (size_t i = 0; i < parameters->dim; i++) { - VarDeclaration *v = (VarDeclaration *)parameters->data[i]; + VarDeclaration *v = parameters->tdata()[i]; if (v->storage_class & (STCref | STCout)) continue; @@ -1722,7 +1722,7 @@ Statement *FuncDeclaration::mergeFrequire(Statement *sf) */ for (int i = 0; i < foverrides.dim; i++) { - FuncDeclaration *fdv = (FuncDeclaration *)foverrides.data[i]; + FuncDeclaration *fdv = foverrides.tdata()[i]; /* The semantic pass on the contracts of the overridden functions must * be completed before code generation occurs (bug 3602). @@ -1779,7 +1779,7 @@ Statement *FuncDeclaration::mergeFensure(Statement *sf) */ for (int i = 0; i < foverrides.dim; i++) { - FuncDeclaration *fdv = (FuncDeclaration *)foverrides.data[i]; + FuncDeclaration *fdv = foverrides.tdata()[i]; /* The semantic pass on the contracts of the overridden functions must * be completed before code generation occurs (bug 3602 and 5230). @@ -1846,13 +1846,13 @@ int FuncDeclaration::overrides(FuncDeclaration *fd) * -2 can't determine because of forward references */ -int FuncDeclaration::findVtblIndex(FuncDeclarations *vtbl, int dim) +int FuncDeclaration::findVtblIndex(Dsymbols *vtbl, int dim) { FuncDeclaration *mismatch = NULL; int bestvi = -1; for (int vi = 0; vi < dim; vi++) { - FuncDeclaration *fdv = ((Dsymbol *)vtbl->data[vi])->isFuncDeclaration(); + FuncDeclaration *fdv = vtbl->tdata()[vi]->isFuncDeclaration(); if (fdv && fdv->ident == ident) { if (type->equals(fdv->type)) // if exact match @@ -2195,7 +2195,7 @@ if (arguments) for (i = 0; i < arguments->dim; i++) { Expression *arg; - arg = (Expression *)arguments->data[i]; + arg = arguments->tdata()[i]; assert(arg->type); printf("\t%s: ", arg->toChars()); arg->type->print(); @@ -2238,7 +2238,7 @@ if (arguments) OutBuffer buf2; tf->modToBuffer(&buf2); - //printf("tf = %s, args = %s\n", tf->deco, ((Expression *)arguments->data[0])->type->deco); + //printf("tf = %s, args = %s\n", tf->deco, arguments->tdata()[0]->type->deco); error(loc, "%s%s is not callable using argument types %s", Parameter::argsTypesToChars(tf->parameters, tf->varargs), buf2.toChars(), @@ -2324,7 +2324,7 @@ MATCH FuncDeclaration::leastAsSpecialized(FuncDeclaration *g) } else e = p->type->defaultInit(); - args.data[u] = e; + args.tdata()[u] = e; } MATCH m = (MATCH) tg->callMatch(NULL, &args, 1); @@ -2767,12 +2767,12 @@ int FuncDeclaration::needsClosure() //printf("FuncDeclaration::needsClosure() %s\n", toChars()); for (int i = 0; i < closureVars.dim; i++) - { VarDeclaration *v = (VarDeclaration *)closureVars.data[i]; + { VarDeclaration *v = closureVars.tdata()[i]; assert(v->isVarDeclaration()); //printf("\tv = %s\n", v->toChars()); for (int j = 0; j < v->nestedrefs.dim; j++) - { FuncDeclaration *f = (FuncDeclaration *)v->nestedrefs.data[j]; + { FuncDeclaration *f = v->nestedrefs.tdata()[j]; assert(f != this); //printf("\t\tf = %s, %d, %p, %d\n", f->toChars(), f->isVirtual(), f->isThis(), f->tookAddressOf); diff --git a/src/glue.c b/src/glue.c index 44b22a151b3b..f592a9aeb7be 100644 --- a/src/glue.c +++ b/src/glue.c @@ -80,7 +80,7 @@ void obj_append(Dsymbol *s) void obj_write_deferred(Library *library) { for (int i = 0; i < obj_symbols_towrite.dim; i++) - { Dsymbol *s = (Dsymbol *)obj_symbols_towrite.data[i]; + { Dsymbol *s = obj_symbols_towrite.tdata()[i]; Module *m = s->getModule(); char *mname; @@ -227,7 +227,7 @@ void Module::genobjfile(int multiobj) /* Generate a reference to the moduleinfo, so the module constructors * and destructors get linked in. */ - Module *m = (Module *)aimports.data[0]; + Module *m = aimports.tdata()[0]; assert(m); if (m->sictor || m->sctor || m->sdtor || m->ssharedctor || m->sshareddtor) { @@ -275,7 +275,7 @@ void Module::genobjfile(int multiobj) for (int i = 0; i < members->dim; i++) { - Dsymbol *member = (Dsymbol *)members->data[i]; + Dsymbol *member = members->tdata()[i]; member->toObjFile(multiobj); } @@ -361,7 +361,7 @@ void Module::genobjfile(int multiobj) cstate.CSpsymtab = &sctor->Sfunc->Flocsym; for (int i = 0; i < ectorgates.dim; i++) - { StaticDtorDeclaration *f = (StaticDtorDeclaration *)ectorgates.data[i]; + { StaticDtorDeclaration *f = ectorgates.tdata()[i]; Symbol *s = f->vgate->toSymbol(); elem *e = el_var(s); @@ -402,7 +402,7 @@ void Module::genobjfile(int multiobj) cstate.CSpsymtab = &ssharedctor->Sfunc->Flocsym; for (int i = 0; i < esharedctorgates.dim; i++) - { SharedStaticDtorDeclaration *f = (SharedStaticDtorDeclaration *)esharedctorgates.data[i]; + { SharedStaticDtorDeclaration *f = esharedctorgates.tdata()[i]; Symbol *s = f->vgate->toSymbol(); elem *e = el_var(s); @@ -737,7 +737,7 @@ void FuncDeclaration::toObjFile(int multiobj) if (parameters) { for (i = 0; i < parameters->dim; i++) - { VarDeclaration *v = (VarDeclaration *)parameters->data[i]; + { VarDeclaration *v = parameters->tdata()[i]; if (v->csym) { error("compiler error, parameter '%s', bugzilla 2962?", v->toChars()); @@ -1023,7 +1023,7 @@ void FuncDeclaration::toObjFile(int multiobj) for (i = 0; i < irs.deferToObj->dim; i++) { - Dsymbol *s = (Dsymbol *)irs.deferToObj->data[i]; + Dsymbol *s = irs.deferToObj->tdata()[i]; s->toObjFile(0); } diff --git a/src/hdrgen.c b/src/hdrgen.c index 512cb0b805a9..80e357413815 100644 --- a/src/hdrgen.c +++ b/src/hdrgen.c @@ -86,7 +86,7 @@ void Module::toCBuffer(OutBuffer *buf, HdrGenState *hgs) } for (int i = 0; i < members->dim; i++) - { Dsymbol *s = (Dsymbol *)members->data[i]; + { Dsymbol *s = members->tdata()[i]; s->toHBuffer(buf, hgs); } diff --git a/src/iasm.c b/src/iasm.c index 1844a50ec6d8..b036662491a9 100644 --- a/src/iasm.c +++ b/src/iasm.c @@ -2004,7 +2004,7 @@ STATIC OPND *asm_merge_opnds(OPND *o1, OPND *o2) error(asmstate.loc, "tuple index %u exceeds length %u", index, tup->objects->dim); else { - Object *o = (Object *)tup->objects->data[index]; + Object *o = tup->objects->tdata()[index]; if (o->dyncast() == DYNCAST_DSYMBOL) { o1->s = (Dsymbol *)o; return o1; diff --git a/src/import.c b/src/import.c index 41f1d0b1b363..0bda649912fd 100644 --- a/src/import.c +++ b/src/import.c @@ -42,7 +42,7 @@ Import::Import(Loc loc, Identifiers *packages, Identifier *id, Identifier *alias this->ident = aliasId; // Kludge to change Import identifier to first package else if (packages && packages->dim) - this->ident = (Identifier *)packages->data[0]; + this->ident = packages->tdata()[0]; } void Import::addAlias(Identifier *name, Identifier *alias) @@ -73,7 +73,7 @@ Dsymbol *Import::syntaxCopy(Dsymbol *s) for (size_t i = 0; i < names.dim; i++) { - si->addAlias((Identifier *)names.data[i], (Identifier *)aliases.data[i]); + si->addAlias(names.tdata()[i], aliases.tdata()[i]); } return si; @@ -198,11 +198,11 @@ void Import::semantic(Scope *sc) sc = sc->push(mod); for (size_t i = 0; i < aliasdecls.dim; i++) - { Dsymbol *s = (Dsymbol *)aliasdecls.data[i]; + { Dsymbol *s = aliasdecls.tdata()[i]; //printf("\tImport alias semantic('%s')\n", s->toChars()); - if (!mod->search(loc, (Identifier *)names.data[i], 0)) - error("%s not found", ((Identifier *)names.data[i])->toChars()); + if (!mod->search(loc, names.tdata()[i], 0)) + error("%s not found", (names.tdata()[i])->toChars()); s->semantic(sc); } @@ -240,7 +240,7 @@ void Import::semantic(Scope *sc) { for (size_t i = 0; i < packages->dim; i++) { - Identifier *pid = (Identifier *)packages->data[i]; + Identifier *pid = packages->tdata()[i]; ob->printf("%s.", pid->toChars()); } } @@ -260,8 +260,8 @@ void Import::semantic(Scope *sc) else ob->writebyte(','); - Identifier *name = (Identifier *)names.data[i]; - Identifier *alias = (Identifier *)aliases.data[i]; + Identifier *name = names.tdata()[i]; + Identifier *alias = aliases.tdata()[i]; if (!alias) { @@ -317,8 +317,8 @@ int Import::addMember(Scope *sc, ScopeDsymbol *sd, int memnum) */ for (size_t i = 0; i < names.dim; i++) { - Identifier *name = (Identifier *)names.data[i]; - Identifier *alias = (Identifier *)aliases.data[i]; + Identifier *name = names.tdata()[i]; + Identifier *alias = aliases.tdata()[i]; if (!alias) alias = name; @@ -367,7 +367,7 @@ void Import::toCBuffer(OutBuffer *buf, HdrGenState *hgs) if (packages && packages->dim) { for (size_t i = 0; i < packages->dim; i++) - { Identifier *pid = (Identifier *)packages->data[i]; + { Identifier *pid = packages->tdata()[i]; buf->printf("%s.", pid->toChars()); } diff --git a/src/init.c b/src/init.c index 3b81f27bd85a..6f1fa75e93d7 100644 --- a/src/init.c +++ b/src/init.c @@ -53,10 +53,10 @@ Initializers *Initializer::arraySyntaxCopy(Initializers *ai) a = new Initializers(); a->setDim(ai->dim); for (int i = 0; i < a->dim; i++) - { Initializer *e = (Initializer *)ai->data[i]; + { Initializer *e = ai->tdata()[i]; e = e->syntaxCopy(); - a->data[i] = e; + a->tdata()[i] = e; } } return a; @@ -125,11 +125,11 @@ Initializer *StructInitializer::syntaxCopy() ai->value.setDim(value.dim); for (int i = 0; i < field.dim; i++) { - ai->field.data[i] = field.data[i]; + ai->field.tdata()[i] = field.tdata()[i]; - Initializer *init = (Initializer *)value.data[i]; + Initializer *init = value.tdata()[i]; init = init->syntaxCopy(); - ai->value.data[i] = init; + ai->value.tdata()[i] = init; } return ai; } @@ -159,8 +159,8 @@ Initializer *StructInitializer::semantic(Scope *sc, Type *t, int needInterpret) ad->kind(), ad->toChars(), ad->toChars()); for (size_t i = 0; i < field.dim; i++) { - Identifier *id = (Identifier *)field.data[i]; - Initializer *val = (Initializer *)value.data[i]; + Identifier *id = field.tdata()[i]; + Initializer *val = value.tdata()[i]; Dsymbol *s; VarDeclaration *v; @@ -175,7 +175,7 @@ Initializer *StructInitializer::semantic(Scope *sc, Type *t, int needInterpret) } else { - s = (Dsymbol *)ad->fields.data[fieldi]; + s = ad->fields.tdata()[fieldi]; } } else @@ -199,15 +199,15 @@ Initializer *StructInitializer::semantic(Scope *sc, Type *t, int needInterpret) errors = 1; break; } - if (s == (Dsymbol *)ad->fields.data[fieldi]) + if (s == ad->fields.tdata()[fieldi]) break; } } if (s && (v = s->isVarDeclaration()) != NULL) { val = val->semantic(sc, v->type, needInterpret); - value.data[i] = (void *)val; - vars.data[i] = (void *)v; + value.tdata()[i] = val; + vars.tdata()[i] = v; } else { error(loc, "%s is not a field of %s", id ? id->toChars() : s->toChars(), ad->toChars()); @@ -263,12 +263,12 @@ Expression *StructInitializer::toExpression() elements->setDim(ad->fields.dim); for (int i = 0; i < elements->dim; i++) { - elements->data[i] = NULL; + elements->tdata()[i] = NULL; } unsigned fieldi = 0; for (int i = 0; i < value.dim; i++) { - Identifier *id = (Identifier *)field.data[i]; + Identifier *id = field.tdata()[i]; if (id) { Dsymbol * s = ad->search(loc, id, 0); @@ -286,7 +286,7 @@ Expression *StructInitializer::toExpression() s->error("is not a per-instance initializable field"); goto Lno; } - if (s == (Dsymbol *)ad->fields.data[fieldi]) + if (s == ad->fields.tdata()[fieldi]) break; } } @@ -294,18 +294,18 @@ Expression *StructInitializer::toExpression() { error(loc, "too many initializers for '%s'", ad->toChars()); goto Lno; } - Initializer *iz = (Initializer *)value.data[i]; + Initializer *iz = value.tdata()[i]; if (!iz) goto Lno; Expression *ex = iz->toExpression(); if (!ex) goto Lno; - if (elements->data[fieldi]) + if (elements->tdata()[fieldi]) { error(loc, "duplicate initializer for field '%s'", - ((Dsymbol *)ad->fields.data[fieldi])->toChars()); + ad->fields.tdata()[fieldi]->toChars()); goto Lno; } - elements->data[fieldi] = ex; + elements->tdata()[fieldi] = ex; ++fieldi; } // Now, fill in any missing elements with default initializers. @@ -313,20 +313,20 @@ Expression *StructInitializer::toExpression() offset = 0; for (int i = 0; i < elements->dim; ) { - VarDeclaration * vd = ((Dsymbol *)ad->fields.data[i])->isVarDeclaration(); + VarDeclaration * vd = ad->fields.tdata()[i]->isVarDeclaration(); //printf("test2 [%d] : %s %d %d\n", i, vd->toChars(), (int)offset, (int)vd->offset); if (vd->offset < offset) { // Only the first field of a union can have an initializer - if (elements->data[i]) + if (elements->tdata()[i]) goto Lno; } else { - if (!elements->data[i]) + if (!elements->tdata()[i]) // Default initialize - elements->data[i] = vd->type->defaultInit(); + elements->tdata()[i] = vd->type->defaultInit(); } offset = vd->offset + vd->type->size(); i++; @@ -334,15 +334,15 @@ Expression *StructInitializer::toExpression() int unionSize = ad->numFieldsInUnion(i); if (unionSize == 1) { // Not a union -- default initialize if missing - if (!elements->data[i]) - elements->data[i] = vd->type->defaultInit(); + if (!elements->tdata()[i]) + elements->tdata()[i] = vd->type->defaultInit(); } else { // anonymous union -- check for errors int found = -1; // index of the first field with an initializer for (int j = i; j < i + unionSize; ++j) { - if (!elements->data[j]) + if (!elements->tdata()[j]) continue; if (found >= 0) { @@ -383,13 +383,13 @@ void StructInitializer::toCBuffer(OutBuffer *buf, HdrGenState *hgs) { if (i > 0) buf->writebyte(','); - Identifier *id = (Identifier *)field.data[i]; + Identifier *id = field.tdata()[i]; if (id) { buf->writestring(id->toChars()); buf->writebyte(':'); } - Initializer *iz = (Initializer *)value.data[i]; + Initializer *iz = value.tdata()[i]; if (iz) iz->toCBuffer(buf, hgs); } @@ -416,14 +416,14 @@ Initializer *ArrayInitializer::syntaxCopy() ai->index.setDim(index.dim); ai->value.setDim(value.dim); for (int i = 0; i < ai->value.dim; i++) - { Expression *e = (Expression *)index.data[i]; + { Expression *e = index.tdata()[i]; if (e) e = e->syntaxCopy(); - ai->index.data[i] = e; + ai->index.tdata()[i] = e; - Initializer *init = (Initializer *)value.data[i]; + Initializer *init = value.tdata()[i]; init = init->syntaxCopy(); - ai->value.data[i] = init; + ai->value.tdata()[i] = init; } return ai; } @@ -462,17 +462,17 @@ Initializer *ArrayInitializer::semantic(Scope *sc, Type *t, int needInterpret) length = 0; for (i = 0; i < index.dim; i++) { - Expression *idx = (Expression *)index.data[i]; + Expression *idx = index.tdata()[i]; if (idx) { idx = idx->semantic(sc); idx = idx->optimize(WANTvalue | WANTinterpret); - index.data[i] = (void *)idx; + index.tdata()[i] = idx; length = idx->toInteger(); } - Initializer *val = (Initializer *)value.data[i]; + Initializer *val = value.tdata()[i]; val = val->semantic(sc, t->nextOf(), needInterpret); - value.data[i] = (void *)val; + value.tdata()[i] = val; length++; if (length == 0) { error(loc, "array dimension overflow"); @@ -541,8 +541,8 @@ Expression *ArrayInitializer::toExpression() edim = value.dim; for (size_t i = 0, j = 0; i < value.dim; i++, j++) { - if (index.data[i]) - j = ((Expression *)index.data[i])->toInteger(); + if (index.tdata()[i]) + j = index.tdata()[i]->toInteger(); if (j >= edim) edim = j + 1; } @@ -553,10 +553,10 @@ Expression *ArrayInitializer::toExpression() elements->zero(); for (size_t i = 0, j = 0; i < value.dim; i++, j++) { - if (index.data[i]) - j = ((Expression *)index.data[i])->toInteger(); + if (index.tdata()[i]) + j = (index.tdata()[i])->toInteger(); assert(j < edim); - Initializer *iz = (Initializer *)value.data[i]; + Initializer *iz = value.tdata()[i]; if (!iz) goto Lno; Expression *ex = iz->toExpression(); @@ -564,7 +564,7 @@ Expression *ArrayInitializer::toExpression() { goto Lno; } - elements->data[j] = ex; + elements->tdata()[j] = ex; } /* Fill in any missing elements with the default initializer @@ -573,13 +573,13 @@ Expression *ArrayInitializer::toExpression() Expression *init = NULL; for (size_t i = 0; i < edim; i++) { - if (!elements->data[i]) + if (!elements->tdata()[i]) { if (!type) goto Lno; if (!init) init = ((TypeNext *)t)->next->defaultInit(); - elements->data[i] = init; + elements->tdata()[i] = init; } } @@ -610,18 +610,18 @@ Expression *ArrayInitializer::toAssocArrayLiteral() for (size_t i = 0; i < value.dim; i++) { - e = (Expression *)index.data[i]; + e = index.tdata()[i]; if (!e) goto Lno; - keys->data[i] = (void *)e; + keys->tdata()[i] = e; - Initializer *iz = (Initializer *)value.data[i]; + Initializer *iz = value.tdata()[i]; if (!iz) goto Lno; e = iz->toExpression(); if (!e) goto Lno; - values->data[i] = (void *)e; + values->tdata()[i] = e; } e = new AssocArrayLiteralExp(loc, keys, values); return e; @@ -637,7 +637,7 @@ int ArrayInitializer::isAssociativeArray() { for (size_t i = 0; i < value.dim; i++) { - if (index.data[i]) + if (index.tdata()[i]) return 1; } return 0; @@ -699,13 +699,13 @@ void ArrayInitializer::toCBuffer(OutBuffer *buf, HdrGenState *hgs) { if (i > 0) buf->writebyte(','); - Expression *ex = (Expression *)index.data[i]; + Expression *ex = index.tdata()[i]; if (ex) { ex->toCBuffer(buf, hgs); buf->writebyte(':'); } - Initializer *iz = (Initializer *)value.data[i]; + Initializer *iz = value.tdata()[i]; if (iz) iz->toCBuffer(buf, hgs); } diff --git a/src/inline.c b/src/inline.c index 7dc31b78f7cd..36e1d2427776 100644 --- a/src/inline.c +++ b/src/inline.c @@ -54,7 +54,7 @@ int CompoundStatement::inlineCost(InlineCostState *ics) { int cost = 0; for (size_t i = 0; i < statements->dim; i++) - { Statement *s = (Statement *) statements->data[i]; + { Statement *s = statements->tdata()[i]; if (s) { cost += s->inlineCost(ics); @@ -69,7 +69,7 @@ int UnrolledLoopStatement::inlineCost(InlineCostState *ics) { int cost = 0; for (size_t i = 0; i < statements->dim; i++) - { Statement *s = (Statement *) statements->data[i]; + { Statement *s = statements->tdata()[i]; if (s) { cost += s->inlineCost(ics); @@ -136,7 +136,7 @@ int arrayInlineCost(InlineCostState *ics, Expressions *arguments) if (arguments) { for (int i = 0; i < arguments->dim; i++) - { Expression *e = (Expression *)arguments->data[i]; + { Expression *e = arguments->tdata()[i]; if (e) cost += e->inlineCost(ics); @@ -226,7 +226,7 @@ int DeclarationExp::inlineCost(InlineCostState *ics) return COST_MAX; // finish DeclarationExp::doInline #else for (size_t i = 0; i < td->objects->dim; i++) - { Object *o = (Object *)td->objects->data[i]; + { Object *o = td->objects->tdata()[i]; if (o->dyncast() != DYNCAST_EXPRESSION) return COST_MAX; Expression *eo = (Expression *)o; @@ -355,7 +355,7 @@ Expression *CompoundStatement::doInline(InlineDoState *ids) //printf("CompoundStatement::doInline() %d\n", statements->dim); for (size_t i = 0; i < statements->dim; i++) - { Statement *s = (Statement *) statements->data[i]; + { Statement *s = statements->tdata()[i]; if (s) { Expression *e2 = s->doInline(ids); @@ -387,7 +387,7 @@ Expression *UnrolledLoopStatement::doInline(InlineDoState *ids) //printf("UnrolledLoopStatement::doInline() %d\n", statements->dim); for (size_t i = 0; i < statements->dim; i++) - { Statement *s = (Statement *) statements->data[i]; + { Statement *s = statements->tdata()[i]; if (s) { Expression *e2 = s->doInline(ids); @@ -460,11 +460,11 @@ Expressions *arrayExpressiondoInline(Expressions *a, InlineDoState *ids) newa->setDim(a->dim); for (int i = 0; i < a->dim; i++) - { Expression *e = (Expression *)a->data[i]; + { Expression *e = a->tdata()[i]; if (e) e = e->doInline(ids); - newa->data[i] = (void *)e; + newa->tdata()[i] = e; } } return newa; @@ -483,11 +483,11 @@ Expression *SymOffExp::doInline(InlineDoState *ids) //printf("SymOffExp::doInline(%s)\n", toChars()); for (i = 0; i < ids->from.dim; i++) { - if (var == (Declaration *)ids->from.data[i]) + if (var == ids->from.tdata()[i]) { SymOffExp *se = (SymOffExp *)copy(); - se->var = (Declaration *)ids->to.data[i]; + se->var = (Declaration *)ids->to.tdata()[i]; return se; } } @@ -501,11 +501,11 @@ Expression *VarExp::doInline(InlineDoState *ids) //printf("VarExp::doInline(%s)\n", toChars()); for (i = 0; i < ids->from.dim; i++) { - if (var == (Declaration *)ids->from.data[i]) + if (var == ids->from.tdata()[i]) { VarExp *ve = (VarExp *)copy(); - ve->var = (Declaration *)ids->to.data[i]; + ve->var = (Declaration *)ids->to.tdata()[i]; return ve; } } @@ -549,7 +549,7 @@ Expression *DeclarationExp::doInline(InlineDoState *ids) if (td) { for (size_t i = 0; i < td->objects->dim; i++) - { DsymbolExp *se = (DsymbolExp *)td->objects->data[i]; + { DsymbolExp *se = td->objects->tdata()[i]; assert(se->op == TOKdsymbol); se->s; } @@ -812,9 +812,9 @@ Statement *ExpStatement::inlineScan(InlineScanState *iss) Statement *CompoundStatement::inlineScan(InlineScanState *iss) { for (size_t i = 0; i < statements->dim; i++) - { Statement *s = (Statement *) statements->data[i]; + { Statement *s = statements->tdata()[i]; if (s) - statements->data[i] = (void *)s->inlineScan(iss); + statements->tdata()[i] = s->inlineScan(iss); } return this; } @@ -822,9 +822,9 @@ Statement *CompoundStatement::inlineScan(InlineScanState *iss) Statement *UnrolledLoopStatement::inlineScan(InlineScanState *iss) { for (size_t i = 0; i < statements->dim; i++) - { Statement *s = (Statement *) statements->data[i]; + { Statement *s = statements->tdata()[i]; if (s) - statements->data[i] = (void *)s->inlineScan(iss); + statements->tdata()[i] = s->inlineScan(iss); } return this; } @@ -908,10 +908,10 @@ Statement *SwitchStatement::inlineScan(InlineScanState *iss) if (cases) { for (int i = 0; i < cases->dim; i++) - { Statement *s; + { CaseStatement *s; - s = (Statement *) cases->data[i]; - cases->data[i] = (void *)s->inlineScan(iss); + s = cases->tdata()[i]; + cases->tdata()[i] = (CaseStatement *)s->inlineScan(iss); } } return this; @@ -974,7 +974,7 @@ Statement *TryCatchStatement::inlineScan(InlineScanState *iss) if (catches) { for (int i = 0; i < catches->dim; i++) - { Catch *c = (Catch *)catches->data[i]; + { Catch *c = catches->tdata()[i]; if (c->handler) c->handler = c->handler->inlineScan(iss); @@ -1024,12 +1024,12 @@ void arrayInlineScan(InlineScanState *iss, Expressions *arguments) if (arguments) { for (int i = 0; i < arguments->dim; i++) - { Expression *e = (Expression *)arguments->data[i]; + { Expression *e = arguments->tdata()[i]; if (e) { e = e->inlineScan(iss); - arguments->data[i] = (void *)e; + arguments->tdata()[i] = e; } } } @@ -1049,7 +1049,7 @@ void scanVar(Dsymbol *s, InlineScanState *iss) if (td) { for (size_t i = 0; i < td->objects->dim; i++) - { DsymbolExp *se = (DsymbolExp *)td->objects->data[i]; + { DsymbolExp *se = (DsymbolExp *)td->objects->tdata()[i]; assert(se->op == TOKdsymbol); scanVar(se->s, iss); } @@ -1352,7 +1352,7 @@ int FuncDeclaration::canInline(int hasthis, int hdrscan) { for (int i = 0; i < parameters->dim; i++) { - VarDeclaration *v = (VarDeclaration *)parameters->data[i]; + VarDeclaration *v = parameters->tdata()[i]; if ( #if DMDV1 v->isOut() || v->isRef() || @@ -1470,9 +1470,9 @@ Expression *FuncDeclaration::doInline(InlineScanState *iss, Expression *ethis, E for (int i = 0; i < arguments->dim; i++) { - VarDeclaration *vfrom = (VarDeclaration *)parameters->data[i]; + VarDeclaration *vfrom = parameters->tdata()[i]; VarDeclaration *vto; - Expression *arg = (Expression *)arguments->data[i]; + Expression *arg = arguments->tdata()[i]; ExpInitializer *ei; VarExp *ve; diff --git a/src/interpret.c b/src/interpret.c index 1a164d41aa44..f69f257b5270 100644 --- a/src/interpret.c +++ b/src/interpret.c @@ -30,7 +30,7 @@ struct InterState { InterState *caller; // calling function's InterState FuncDeclaration *fd; // function being interpreted - Dsymbols vars; // variables used in this function + VarDeclarations vars; // variables used in this function Statement *start; // if !=NULL, start execution at this statement Statement *gotoTarget; // target of EXP_GOTO_INTERPRET result Expression *localThis; // value of 'this', or NULL if none @@ -149,7 +149,7 @@ Expression *FuncDeclaration::interpret(InterState *istate, Expressions *argument eargs.setDim(dim); for (size_t i = 0; i < dim; i++) - { Expression *earg = (Expression *)arguments->data[i]; + { Expression *earg = arguments->tdata()[i]; Parameter *arg = Parameter::getNth(tf->parameters, i); if (arg->storageClass & (STCout | STCref)) @@ -180,14 +180,14 @@ Expression *FuncDeclaration::interpret(InterState *istate, Expressions *argument return NULL; } } - eargs.data[i] = earg; + eargs.tdata()[i] = earg; } for (size_t i = 0; i < dim; i++) - { Expression *earg = (Expression *)eargs.data[i]; + { Expression *earg = eargs.tdata()[i]; Parameter *arg = Parameter::getNth(tf->parameters, i); - VarDeclaration *v = (VarDeclaration *)parameters->data[i]; - vsave.data[i] = v->getValue(); + VarDeclaration *v = parameters->tdata()[i]; + vsave.tdata()[i] = v->getValue(); #if LOG printf("arg[%d] = %s\n", i, earg->toChars()); #endif @@ -204,9 +204,9 @@ Expression *FuncDeclaration::interpret(InterState *istate, Expressions *argument */ assert(istate); for (size_t i = 0; i < istate->vars.dim; i++) - { VarDeclaration *vx = (VarDeclaration *)istate->vars.data[i]; + { VarDeclaration *vx = istate->vars.tdata()[i]; if (vx == v2) - { istate->vars.data[i] = NULL; + { istate->vars.tdata()[i] = NULL; break; } } @@ -227,9 +227,9 @@ Expression *FuncDeclaration::interpret(InterState *istate, Expressions *argument if (!thisvar) // it's a reference. Find which variable it refers to. thisvar = findParentVar(thisarg->interpret(istate), istate->localThis); for (size_t i = 0; i < istate->vars.dim; i++) - { VarDeclaration *v = (VarDeclaration *)istate->vars.data[i]; + { VarDeclaration *v = istate->vars.tdata()[i]; if (v == thisvar) - { istate->vars.data[i] = NULL; + { istate->vars.tdata()[i] = NULL; break; } } @@ -243,11 +243,11 @@ Expression *FuncDeclaration::interpret(InterState *istate, Expressions *argument //printf("saving local variables...\n"); valueSaves.setDim(istate->vars.dim); for (size_t i = 0; i < istate->vars.dim; i++) - { VarDeclaration *v = (VarDeclaration *)istate->vars.data[i]; + { VarDeclaration *v = istate->vars.tdata()[i]; if (v) { //printf("\tsaving [%d] %s = %s\n", i, v->toChars(), v->value ? v->value->toChars() : ""); - valueSaves.data[i] = v->getValue(); + valueSaves.tdata()[i] = v->getValue(); v->setValueNull(); } } @@ -284,8 +284,8 @@ Expression *FuncDeclaration::interpret(InterState *istate, Expressions *argument */ for (size_t i = 0; i < dim; i++) { - VarDeclaration *v = (VarDeclaration *)parameters->data[i]; - v->setValueWithoutChecking((Expression *)vsave.data[i]); + VarDeclaration *v = parameters->tdata()[i]; + v->setValueWithoutChecking(vsave.tdata()[i]); } if (istate && !isNested()) @@ -294,9 +294,9 @@ Expression *FuncDeclaration::interpret(InterState *istate, Expressions *argument */ //printf("restoring local variables...\n"); for (size_t i = 0; i < istate->vars.dim; i++) - { VarDeclaration *v = (VarDeclaration *)istate->vars.data[i]; + { VarDeclaration *v = istate->vars.tdata()[i]; if (v) - { v->setValueWithoutChecking((Expression *)valueSaves.data[i]); + { v->setValueWithoutChecking(valueSaves.tdata()[i]); //printf("\trestoring [%d] %s = %s\n", i, v->toChars(), v->getValue() ? v->getValue()->toChars() : ""); } } @@ -360,7 +360,7 @@ Expression *CompoundStatement::interpret(InterState *istate) if (statements) { for (size_t i = 0; i < statements->dim; i++) - { Statement *s = (Statement *)statements->data[i]; + { Statement *s = statements->tdata()[i]; if (s) { @@ -387,7 +387,7 @@ Expression *UnrolledLoopStatement::interpret(InterState *istate) if (statements) { for (size_t i = 0; i < statements->dim; i++) - { Statement *s = (Statement *)statements->data[i]; + { Statement *s = statements->tdata()[i]; e = s->interpret(istate); if (e == EXP_CANT_INTERPRET) @@ -976,7 +976,7 @@ Expression *SwitchStatement::interpret(InterState *istate) { for (size_t i = 0; i < cases->dim; i++) { - CaseStatement *cs = (CaseStatement *)cases->data[i]; + CaseStatement *cs = cases->tdata()[i]; e = Equal(TOKequal, Type::tint32, econdition, cs->exp); if (e == EXP_CANT_INTERPRET) return EXP_CANT_INTERPRET; @@ -1455,7 +1455,7 @@ Expression *TupleExp::interpret(InterState *istate, CtfeGoal goal) Expressions *expsx = NULL; for (size_t i = 0; i < exps->dim; i++) - { Expression *e = (Expression *)exps->data[i]; + { Expression *e = exps->tdata()[i]; Expression *ex; ex = e->interpret(istate); @@ -1473,10 +1473,10 @@ Expression *TupleExp::interpret(InterState *istate, CtfeGoal goal) expsx->setDim(exps->dim); for (size_t j = 0; j < i; j++) { - expsx->data[j] = exps->data[j]; + expsx->tdata()[j] = exps->tdata()[j]; } } - expsx->data[i] = (void *)ex; + expsx->tdata()[i] = ex; } } if (expsx) @@ -1497,7 +1497,7 @@ Expression *ArrayLiteralExp::interpret(InterState *istate, CtfeGoal goal) if (elements) { for (size_t i = 0; i < elements->dim; i++) - { Expression *e = (Expression *)elements->data[i]; + { Expression *e = elements->tdata()[i]; Expression *ex; ex = e->interpret(istate); @@ -1513,10 +1513,10 @@ Expression *ArrayLiteralExp::interpret(InterState *istate, CtfeGoal goal) expsx->setDim(elements->dim); for (size_t j = 0; j < elements->dim; j++) { - expsx->data[j] = elements->data[j]; + expsx->tdata()[j] = elements->tdata()[j]; } } - expsx->data[i] = (void *)ex; + expsx->tdata()[i] = ex; } } } @@ -1546,8 +1546,8 @@ Expression *AssocArrayLiteralExp::interpret(InterState *istate, CtfeGoal goal) printf("AssocArrayLiteralExp::interpret() %s\n", toChars()); #endif for (size_t i = 0; i < keys->dim; i++) - { Expression *ekey = (Expression *)keys->data[i]; - Expression *evalue = (Expression *)values->data[i]; + { Expression *ekey = keys->tdata()[i]; + Expression *evalue = values->tdata()[i]; Expression *ex; ex = ekey->interpret(istate); @@ -1560,7 +1560,7 @@ Expression *AssocArrayLiteralExp::interpret(InterState *istate, CtfeGoal goal) { if (keysx == keys) keysx = (Expressions *)keys->copy(); - keysx->data[i] = (void *)ex; + keysx->tdata()[i] = ex; } ex = evalue->interpret(istate); @@ -1573,7 +1573,7 @@ Expression *AssocArrayLiteralExp::interpret(InterState *istate, CtfeGoal goal) { if (valuesx == values) valuesx = (Expressions *)values->copy(); - valuesx->data[i] = (void *)ex; + valuesx->tdata()[i] = ex; } } if (keysx != keys) @@ -1586,10 +1586,10 @@ Expression *AssocArrayLiteralExp::interpret(InterState *istate, CtfeGoal goal) /* Remove duplicate keys */ for (size_t i = 1; i < keysx->dim; i++) - { Expression *ekey = (Expression *)keysx->data[i - 1]; + { Expression *ekey = keysx->tdata()[i - 1]; for (size_t j = i; j < keysx->dim; j++) - { Expression *ekey2 = (Expression *)keysx->data[j]; + { Expression *ekey2 = keysx->tdata()[j]; Expression *ex = Equal(TOKequal, Type::tbool, ekey, ekey2); if (ex == EXP_CANT_INTERPRET) goto Lerr; @@ -1641,7 +1641,7 @@ Expression *StructLiteralExp::interpret(InterState *istate, CtfeGoal goal) if (elements) { for (size_t i = 0; i < elements->dim; i++) - { Expression *e = (Expression *)elements->data[i]; + { Expression *e = elements->tdata()[i]; if (!e) continue; @@ -1660,10 +1660,10 @@ Expression *StructLiteralExp::interpret(InterState *istate, CtfeGoal goal) expsx->setDim(elements->dim); for (size_t j = 0; j < elements->dim; j++) { - expsx->data[j] = elements->data[j]; + expsx->tdata()[j] = elements->tdata()[j]; } } - expsx->data[i] = (void *)ex; + expsx->tdata()[i] = ex; } } } @@ -1691,7 +1691,7 @@ ArrayLiteralExp *createBlockDuplicatedArrayLiteral(Type *type, Expressions *elements = new Expressions(); elements->setDim(dim); for (size_t i = 0; i < dim; i++) - elements->data[i] = elem; + elements->tdata()[i] = elem; ArrayLiteralExp *ae = new ArrayLiteralExp(0, elements); ae->type = type; return ae; @@ -1728,7 +1728,7 @@ Expression *NewExp::interpret(InterState *istate, CtfeGoal goal) #endif if (newtype->ty == Tarray && arguments && arguments->dim == 1) { - Expression *lenExpr = ((Expression *)(arguments->data[0]))->interpret(istate); + Expression *lenExpr = ((arguments->tdata()[0]))->interpret(istate); if (lenExpr == EXP_CANT_INTERPRET) return EXP_CANT_INTERPRET; return createBlockDuplicatedArrayLiteral(newtype, @@ -1883,16 +1883,16 @@ BIN_INTERPRET2(Cmp) /*************************************** * Duplicate the elements array, then set field 'indexToChange' = newelem. */ -Expressions *changeOneElement(Expressions *oldelems, size_t indexToChange, void *newelem) +Expressions *changeOneElement(Expressions *oldelems, size_t indexToChange, Expression *newelem) { Expressions *expsx = new Expressions(); expsx->setDim(oldelems->dim); for (size_t j = 0; j < expsx->dim; j++) { if (j == indexToChange) - expsx->data[j] = newelem; + expsx->tdata()[j] = newelem; else - expsx->data[j] = oldelems->data[j]; + expsx->tdata()[j] = oldelems->tdata()[j]; } return expsx; } @@ -1911,7 +1911,7 @@ void addVarToInterstate(InterState *istate, VarDeclaration *v) //printf("\tadding %s to istate\n", v->toChars()); break; } - if (v == (VarDeclaration *)istate->vars.data[i]) + if (v == istate->vars.tdata()[i]) break; } } @@ -1945,12 +1945,12 @@ Expression *assignAssocArrayElement(Loc loc, AssocArrayLiteralExp *aae, Expressi int updated = 0; for (size_t j = valuesx->dim; j; ) { j--; - Expression *ekey = (Expression *)aae->keys->data[j]; + Expression *ekey = aae->keys->tdata()[j]; Expression *ex = Equal(TOKequal, Type::tbool, ekey, index); if (ex == EXP_CANT_INTERPRET) return EXP_CANT_INTERPRET; if (ex->isBool(TRUE)) - { valuesx->data[j] = (void *)newval; + { valuesx->tdata()[j] = newval; updated = 1; } } @@ -2091,7 +2091,7 @@ Expression *assignDotVar(ExpressionReverseIterator rvs, int depth, Expression *e if (fieldi == -1) return EXP_CANT_INTERPRET; assert(fieldi>=0 && fieldi < se->elements->dim); - Expression *ex = (Expression *)(se->elements->data[fieldi]); + Expression *ex = (se->elements->tdata()[fieldi]); newval = assignDotVar(rvs, depth - 1, ex, newval); Expressions *expsx = changeOneElement(se->elements, fieldi, newval); @@ -2170,7 +2170,7 @@ Expression *copyLiteral(Expression *e) Expressions *newelems = new Expressions(); newelems->setDim(oldelems->dim); for (size_t i = 0; i < oldelems->dim; i++) - newelems->data[i] = copyLiteral((Expression *)(oldelems->data[i])); + newelems->tdata()[i] = copyLiteral((oldelems->tdata()[i])); ArrayLiteralExp *r = new ArrayLiteralExp(ae->loc, newelems); r->type = e->type; return r; @@ -2187,10 +2187,10 @@ Expression *copyLiteral(Expression *e) newelems->setDim(oldelems->dim); for (size_t i = 0; i < newelems->dim; i++) { - Expression *m = (Expression *)oldelems->data[i]; + Expression *m = oldelems->tdata()[i]; // We need the struct definition to detect block assignment StructDeclaration *sd = se->sd; - Dsymbol *s = (Dsymbol *)sd->fields.data[i]; + Dsymbol *s = sd->fields.tdata()[i]; VarDeclaration *v = s->isVarDeclaration(); assert(v); if ((v->type->ty != m->type->ty) && v->type->ty == Tsarray) @@ -2201,7 +2201,7 @@ Expression *copyLiteral(Expression *e) m = createBlockDuplicatedArrayLiteral(v->type, m, length); } else m = copyLiteral(m); - newelems->data[i] = m; + newelems->tdata()[i] = m; } #if DMDV2 StructLiteralExp *r = new StructLiteralExp(e->loc, se->sd, newelems, se->stype); @@ -2229,11 +2229,11 @@ void recursiveBlockAssign(ArrayLiteralExp *ae, Expression *val) #endif for (size_t k = 0; k < ae->elements->dim; k++) { - if (!directblk && ((Expression *)(ae->elements->data[k]))->op == TOKarrayliteral) + if (!directblk && ae->elements->tdata()[k]->op == TOKarrayliteral) { - recursiveBlockAssign((ArrayLiteralExp *)(ae->elements->data[k]), val); + recursiveBlockAssign((ArrayLiteralExp *)ae->elements->tdata()[k], val); } - else ae->elements->data[k] = val; + else ae->elements->tdata()[k] = val; } } @@ -2421,10 +2421,10 @@ Expression *BinExp::interpretAssignCommon(InterState *istate, CtfeGoal goal, fp_ size_t copylen = oldlen < newlen ? oldlen : newlen; ArrayLiteralExp *ae = (ArrayLiteralExp *)oldval; for (size_t i = 0; i < copylen; i++) - elements->data[i] = ae->elements->data[i]; + elements->tdata()[i] = ae->elements->tdata()[i]; for (size_t i = copylen; i < newlen; i++) - elements->data[i] = defaultElem; + elements->tdata()[i] = defaultElem; ArrayLiteralExp *aae = new ArrayLiteralExp(0, elements); aae->type = t; newval = aae; @@ -2703,7 +2703,7 @@ Expression *BinExp::interpretAssignCommon(InterState *istate, CtfeGoal goal, fp_ return EXP_CANT_INTERPRET; } int se_indx = se3->getFieldIndex(e1->type, vv->offset); - se3->elements->data[se_indx] = newval; + se3->elements->tdata()[se_indx] = newval; // Mark the parent variable as modified if (!destinationIsReference) addVarToInterstate(istate, ultimateVar); @@ -2865,7 +2865,7 @@ Expression *BinExp::interpretAssignCommon(InterState *istate, CtfeGoal goal, fp_ } if (existingAE) { - existingAE->elements->data[indexToModify] = newval; + existingAE->elements->tdata()[indexToModify] = newval; return e; } if (existingSE) @@ -2998,7 +2998,7 @@ Expression *BinExp::interpretAssignCommon(InterState *istate, CtfeGoal goal, fp_ Expressions *newelems = ((ArrayLiteralExp *)newval)->elements; for (size_t j = 0; j < newelems->dim; j++) { - oldelems->data[j + firstIndex] = newelems->data[j]; + oldelems->tdata()[j + firstIndex] = newelems->tdata()[j]; } return newval; } @@ -3031,7 +3031,7 @@ Expression *BinExp::interpretAssignCommon(InterState *istate, CtfeGoal goal, fp_ assert(0); break; } - existingAE->elements->data[j+firstIndex] + existingAE->elements->tdata()[j+firstIndex] = new IntegerExp(newval->loc, val, elemType); } return newval; @@ -3044,7 +3044,7 @@ Expression *BinExp::interpretAssignCommon(InterState *istate, CtfeGoal goal, fp_ ArrayLiteralExp *newae = (ArrayLiteralExp *)newval; for (size_t j = 0; j < newae->elements->dim; j++) { - unsigned value = ((Expression *)(newae->elements->data[j]))->toInteger(); + unsigned value = ((newae->elements->tdata()[j]))->toInteger(); switch (existingSE->sz) { case 1: s[j+firstIndex] = value; break; @@ -3102,9 +3102,9 @@ Expression *BinExp::interpretAssignCommon(InterState *istate, CtfeGoal goal, fp_ { if (!directblk) // Multidimensional array block assign - recursiveBlockAssign((ArrayLiteralExp *)w->data[j+firstIndex], newval); + recursiveBlockAssign((ArrayLiteralExp *)w->tdata()[j+firstIndex], newval); else - existingAE->elements->data[j+firstIndex] = newval; + existingAE->elements->tdata()[j+firstIndex] = newval; } if (goal == ctfeNeedNothing) return NULL; // avoid creating an unused literal @@ -3377,11 +3377,11 @@ Expression *CallExp::interpret(InterState *istate, CtfeGoal goal) args.setDim(arguments->dim); for (size_t i = 0; i < args.dim; i++) { - Expression *earg = (Expression *)arguments->data[i]; + Expression *earg = arguments->tdata()[i]; earg = earg->interpret(istate); if (earg == EXP_CANT_INTERPRET) return earg; - args.data[i] = (void *)earg; + args.tdata()[i] = earg; } e = eval_builtin(b, &args); if (!e) @@ -3402,7 +3402,7 @@ Expression *CallExp::interpret(InterState *istate, CtfeGoal goal) // Inline .dup if (fd->ident == Id::adDup && arguments && arguments->dim == 2) { - e = (Expression *)arguments->data[1]; + e = arguments->tdata()[1]; e = e->interpret(istate); if (e != EXP_CANT_INTERPRET) { @@ -3880,7 +3880,7 @@ Expression *DotVarExp::interpret(InterState *istate, CtfeGoal goal) error("couldn't find field %s in %s", v->toChars(), type->toChars()); return EXP_CANT_INTERPRET; } - e = (Expression *)se->elements->data[i]; + e = se->elements->tdata()[i]; // If it is an lvalue literal, return it... if (e->op == TOKstructliteral || e->op == TOKarrayliteral || e->op == TOKassocarrayliteral || e->op == TOKstring || @@ -3917,7 +3917,7 @@ Expression *interpret_aaLen(InterState *istate, Expressions *arguments) { if (!arguments || arguments->dim != 1) return NULL; - Expression *earg = (Expression *)arguments->data[0]; + Expression *earg = arguments->tdata()[0]; earg = earg->interpret(istate); if (earg == EXP_CANT_INTERPRET) return NULL; @@ -3935,7 +3935,7 @@ Expression *interpret_aaKeys(InterState *istate, Expressions *arguments) #endif if (!arguments || arguments->dim != 2) return NULL; - Expression *earg = (Expression *)arguments->data[0]; + Expression *earg = arguments->tdata()[0]; earg = earg->interpret(istate); if (earg == EXP_CANT_INTERPRET) return NULL; @@ -3957,7 +3957,7 @@ Expression *interpret_aaValues(InterState *istate, Expressions *arguments) #endif if (!arguments || arguments->dim != 3) return NULL; - Expression *earg = (Expression *)arguments->data[0]; + Expression *earg = arguments->tdata()[0]; earg = earg->interpret(istate); if (earg == EXP_CANT_INTERPRET) return NULL; diff --git a/src/irstate.h b/src/irstate.h index fa306ce73b30..fbe1eb1c8cf5 100644 --- a/src/irstate.h +++ b/src/irstate.h @@ -37,7 +37,7 @@ struct IRState Dsymbols *deferToObj; // array of Dsymbol's to run toObjFile(int multiobj) on later elem *ehidden; // transmit hidden pointer to CallExp::toElem() Symbol *startaddress; - Dsymbols *varsInScope; // variables that are in scope that will need destruction later + VarDeclarations *varsInScope; // variables that are in scope that will need destruction later block *breakBlock; block *contBlock; diff --git a/src/json.c b/src/json.c index 8c33f4d26541..a1328bfb5113 100644 --- a/src/json.c +++ b/src/json.c @@ -51,7 +51,7 @@ void json_generate(Modules *modules) buf.writestring("[\n"); for (int i = 0; i < modules->dim; i++) - { Module *m = (Module *)modules->data[i]; + { Module *m = modules->tdata()[i]; if (global.params.verbose) printf("json gen %s\n", m->toChars()); m->toJsonBuffer(&buf); @@ -64,7 +64,7 @@ void json_generate(Modules *modules) char *arg = global.params.xfilename; if (!arg || !*arg) { // Generate lib file name from first obj name - char *n = (char *)global.params.objfiles->data[0]; + char *n = global.params.objfiles->tdata()[0]; n = FileName::name(n); FileName *fn = FileName::forceExt(n, global.json_ext); @@ -193,7 +193,7 @@ void Module::toJsonBuffer(OutBuffer *buf) size_t offset = buf->offset; for (int i = 0; i < members->dim; i++) - { Dsymbol *s = (Dsymbol *)members->data[i]; + { Dsymbol *s = members->tdata()[i]; if (offset != buf->offset) { buf->writestring(",\n"); offset = buf->offset; @@ -217,7 +217,7 @@ void AttribDeclaration::toJsonBuffer(OutBuffer *buf) { size_t offset = buf->offset; for (unsigned i = 0; i < d->dim; i++) - { Dsymbol *s = (Dsymbol *)d->data[i]; + { Dsymbol *s = d->tdata()[i]; //printf("AttribDeclaration::toJsonBuffer %s\n", s->toChars()); if (offset != buf->offset) { buf->writestring(",\n"); @@ -321,7 +321,7 @@ void AggregateDeclaration::toJsonBuffer(OutBuffer *buf) buf->writestring(" : [\n"); size_t offset = buf->offset; for (int i = 0; i < members->dim; i++) - { Dsymbol *s = (Dsymbol *)members->data[i]; + { Dsymbol *s = members->tdata()[i]; if (offset != buf->offset) { buf->writestring(",\n"); offset = buf->offset; @@ -354,7 +354,7 @@ void TemplateDeclaration::toJsonBuffer(OutBuffer *buf) buf->writestring(" : [\n"); size_t offset = buf->offset; for (int i = 0; i < members->dim; i++) - { Dsymbol *s = (Dsymbol *)members->data[i]; + { Dsymbol *s = members->tdata()[i]; if (offset != buf->offset) { buf->writestring(",\n"); offset = buf->offset; @@ -376,7 +376,7 @@ void EnumDeclaration::toJsonBuffer(OutBuffer *buf) { for (int i = 0; i < members->dim; i++) { - Dsymbol *s = (Dsymbol *)members->data[i]; + Dsymbol *s = members->tdata()[i]; s->toJsonBuffer(buf); buf->writestring(",\n"); } @@ -404,7 +404,7 @@ void EnumDeclaration::toJsonBuffer(OutBuffer *buf) buf->writestring(" : [\n"); size_t offset = buf->offset; for (int i = 0; i < members->dim; i++) - { Dsymbol *s = (Dsymbol *)members->data[i]; + { Dsymbol *s = members->tdata()[i]; if (offset != buf->offset) { buf->writestring(",\n"); offset = buf->offset; diff --git a/src/libelf.c b/src/libelf.c index 2b7308b8f889..5e2e3f410554 100644 --- a/src/libelf.c +++ b/src/libelf.c @@ -46,7 +46,7 @@ void Library::setFilename(char *dir, char *filename) char *arg = filename; if (!arg || !*arg) { // Generate lib file name from first obj name - char *n = (char *)global.params.objfiles->data[0]; + char *n = global.params.objfiles->tdata()[0]; n = FileName::name(n); FileName *fn = FileName::forceExt(n, global.lib_ext); diff --git a/src/libmach.c b/src/libmach.c index 7086f9ffeae8..d6776c0ea788 100644 --- a/src/libmach.c +++ b/src/libmach.c @@ -57,7 +57,7 @@ void Library::setFilename(char *dir, char *filename) char *arg = filename; if (!arg || !*arg) { // Generate lib file name from first obj name - char *n = (char *)global.params.objfiles->data[0]; + char *n = global.params.objfiles->tdata()[0]; n = FileName::name(n); FileName *fn = FileName::forceExt(n, global.lib_ext); @@ -479,7 +479,7 @@ void Library::addObject(const char *module_name, void *buf, size_t buflen) { reason = 12; goto Lcorrupt; // didn't find it } - ObjModule *om = (ObjModule *)objmodules.data[m]; + ObjModule *om = objmodules.tdata()[m]; //printf("\tom offset = x%x\n", (char *)om->base - (char *)buf); if (moff == (char *)om->base - (char *)buf) { @@ -562,7 +562,7 @@ void Library::WriteLibToBuffer(OutBuffer *libbuf) /************* Scan Object Modules for Symbols ******************/ for (int i = 0; i < objmodules.dim; i++) - { ObjModule *om = (ObjModule *)objmodules.data[i]; + { ObjModule *om = objmodules.tdata()[i]; if (om->scan) { scanObjModule(om); @@ -574,7 +574,7 @@ void Library::WriteLibToBuffer(OutBuffer *libbuf) unsigned moffset = 8 + sizeof(Header) + 4 + 4; for (int i = 0; i < objsymbols.dim; i++) - { ObjSymbol *os = (ObjSymbol *)objsymbols.data[i]; + { ObjSymbol *os = objsymbols.tdata()[i]; moffset += 8 + strlen(os->name) + 1; } @@ -588,7 +588,7 @@ void Library::WriteLibToBuffer(OutBuffer *libbuf) #endif for (int i = 0; i < objmodules.dim; i++) - { ObjModule *om = (ObjModule *)objmodules.data[i]; + { ObjModule *om = objmodules.tdata()[i]; moffset += moffset & 1; om->offset = moffset; @@ -639,7 +639,7 @@ void Library::WriteLibToBuffer(OutBuffer *libbuf) int stringoff = 0; for (int i = 0; i < objsymbols.dim; i++) - { ObjSymbol *os = (ObjSymbol *)objsymbols.data[i]; + { ObjSymbol *os = objsymbols.tdata()[i]; sputl(stringoff, buf); libbuf->write(buf, 4); @@ -654,7 +654,7 @@ void Library::WriteLibToBuffer(OutBuffer *libbuf) libbuf->write(buf, 4); for (int i = 0; i < objsymbols.dim; i++) - { ObjSymbol *os = (ObjSymbol *)objsymbols.data[i]; + { ObjSymbol *os = objsymbols.tdata()[i]; libbuf->writestring(os->name); libbuf->writeByte(0); @@ -673,7 +673,7 @@ void Library::WriteLibToBuffer(OutBuffer *libbuf) /* Write out each of the object modules */ for (int i = 0; i < objmodules.dim; i++) - { ObjModule *om = (ObjModule *)objmodules.data[i]; + { ObjModule *om = objmodules.tdata()[i]; if (libbuf->offset & 1) libbuf->writeByte('\n'); // module alignment diff --git a/src/libomf.c b/src/libomf.c index 7f136a484387..599a9266317e 100644 --- a/src/libomf.c +++ b/src/libomf.c @@ -42,7 +42,7 @@ void Library::setFilename(char *dir, char *filename) char *arg = filename; if (!arg || !*arg) { // Generate lib file name from first obj name - char *n = (char *)global.params.objfiles->data[0]; + char *n = global.params.objfiles->tdata()[0]; n = FileName::name(n); FileName *fn = FileName::forceExt(n, global.lib_ext); diff --git a/src/link.c b/src/link.c index d7b62bc501fd..11e8d9050fd4 100644 --- a/src/link.c +++ b/src/link.c @@ -224,19 +224,19 @@ int runLINK() const char *cc = getenv("CC"); if (!cc) cc = "gcc"; - argv.push((void *)cc); + argv.push((char *)cc); argv.insert(1, global.params.objfiles); #if __APPLE__ // If we are on Mac OS X and linking a dynamic library, // add the "-dynamiclib" flag if (global.params.dll) - argv.push((void *) "-dynamiclib"); + argv.push((char *) "-dynamiclib"); #endif // None of that a.out stuff. Use explicit exe file name, or // generate one from name of first source file. - argv.push((void *)"-o"); + argv.push((char *)"-o"); if (global.params.exefile) { if (global.params.dll) @@ -245,7 +245,7 @@ int runLINK() } else { // Generate exe file name from first obj name - char *n = (char *)global.params.objfiles->data[0]; + char *n = global.params.objfiles->tdata()[0]; char *e; char *ex; @@ -274,20 +274,20 @@ int runLINK() } if (global.params.symdebug) - argv.push((void *)"-g"); + argv.push((char *)"-g"); if (global.params.isX86_64) - argv.push((void *)"-m64"); + argv.push((char *)"-m64"); else - argv.push((void *)"-m32"); + argv.push((char *)"-m32"); if (global.params.map || global.params.mapfile) { - argv.push((void *)"-Xlinker"); + argv.push((char *)"-Xlinker"); #if __APPLE__ - argv.push((void *)"-map"); + argv.push((char *)"-map"); #else - argv.push((void *)"-Map"); + argv.push((char *)"-Map"); #endif if (!global.params.mapfile) { @@ -302,7 +302,7 @@ int runLINK() global.params.mapfile = p; } - argv.push((void *)"-Xlinker"); + argv.push((char *)"-Xlinker"); argv.push(global.params.mapfile); } @@ -318,16 +318,16 @@ int runLINK() * BUG: disabled because it causes exception handling to fail * because EH sections are "unreferenced" and elided */ - argv.push((void *)"-Xlinker"); - argv.push((void *)"--gc-sections"); + argv.push((char *)"-Xlinker"); + argv.push((char *)"--gc-sections"); } for (i = 0; i < global.params.linkswitches->dim; i++) - { char *p = (char *)global.params.linkswitches->data[i]; + { char *p = global.params.linkswitches->tdata()[i]; if (!p || !p[0] || !(p[0] == '-' && p[1] == 'l')) // Don't need -Xlinker if switch starts with -l - argv.push((void *)"-Xlinker"); - argv.push((void *) p); + argv.push((char *)"-Xlinker"); + argv.push(p); } /* Add each library, prefixing it with "-l". @@ -339,17 +339,17 @@ int runLINK() * 4. standard libraries. */ for (i = 0; i < global.params.libfiles->dim; i++) - { char *p = (char *)global.params.libfiles->data[i]; + { char *p = global.params.libfiles->tdata()[i]; size_t plen = strlen(p); if (plen > 2 && p[plen - 2] == '.' && p[plen -1] == 'a') - argv.push((void *)p); + argv.push(p); else { char *s = (char *)mem.malloc(plen + 3); s[0] = '-'; s[1] = 'l'; memcpy(s + 2, p, plen + 1); - argv.push((void *)s); + argv.push(s); } } @@ -362,17 +362,17 @@ int runLINK() char *buf = (char *)malloc(2 + strlen(libname) + 1); strcpy(buf, "-l"); strcpy(buf + 2, libname); - argv.push((void *)buf); // turns into /usr/lib/libphobos2.a + argv.push(buf); // turns into /usr/lib/libphobos2.a // argv.push((void *)"-ldruntime"); - argv.push((void *)"-lpthread"); - argv.push((void *)"-lm"); + argv.push((char *)"-lpthread"); + argv.push((char *)"-lm"); if (!global.params.quiet || global.params.verbose) { // Print it for (i = 0; i < argv.dim; i++) - printf("%s ", (char *)argv.data[i]); + printf("%s ", argv.tdata()[i]); printf("\n"); fflush(stdout); } @@ -381,8 +381,8 @@ int runLINK() childpid = fork(); if (childpid == 0) { - execvp((char *)argv.data[0], (char **)argv.data); - perror((char *)argv.data[0]); // failed to execute + execvp(argv.tdata()[0], argv.tdata()); + perror(argv.tdata()[0]); // failed to execute return -1; } @@ -543,7 +543,7 @@ int runProgram() // Build argv[] Strings argv; - argv.push((void *)global.params.exefile); + argv.push(global.params.exefile); for (size_t i = 0; i < global.params.runargs_length; i++) { char *a = global.params.runargs[i]; @@ -555,7 +555,7 @@ int runProgram() a = b; } #endif - argv.push((void *)a); + argv.push(a); } argv.push(NULL); @@ -573,12 +573,12 @@ int runProgram() childpid = fork(); if (childpid == 0) { - const char *fn = (const char *)argv.data[0]; + char *fn = argv.tdata()[0]; if (!FileName::absolute(fn)) { // Make it "./fn" fn = FileName::combine(".", fn); } - execv(fn, (char **)argv.data); + execv(fn, argv.tdata()); perror(fn); // failed to execute return -1; } diff --git a/src/mars.c b/src/mars.c index f9ebd9c89fff..256edda0d032 100644 --- a/src/mars.c +++ b/src/mars.c @@ -909,7 +909,7 @@ int main(int argc, char *argv[]) { for (i = 0; i < global.params.imppath->dim; i++) { - char *path = (char *)global.params.imppath->data[i]; + char *path = global.params.imppath->tdata()[i]; Strings *a = FileName::splitPath(path); if (a) @@ -926,7 +926,7 @@ int main(int argc, char *argv[]) { for (i = 0; i < global.params.fileImppath->dim; i++) { - char *path = (char *)global.params.fileImppath->data[i]; + char *path = global.params.fileImppath->tdata()[i]; Strings *a = FileName::splitPath(path); if (a) @@ -947,7 +947,7 @@ int main(int argc, char *argv[]) char *ext; char *name; - p = (char *) files.data[i]; + p = files.tdata()[i]; #if _WIN32 // Convert / to \ so linker will work @@ -965,47 +965,47 @@ int main(int argc, char *argv[]) */ if (FileName::equals(ext, global.obj_ext)) { - global.params.objfiles->push(files.data[i]); - libmodules.push(files.data[i]); + global.params.objfiles->push(files.tdata()[i]); + libmodules.push(files.tdata()[i]); continue; } if (FileName::equals(ext, global.lib_ext)) { - global.params.libfiles->push(files.data[i]); - libmodules.push(files.data[i]); + global.params.libfiles->push(files.tdata()[i]); + libmodules.push(files.tdata()[i]); continue; } if (strcmp(ext, global.ddoc_ext) == 0) { - global.params.ddocfiles->push(files.data[i]); + global.params.ddocfiles->push(files.tdata()[i]); continue; } if (FileName::equals(ext, global.json_ext)) { global.params.doXGeneration = 1; - global.params.xfilename = (char *)files.data[i]; + global.params.xfilename = files.tdata()[i]; continue; } if (FileName::equals(ext, global.map_ext)) { - global.params.mapfile = (char *)files.data[i]; + global.params.mapfile = files.tdata()[i]; continue; } #if TARGET_WINDOS if (FileName::equals(ext, "res")) { - global.params.resfile = (char *)files.data[i]; + global.params.resfile = files.tdata()[i]; continue; } if (FileName::equals(ext, "def")) { - global.params.deffile = (char *)files.data[i]; + global.params.deffile = files.tdata()[i]; continue; } @@ -1036,7 +1036,7 @@ int main(int argc, char *argv[]) strcmp(name, ".") == 0) { Linvalid: - error("invalid file name '%s'", (char *)files.data[i]); + error("invalid file name '%s'", files.tdata()[i]); fatal(); } } @@ -1056,7 +1056,7 @@ int main(int argc, char *argv[]) */ Identifier *id = Lexer::idPool(name); - m = new Module((char *) files.data[i], id, global.params.doDocComments, global.params.doHdrGeneration); + m = new Module(files.tdata()[i], id, global.params.doDocComments, global.params.doHdrGeneration); modules.push(m); if (firstmodule) @@ -1076,7 +1076,7 @@ int main(int argc, char *argv[]) AsyncRead *aw = AsyncRead::create(modules.dim); for (i = 0; i < modules.dim; i++) { - m = (Module *)modules.data[i]; + m = modules.tdata()[i]; aw->addFile(m->srcfile); } aw->start(); @@ -1084,7 +1084,7 @@ int main(int argc, char *argv[]) // Single threaded for (i = 0; i < modules.dim; i++) { - m = (Module *)modules.data[i]; + m = modules.tdata()[i]; m->read(0); } #endif @@ -1093,7 +1093,7 @@ int main(int argc, char *argv[]) int anydocfiles = 0; for (i = 0; i < modules.dim; i++) { - m = (Module *)modules.data[i]; + m = modules.tdata()[i]; if (global.params.verbose) printf("parse %s\n", m->toChars()); if (!Module::rootModule) @@ -1120,7 +1120,7 @@ int main(int argc, char *argv[]) // Remove m's object file from list of object files for (int j = 0; j < global.params.objfiles->dim; j++) { - if (m->objfile->name->str == global.params.objfiles->data[j]) + if (m->objfile->name->str == global.params.objfiles->tdata()[j]) { global.params.objfiles->remove(j); break; @@ -1153,7 +1153,7 @@ int main(int argc, char *argv[]) */ for (i = 0; i < modules.dim; i++) { - m = (Module *)modules.data[i]; + m = modules.tdata()[i]; if (global.params.verbose) printf("import %s\n", m->toChars()); m->genhdrfile(); @@ -1166,7 +1166,7 @@ int main(int argc, char *argv[]) // load all unconditional imports for better symbol resolving for (i = 0; i < modules.dim; i++) { - m = (Module *)modules.data[i]; + m = modules.tdata()[i]; if (global.params.verbose) printf("importall %s\n", m->toChars()); m->importAll(0); @@ -1177,7 +1177,7 @@ int main(int argc, char *argv[]) // Do semantic analysis for (i = 0; i < modules.dim; i++) { - m = (Module *)modules.data[i]; + m = modules.tdata()[i]; if (global.params.verbose) printf("semantic %s\n", m->toChars()); m->semantic(); @@ -1191,7 +1191,7 @@ int main(int argc, char *argv[]) // Do pass 2 semantic analysis for (i = 0; i < modules.dim; i++) { - m = (Module *)modules.data[i]; + m = modules.tdata()[i]; if (global.params.verbose) printf("semantic2 %s\n", m->toChars()); m->semantic2(); @@ -1202,7 +1202,7 @@ int main(int argc, char *argv[]) // Do pass 3 semantic analysis for (i = 0; i < modules.dim; i++) { - m = (Module *)modules.data[i]; + m = modules.tdata()[i]; if (global.params.verbose) printf("semantic3 %s\n", m->toChars()); m->semantic3(); @@ -1235,7 +1235,7 @@ int main(int argc, char *argv[]) // since otherwise functions in them cannot be inlined for (i = 0; i < Module::amodules.dim; i++) { - m = (Module *)Module::amodules.data[i]; + m = Module::amodules.tdata()[i]; if (global.params.verbose) printf("semantic3 %s\n", m->toChars()); m->semantic3(); @@ -1246,7 +1246,7 @@ int main(int argc, char *argv[]) for (i = 0; i < modules.dim; i++) { - m = (Module *)modules.data[i]; + m = modules.tdata()[i]; if (global.params.verbose) printf("inline scan %s\n", m->toChars()); m->inlineScan(); @@ -1266,7 +1266,7 @@ int main(int argc, char *argv[]) // Add input object and input library files to output library for (int i = 0; i < libmodules.dim; i++) { - char *p = (char *)libmodules.data[i]; + char *p = libmodules.tdata()[i]; library->addObject(p, NULL, 0); } } @@ -1280,7 +1280,7 @@ int main(int argc, char *argv[]) { for (i = 0; i < modules.dim; i++) { - m = (Module *)modules.data[i]; + m = modules.tdata()[i]; if (global.params.verbose) printf("code %s\n", m->toChars()); if (i == 0) @@ -1291,14 +1291,14 @@ int main(int argc, char *argv[]) } if (!global.errors && modules.dim) { - obj_end(library, ((Module *)modules.data[0])->objfile); + obj_end(library, modules.tdata()[0]->objfile); } } else { for (i = 0; i < modules.dim; i++) { - m = (Module *)modules.data[i]; + m = modules.tdata()[i]; if (global.params.verbose) printf("code %s\n", m->toChars()); if (global.params.obj) @@ -1355,7 +1355,7 @@ int main(int argc, char *argv[]) */ for (i = 0; i < modules.dim; i++) { - Module *m = (Module *)modules.data[i]; + Module *m = modules.tdata()[i]; m->deleteObjFile(); if (global.params.oneobj) break; @@ -1395,7 +1395,7 @@ void getenv_setargv(const char *envvar, int *pargc, char** *pargv) argv->setDim(argc); for (int i = 0; i < argc; i++) - argv->data[i] = (void *)(*pargv)[i]; + argv->tdata()[i] = (*pargv)[i]; int j = 1; // leave argv[0] alone while (1) @@ -1471,7 +1471,7 @@ void getenv_setargv(const char *envvar, int *pargc, char** *pargv) Ldone: *pargc = argc; - *pargv = (char **)argv->data; + *pargv = argv->tdata(); } #if WINDOWS_SEH diff --git a/src/mars.h b/src/mars.h index 1c7cc2658f63..a68987daba7b 100644 --- a/src/mars.h +++ b/src/mars.h @@ -189,10 +189,10 @@ struct Param char *xfilename; // write JSON file to xfilename unsigned debuglevel; // debug level - Identifiers *debugids; // debug identifiers + Strings *debugids; // debug identifiers unsigned versionlevel; // version level - Identifiers *versionids; // version identifiers + Strings *versionids; // version identifiers bool dump_source; diff --git a/src/module.c b/src/module.c index 7aaae8189b15..c392372d710a 100644 --- a/src/module.c +++ b/src/module.c @@ -277,7 +277,7 @@ Module *Module::load(Loc loc, Identifiers *packages, Identifier *ident) int i; for (i = 0; i < packages->dim; i++) - { Identifier *pid = (Identifier *)packages->data[i]; + { Identifier *pid = packages->tdata()[i]; buf.writestring(pid->toChars()); #if _WIN32 @@ -314,7 +314,7 @@ Module *Module::load(Loc loc, Identifiers *packages, Identifier *ident) { for (size_t i = 0; i < global.path->dim; i++) { - char *p = (char *)global.path->data[i]; + char *p = global.path->tdata()[i]; char *n = FileName::combine(p, sdi); if (FileName::exists(n)) { result = n; @@ -338,7 +338,7 @@ Module *Module::load(Loc loc, Identifiers *packages, Identifier *ident) if (packages) { for (size_t i = 0; i < packages->dim; i++) - { Identifier *pid = (Identifier *)packages->data[i]; + { Identifier *pid = packages->tdata()[i]; printf("%s.", pid->toChars()); } } @@ -367,7 +367,7 @@ void Module::read(Loc loc) { for (int i = 0; i < global.path->dim; i++) { - char *p = (char *)global.path->data[i]; + char *p = global.path->tdata()[i]; fprintf(stdmsg, "import path[%d] = %s\n", i, p); } } @@ -686,7 +686,7 @@ void Module::importAll(Scope *prevsc) // Add import of "object" if this module isn't "object" if (ident != Id::object) { - if (members->dim == 0 || ((Dsymbol *)members->data[0])->ident != Id::object) + if (members->dim == 0 || members->tdata()[0]->ident != Id::object) { Import *im = new Import(0, NULL, Id::object, NULL, 0); members->shift(im); @@ -699,7 +699,7 @@ void Module::importAll(Scope *prevsc) symtab = new DsymbolTable(); for (int i = 0; i < members->dim; i++) { - Dsymbol *s = (Dsymbol *)members->data[i]; + Dsymbol *s = members->tdata()[i]; s->addMember(NULL, sc->scopesym, 1); } } @@ -712,13 +712,13 @@ void Module::importAll(Scope *prevsc) */ setScope(sc); // remember module scope for semantic for (int i = 0; i < members->dim; i++) - { Dsymbol *s = (Dsymbol *)members->data[i]; + { Dsymbol *s = members->tdata()[i]; s->setScope(sc); } for (int i = 0; i < members->dim; i++) { - Dsymbol *s = (Dsymbol *)members->data[i]; + Dsymbol *s = members->tdata()[i]; s->importAll(sc); } @@ -773,7 +773,7 @@ void Module::semantic() // Do semantic() on members that don't depend on others for (int i = 0; i < members->dim; i++) - { Dsymbol *s = (Dsymbol *)members->data[i]; + { Dsymbol *s = members->tdata()[i]; //printf("\tModule('%s'): '%s'.semantic0()\n", toChars(), s->toChars()); s->semantic0(sc); @@ -781,7 +781,7 @@ void Module::semantic() // Pass 1 semantic routines: do public side of the definition for (int i = 0; i < members->dim; i++) - { Dsymbol *s = (Dsymbol *)members->data[i]; + { Dsymbol *s = members->tdata()[i]; //printf("\tModule('%s'): '%s'.semantic()\n", toChars(), s->toChars()); s->semantic(sc); @@ -803,7 +803,7 @@ void Module::semantic2() { for (int i = 0; i < deferred.dim; i++) { - Dsymbol *sd = (Dsymbol *)deferred.data[i]; + Dsymbol *sd = deferred.tdata()[i]; sd->error("unable to resolve forward reference in definition"); } @@ -825,7 +825,7 @@ void Module::semantic2() for (i = 0; i < members->dim; i++) { Dsymbol *s; - s = (Dsymbol *)members->data[i]; + s = members->tdata()[i]; s->semantic2(sc); } @@ -854,7 +854,7 @@ void Module::semantic3() for (i = 0; i < members->dim; i++) { Dsymbol *s; - s = (Dsymbol *)members->data[i]; + s = members->tdata()[i]; //printf("Module %s: %s.semantic3()\n", toChars(), s->toChars()); s->semantic3(sc); } @@ -877,7 +877,7 @@ void Module::inlineScan() //printf("Module = %p\n", sc.scopesym); for (int i = 0; i < members->dim; i++) - { Dsymbol *s = (Dsymbol *)members->data[i]; + { Dsymbol *s = members->tdata()[i]; //if (global.params.verbose) //printf("inline scan symbol %s\n", s->toChars()); @@ -900,7 +900,7 @@ void Module::gensymfile() buf.writenl(); for (int i = 0; i < members->dim; i++) - { Dsymbol *s = (Dsymbol *)members->data[i]; + { Dsymbol *s = members->tdata()[i]; s->toCBuffer(&buf, &hgs); } @@ -961,7 +961,7 @@ Dsymbol *Module::symtabInsert(Dsymbol *s) void Module::clearCache() { for (int i = 0; i < amodules.dim; i++) - { Module *m = (Module *)amodules.data[i]; + { Module *m = amodules.tdata()[i]; m->searchCacheIdent = NULL; } } @@ -975,7 +975,7 @@ void Module::addDeferredSemantic(Dsymbol *s) // Don't add it if it is already there for (int i = 0; i < deferred.dim; i++) { - Dsymbol *sd = (Dsymbol *)deferred.data[i]; + Dsymbol *sd = deferred.tdata()[i]; if (sd == s) return; @@ -1020,7 +1020,7 @@ void Module::runDeferredSemantic() todo = (Dsymbol **)alloca(len * sizeof(Dsymbol *)); assert(todo); } - memcpy(todo, deferred.data, len * sizeof(Dsymbol *)); + memcpy(todo, deferred.tdata(), len * sizeof(Dsymbol *)); deferred.setDim(0); for (int i = 0; i < len; i++) @@ -1053,7 +1053,7 @@ int Module::imports(Module *m) } #endif for (int i = 0; i < aimports.dim; i++) - { Module *mi = (Module *)aimports.data[i]; + { Module *mi = aimports.tdata()[i]; if (mi == m) return TRUE; if (!mi->insearch) @@ -1077,7 +1077,7 @@ int Module::selfImports() if (!selfimports) { for (int i = 0; i < amodules.dim; i++) - { Module *mi = (Module *)amodules.data[i]; + { Module *mi = amodules.tdata()[i]; //printf("\t[%d] %s\n", i, mi->toChars()); mi->insearch = 0; } @@ -1085,7 +1085,7 @@ int Module::selfImports() selfimports = imports(this) + 1; for (int i = 0; i < amodules.dim; i++) - { Module *mi = (Module *)amodules.data[i]; + { Module *mi = amodules.tdata()[i]; //printf("\t[%d] %s\n", i, mi->toChars()); mi->insearch = 0; } @@ -1111,7 +1111,7 @@ char *ModuleDeclaration::toChars() if (packages && packages->dim) { for (i = 0; i < packages->dim; i++) - { Identifier *pid = (Identifier *)packages->data[i]; + { Identifier *pid = packages->tdata()[i]; buf.writestring(pid->toChars()); buf.writeByte('.'); @@ -1149,7 +1149,7 @@ DsymbolTable *Package::resolve(Identifiers *packages, Dsymbol **pparent, Package { int i; for (i = 0; i < packages->dim; i++) - { Identifier *pid = (Identifier *)packages->data[i]; + { Identifier *pid = packages->tdata()[i]; Dsymbol *p; p = dst->lookup(pid); diff --git a/src/module.h b/src/module.h index 0187f838cef0..b1c278db8f2f 100644 --- a/src/module.h +++ b/src/module.h @@ -97,12 +97,12 @@ struct Module : Package ModuleInfoDeclaration *vmoduleinfo; unsigned debuglevel; // debug level - Identifiers *debugids; // debug identifiers - Identifiers *debugidsNot; // forward referenced debug identifiers + Strings *debugids; // debug identifiers + Strings *debugidsNot; // forward referenced debug identifiers unsigned versionlevel; // version level - Identifiers *versionids; // version identifiers - Identifiers *versionidsNot; // forward referenced version identifiers + Strings *versionids; // version identifiers + Strings *versionidsNot; // forward referenced version identifiers Macro *macrotable; // document comment macros Escape *escapetable; // document comment escapes diff --git a/src/mtype.c b/src/mtype.c index d1472ab01cbe..fce704ad0940 100644 --- a/src/mtype.c +++ b/src/mtype.c @@ -3279,7 +3279,7 @@ void TypeSArray::resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol { error(loc, "tuple index %ju exceeds length %u", d, td->objects->dim); goto Ldefault; } - Object *o = (Object *)td->objects->data[(size_t)d]; + Object *o = td->objects->tdata()[(size_t)d]; if (o->dyncast() == DYNCAST_DSYMBOL) { *ps = (Dsymbol *)o; @@ -3299,7 +3299,7 @@ void TypeSArray::resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol */ Objects *objects = new Objects; objects->setDim(1); - objects->data[0] = o; + objects->tdata()[0] = o; TupleDeclaration *tds = new TupleDeclaration(loc, td->ident, objects); *ps = tds; @@ -3333,7 +3333,7 @@ Type *TypeSArray::semantic(Loc loc, Scope *sc) { error(loc, "tuple index %ju exceeds %u", d, sd->objects->dim); return Type::terror; } - Object *o = (Object *)sd->objects->data[(size_t)d]; + Object *o = sd->objects->tdata()[(size_t)d]; if (o->dyncast() != DYNCAST_TYPE) { error(loc, "%s is not a type", toChars()); return Type::terror; @@ -3407,7 +3407,7 @@ Type *TypeSArray::semantic(Loc loc, Scope *sc) { error(loc, "tuple index %ju exceeds %u", d, tt->arguments->dim); goto Lerror; } - Parameter *arg = (Parameter *)tt->arguments->data[(size_t)d]; + Parameter *arg = tt->arguments->tdata()[(size_t)d]; return arg->type; } case Tstruct: @@ -3593,7 +3593,7 @@ Expression *TypeSArray::defaultInitLiteral(Loc loc) Expressions *elements = new Expressions(); elements->setDim(d); for (size_t i = 0; i < d; i++) - elements->data[i] = elementinit; + elements->tdata()[i] = elementinit; ArrayLiteralExp *ae = new ArrayLiteralExp(0, elements); ae->type = this; return ae; @@ -4863,10 +4863,10 @@ Type *TypeFunction::semantic(Loc loc, Scope *sc) if (parameters) { tf->parameters = (Parameters *)parameters->copy(); for (size_t i = 0; i < parameters->dim; i++) - { Parameter *arg = (Parameter *)parameters->data[i]; + { Parameter *arg = parameters->tdata()[i]; Parameter *cpy = (Parameter *)mem.malloc(sizeof(Parameter)); memcpy(cpy, arg, sizeof(Parameter)); - tf->parameters->data[i] = (void *)cpy; + tf->parameters->tdata()[i] = cpy; } } @@ -4990,7 +4990,7 @@ Type *TypeFunction::semantic(Loc loc, Scope *sc) { size_t tdim = tt->arguments->dim; for (size_t j = 0; j < tdim; j++) - { Parameter *narg = (Parameter *)tt->arguments->data[j]; + { Parameter *narg = tt->arguments->tdata()[j]; narg->storageClass = fparam->storageClass; } } @@ -5009,7 +5009,7 @@ Type *TypeFunction::semantic(Loc loc, Scope *sc) if (fparam->storageClass & STCauto) { if (fargs && i < fargs->dim) - { Expression *farg = (Expression *)fargs->data[i]; + { Expression *farg = fargs->tdata()[i]; if (farg->isLvalue()) ; // ref parameter else @@ -5182,7 +5182,7 @@ int TypeFunction::callMatch(Expression *ethis, Expressions *args, int flag) goto L1; goto Nomatch; // not enough arguments } - arg = (Expression *)args->data[u]; + arg = args->tdata()[u]; assert(arg); //printf("arg: %s, type: %s\n", arg->toChars(), arg->type->toChars()); @@ -5259,7 +5259,7 @@ int TypeFunction::callMatch(Expression *ethis, Expressions *args, int flag) { TypeArray *ta = (TypeArray *)tb; for (; u < nargs; u++) { - arg = (Expression *)args->data[u]; + arg = args->tdata()[u]; assert(arg); #if 1 /* If lazy array of delegates, @@ -5514,7 +5514,7 @@ void TypeQualified::syntaxCopyHelper(TypeQualified *t) idents.setDim(t->idents.dim); for (int i = 0; i < idents.dim; i++) { - Identifier *id = (Identifier *)t->idents.data[i]; + Identifier *id = t->idents.tdata()[i]; if (id->dyncast() == DYNCAST_DSYMBOL) { TemplateInstance *ti = (TemplateInstance *)id; @@ -5522,7 +5522,7 @@ void TypeQualified::syntaxCopyHelper(TypeQualified *t) ti = (TemplateInstance *)ti->syntaxCopy(NULL); id = (Identifier *)ti; } - idents.data[i] = id; + idents.tdata()[i] = id; } } @@ -5537,7 +5537,7 @@ void TypeQualified::toCBuffer2Helper(OutBuffer *buf, HdrGenState *hgs) int i; for (i = 0; i < idents.dim; i++) - { Identifier *id = (Identifier *)idents.data[i]; + { Identifier *id = idents.tdata()[i]; buf->writeByte('.'); @@ -5591,7 +5591,7 @@ void TypeQualified::resolveHelper(Loc loc, Scope *sc, //printf("\t2: s = '%s' %p, kind = '%s'\n",s->toChars(), s, s->kind()); for (int i = 0; i < idents.dim; i++) { - Identifier *id = (Identifier *)idents.data[i]; + Identifier *id = idents.tdata()[i]; Dsymbol *sm = s->searchX(loc, sc, id); //printf("\t3: s = '%s' %p, kind = '%s'\n",s->toChars(), s, s->kind()); //printf("\tgetType = '%s'\n", s->getType()->toChars()); @@ -5614,7 +5614,7 @@ void TypeQualified::resolveHelper(Loc loc, Scope *sc, e = new DsymbolExp(loc, s, 0); do { - id = (Identifier *)idents.data[i]; + id = idents.tdata()[i]; e = new DotIdExp(loc, e, id); } while (++i < idents.dim); e = e->semantic(sc); @@ -5640,7 +5640,7 @@ void TypeQualified::resolveHelper(Loc loc, Scope *sc, L3: for (; i < idents.dim; i++) { - id = (Identifier *)idents.data[i]; + id = idents.tdata()[i]; //printf("e: '%s', id: '%s', type = %p\n", e->toChars(), id->toChars(), e->type); if (id == Id::offsetof || !e->type) { e = new DotIdExp(e->loc, e, id); @@ -5835,7 +5835,7 @@ Dsymbol *TypeIdentifier::toDsymbol(Scope *sc) { for (int i = 0; i < idents.dim; i++) { - Identifier *id = (Identifier *)idents.data[i]; + Identifier *id = idents.tdata()[i]; s = s->searchX(loc, sc, id); if (!s) // failed to find a symbol { //printf("\tdidn't find a symbol\n"); @@ -5895,7 +5895,7 @@ Expression *TypeIdentifier::toExpression() Expression *e = new IdentifierExp(loc, ident); for (int i = 0; i < idents.dim; i++) { - Identifier *id = (Identifier *)idents.data[i]; + Identifier *id = idents.tdata()[i]; e = new DotIdExp(loc, e, id); } @@ -6166,7 +6166,7 @@ Type *TypeTypeof::semantic(Loc loc, Scope *sc) { if (!s) break; - Identifier *id = (Identifier *)idents.data[i]; + Identifier *id = idents.tdata()[i]; s = s->searchX(loc, sc, id); } @@ -6246,7 +6246,7 @@ Type *TypeReturn::semantic(Loc loc, Scope *sc) { if (!s) break; - Identifier *id = (Identifier *)idents.data[i]; + Identifier *id = idents.tdata()[i]; s = s->searchX(loc, sc, id); } if (s) @@ -6915,7 +6915,7 @@ Expression *TypeStruct::dotExp(Scope *sc, Expression *e, Identifier *ident) Expressions *exps = new Expressions; exps->reserve(sym->fields.dim); for (size_t i = 0; i < sym->fields.dim; i++) - { VarDeclaration *v = (VarDeclaration *)sym->fields.data[i]; + { VarDeclaration *v = sym->fields.tdata()[i]; Expression *fe = new DotVarExp(e->loc, e, v); exps->push(fe); } @@ -7127,7 +7127,7 @@ Expression *TypeStruct::defaultInitLiteral(Loc loc) structelems->setDim(sym->fields.dim); for (size_t j = 0; j < structelems->dim; j++) { - VarDeclaration *vd = (VarDeclaration *)(sym->fields.data[j]); + VarDeclaration *vd = sym->fields.tdata()[j]; Expression *e; if (vd->init) { if (vd->init->isVoidInitializer()) @@ -7137,7 +7137,7 @@ Expression *TypeStruct::defaultInitLiteral(Loc loc) } else e = vd->type->defaultInitLiteral(); - structelems->data[j] = e; + structelems->tdata()[j] = e; } StructLiteralExp *structinit = new StructLiteralExp(loc, (StructDeclaration *)sym, structelems); // Why doesn't the StructLiteralExp constructor do this, when @@ -7168,7 +7168,7 @@ int TypeStruct::isAssignable() * then one cannot assign this struct. */ for (size_t i = 0; i < sym->fields.dim; i++) - { VarDeclaration *v = (VarDeclaration *)sym->fields.data[i]; + { VarDeclaration *v = sym->fields.tdata()[i]; if (v->isConst() || v->isImmutable()) return FALSE; } @@ -7183,7 +7183,7 @@ int TypeStruct::hasPointers() sym->size(0); // give error for forward references for (size_t i = 0; i < s->fields.dim; i++) { - Dsymbol *sm = (Dsymbol *)s->fields.data[i]; + Dsymbol *sm = s->fields.tdata()[i]; Declaration *d = sm->isDeclaration(); if (d->storage_class & STCref || d->hasPointers()) return TRUE; @@ -7249,7 +7249,7 @@ MATCH TypeStruct::implicitConvTo(Type *to) * allow the conversion. */ for (int i = 0; i < sym->fields.dim; i++) - { Dsymbol *s = (Dsymbol *)sym->fields.data[i]; + { Dsymbol *s = sym->fields.tdata()[i]; VarDeclaration *v = s->isVarDeclaration(); assert(v && v->storage_class & STCfield); @@ -7378,7 +7378,7 @@ Expression *TypeClass::dotExp(Scope *sc, Expression *e, Identifier *ident) Expressions *exps = new Expressions; exps->reserve(sym->fields.dim); for (size_t i = 0; i < sym->fields.dim; i++) - { VarDeclaration *v = (VarDeclaration *)sym->fields.data[i]; + { VarDeclaration *v = sym->fields.tdata()[i]; // Don't include hidden 'this' pointer if (v->isThisDeclaration()) continue; @@ -7740,7 +7740,7 @@ TypeTuple::TypeTuple(Parameters *arguments) { for (size_t i = 0; i < arguments->dim; i++) { - Parameter *arg = (Parameter *)arguments->data[i]; + Parameter *arg = arguments->tdata()[i]; assert(arg && arg->type); } } @@ -7760,11 +7760,11 @@ TypeTuple::TypeTuple(Expressions *exps) { arguments->setDim(exps->dim); for (size_t i = 0; i < exps->dim; i++) - { Expression *e = (Expression *)exps->data[i]; + { Expression *e = exps->tdata()[i]; if (e->type->ty == Ttuple) e->error("cannot form tuple of tuples"); Parameter *arg = new Parameter(STCundefined, e->type, NULL, NULL); - arguments->data[i] = (void *)arg; + arguments->tdata()[i] = arg; } } this->arguments = arguments; @@ -7831,8 +7831,8 @@ int TypeTuple::equals(Object *o) if (arguments->dim == tt->arguments->dim) { for (size_t i = 0; i < tt->arguments->dim; i++) - { Parameter *arg1 = (Parameter *)arguments->data[i]; - Parameter *arg2 = (Parameter *)tt->arguments->data[i]; + { Parameter *arg1 = arguments->tdata()[i]; + Parameter *arg2 = tt->arguments->tdata()[i]; if (!arg1->type->equals(arg2->type)) return 0; @@ -7849,7 +7849,7 @@ Type *TypeTuple::reliesOnTident() { for (size_t i = 0; i < arguments->dim; i++) { - Parameter *arg = (Parameter *)arguments->data[i]; + Parameter *arg = arguments->tdata()[i]; Type *t = arg->type->reliesOnTident(); if (t) return t; @@ -7868,9 +7868,9 @@ Type *TypeTuple::makeConst() t->arguments = new Parameters(); t->arguments->setDim(arguments->dim); for (size_t i = 0; i < arguments->dim; i++) - { Parameter *arg = (Parameter *)arguments->data[i]; + { Parameter *arg = arguments->tdata()[i]; Parameter *narg = new Parameter(arg->storageClass, arg->type->constOf(), arg->ident, arg->defaultArg); - t->arguments->data[i] = (Parameter *)narg; + t->arguments->tdata()[i] = (Parameter *)narg; } return t; } @@ -7958,7 +7958,7 @@ Type *TypeSlice::semantic(Loc loc, Scope *sc) Parameters *args = new Parameters; args->reserve(i2 - i1); for (size_t i = i1; i < i2; i++) - { Parameter *arg = (Parameter *)tt->arguments->data[i]; + { Parameter *arg = tt->arguments->tdata()[i]; args->push(arg); } @@ -8014,7 +8014,7 @@ void TypeSlice::resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol objects->setDim(i2 - i1); for (size_t i = 0; i < objects->dim; i++) { - objects->data[i] = td->objects->data[(size_t)i1 + i]; + objects->tdata()[i] = td->objects->tdata()[(size_t)i1 + i]; } TupleDeclaration *tds = new TupleDeclaration(loc, td->ident, objects); @@ -8090,10 +8090,10 @@ Parameters *Parameter::arraySyntaxCopy(Parameters *args) a = new Parameters(); a->setDim(args->dim); for (size_t i = 0; i < a->dim; i++) - { Parameter *arg = (Parameter *)args->data[i]; + { Parameter *arg = args->tdata()[i]; arg = arg->syntaxCopy(); - a->data[i] = (void *)arg; + a->tdata()[i] = arg; } } return a; @@ -8115,7 +8115,7 @@ char *Parameter::argsTypesToChars(Parameters *args, int varargs) for (int i = 0; i < args->dim; i++) { if (i) buf->writeByte(','); - Parameter *arg = (Parameter *)args->data[i]; + Parameter *arg = args->tdata()[i]; argbuf.reset(); arg->type->toCBuffer2(&argbuf, &hgs, 0); buf->write(&argbuf); @@ -8143,7 +8143,7 @@ void Parameter::argsToCBuffer(OutBuffer *buf, HdrGenState *hgs, Parameters *argu { if (i) buf->writestring(", "); - Parameter *arg = (Parameter *)arguments->data[i]; + Parameter *arg = arguments->tdata()[i]; if (arg->storageClass & STCauto) buf->writestring("auto "); @@ -8309,7 +8309,7 @@ size_t Parameter::dim(Parameters *args) if (args) { for (size_t i = 0; i < args->dim; i++) - { Parameter *arg = (Parameter *)args->data[i]; + { Parameter *arg = args->tdata()[i]; Type *t = arg->type->toBasetype(); if (t->ty == Ttuple) @@ -8338,7 +8338,7 @@ Parameter *Parameter::getNth(Parameters *args, size_t nth, size_t *pn) size_t n = 0; for (size_t i = 0; i < args->dim; i++) - { Parameter *arg = (Parameter *)args->data[i]; + { Parameter *arg = args->tdata()[i]; Type *t = arg->type->toBasetype(); if (t->ty == Ttuple) diff --git a/src/opover.c b/src/opover.c index 1bc86aa073d9..0bc43e65efb7 100644 --- a/src/opover.c +++ b/src/opover.c @@ -501,9 +501,9 @@ Expression *BinExp::op_overload(Scope *sc) */ args1.setDim(1); - args1.data[0] = (void*) e1; + args1.tdata()[0] = e1; args2.setDim(1); - args2.data[0] = (void*) e2; + args2.tdata()[0] = e2; argsset = 1; Match m; @@ -594,9 +594,9 @@ Expression *BinExp::op_overload(Scope *sc) if (!argsset) { args1.setDim(1); - args1.data[0] = (void*) e1; + args1.tdata()[0] = e1; args2.setDim(1); - args2.data[0] = (void*) e2; + args2.tdata()[0] = e2; } Match m; @@ -753,9 +753,9 @@ Expression *BinExp::compare_overload(Scope *sc, Identifier *id) Expressions args2; args1.setDim(1); - args1.data[0] = (void*) e1; + args1.tdata()[0] = e1; args2.setDim(1); - args2.data[0] = (void*) e2; + args2.tdata()[0] = e2; Match m; memset(&m, 0, sizeof(m)); @@ -939,7 +939,7 @@ Expression *BinAssignExp::op_overload(Scope *sc) Expressions *a = new Expressions(); a->push(e2); for (int i = 0; i < ae->arguments->dim; i++) - a->push(ae->arguments->data[i]); + a->push(ae->arguments->tdata()[i]); Objects *targsi = opToArg(sc, op); Expression *e = new DotTemplateInstanceExp(loc, ae->e1, fd->ident, targsi); @@ -1051,7 +1051,7 @@ Expression *BinAssignExp::op_overload(Scope *sc) */ args2.setDim(1); - args2.data[0] = (void*) e2; + args2.tdata()[0] = e2; Match m; memset(&m, 0, sizeof(m)); @@ -1195,7 +1195,7 @@ void inferApplyArgTypes(enum TOK op, Parameters *arguments, Expression *aggr) for (size_t u = 0; 1; u++) { if (u == arguments->dim) return; - Parameter *arg = (Parameter *)arguments->data[u]; + Parameter *arg = arguments->tdata()[u]; if (!arg->type) break; } @@ -1203,7 +1203,7 @@ void inferApplyArgTypes(enum TOK op, Parameters *arguments, Expression *aggr) Dsymbol *s; AggregateDeclaration *ad; - Parameter *arg = (Parameter *)arguments->data[0]; + Parameter *arg = arguments->tdata()[0]; Type *taggr = aggr->type; if (!taggr) return; @@ -1217,7 +1217,7 @@ void inferApplyArgTypes(enum TOK op, Parameters *arguments, Expression *aggr) { if (!arg->type) arg->type = Type::tsize_t; // key type - arg = (Parameter *)arguments->data[1]; + arg = arguments->tdata()[1]; } if (!arg->type && tab->ty != Ttuple) arg->type = tab->nextOf(); // value type @@ -1230,7 +1230,7 @@ void inferApplyArgTypes(enum TOK op, Parameters *arguments, Expression *aggr) { if (!arg->type) arg->type = taa->index; // key type - arg = (Parameter *)arguments->data[1]; + arg = arguments->tdata()[1]; } if (!arg->type) arg->type = taa->next; // value type @@ -1366,7 +1366,7 @@ static int inferApplyArgTypesY(TypeFunction *tf, Parameters *arguments) for (size_t u = 0; u < nparams; u++) { - Parameter *arg = (Parameter *)arguments->data[u]; + Parameter *arg = arguments->tdata()[u]; Parameter *param = Parameter::getNth(tf->parameters, u); if (arg->type) { if (!arg->type->equals(param->type)) @@ -1410,7 +1410,7 @@ void inferApplyArgTypesZ(TemplateDeclaration *tstart, Parameters *arguments) } if (!td->parameters || td->parameters->dim != 1) continue; - TemplateParameter *tp = (TemplateParameter *)td->parameters->data[0]; + TemplateParameter *tp = td->parameters->tdata()[0]; TemplateAliasParameter *tap = tp->isTemplateAliasParameter(); if (!tap || !tap->specType || tap->specType->ty != Tfunction) continue; diff --git a/src/optimize.c b/src/optimize.c index b9948aa8aa88..4a59e6e71408 100644 --- a/src/optimize.c +++ b/src/optimize.c @@ -202,10 +202,10 @@ Expression *VarExp::optimize(int result) Expression *TupleExp::optimize(int result) { for (size_t i = 0; i < exps->dim; i++) - { Expression *e = (Expression *)exps->data[i]; + { Expression *e = exps->tdata()[i]; e = e->optimize(WANTvalue | (result & WANTinterpret)); - exps->data[i] = (void *)e; + exps->tdata()[i] = e; } return this; } @@ -215,10 +215,10 @@ Expression *ArrayLiteralExp::optimize(int result) if (elements) { for (size_t i = 0; i < elements->dim; i++) - { Expression *e = (Expression *)elements->data[i]; + { Expression *e = elements->tdata()[i]; e = e->optimize(WANTvalue | (result & (WANTinterpret | WANTexpand))); - elements->data[i] = (void *)e; + elements->tdata()[i] = e; } } return this; @@ -228,14 +228,14 @@ Expression *AssocArrayLiteralExp::optimize(int result) { assert(keys->dim == values->dim); for (size_t i = 0; i < keys->dim; i++) - { Expression *e = (Expression *)keys->data[i]; + { Expression *e = keys->tdata()[i]; e = e->optimize(WANTvalue | (result & (WANTinterpret | WANTexpand))); - keys->data[i] = (void *)e; + keys->tdata()[i] = e; - e = (Expression *)values->data[i]; + e = values->tdata()[i]; e = e->optimize(WANTvalue | (result & (WANTinterpret | WANTexpand))); - values->data[i] = (void *)e; + values->tdata()[i] = e; } return this; } @@ -245,11 +245,11 @@ Expression *StructLiteralExp::optimize(int result) if (elements) { for (size_t i = 0; i < elements->dim; i++) - { Expression *e = (Expression *)elements->data[i]; + { Expression *e = elements->tdata()[i]; if (!e) continue; e = e->optimize(WANTvalue | (result & (WANTinterpret | WANTexpand))); - elements->data[i] = (void *)e; + elements->tdata()[i] = e; } } return this; @@ -468,20 +468,20 @@ Expression *NewExp::optimize(int result) if (newargs) { for (size_t i = 0; i < newargs->dim; i++) - { Expression *e = (Expression *)newargs->data[i]; + { Expression *e = newargs->tdata()[i]; e = e->optimize(WANTvalue); - newargs->data[i] = (void *)e; + newargs->tdata()[i] = e; } } if (arguments) { for (size_t i = 0; i < arguments->dim; i++) - { Expression *e = (Expression *)arguments->data[i]; + { Expression *e = arguments->tdata()[i]; e = e->optimize(WANTvalue); - arguments->data[i] = (void *)e; + arguments->tdata()[i] = e; } } if (result & WANTinterpret) @@ -500,10 +500,10 @@ Expression *CallExp::optimize(int result) if (arguments) { for (size_t i = 0; i < arguments->dim; i++) - { Expression *e = (Expression *)arguments->data[i]; + { Expression *e = arguments->tdata()[i]; e = e->optimize(WANTvalue); - arguments->data[i] = (void *)e; + arguments->tdata()[i] = e; } } diff --git a/src/parse.c b/src/parse.c index f803d5309f54..94e587087382 100644 --- a/src/parse.c +++ b/src/parse.c @@ -1984,7 +1984,7 @@ Objects *Parser::parseTemplateArgumentList2() */ TemplateParameters *tpl = NULL; for (int i = 0; i < tf->parameters->dim; i++) - { Parameter *param = (Parameter *)tf->parameters->data[i]; + { Parameter *param = tf->parameters->tdata()[i]; if (param->ident == NULL && param->type && param->type->ty == Tident && @@ -3489,7 +3489,7 @@ Statement *Parser::parseStatement(int flags) as->reserve(a->dim); for (int i = 0; i < a->dim; i++) { - Dsymbol *d = (Dsymbol *)a->data[i]; + Dsymbol *d = a->tdata()[i]; s = new ExpStatement(loc, d); as->push(s); } @@ -3497,7 +3497,7 @@ Statement *Parser::parseStatement(int flags) } else if (a->dim == 1) { - Dsymbol *d = (Dsymbol *)a->data[0]; + Dsymbol *d = a->tdata()[0]; s = new ExpStatement(loc, d); } else @@ -3707,7 +3707,7 @@ Statement *Parser::parseStatement(int flags) Expression *aggr = parseExpression(); if (token.value == TOKslice && arguments->dim == 1) { - Parameter *a = (Parameter *)arguments->data[0]; + Parameter *a = arguments->tdata()[0]; delete arguments; nextToken(); Expression *upr = parseExpression(); @@ -3939,7 +3939,7 @@ Statement *Parser::parseStatement(int flags) // Keep cases in order by building the case statements backwards for (int i = cases.dim; i; i--) { - exp = (Expression *)cases.data[i - 1]; + exp = cases.tdata()[i - 1]; s = new CaseStatement(loc, exp, s); } } diff --git a/src/root/root.c b/src/root/root.c index c6553da90cbd..f820fbbaccdc 100644 --- a/src/root/root.c +++ b/src/root/root.c @@ -804,7 +804,7 @@ char *FileName::searchPath(Strings *path, const char *name, int cwd) for (i = 0; i < path->dim; i++) { - char *p = (char *)path->data[i]; + char *p = path->tdata()[i]; char *n = combine(p, name); if (exists(n)) @@ -865,7 +865,7 @@ char *FileName::safeSearchPath(Strings *path, const char *name) for (i = 0; i < path->dim; i++) { char *cname = NULL; - char *cpath = canonicalName((char *)path->data[i]); + char *cpath = canonicalName(path->tdata()[i]); //printf("FileName::safeSearchPath(): name=%s; path=%s; cpath=%s\n", // name, (char *)path->data[i], cpath); if (cpath == NULL) @@ -1552,11 +1552,11 @@ OutBuffer::~OutBuffer() mem.free(data); } -void *OutBuffer::extractData() +char *OutBuffer::extractData() { - void *p; + char *p; - p = (void *)data; + p = (char *)data; data = NULL; offset = 0; size = 0; diff --git a/src/root/root.h b/src/root/root.h index 56965de6bc18..d71f54709b7c 100644 --- a/src/root/root.h +++ b/src/root/root.h @@ -271,7 +271,7 @@ struct OutBuffer : Object OutBuffer(); ~OutBuffer(); - void *extractData(); + char *extractData(); void mark(); void reserve(unsigned nbytes); @@ -314,7 +314,7 @@ struct OutBuffer : Object struct ArrayBase : Object { unsigned dim; - //protected: + protected: void **data; private: @@ -336,7 +336,7 @@ struct ArrayBase : Object void *pop(); void shift(void *ptr); void insert(unsigned index, void *ptr); - //protected: + protected: void insert(unsigned index, ArrayBase *a); void append(ArrayBase *a); public: @@ -344,7 +344,7 @@ struct ArrayBase : Object void zero(); void *tos(); void sort(); - //protected: + protected: ArrayBase *copy(); }; diff --git a/src/s2ir.c b/src/s2ir.c index 9f4ccfdbdb15..a9fe47bb3b6e 100644 --- a/src/s2ir.c +++ b/src/s2ir.c @@ -203,7 +203,7 @@ void PragmaStatement::toIR(IRState *irs) if (ident == Id::startaddress) { assert(args && args->dim == 1); - Expression *e = (Expression *)args->data[0]; + Expression *e = args->tdata()[0]; Dsymbol *sa = getDsymbol(e); FuncDeclaration *f = sa->isFuncDeclaration(); assert(f); @@ -869,7 +869,7 @@ void LabelStatement::toIR(IRState *irs) if (fwdrefs) { for (int i = 0; i < fwdrefs->dim; i++) - { block *b = (block *)fwdrefs->data[i]; + { block *b = fwdrefs->tdata()[i]; if (b->Btry != lblock->Btry) { @@ -941,7 +941,7 @@ void SwitchStatement::toIR(IRState *irs) } for (int i = 0; i < numcases; i++) - { CaseStatement *cs = (CaseStatement *)cases->data[i]; + { CaseStatement *cs = cases->tdata()[i]; elem *ecase = cs->exp->toElem(&mystate); elem *e = el_bin(OPeqeq, TYbool, el_copytree(econd), ecase); @@ -974,7 +974,7 @@ void SwitchStatement::toIR(IRState *irs) { // Number the cases so we can unscramble things after the sort() for (int i = 0; i < numcases; i++) - { CaseStatement *cs = (CaseStatement *)cases->data[i]; + { CaseStatement *cs = cases->tdata()[i]; cs->index = i; } @@ -992,7 +992,7 @@ void SwitchStatement::toIR(IRState *irs) dtxoff(&dt, si, PTRSIZE * 2, TYnptr); for (int i = 0; i < numcases; i++) - { CaseStatement *cs = (CaseStatement *)cases->data[i]; + { CaseStatement *cs = cases->tdata()[i]; if (cs->exp->op != TOKstring) { error("case '%s' is not a string", cs->exp->toChars()); // BUG: this should be an assert @@ -1050,7 +1050,7 @@ void SwitchStatement::toIR(IRState *irs) */ for (int i = 0; i < numcases; i++) { - CaseStatement *cs = (CaseStatement *)cases->data[i]; + CaseStatement *cs = cases->tdata()[i]; if (string) { pu[cs->index] = i; @@ -1324,7 +1324,7 @@ void CompoundStatement::toIR(IRState *irs) size_t dim = statements->dim; for (size_t i = 0 ; i < dim ; i++) { - Statement *s = (Statement *)statements->data[i]; + Statement *s = statements->tdata()[i]; if (s != NULL) { s->toIR(irs); @@ -1355,7 +1355,7 @@ void UnrolledLoopStatement::toIR(IRState *irs) size_t dim = statements->dim; for (size_t i = 0 ; i < dim ; i++) { - Statement *s = (Statement *)statements->data[i]; + Statement *s = statements->tdata()[i]; if (s != NULL) { mystate.contBlock = block_calloc(blx); @@ -1501,7 +1501,7 @@ void TryCatchStatement::toIR(IRState *irs) assert(catches); for (int i = 0 ; i < catches->dim; i++) { - Catch *cs = (Catch *)(catches->data[i]); + Catch *cs = catches->tdata()[i]; if (cs->var) cs->var->csym = tryblock->jcatchvar; block *bcatch = blx->curblock; diff --git a/src/statement.c b/src/statement.c index f814d535e900..910234e19290 100644 --- a/src/statement.c +++ b/src/statement.c @@ -445,10 +445,10 @@ Statement *CompoundStatement::syntaxCopy() Statements *a = new Statements(); a->setDim(statements->dim); for (size_t i = 0; i < statements->dim; i++) - { Statement *s = (Statement *)statements->data[i]; + { Statement *s = statements->tdata()[i]; if (s) s = s->syntaxCopy(); - a->data[i] = s; + a->tdata()[i] = s; } CompoundStatement *cs = new CompoundStatement(loc, a); return cs; @@ -463,7 +463,7 @@ Statement *CompoundStatement::semantic(Scope *sc) #if 0 for (size_t i = 0; i < statements->dim; i++) { - s = (Statement *) statements->data[i]; + s = statements->tdata()[i]; if (s) printf("[%d]: %s", i, s->toChars()); } @@ -471,7 +471,7 @@ Statement *CompoundStatement::semantic(Scope *sc) for (size_t i = 0; i < statements->dim; ) { - s = (Statement *) statements->data[i]; + s = statements->tdata()[i]; if (s) { Statements *a = s->flatten(sc); @@ -482,14 +482,14 @@ Statement *CompoundStatement::semantic(Scope *sc) continue; } s = s->semantic(sc); - statements->data[i] = s; + statements->tdata()[i] = s; if (s) { Statement *sentry; Statement *sexception; Statement *sfinally; - statements->data[i] = s->scopeCode(sc, &sentry, &sexception, &sfinally); + statements->tdata()[i] = s->scopeCode(sc, &sentry, &sexception, &sfinally); if (sentry) { sentry = sentry->semantic(sc); @@ -517,7 +517,7 @@ Statement *CompoundStatement::semantic(Scope *sc) for (int j = i + 1; j < statements->dim; j++) { - a->push(statements->data[j]); + a->push(statements->tdata()[j]); } body = new CompoundStatement(0, a); body = new ScopeStatement(0, body); @@ -558,7 +558,7 @@ Statement *CompoundStatement::semantic(Scope *sc) for (int j = i + 1; j < statements->dim; j++) { - a->push(statements->data[j]); + a->push(statements->tdata()[j]); } body = new CompoundStatement(0, a); s = new TryFinallyStatement(0, body, sfinally); @@ -574,7 +574,7 @@ Statement *CompoundStatement::semantic(Scope *sc) } if (statements->dim == 1) { - return (Statement *)statements->data[0]; + return statements->tdata()[0]; } return this; } @@ -589,7 +589,7 @@ ReturnStatement *CompoundStatement::isReturnStatement() ReturnStatement *rs = NULL; for (int i = 0; i < statements->dim; i++) - { Statement *s = (Statement *) statements->data[i]; + { Statement *s = statements->tdata()[i]; if (s) { rs = s->isReturnStatement(); @@ -603,7 +603,7 @@ ReturnStatement *CompoundStatement::isReturnStatement() void CompoundStatement::toCBuffer(OutBuffer *buf, HdrGenState *hgs) { for (int i = 0; i < statements->dim; i++) - { Statement *s = (Statement *) statements->data[i]; + { Statement *s = statements->tdata()[i]; if (s) s->toCBuffer(buf, hgs); } @@ -612,7 +612,7 @@ void CompoundStatement::toCBuffer(OutBuffer *buf, HdrGenState *hgs) int CompoundStatement::usesEH() { for (int i = 0; i < statements->dim; i++) - { Statement *s = (Statement *) statements->data[i]; + { Statement *s = statements->tdata()[i]; if (s && s->usesEH()) return TRUE; } @@ -624,7 +624,7 @@ int CompoundStatement::blockExit(bool mustNotThrow) //printf("CompoundStatement::blockExit(%p) %d\n", this, statements->dim); int result = BEfallthru; for (size_t i = 0; i < statements->dim; i++) - { Statement *s = (Statement *) statements->data[i]; + { Statement *s = statements->tdata()[i]; if (s) { //printf("result = x%x\n", result); @@ -649,7 +649,7 @@ int CompoundStatement::comeFrom() //printf("CompoundStatement::comeFrom()\n"); for (int i = 0; i < statements->dim; i++) - { Statement *s = (Statement *)statements->data[i]; + { Statement *s = statements->tdata()[i]; if (!s) continue; @@ -662,7 +662,7 @@ int CompoundStatement::comeFrom() int CompoundStatement::isEmpty() { for (int i = 0; i < statements->dim; i++) - { Statement *s = (Statement *) statements->data[i]; + { Statement *s = statements->tdata()[i]; if (s && !s->isEmpty()) return FALSE; } @@ -683,10 +683,10 @@ Statement *CompoundDeclarationStatement::syntaxCopy() Statements *a = new Statements(); a->setDim(statements->dim); for (size_t i = 0; i < statements->dim; i++) - { Statement *s = (Statement *)statements->data[i]; + { Statement *s = statements->tdata()[i]; if (s) s = s->syntaxCopy(); - a->data[i] = s; + a->tdata()[i] = s; } CompoundDeclarationStatement *cs = new CompoundDeclarationStatement(loc, a); return cs; @@ -696,7 +696,7 @@ void CompoundDeclarationStatement::toCBuffer(OutBuffer *buf, HdrGenState *hgs) { int nwritten = 0; for (int i = 0; i < statements->dim; i++) - { Statement *s = (Statement *) statements->data[i]; + { Statement *s = statements->tdata()[i]; ExpStatement *ds; if (s && (ds = s->isExpStatement()) != NULL && @@ -760,10 +760,10 @@ Statement *UnrolledLoopStatement::syntaxCopy() Statements *a = new Statements(); a->setDim(statements->dim); for (size_t i = 0; i < statements->dim; i++) - { Statement *s = (Statement *)statements->data[i]; + { Statement *s = statements->tdata()[i]; if (s) s = s->syntaxCopy(); - a->data[i] = s; + a->tdata()[i] = s; } UnrolledLoopStatement *cs = new UnrolledLoopStatement(loc, a); return cs; @@ -781,12 +781,12 @@ Statement *UnrolledLoopStatement::semantic(Scope *sc) for (size_t i = 0; i < statements->dim; i++) { - Statement *s = (Statement *) statements->data[i]; + Statement *s = statements->tdata()[i]; if (s) { //printf("[%d]: %s\n", i, s->toChars()); s = s->semantic(scd); - statements->data[i] = s; + statements->tdata()[i] = s; } } @@ -803,7 +803,7 @@ void UnrolledLoopStatement::toCBuffer(OutBuffer *buf, HdrGenState *hgs) for (size_t i = 0; i < statements->dim; i++) { Statement *s; - s = (Statement *) statements->data[i]; + s = statements->tdata()[i]; if (s) s->toCBuffer(buf, hgs); } @@ -825,7 +825,7 @@ int UnrolledLoopStatement::hasContinue() int UnrolledLoopStatement::usesEH() { for (size_t i = 0; i < statements->dim; i++) - { Statement *s = (Statement *) statements->data[i]; + { Statement *s = statements->tdata()[i]; if (s && s->usesEH()) return TRUE; } @@ -836,7 +836,7 @@ int UnrolledLoopStatement::blockExit(bool mustNotThrow) { int result = BEfallthru; for (size_t i = 0; i < statements->dim; i++) - { Statement *s = (Statement *) statements->data[i]; + { Statement *s = statements->tdata()[i]; if (s) { int r = s->blockExit(mustNotThrow); @@ -852,7 +852,7 @@ int UnrolledLoopStatement::comeFrom() //printf("UnrolledLoopStatement::comeFrom()\n"); for (size_t i = 0; i < statements->dim; i++) - { Statement *s = (Statement *)statements->data[i]; + { Statement *s = statements->tdata()[i]; if (!s) continue; @@ -1396,10 +1396,10 @@ Statement *ForeachStatement::semantic(Scope *sc) Expression *e; Type *t; if (te) - e = (Expression *)te->exps->data[k]; + e = te->exps->tdata()[k]; else t = Parameter::getNth(tuple->arguments, k)->type; - Parameter *arg = (Parameter *)arguments->data[0]; + Parameter *arg = arguments->tdata()[0]; Statements *st = new Statements(); if (dim == 2) @@ -1422,7 +1422,7 @@ Statement *ForeachStatement::semantic(Scope *sc) var->storage_class |= STCmanifest; DeclarationExp *de = new DeclarationExp(loc, var); st->push(new ExpStatement(loc, de)); - arg = (Parameter *)arguments->data[1]; // value + arg = arguments->tdata()[1]; // value } // Declare value if (arg->storageClass & (STCout | STCref | STClazy)) @@ -1493,7 +1493,7 @@ Statement *ForeachStatement::semantic(Scope *sc) { Parameter *arg; int i = (dim == 1) ? 0 : 1; // index of value - arg = (Parameter *)arguments->data[i]; + arg = arguments->tdata()[i]; arg->type = arg->type->semantic(loc, sc); tnv = arg->type->toBasetype(); if (tnv->ty != tn->ty && @@ -1502,7 +1502,7 @@ Statement *ForeachStatement::semantic(Scope *sc) if (arg->storageClass & STCref) error("foreach: value of UTF conversion cannot be ref"); if (dim == 2) - { arg = (Parameter *)arguments->data[0]; + { arg = arguments->tdata()[0]; if (arg->storageClass & STCref) error("foreach: key cannot be ref"); } @@ -1512,7 +1512,7 @@ Statement *ForeachStatement::semantic(Scope *sc) for (size_t i = 0; i < dim; i++) { // Declare args - Parameter *arg = (Parameter *)arguments->data[i]; + Parameter *arg = arguments->tdata()[i]; Type *argtype = arg->type->semantic(loc, sc); VarDeclaration *var; @@ -1717,7 +1717,7 @@ Statement *ForeachStatement::semantic(Scope *sc) e = new VarExp(loc, r); Expression *einit = new DotIdExp(loc, e, idhead); // einit = einit->semantic(sc); - Parameter *arg = (Parameter *)arguments->data[0]; + Parameter *arg = arguments->tdata()[0]; VarDeclaration *ve = new VarDeclaration(loc, arg->type, arg->ident, new ExpInitializer(loc, einit)); ve->storage_class |= STCforeach; ve->storage_class |= arg->storageClass & (STCin | STCout | STCref | STC_TYPECTOR); @@ -1769,7 +1769,7 @@ Statement *ForeachStatement::semantic(Scope *sc) */ Parameters *args = new Parameters(); for (size_t i = 0; i < dim; i++) - { Parameter *arg = (Parameter *)arguments->data[i]; + { Parameter *arg = arguments->tdata()[i]; Identifier *id; arg->type = arg->type->semantic(loc, sc); @@ -1789,7 +1789,7 @@ Statement *ForeachStatement::semantic(Scope *sc) args->push(a); } Type *t = new TypeFunction(args, Type::tint32, 0, LINKd); - cases = new CaseStatements(); + cases = new Statements(); gotos = new CompoundStatements(); FuncLiteralDeclaration *fld = new FuncLiteralDeclaration(loc, 0, t, TOKdelegate, this); fld->fbody = body; @@ -1799,28 +1799,28 @@ Statement *ForeachStatement::semantic(Scope *sc) // Resolve any forward referenced goto's for (size_t i = 0; i < gotos->dim; i++) - { CompoundStatement *cs = (CompoundStatement *)gotos->data[i]; - GotoStatement *gs = (GotoStatement *)cs->statements->data[0]; + { CompoundStatement *cs = gotos->tdata()[i]; + GotoStatement *gs = (GotoStatement *)cs->statements->tdata()[0]; if (!gs->label->statement) { // 'Promote' it to this scope, and replace with a return cases->push(gs); s = new ReturnStatement(0, new IntegerExp(cases->dim + 1)); - cs->statements->data[0] = (void *)s; + cs->statements->tdata()[0] = s; } } if (tab->ty == Taarray) { // Check types - Parameter *arg = (Parameter *)arguments->data[0]; + Parameter *arg = arguments->tdata()[0]; if (dim == 2) { if (arg->storageClass & STCref) error("foreach: index cannot be ref"); if (!arg->type->equals(taa->index)) error("foreach: index must be type %s, not %s", taa->index->toChars(), arg->type->toChars()); - arg = (Parameter *)arguments->data[1]; + arg = arguments->tdata()[1]; } if (!arg->type->equals(taa->nextOf())) error("foreach: value must be type %s, not %s", taa->nextOf()->toChars(), arg->type->toChars()); @@ -1949,7 +1949,7 @@ Statement *ForeachStatement::semantic(Scope *sc) // cases 2... for (int i = 0; i < cases->dim; i++) { - s = (Statement *)cases->data[i]; + s = cases->tdata()[i]; s = new CaseStatement(0, new IntegerExp(i + 2), s); a->push(s); } @@ -1978,7 +1978,7 @@ bool ForeachStatement::checkForArgTypes() { bool result = TRUE; for (size_t i = 0; i < arguments->dim; i++) - { Parameter *arg = (Parameter *)arguments->data[i]; + { Parameter *arg = arguments->tdata()[i]; if (!arg->type) { error("cannot infer type for %s", arg->ident->toChars()); @@ -2031,7 +2031,7 @@ void ForeachStatement::toCBuffer(OutBuffer *buf, HdrGenState *hgs) buf->writestring(" ("); for (int i = 0; i < arguments->dim; i++) { - Parameter *a = (Parameter *)arguments->data[i]; + Parameter *a = arguments->tdata()[i]; if (i) buf->writestring(", "); if (a->storageClass & STCref) @@ -2574,7 +2574,7 @@ Statement *PragmaStatement::semantic(Scope *sc) { for (size_t i = 0; i < args->dim; i++) { - Expression *e = (Expression *)args->data[i]; + Expression *e = args->tdata()[i]; e = e->semantic(sc); e = e->optimize(WANTvalue | WANTinterpret); @@ -2600,11 +2600,11 @@ Statement *PragmaStatement::semantic(Scope *sc) error("string expected for library name"); else { - Expression *e = (Expression *)args->data[0]; + Expression *e = args->tdata()[0]; e = e->semantic(sc); e = e->optimize(WANTvalue | WANTinterpret); - args->data[0] = (void *)e; + args->tdata()[0] = e; if (e->op != TOKstring) error("string expected for library name, not '%s'", e->toChars()); else if (global.params.verbose) @@ -2626,10 +2626,10 @@ Statement *PragmaStatement::semantic(Scope *sc) error("function name expected for start address"); else { - Expression *e = (Expression *)args->data[0]; + Expression *e = args->tdata()[0]; e = e->semantic(sc); e = e->optimize(WANTvalue | WANTinterpret); - args->data[0] = (void *)e; + args->tdata()[0] = e; Dsymbol *sa = getDsymbol(e); if (!sa || !sa->isFuncDeclaration()) error("function name expected for start address, not '%s'", e->toChars()); @@ -2785,7 +2785,7 @@ Statement *SwitchStatement::semantic(Scope *sc) // Resolve any goto case's with exp for (int i = 0; i < gotoCases.dim; i++) { - GotoCaseStatement *gcs = (GotoCaseStatement *)gotoCases.data[i]; + GotoCaseStatement *gcs = gotoCases.tdata()[i]; if (!gcs->exp) { @@ -2799,7 +2799,7 @@ Statement *SwitchStatement::semantic(Scope *sc) continue; for (int j = 0; j < scx->sw->cases->dim; j++) { - CaseStatement *cs = (CaseStatement *)scx->sw->cases->data[j]; + CaseStatement *cs = scx->sw->cases->tdata()[j]; if (cs->exp->equals(gcs->exp)) { @@ -2854,11 +2854,11 @@ Statement *SwitchStatement::semantic(Scope *sc) size_t dim = ed->members->dim; for (size_t i = 0; i < dim; i++) { - EnumMember *em = ((Dsymbol *)ed->members->data[i])->isEnumMember(); + EnumMember *em = ed->members->tdata()[i]->isEnumMember(); if (em) { for (size_t j = 0; j < cases->dim; j++) - { CaseStatement *cs = (CaseStatement *)cases->data[j]; + { CaseStatement *cs = cases->tdata()[j]; if (cs->exp->equals(em->value)) goto L1; } @@ -2981,7 +2981,7 @@ Statement *CaseStatement::semantic(Scope *sc) L1: for (int i = 0; i < sw->cases->dim; i++) { - CaseStatement *cs = (CaseStatement *)sw->cases->data[i]; + CaseStatement *cs = sw->cases->tdata()[i]; //printf("comparing '%s' with '%s'\n", exp->toChars(), cs->exp->toChars()); if (cs->exp->equals(exp)) @@ -2995,7 +2995,7 @@ Statement *CaseStatement::semantic(Scope *sc) // Resolve any goto case's with no exp to this case statement for (int i = 0; i < sw->gotoCases.dim; i++) { - GotoCaseStatement *gcs = (GotoCaseStatement *)sw->gotoCases.data[i]; + GotoCaseStatement *gcs = sw->gotoCases.tdata()[i]; if (!gcs->exp) { @@ -4103,9 +4103,9 @@ Statement *TryCatchStatement::syntaxCopy() for (int i = 0; i < a->dim; i++) { Catch *c; - c = (Catch *)catches->data[i]; + c = catches->tdata()[i]; c = c->syntaxCopy(); - a->data[i] = c; + a->tdata()[i] = c; } TryCatchStatement *s = new TryCatchStatement(loc, body->syntaxCopy(), a); return s; @@ -4118,12 +4118,12 @@ Statement *TryCatchStatement::semantic(Scope *sc) /* Even if body is NULL, still do semantic analysis on catches */ for (size_t i = 0; i < catches->dim; i++) - { Catch *c = (Catch *)catches->data[i]; + { Catch *c = catches->tdata()[i]; c->semantic(sc); // Determine if current catch 'hides' any previous catches for (size_t j = 0; j < i; j++) - { Catch *cj = (Catch *)catches->data[j]; + { Catch *cj = catches->tdata()[j]; char *si = c->loc.toChars(); char *sj = cj->loc.toChars(); @@ -4157,7 +4157,7 @@ int TryCatchStatement::blockExit(bool mustNotThrow) int catchresult = 0; for (size_t i = 0; i < catches->dim; i++) { - Catch *c = (Catch *)catches->data[i]; + Catch *c = catches->tdata()[i]; if (c->type == Type::terror) continue; @@ -4188,7 +4188,7 @@ void TryCatchStatement::toCBuffer(OutBuffer *buf, HdrGenState *hgs) body->toCBuffer(buf, hgs); for (size_t i = 0; i < catches->dim; i++) { - Catch *c = (Catch *)catches->data[i]; + Catch *c = catches->tdata()[i]; c->toCBuffer(buf, hgs); } } @@ -4518,10 +4518,10 @@ Statements *VolatileStatement::flatten(Scope *sc) a = statement ? statement->flatten(sc) : NULL; if (a) { for (int i = 0; i < a->dim; i++) - { Statement *s = (Statement *)a->data[i]; + { Statement *s = a->tdata()[i]; s = new VolatileStatement(loc, s); - a->data[i] = s; + a->tdata()[i] = s; } } @@ -4579,10 +4579,10 @@ Statements *DebugStatement::flatten(Scope *sc) Statements *a = statement ? statement->flatten(sc) : NULL; if (a) { for (size_t i = 0; i < a->dim; i++) - { Statement *s = (Statement *)a->data[i]; + { Statement *s = a->tdata()[i]; s = new DebugStatement(loc, s); - a->data[i] = s; + a->tdata()[i] = s; } } @@ -4629,7 +4629,7 @@ Statement *GotoStatement::semantic(Scope *sc) * list. */ Statements *a = new Statements(); - Statement *s; + CompoundStatement *s; a->push(this); s = new CompoundStatement(loc, a); @@ -4708,10 +4708,10 @@ Statements *LabelStatement::flatten(Scope *sc) { a->push(new ExpStatement(loc, (Expression *)NULL)); } - Statement *s = (Statement *)a->data[0]; + Statement *s = a->tdata()[0]; s = new LabelStatement(loc, ident, s); - a->data[0] = s; + a->tdata()[0] = s; } } diff --git a/src/statement.h b/src/statement.h index 937a13b9bc3c..71ad02cafe67 100644 --- a/src/statement.h +++ b/src/statement.h @@ -322,7 +322,7 @@ struct ForeachStatement : Statement FuncDeclaration *func; // function we're lexically in - CaseStatements *cases; // put breaks, continues, gotos and returns here + Statements *cases; // put breaks, continues, gotos and returns here CompoundStatements *gotos; // forward referenced goto's go here ForeachStatement(Loc loc, enum TOK op, Parameters *arguments, Expression *aggr, Statement *body); diff --git a/src/struct.c b/src/struct.c index fe614b3e4fb3..f48ae77e27a6 100644 --- a/src/struct.c +++ b/src/struct.c @@ -72,7 +72,7 @@ void AggregateDeclaration::semantic2(Scope *sc) sc = sc->push(this); for (size_t i = 0; i < members->dim; i++) { - Dsymbol *s = (Dsymbol *)members->data[i]; + Dsymbol *s = members->tdata()[i]; s->semantic2(sc); } sc->pop(); @@ -88,7 +88,7 @@ void AggregateDeclaration::semantic3(Scope *sc) sc = sc->push(this); for (i = 0; i < members->dim; i++) { - Dsymbol *s = (Dsymbol *)members->data[i]; + Dsymbol *s = members->tdata()[i]; s->semantic3(sc); } sc->pop(); @@ -103,7 +103,7 @@ void AggregateDeclaration::inlineScan() { for (i = 0; i < members->dim; i++) { - Dsymbol *s = (Dsymbol *)members->data[i]; + Dsymbol *s = members->tdata()[i]; //printf("inline scan aggregate symbol '%s'\n", s->toChars()); s->inlineScan(); } @@ -247,13 +247,13 @@ int AggregateDeclaration::firstFieldInUnion(int indx) { if (isUnionDeclaration()) return 0; - VarDeclaration * vd = (VarDeclaration *)fields.data[indx]; + VarDeclaration * vd = fields.tdata()[indx]; int firstNonZero = indx; // first index in the union with non-zero size for (; ;) { if (indx == 0) return firstNonZero; - VarDeclaration * v = (VarDeclaration *)fields.data[indx - 1]; + VarDeclaration * v = fields.tdata()[indx - 1]; if (v->offset != vd->offset) return firstNonZero; --indx; @@ -272,7 +272,7 @@ int AggregateDeclaration::firstFieldInUnion(int indx) */ int AggregateDeclaration::numFieldsInUnion(int firstIndex) { - VarDeclaration * vd = (VarDeclaration *)fields.data[firstIndex]; + VarDeclaration * vd = fields.tdata()[firstIndex]; /* If it is a zero-length field, AND we can't find an earlier non-zero * sized field with the same offset, we assume it's not part of a union. */ @@ -282,7 +282,7 @@ int AggregateDeclaration::numFieldsInUnion(int firstIndex) int count = 1; for (int i = firstIndex+1; i < fields.dim; ++i) { - VarDeclaration * v = (VarDeclaration *)fields.data[i]; + VarDeclaration * v = fields.tdata()[i]; // If offsets are different, they are not in the same union if (v->offset != vd->offset) break; @@ -380,7 +380,7 @@ void StructDeclaration::semantic(Scope *sc) int hasfunctions = 0; for (int i = 0; i < members->dim; i++) { - Dsymbol *s = (Dsymbol *)members->data[i]; + Dsymbol *s = members->tdata()[i]; //printf("adding member '%s' to '%s'\n", s->toChars(), this->toChars()); s->addMember(sc, this, 1); if (s->isFuncDeclaration()) @@ -436,7 +436,7 @@ void StructDeclaration::semantic(Scope *sc) * resolve individual members like enums. */ for (int i = 0; i < members_dim; i++) - { Dsymbol *s = (Dsymbol *)members->data[i]; + { Dsymbol *s = members->tdata()[i]; /* There are problems doing this in the general case because * Scope keeps track of things like 'offset' */ @@ -449,7 +449,7 @@ void StructDeclaration::semantic(Scope *sc) for (int i = 0; i < members_dim; i++) { - Dsymbol *s = (Dsymbol *)members->data[i]; + Dsymbol *s = members->tdata()[i]; s->semantic(sc2); #if 0 if (sizeok == 2) @@ -616,7 +616,7 @@ void StructDeclaration::semantic(Scope *sc) zeroInit = 1; for (int i = 0; i < fields.dim; i++) { - Dsymbol *s = (Dsymbol *)fields.data[i]; + Dsymbol *s = fields.tdata()[i]; VarDeclaration *vd = s->isVarDeclaration(); if (vd && !vd->isDataseg()) { @@ -686,7 +686,7 @@ void StructDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) buf->writenl(); for (i = 0; i < members->dim; i++) { - Dsymbol *s = (Dsymbol *)members->data[i]; + Dsymbol *s = members->tdata()[i]; buf->writestring(" "); s->toCBuffer(buf, hgs); diff --git a/src/template.c b/src/template.c index 6f9a68e27e70..31e6305e94b0 100644 --- a/src/template.c +++ b/src/template.c @@ -100,7 +100,7 @@ int arrayObjectIsError(Objects *args) { for (size_t i = 0; i < args->dim; i++) { - Object *o = (Object *)args->data[i]; + Object *o = args->tdata()[i]; if (isError(o)) return 1; } @@ -248,8 +248,8 @@ int match(Object *o1, Object *o2, TemplateDeclaration *tempdecl, Scope *sc) goto Lnomatch; for (size_t i = 0; i < v1->objects.dim; i++) { - if (!match((Object *)v1->objects.data[i], - (Object *)v2->objects.data[i], + if (!match(v1->objects.tdata()[i], + v2->objects.tdata()[i], tempdecl, sc)) goto Lnomatch; } @@ -273,8 +273,8 @@ int arrayObjectMatch(Objects *oa1, Objects *oa2, TemplateDeclaration *tempdecl, if (oa1->dim != oa2->dim) return 0; for (size_t j = 0; j < oa1->dim; j++) - { Object *o1 = (Object *)oa1->data[j]; - Object *o2 = (Object *)oa2->data[j]; + { Object *o1 = oa1->tdata()[j]; + Object *o2 = oa2->tdata()[j]; if (!match(o1, o2, tempdecl, sc)) { return 0; @@ -311,7 +311,7 @@ void ObjectToCBuffer(OutBuffer *buf, HdrGenState *hgs, Object *oarg) { if (i) buf->writeByte(','); - Object *o = (Object *)args->data[i]; + Object *o = args->tdata()[i]; ObjectToCBuffer(buf, hgs, o); } } @@ -356,7 +356,7 @@ TemplateDeclaration::TemplateDeclaration(Loc loc, Identifier *id, #if 0 if (parameters) for (int i = 0; i < parameters->dim; i++) - { TemplateParameter *tp = (TemplateParameter *)parameters->data[i]; + { TemplateParameter *tp = parameters->tdata()[i]; //printf("\tparameter[%d] = %p\n", i, tp); TemplateTypeParameter *ttp = tp->isTemplateTypeParameter(); @@ -392,8 +392,8 @@ Dsymbol *TemplateDeclaration::syntaxCopy(Dsymbol *) p = new TemplateParameters(); p->setDim(parameters->dim); for (int i = 0; i < p->dim; i++) - { TemplateParameter *tp = (TemplateParameter *)parameters->data[i]; - p->data[i] = (void *)tp->syntaxCopy(); + { TemplateParameter *tp = parameters->tdata()[i]; + p->tdata()[i] = tp->syntaxCopy(); } } Expression *e = NULL; @@ -471,21 +471,21 @@ void TemplateDeclaration::semantic(Scope *sc) origParameters->setDim(parameters->dim); for (int i = 0; i < parameters->dim; i++) { - TemplateParameter *tp = (TemplateParameter *)parameters->data[i]; - origParameters->data[i] = (void *)tp->syntaxCopy(); + TemplateParameter *tp = parameters->tdata()[i]; + origParameters->tdata()[i] = tp->syntaxCopy(); } } for (int i = 0; i < parameters->dim; i++) { - TemplateParameter *tp = (TemplateParameter *)parameters->data[i]; + TemplateParameter *tp = parameters->tdata()[i]; tp->declareParameter(paramscope); } for (int i = 0; i < parameters->dim; i++) { - TemplateParameter *tp = (TemplateParameter *)parameters->data[i]; + TemplateParameter *tp = parameters->tdata()[i]; tp->semantic(paramscope); if (i + 1 != parameters->dim && tp->isTemplateTupleParameter()) @@ -548,8 +548,8 @@ int TemplateDeclaration::overloadInsert(Dsymbol *s) goto Lcontinue; for (int i = 0; i < f->parameters->dim; i++) - { TemplateParameter *p1 = (TemplateParameter *)f->parameters->data[i]; - TemplateParameter *p2 = (TemplateParameter *)f2->parameters->data[i]; + { TemplateParameter *p1 = f->parameters->tdata()[i]; + TemplateParameter *p2 = f2->parameters->tdata()[i]; if (!p1->overloadMatch(p2)) goto Lcontinue; @@ -643,7 +643,7 @@ MATCH TemplateDeclaration::matchWithInstance(TemplateInstance *ti, if (ti->tiargs->dim) printf("ti->tiargs->dim = %d, [0] = %p\n", ti->tiargs->dim, - ti->tiargs->data[0]); + ti->tiargs->tdata()[0]); #endif dedtypes->zero(); @@ -673,7 +673,7 @@ MATCH TemplateDeclaration::matchWithInstance(TemplateInstance *ti, m = MATCHexact; for (int i = 0; i < dedtypes_dim; i++) { MATCH m2; - TemplateParameter *tp = (TemplateParameter *)parameters->data[i]; + TemplateParameter *tp = parameters->tdata()[i]; Declaration *sparam; //printf("\targument [%d]\n", i); @@ -716,9 +716,9 @@ MATCH TemplateDeclaration::matchWithInstance(TemplateInstance *ti, */ for (int i = 0; i < dedtypes_dim; i++) { - if (!dedtypes->data[i]) + if (!dedtypes->tdata()[i]) { assert(i < ti->tiargs->dim); - dedtypes->data[i] = ti->tiargs->data[i]; + dedtypes->tdata()[i] = (Type *)ti->tiargs->tdata()[i]; } } } @@ -754,16 +754,16 @@ MATCH TemplateDeclaration::matchWithInstance(TemplateInstance *ti, { for (int i = 0; i < dedtypes_dim; i++) { - TemplateParameter *tp = (TemplateParameter *)parameters->data[i]; + TemplateParameter *tp = parameters->tdata()[i]; Object *oarg; printf(" [%d]", i); if (i < ti->tiargs->dim) - oarg = (Object *)ti->tiargs->data[i]; + oarg = ti->tiargs->tdata()[i]; else oarg = NULL; - tp->print(oarg, (Object *)dedtypes->data[i]); + tp->print(oarg, dedtypes->tdata()[i]); } } else @@ -820,11 +820,11 @@ MATCH TemplateDeclaration::leastAsSpecialized(TemplateDeclaration *td2) ti.tiargs->setDim(parameters->dim); for (int i = 0; i < ti.tiargs->dim; i++) { - TemplateParameter *tp = (TemplateParameter *)parameters->data[i]; + TemplateParameter *tp = parameters->tdata()[i]; - void *p = tp->dummyArg(); + Object *p = (Object *)tp->dummyArg(); if (p) - ti.tiargs->data[i] = p; + ti.tiargs->tdata()[i] = p; else ti.tiargs->setDim(i); } @@ -888,7 +888,7 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch(Scope *sc, Loc loc, Objec #if 0 printf("\nTemplateDeclaration::deduceFunctionTemplateMatch() %s\n", toChars()); for (i = 0; i < fargs->dim; i++) - { Expression *e = (Expression *)fargs->data[i]; + { Expression *e = fargs->tdata()[i]; printf("\tfarg[%d] is %s, type is %s\n", i, e->toChars(), e->type->toChars()); } printf("fd = %s\n", fd->toChars()); @@ -918,7 +918,7 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch(Scope *sc, Loc loc, Objec for (i = 0; i < dedargs->dim; i++) { printf("\tdedarg[%d] = ", i); - Object *oarg = (Object *)dedargs->data[i]; + Object *oarg = dedargs->tdata()[i]; if (oarg) printf("%s", oarg->toChars()); printf("\n"); } @@ -942,13 +942,13 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch(Scope *sc, Loc loc, Objec */ Tuple *t = new Tuple(); assert(parameters->dim); - dedargs->data[parameters->dim - 1] = (void *)t; + dedargs->tdata()[parameters->dim - 1] = t; tuple_dim = nargsi - n; t->objects.setDim(tuple_dim); for (size_t i = 0; i < tuple_dim; i++) { - t->objects.data[i] = (void *)targsi->data[n + i]; + t->objects.tdata()[i] = targsi->tdata()[n + i]; } declareParameter(paramscope, tp, t); tp_is_declared = 1; @@ -956,11 +956,11 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch(Scope *sc, Loc loc, Objec else n = nargsi; - memcpy(dedargs->data, targsi->data, n * sizeof(*dedargs->data)); + memcpy(dedargs->tdata(), targsi->tdata(), n * sizeof(*dedargs->tdata())); for (size_t i = 0; i < n; i++) { assert(i < parameters->dim); - TemplateParameter *tp = (TemplateParameter *)parameters->data[i]; + TemplateParameter *tp = parameters->tdata()[i]; MATCH m; Declaration *sparam = NULL; @@ -980,7 +980,7 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch(Scope *sc, Loc loc, Objec for (i = 0; i < dedargs->dim; i++) { printf("\tdedarg[%d] = ", i); - Object *oarg = (Object *)dedargs->data[i]; + Object *oarg = dedargs->tdata()[i]; if (oarg) printf("%s", oarg->toChars()); printf("\n"); } @@ -1004,7 +1004,7 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch(Scope *sc, Loc loc, Objec goto L2; Tuple *t = new Tuple(); //printf("t = %p\n", t); - dedargs->data[parameters->dim - 1] = (void *)t; + dedargs->tdata()[parameters->dim - 1] = t; declareParameter(paramscope, tp, t); goto L2; } @@ -1019,7 +1019,7 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch(Scope *sc, Loc loc, Objec */ for (fptupindex = 0; fptupindex < nfparams; fptupindex++) { - Parameter *fparam = (Parameter *)fparameters->data[fptupindex]; + Parameter *fparam = fparameters->tdata()[fptupindex]; if (fparam->type->ty != Tident) continue; TypeIdentifier *tid = (TypeIdentifier *)fparam->type; @@ -1036,13 +1036,13 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch(Scope *sc, Loc loc, Objec * now form the tuple argument. */ Tuple *t = new Tuple(); - dedargs->data[parameters->dim - 1] = (void *)t; + dedargs->tdata()[parameters->dim - 1] = t; tuple_dim = nfargs - (nfparams - 1); t->objects.setDim(tuple_dim); for (i = 0; i < tuple_dim; i++) - { Expression *farg = (Expression *)fargs->data[fptupindex + i]; - t->objects.data[i] = (void *)farg->type; + { Expression *farg = fargs->tdata()[fptupindex + i]; + t->objects.tdata()[i] = farg->type; } declareParameter(paramscope, tp, t); goto L2; @@ -1067,7 +1067,7 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch(Scope *sc, Loc loc, Objec { // Match 'ethis' to any TemplateThisParameter's for (size_t i = 0; i < parameters->dim; i++) - { TemplateParameter *tp = (TemplateParameter *)parameters->data[i]; + { TemplateParameter *tp = parameters->tdata()[i]; TemplateThisParameter *ttp = tp->isTemplateThisParameter(); if (ttp) { MATCH m; @@ -1151,7 +1151,7 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch(Scope *sc, Loc loc, Objec } } else - { Expression *farg = (Expression *)fargs->data[i]; + { Expression *farg = fargs->tdata()[i]; #if 0 printf("\tfarg->type = %s\n", farg->type->toChars()); printf("\tfparam->type = %s\n", fparam->type->toChars()); @@ -1222,7 +1222,7 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch(Scope *sc, Loc loc, Objec { TypeArray *ta = (TypeArray *)tb; for (; i < nfargs; i++) { - Expression *arg = (Expression *)fargs->data[i]; + Expression *arg = fargs->tdata()[i]; assert(arg); MATCH m; /* If lazy array of delegates, @@ -1269,13 +1269,13 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch(Scope *sc, Loc loc, Objec for (i = nargsi; i < dedargs->dim; i++) { - TemplateParameter *tparam = (TemplateParameter *)parameters->data[i]; + TemplateParameter *tparam = parameters->tdata()[i]; //printf("tparam[%d] = %s\n", i, tparam->ident->toChars()); /* For T:T*, the dedargs is the T*, dedtypes is the T * But for function templates, we really need them to match */ - Object *oarg = (Object *)dedargs->data[i]; - Object *oded = (Object *)dedtypes.data[i]; + Object *oarg = dedargs->tdata()[i]; + Object *oded = dedtypes.tdata()[i]; //printf("1dedargs[%d] = %p, dedtypes[%d] = %p\n", i, oarg, i, oded); //if (oarg) printf("oarg: %s\n", oarg->toChars()); //if (oded) printf("oded: %s\n", oded->toChars()); @@ -1288,14 +1288,14 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch(Scope *sc, Loc loc, Objec * the oded == oarg */ Declaration *sparam; - dedargs->data[i] = (void *)oded; + dedargs->tdata()[i] = oded; MATCH m2 = tparam->matchArg(paramscope, dedargs, i, parameters, &dedtypes, &sparam, 0); //printf("m2 = %d\n", m2); if (!m2) goto Lnomatch; if (m2 < match) match = m2; // pick worst match - if (dedtypes.data[i] != oded) + if (dedtypes.tdata()[i] != oded) error("specialization not allowed for deduced parameter %s", tparam->ident->toChars()); } } @@ -1314,7 +1314,7 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch(Scope *sc, Loc loc, Objec } } declareParameter(paramscope, tparam, oded); - dedargs->data[i] = (void *)oded; + dedargs->tdata()[i] = oded; } } @@ -1380,7 +1380,7 @@ MATCH TemplateDeclaration::deduceFunctionTemplateMatch(Scope *sc, Loc loc, Objec #if 0 for (i = 0; i < dedargs->dim; i++) - { Type *t = (Type *)dedargs->data[i]; + { Type *t = dedargs->tdata()[i]; printf("\tdedargs[%d] = %d, %s\n", i, t->dyncast(), t->toChars()); } #endif @@ -1474,7 +1474,7 @@ TemplateTupleParameter *isVariadic(TemplateParameters *parameters) TemplateTupleParameter *tp = NULL; if (dim) - tp = ((TemplateParameter *)parameters->data[dim - 1])->isTemplateTupleParameter(); + tp = (parameters->tdata()[dim - 1])->isTemplateTupleParameter(); return tp; } @@ -1520,13 +1520,13 @@ FuncDeclaration *TemplateDeclaration::deduceFunctionTemplate(Scope *sc, Loc loc, printf(" targsi:\n"); if (targsi) { for (int i = 0; i < targsi->dim; i++) - { Object *arg = (Object *)targsi->data[i]; + { Object *arg = targsi->tdata()[i]; printf("\t%s\n", arg->toChars()); } } printf(" fargs:\n"); for (int i = 0; i < fargs->dim; i++) - { Expression *arg = (Expression *)fargs->data[i]; + { Expression *arg = fargs->tdata()[i]; printf("\t%s %s\n", arg->type->toChars(), arg->toChars()); //printf("\tty = %d\n", arg->type->ty); } @@ -1587,7 +1587,7 @@ FuncDeclaration *TemplateDeclaration::deduceFunctionTemplate(Scope *sc, Loc loc, td_best = td; m_best = m; tdargs->setDim(dedargs.dim); - memcpy(tdargs->data, dedargs.data, tdargs->dim * sizeof(void *)); + memcpy(tdargs->tdata(), dedargs.tdata(), tdargs->dim * sizeof(void *)); continue; } if (!td_best) @@ -1629,7 +1629,7 @@ FuncDeclaration *TemplateDeclaration::deduceFunctionTemplate(Scope *sc, Loc loc, { if (i) bufa.writeByte(','); - Object *oarg = (Object *)args->data[i]; + Object *oarg = args->tdata()[i]; ObjectToCBuffer(&bufa, &hgs, oarg); } } @@ -1654,9 +1654,9 @@ void TemplateDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) buf->writeByte('('); for (int i = 0; i < parameters->dim; i++) { - TemplateParameter *tp = (TemplateParameter *)parameters->data[i]; + TemplateParameter *tp = parameters->tdata()[i]; if (hgs->ddoc) - tp = (TemplateParameter *)origParameters->data[i]; + tp = origParameters->tdata()[i]; if (i) buf->writeByte(','); tp->toCBuffer(buf, hgs); @@ -1678,7 +1678,7 @@ void TemplateDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) buf->writenl(); for (int i = 0; i < members->dim; i++) { - Dsymbol *s = (Dsymbol *)members->data[i]; + Dsymbol *s = members->tdata()[i]; s->toCBuffer(buf, hgs); } buf->writebyte('}'); @@ -1697,7 +1697,7 @@ char *TemplateDeclaration::toChars() buf.writeByte('('); for (int i = 0; i < parameters->dim; i++) { - TemplateParameter *tp = (TemplateParameter *)parameters->data[i]; + TemplateParameter *tp = parameters->tdata()[i]; if (i) buf.writeByte(','); tp->toCBuffer(&buf, &hgs); @@ -1724,7 +1724,7 @@ char *TemplateDeclaration::toChars() int templateIdentifierLookup(Identifier *id, TemplateParameters *parameters) { for (size_t i = 0; i < parameters->dim; i++) - { TemplateParameter *tp = (TemplateParameter *)parameters->data[i]; + { TemplateParameter *tp = parameters->tdata()[i]; if (tp->ident->equals(id)) return i; @@ -1787,7 +1787,7 @@ MATCH Type::deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, Loc loc; if (parameters->dim) { - TemplateParameter *tp = (TemplateParameter *)parameters->data[0]; + TemplateParameter *tp = parameters->tdata()[0]; loc = tp->loc; } @@ -1799,13 +1799,13 @@ MATCH Type::deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, return deduceType(sc, tparam, parameters, dedtypes); } - TemplateParameter *tp = (TemplateParameter *)parameters->data[i]; + TemplateParameter *tp = parameters->tdata()[i]; // Found the corresponding parameter tp if (!tp->isTemplateTypeParameter()) goto Lnomatch; Type *tt = this; - Type *at = (Type *)dedtypes->data[i]; + Type *at = (Type *)dedtypes->tdata()[i]; // 7*7 == 49 cases @@ -1827,7 +1827,7 @@ MATCH Type::deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, // foo(U:U) wild(T) => wild(T) // foo(U:U) wild(shared(T)) => wild(shared(T)) if (!at) - { dedtypes->data[i] = (void *)tt; + { dedtypes->tdata()[i] = tt; goto Lexact; } break; @@ -1846,7 +1846,7 @@ MATCH Type::deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, // foo(U:wild(shared(U)) wild(shared(T)) => T tt = mutableOf()->unSharedOf(); if (!at) - { dedtypes->data[i] = (void *)tt; + { dedtypes->tdata()[i] = tt; goto Lexact; } break; @@ -1864,7 +1864,7 @@ MATCH Type::deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, // foo(U:const(U)) wild(shared(T)) => shared(T) tt = mutableOf(); if (!at) - { dedtypes->data[i] = (void *)tt; + { dedtypes->tdata()[i] = tt; goto Lconst; } break; @@ -1877,7 +1877,7 @@ MATCH Type::deduceType(Scope *sc, Type *tparam, TemplateParameters *parameters, // foo(U:shared(U)) wild(shared(T)) => wild(T) tt = unSharedOf(); if (!at) - { dedtypes->data[i] = (void *)tt; + { dedtypes->tdata()[i] = tt; goto Lconst; } break; @@ -2024,11 +2024,11 @@ MATCH TypeSArray::deduceType(Scope *sc, Type *tparam, TemplateParameters *parame // This code matches code in TypeInstance::deduceType() if (i == -1) goto Lnomatch; - TemplateParameter *tp = (TemplateParameter *)parameters->data[i]; + TemplateParameter *tp = parameters->tdata()[i]; TemplateValueParameter *tvp = tp->isTemplateValueParameter(); if (!tvp) goto Lnomatch; - Expression *e = (Expression *)dedtypes->data[i]; + Expression *e = (Expression *)dedtypes->tdata()[i]; if (e) { if (!dim->equals(e)) @@ -2039,7 +2039,7 @@ MATCH TypeSArray::deduceType(Scope *sc, Type *tparam, TemplateParameters *parame MATCH m = (MATCH)dim->implicitConvTo(vt); if (!m) goto Lnomatch; - dedtypes->data[i] = dim; + dedtypes->tdata()[i] = dim; } } else if (dim->toInteger() != tp->dim->toInteger()) @@ -2056,7 +2056,7 @@ MATCH TypeSArray::deduceType(Scope *sc, Type *tparam, TemplateParameters *parame for (size_t i = 0; i < parameters->dim; i++) { - TemplateParameter *tp = (TemplateParameter *)parameters->data[i]; + TemplateParameter *tp = parameters->tdata()[i]; if (tp->ident->equals(id)) { // Found the corresponding template parameter @@ -2064,13 +2064,13 @@ MATCH TypeSArray::deduceType(Scope *sc, Type *tparam, TemplateParameters *parame if (!tvp || !tvp->valType->isintegral()) goto Lnomatch; - if (dedtypes->data[i]) + if (dedtypes->tdata()[i]) { - if (!dim->equals((Object *)dedtypes->data[i])) + if (!dim->equals(dedtypes->tdata()[i])) goto Lnomatch; } else - { dedtypes->data[i] = (void *)dim; + { dedtypes->tdata()[i] = dim; } return next->deduceType(sc, tparam->nextOf(), parameters, dedtypes); } @@ -2152,7 +2152,7 @@ MATCH TypeFunction::deduceType(Scope *sc, Type *tparam, TemplateParameters *para for (; 1; tupi++) { if (tupi == parameters->dim) goto L1; - TemplateParameter *t = (TemplateParameter *)parameters->data[tupi]; + TemplateParameter *t = parameters->tdata()[tupi]; TemplateTupleParameter *tup = t->isTemplateTupleParameter(); if (tup && tup->ident->equals(tid->ident)) break; @@ -2165,7 +2165,7 @@ MATCH TypeFunction::deduceType(Scope *sc, Type *tparam, TemplateParameters *para /* See if existing tuple, and whether it matches or not */ - Object *o = (Object *)dedtypes->data[tupi]; + Object *o = dedtypes->tdata()[tupi]; if (o) { // Existing deduced argument must be a tuple, and must match Tuple *t = isTuple(o); @@ -2173,7 +2173,7 @@ MATCH TypeFunction::deduceType(Scope *sc, Type *tparam, TemplateParameters *para return MATCHnomatch; for (size_t i = 0; i < tuple_dim; i++) { Parameter *arg = Parameter::getNth(this->parameters, nfparams - 1 + i); - if (!arg->type->equals((Object *)t->objects.data[i])) + if (!arg->type->equals(t->objects.tdata()[i])) return MATCHnomatch; } } @@ -2183,9 +2183,9 @@ MATCH TypeFunction::deduceType(Scope *sc, Type *tparam, TemplateParameters *para t->objects.setDim(tuple_dim); for (size_t i = 0; i < tuple_dim; i++) { Parameter *arg = Parameter::getNth(this->parameters, nfparams - 1 + i); - t->objects.data[i] = (void *)arg->type; + t->objects.tdata()[i] = arg->type; } - dedtypes->data[tupi] = (void *)t; + dedtypes->tdata()[tupi] = t; } nfparams--; // don't consider the last parameter for type deduction goto L2; @@ -2216,8 +2216,8 @@ MATCH TypeIdentifier::deduceType(Scope *sc, Type *tparam, TemplateParameters *pa for (int i = 0; i < idents.dim; i++) { - Identifier *id1 = (Identifier *)idents.data[i]; - Identifier *id2 = (Identifier *)tp->idents.data[i]; + Identifier *id1 = idents.tdata()[i]; + Identifier *id2 = tp->idents.tdata()[i]; if (!id1->equals(id2)) return MATCHnomatch; @@ -2265,7 +2265,7 @@ MATCH TypeInstance::deduceType(Scope *sc, } goto Lnomatch; } - TemplateParameter *tpx = (TemplateParameter *)parameters->data[i]; + TemplateParameter *tpx = parameters->tdata()[i]; // This logic duplicates tpx->matchArg() TemplateAliasParameter *ta = tpx->isTemplateAliasParameter(); if (!ta) @@ -2275,14 +2275,14 @@ MATCH TypeInstance::deduceType(Scope *sc, goto Lnomatch; if (ta->specAlias && sa != ta->specAlias) goto Lnomatch; - if (dedtypes->data[i]) + if (dedtypes->tdata()[i]) { // Must match already deduced symbol - Object *s = (Object *)dedtypes->data[i]; + Object *s = dedtypes->tdata()[i]; if (s != sa) goto Lnomatch; } - dedtypes->data[i] = sa; + dedtypes->tdata()[i] = sa; } } else if (tempinst->tempdecl != tp->tempinst->tempdecl) @@ -2295,17 +2295,17 @@ MATCH TypeInstance::deduceType(Scope *sc, //printf("\ttest: tempinst->tiargs[%d]\n", i); Object *o1; if (i < tempinst->tiargs->dim) - o1 = (Object *)tempinst->tiargs->data[i]; + o1 = tempinst->tiargs->tdata()[i]; else if (i < tempinst->tdtypes.dim && i < tp->tempinst->tiargs->dim) // Pick up default arg - o1 = (Object *)tempinst->tdtypes.data[i]; + o1 = tempinst->tdtypes.tdata()[i]; else break; if (i >= tp->tempinst->tiargs->dim) goto Lnomatch; - Object *o2 = (Object *)tp->tempinst->tiargs->data[i]; + Object *o2 = tp->tempinst->tiargs->tdata()[i]; Type *t1 = isType(o1); Type *t2 = isType(o2); @@ -2354,16 +2354,16 @@ MATCH TypeInstance::deduceType(Scope *sc, int vtdim = tempinst->tiargs->dim - i; vt->objects.setDim(vtdim); for (size_t k = 0; k < vtdim; k++) - vt->objects.data[k] = (void *)tempinst->tiargs->data[i + k]; + vt->objects.tdata()[k] = tempinst->tiargs->tdata()[i + k]; - Tuple *v = (Tuple *)dedtypes->data[j]; + Tuple *v = (Tuple *)dedtypes->tdata()[j]; if (v) { if (!match(v, vt, tempinst->tempdecl, sc)) goto Lnomatch; } else - dedtypes->data[j] = vt; + dedtypes->tdata()[j] = vt; break; //return MATCHexact; } @@ -2392,12 +2392,12 @@ MATCH TypeInstance::deduceType(Scope *sc, L1: if (j == -1) goto Lnomatch; - TemplateParameter *tp = (TemplateParameter *)parameters->data[j]; + TemplateParameter *tp = parameters->tdata()[j]; // BUG: use tp->matchArg() instead of the following TemplateValueParameter *tv = tp->isTemplateValueParameter(); if (!tv) goto Lnomatch; - Expression *e = (Expression *)dedtypes->data[j]; + Expression *e = (Expression *)dedtypes->tdata()[j]; if (e) { if (!e1->equals(e)) @@ -2408,7 +2408,7 @@ MATCH TypeInstance::deduceType(Scope *sc, MATCH m = (MATCH)e1->implicitConvTo(vt); if (!m) goto Lnomatch; - dedtypes->data[j] = e1; + dedtypes->tdata()[j] = e1; } } else if (s1 && t2 && t2->ty == Tident) @@ -2416,12 +2416,12 @@ MATCH TypeInstance::deduceType(Scope *sc, j = templateParameterLookup(t2, parameters); if (j == -1) goto Lnomatch; - TemplateParameter *tp = (TemplateParameter *)parameters->data[j]; + TemplateParameter *tp = parameters->tdata()[j]; // BUG: use tp->matchArg() instead of the following TemplateAliasParameter *ta = tp->isTemplateAliasParameter(); if (!ta) goto Lnomatch; - Dsymbol *s = (Dsymbol *)dedtypes->data[j]; + Dsymbol *s = (Dsymbol *)dedtypes->tdata()[j]; if (s) { if (!s1->equals(s)) @@ -2429,7 +2429,7 @@ MATCH TypeInstance::deduceType(Scope *sc, } else { - dedtypes->data[j] = s1; + dedtypes->tdata()[j] = s1; } } else if (s1 && s2) @@ -2474,7 +2474,7 @@ MATCH TypeStruct::deduceType(Scope *sc, Type *tparam, TemplateParameters *parame */ TypeInstance *tpi = (TypeInstance *)tparam; if (tpi->idents.dim) - { Identifier *id = (Identifier *)tpi->idents.data[tpi->idents.dim - 1]; + { Identifier *id = tpi->idents.tdata()[tpi->idents.dim - 1]; if (id->dyncast() == DYNCAST_IDENTIFIER && sym->ident->equals(id)) { Type *tparent = sym->parent->getType(); @@ -2556,7 +2556,7 @@ void deduceBaseClassParameters(BaseClass *b, // Make a temporary copy of dedtypes so we don't destroy it Objects *tmpdedtypes = new Objects(); tmpdedtypes->setDim(dedtypes->dim); - memcpy(tmpdedtypes->data, dedtypes->data, dedtypes->dim * sizeof(void *)); + memcpy(tmpdedtypes->tdata(), dedtypes->tdata(), dedtypes->dim * sizeof(void *)); TypeInstance *t = new TypeInstance(0, parti); MATCH m = t->deduceType(sc, tparam, parameters, tmpdedtypes); @@ -2564,13 +2564,13 @@ void deduceBaseClassParameters(BaseClass *b, { // If this is the first ever match, it becomes our best estimate if (numBaseClassMatches==0) - memcpy(best->data, tmpdedtypes->data, tmpdedtypes->dim * sizeof(void *)); + memcpy(best->tdata(), tmpdedtypes->tdata(), tmpdedtypes->dim * sizeof(void *)); else for (size_t k = 0; k < tmpdedtypes->dim; ++k) { // If we've found more than one possible type for a parameter, // mark it as unknown. - if (tmpdedtypes->data[k] != best->data[k]) - best->data[k] = dedtypes->data[k]; + if (tmpdedtypes->tdata()[k] != best->tdata()[k]) + best->tdata()[k] = dedtypes->tdata()[k]; } ++numBaseClassMatches; } @@ -2612,7 +2612,7 @@ MATCH TypeClass::deduceType(Scope *sc, Type *tparam, TemplateParameters *paramet */ TypeInstance *tpi = (TypeInstance *)tparam; if (tpi->idents.dim) - { Identifier *id = (Identifier *)tpi->idents.data[tpi->idents.dim - 1]; + { Identifier *id = tpi->idents.tdata()[tpi->idents.dim - 1]; if (id->dyncast() == DYNCAST_IDENTIFIER && sym->ident->equals(id)) { Type *tparent = sym->parent->getType(); @@ -2648,7 +2648,7 @@ MATCH TypeClass::deduceType(Scope *sc, Type *tparam, TemplateParameters *paramet while(s && s->baseclasses->dim > 0) { // Test the base class - deduceBaseClassParameters((BaseClass *)(s->baseclasses->data[0]), + deduceBaseClassParameters((s->baseclasses->tdata()[0]), sc, tparam, parameters, dedtypes, best, numBaseClassMatches); @@ -2659,14 +2659,14 @@ MATCH TypeClass::deduceType(Scope *sc, Type *tparam, TemplateParameters *paramet deduceBaseClassParameters(b, sc, tparam, parameters, dedtypes, best, numBaseClassMatches); } - s = ((BaseClass *)(s->baseclasses->data[0]))->base; + s = ((s->baseclasses->tdata()[0]))->base; } if (numBaseClassMatches == 0) return MATCHnomatch; // If we got at least one match, copy the known types into dedtypes - memcpy(dedtypes->data, best->data, best->dim * sizeof(void *)); + memcpy(dedtypes->tdata(), best->tdata(), best->dim * sizeof(void *)); return MATCHconvert; } @@ -2818,14 +2818,14 @@ MATCH TemplateTypeParameter::matchArg(Scope *sc, Objects *tiargs, Type *ta; if (i < tiargs->dim) - oarg = (Object *)tiargs->data[i]; + oarg = tiargs->tdata()[i]; else { // Get default argument instead oarg = defaultArg(loc, sc); if (!oarg) { assert(i < dedtypes->dim); // It might have already been deduced - oarg = (Object *)dedtypes->data[i]; + oarg = dedtypes->tdata()[i]; if (!oarg) { goto Lnomatch; @@ -2842,7 +2842,7 @@ MATCH TemplateTypeParameter::matchArg(Scope *sc, Objects *tiargs, } //printf("ta is %s\n", ta->toChars()); - t = (Type *)dedtypes->data[i]; + t = (Type *)dedtypes->tdata()[i]; if (specType) { @@ -2855,7 +2855,7 @@ MATCH TemplateTypeParameter::matchArg(Scope *sc, Objects *tiargs, if (m2 < m) m = m2; - t = (Type *)dedtypes->data[i]; + t = (Type *)dedtypes->tdata()[i]; } else { @@ -2881,7 +2881,7 @@ MATCH TemplateTypeParameter::matchArg(Scope *sc, Objects *tiargs, if (!t) { - dedtypes->data[i] = ta; + dedtypes->tdata()[i] = ta; t = ta; } *psparam = new AliasDeclaration(loc, ident, t); @@ -3098,14 +3098,14 @@ MATCH TemplateAliasParameter::matchArg(Scope *sc, //printf("TemplateAliasParameter::matchArg()\n"); if (i < tiargs->dim) - oarg = (Object *)tiargs->data[i]; + oarg = tiargs->tdata()[i]; else { // Get default argument instead oarg = defaultArg(loc, sc); if (!oarg) { assert(i < dedtypes->dim); // It might have already been deduced - oarg = (Object *)dedtypes->data[i]; + oarg = dedtypes->tdata()[i]; if (!oarg) goto Lnomatch; } @@ -3147,14 +3147,14 @@ MATCH TemplateAliasParameter::matchArg(Scope *sc, if (sa != specAlias) goto Lnomatch; } - else if (dedtypes->data[i]) + else if (dedtypes->tdata()[i]) { // Must match already deduced symbol - Object *s = (Object *)dedtypes->data[i]; + Object *s = dedtypes->tdata()[i]; if (!sa || s != sa) goto Lnomatch; } - dedtypes->data[i] = sa; + dedtypes->tdata()[i] = sa; s = isDsymbol(sa); if (s) @@ -3363,14 +3363,14 @@ MATCH TemplateValueParameter::matchArg(Scope *sc, Object *oarg; if (i < tiargs->dim) - oarg = (Object *)tiargs->data[i]; + oarg = tiargs->tdata()[i]; else { // Get default argument instead oarg = defaultArg(loc, sc); if (!oarg) { assert(i < dedtypes->dim); // It might have already been deduced - oarg = (Object *)dedtypes->data[i]; + oarg = dedtypes->tdata()[i]; if (!oarg) goto Lnomatch; } @@ -3408,9 +3408,9 @@ MATCH TemplateValueParameter::matchArg(Scope *sc, if (!ei->equals(e)) goto Lnomatch; } - else if (dedtypes->data[i]) + else if (dedtypes->tdata()[i]) { // Must match already deduced value - Expression *e = (Expression *)dedtypes->data[i]; + Expression *e = (Expression *)dedtypes->tdata()[i]; if (!ei || !ei->equals(e)) goto Lnomatch; @@ -3427,7 +3427,7 @@ MATCH TemplateValueParameter::matchArg(Scope *sc, if (!m) goto Lnomatch; } - dedtypes->data[i] = ei; + dedtypes->tdata()[i] = ei; init = new ExpInitializer(loc, ei); sparam = new VarDeclaration(loc, vt, ident, init); @@ -3564,11 +3564,11 @@ MATCH TemplateTupleParameter::matchArg(Scope *sc, assert(i + 1 == dedtypes->dim); // must be the last one Tuple *ovar; - if (dedtypes->data[i] && isTuple((Object *)dedtypes->data[i])) + if (dedtypes->tdata()[i] && isTuple(dedtypes->tdata()[i])) // It was already been deduced - ovar = isTuple((Object *)dedtypes->data[i]); - else if (i + 1 == tiargs->dim && isTuple((Object *)tiargs->data[i])) - ovar = isTuple((Object *)tiargs->data[i]); + ovar = isTuple(dedtypes->tdata()[i]); + else if (i + 1 == tiargs->dim && isTuple(tiargs->tdata()[i])) + ovar = isTuple(tiargs->tdata()[i]); else { ovar = new Tuple(); @@ -3578,11 +3578,11 @@ MATCH TemplateTupleParameter::matchArg(Scope *sc, //printf("i = %d, tiargs->dim = %d\n", i, tiargs->dim); ovar->objects.setDim(tiargs->dim - i); for (size_t j = 0; j < ovar->objects.dim; j++) - ovar->objects.data[j] = tiargs->data[i + j]; + ovar->objects.tdata()[j] = tiargs->tdata()[i + j]; } } *psparam = new TupleDeclaration(loc, ident, &ovar->objects); - dedtypes->data[i] = (void *)ovar; + dedtypes->tdata()[i] = ovar; return MATCHexact; } @@ -3599,7 +3599,7 @@ void TemplateTupleParameter::print(Object *oarg, Object *oded) if (i) printf(", "); - Object *o = (Object *)v->objects.data[i]; + Object *o = v->objects.tdata()[i]; Dsymbol *sa = isDsymbol(o); if (sa) @@ -3707,7 +3707,7 @@ Objects *TemplateInstance::arraySyntaxCopy(Objects *objs) a->setDim(objs->dim); for (size_t i = 0; i < objs->dim; i++) { - a->data[i] = objectSyntaxCopy((Object *)objs->data[i]); + a->tdata()[i] = objectSyntaxCopy(objs->tdata()[i]); } } return a; @@ -3823,7 +3823,7 @@ void TemplateInstance::semantic(Scope *sc, Expressions *fargs) for (size_t i = 0; i < tempdecl->instances.dim; i++) { - TemplateInstance *ti = (TemplateInstance *)tempdecl->instances.data[i]; + TemplateInstance *ti = tempdecl->instances.tdata()[i]; #if LOG printf("\t%s: checking for match with instance %d (%p): '%s'\n", toChars(), i, ti, ti->toChars()); #endif @@ -3854,7 +3854,7 @@ void TemplateInstance::semantic(Scope *sc, Expressions *fargs) size_t nfparams = Parameter::dim(fparameters); // Num function parameters for (int i = 0; i < nfparams && i < fargs->dim; i++) { Parameter *fparam = Parameter::getNth(fparameters, i); - Expression *farg = (Expression *)fargs->data[i]; + Expression *farg = fargs->tdata()[i]; if (fparam->storageClass & STCauto) // if "auto ref" { if (farg->isLvalue()) @@ -3949,7 +3949,7 @@ void TemplateInstance::semantic(Scope *sc, Expressions *fargs) a->push(this); break; } - if (this == (Dsymbol *)a->data[i]) // if already in Array + if (this == a->tdata()[i]) // if already in Array break; } } @@ -3986,7 +3986,7 @@ void TemplateInstance::semantic(Scope *sc, Expressions *fargs) int memnum = 0; for (int i = 0; i < members->dim; i++) { - Dsymbol *s = (Dsymbol *)members->data[i]; + Dsymbol *s = members->tdata()[i]; #if LOG printf("\t[%d] adding member '%s' %p kind %s to '%s', memnum = %d\n", i, s->toChars(), s, s->kind(), this->toChars(), memnum); #endif @@ -4057,7 +4057,7 @@ void TemplateInstance::semantic(Scope *sc, Expressions *fargs) } for (int i = 0; i < members->dim; i++) { - Dsymbol *s = (Dsymbol *)members->data[i]; + Dsymbol *s = members->tdata()[i]; //printf("\t[%d] semantic on '%s' %p kind %s in '%s'\n", i, s->toChars(), s, s->kind(), this->toChars()); //printf("test: isnested = %d, sc2->parent = %s\n", isnested, sc2->parent->toChars()); // if (isnested) @@ -4083,7 +4083,7 @@ void TemplateInstance::semantic(Scope *sc, Expressions *fargs) * or semantic3() yet. */ for (size_t i = 0; i < Module::deferred.dim; i++) - { Dsymbol *sd = (Dsymbol *)Module::deferred.data[i]; + { Dsymbol *sd = Module::deferred.tdata()[i]; if (sd->parent == this) goto Laftersemantic; @@ -4180,12 +4180,12 @@ void TemplateInstance::semanticTiargs(Loc loc, Scope *sc, Objects *tiargs, int f return; for (size_t j = 0; j < tiargs->dim; j++) { - Object *o = (Object *)tiargs->data[j]; + Object *o = tiargs->tdata()[j]; Type *ta = isType(o); Expression *ea = isExpression(o); Dsymbol *sa = isDsymbol(o); - //printf("1: tiargs->data[%d] = %p, %p, %p, ea=%p, ta=%p\n", j, o, isDsymbol(o), isTuple(o), ea, ta); + //printf("1: tiargs->tdata()[%d] = %p, %p, %p, ea=%p, ta=%p\n", j, o, isDsymbol(o), isTuple(o), ea, ta); if (ta) { //printf("type %s\n", ta->toChars()); @@ -4203,10 +4203,10 @@ void TemplateInstance::semanticTiargs(Loc loc, Scope *sc, Objects *tiargs, int f ea = ea->optimize(WANTvalue); else if (ea->op != TOKvar) ea = ea->optimize(WANTvalue | WANTinterpret); - tiargs->data[j] = ea; + tiargs->tdata()[j] = ea; } else if (sa) - { tiargs->data[j] = sa; + { tiargs->tdata()[j] = sa; TupleDeclaration *d = sa->toAlias()->isTupleDeclaration(); if (d) { @@ -4227,19 +4227,19 @@ void TemplateInstance::semanticTiargs(Loc loc, Scope *sc, Objects *tiargs, int f if (dim) { tiargs->reserve(dim); for (size_t i = 0; i < dim; i++) - { Parameter *arg = (Parameter *)tt->arguments->data[i]; + { Parameter *arg = tt->arguments->tdata()[i]; tiargs->insert(j + i, arg->type); } } j--; } else - tiargs->data[j] = ta; + tiargs->tdata()[j] = ta; } else { assert(global.errors); - tiargs->data[j] = Type::terror; + tiargs->tdata()[j] = Type::terror; } } else if (ea) @@ -4254,7 +4254,7 @@ void TemplateInstance::semanticTiargs(Loc loc, Scope *sc, Objects *tiargs, int f ea = ea->optimize(WANTvalue); else if (ea->op != TOKvar) ea = ea->optimize(WANTvalue | WANTinterpret); - tiargs->data[j] = ea; + tiargs->tdata()[j] = ea; if (ea->op == TOKtype) { ta = ea->type; goto Ltype; @@ -4282,13 +4282,13 @@ void TemplateInstance::semanticTiargs(Loc loc, Scope *sc, Objects *tiargs, int f { assert(0); } - //printf("1: tiargs->data[%d] = %p\n", j, tiargs->data[j]); + //printf("1: tiargs->tdata()[%d] = %p\n", j, tiargs->tdata()[j]); } #if 0 printf("-TemplateInstance::semanticTiargs()\n"); for (size_t j = 0; j < tiargs->dim; j++) { - Object *o = (Object *)tiargs->data[j]; + Object *o = tiargs->tdata()[j]; Type *ta = isType(o); Expression *ea = isExpression(o); Dsymbol *sa = isDsymbol(o); @@ -4335,7 +4335,7 @@ TemplateDeclaration *TemplateInstance::findTemplateDeclaration(Scope *sc) if (os) { s = NULL; for (int i = 0; i < os->a.dim; i++) - { Dsymbol *s2 = (Dsymbol *)os->a.data[i]; + { Dsymbol *s2 = os->a.tdata()[i]; if (s2->isTemplateDeclaration()) { if (s) @@ -4459,7 +4459,7 @@ TemplateDeclaration *TemplateInstance::findBestMatch(Scope *sc) { MATCH m; -//if (tiargs->dim) printf("2: tiargs->dim = %d, data[0] = %p\n", tiargs->dim, tiargs->data[0]); +//if (tiargs->dim) printf("2: tiargs->dim = %d, data[0] = %p\n", tiargs->dim, tiargs->tdata()[0]); // If more arguments than parameters, // then this is no match. @@ -4509,7 +4509,7 @@ TemplateDeclaration *TemplateInstance::findBestMatch(Scope *sc) td_best = td; m_best = m; tdtypes.setDim(dedtypes.dim); - memcpy(tdtypes.data, dedtypes.data, tdtypes.dim * sizeof(void *)); + memcpy(tdtypes.tdata(), dedtypes.tdata(), tdtypes.dim * sizeof(void *)); continue; } @@ -4538,9 +4538,9 @@ TemplateDeclaration *TemplateInstance::findBestMatch(Scope *sc) /* Cast any value arguments to be same type as value parameter */ for (size_t i = 0; i < tiargs->dim; i++) - { Object *o = (Object *)tiargs->data[i]; + { Object *o = tiargs->tdata()[i]; Expression *ea = isExpression(o); // value argument - TemplateParameter *tp = (TemplateParameter *)tempdecl->parameters->data[i]; + TemplateParameter *tp = tempdecl->parameters->tdata()[i]; assert(tp); TemplateValueParameter *tvp = tp->isTemplateValueParameter(); if (tvp) @@ -4548,7 +4548,7 @@ TemplateDeclaration *TemplateInstance::findBestMatch(Scope *sc) assert(ea); ea = ea->castTo(tvp->valType); ea = ea->optimize(WANTvalue | WANTinterpret); - tiargs->data[i] = (Object *)ea; + tiargs->tdata()[i] = (Object *)ea; } } #endif @@ -4573,7 +4573,7 @@ int TemplateInstance::hasNestedArgs(Objects *args) * symbol that is on the stack. */ for (size_t i = 0; i < args->dim; i++) - { Object *o = (Object *)args->data[i]; + { Object *o = args->tdata()[i]; Expression *ea = isExpression(o); Dsymbol *sa = isDsymbol(o); Tuple *va = isTuple(o); @@ -4658,7 +4658,7 @@ Identifier *TemplateInstance::genIdent(Objects *args) char *id = tempdecl->ident->toChars(); buf.printf("__T%zu%s", strlen(id), id); for (int i = 0; i < args->dim; i++) - { Object *o = (Object *)args->data[i]; + { Object *o = args->tdata()[i]; Type *ta = isType(o); Expression *ea = isExpression(o); Dsymbol *sa = isDsymbol(o); @@ -4709,7 +4709,7 @@ Identifier *TemplateInstance::genIdent(Objects *args) buf.writestring(ea->type->deco); #else // Use type of parameter, not type of argument - TemplateParameter *tp = (TemplateParameter *)tempdecl->parameters->data[i]; + TemplateParameter *tp = tempdecl->parameters->tdata()[i]; assert(tp); TemplateValueParameter *tvp = tp->isTemplateValueParameter(); assert(tvp); @@ -4775,9 +4775,9 @@ void TemplateInstance::declareParameters(Scope *sc) //printf("TemplateInstance::declareParameters()\n"); for (int i = 0; i < tdtypes.dim; i++) { - TemplateParameter *tp = (TemplateParameter *)tempdecl->parameters->data[i]; - //Object *o = (Object *)tiargs->data[i]; - Object *o = (Object *)tdtypes.data[i]; // initializer for tp + TemplateParameter *tp = tempdecl->parameters->tdata()[i]; + //Object *o = tiargs->tdata()[i]; + Object *o = tdtypes.tdata()[i]; // initializer for tp //printf("\ttdtypes[%d] = %p\n", i, o); tempdecl->declareParameter(sc, tp, o); @@ -4849,7 +4849,7 @@ void TemplateInstance::semantic2(Scope *sc) sc->tinst = this; for (i = 0; i < members->dim; i++) { - Dsymbol *s = (Dsymbol *)members->data[i]; + Dsymbol *s = members->tdata()[i]; #if LOG printf("\tmember '%s', kind = '%s'\n", s->toChars(), s->kind()); #endif @@ -4880,7 +4880,7 @@ void TemplateInstance::semantic3(Scope *sc) sc->tinst = this; for (int i = 0; i < members->dim; i++) { - Dsymbol *s = (Dsymbol *)members->data[i]; + Dsymbol *s = members->tdata()[i]; s->semantic3(sc); } sc = sc->pop(); @@ -4979,7 +4979,7 @@ void TemplateInstance::toObjFile(int multiobj) { for (int i = 0; i < members->dim; i++) { - Dsymbol *s = (Dsymbol *)members->data[i]; + Dsymbol *s = members->tdata()[i]; s->toObjFile(multiobj); } } @@ -4995,7 +4995,7 @@ void TemplateInstance::inlineScan() { for (int i = 0; i < members->dim; i++) { - Dsymbol *s = (Dsymbol *)members->data[i]; + Dsymbol *s = members->tdata()[i]; s->inlineScan(); } } @@ -5018,7 +5018,7 @@ void TemplateInstance::toCBuffer(OutBuffer *buf, HdrGenState *hgs) { if (i) buf->writeByte(','); - Object *oarg = (Object *)args->data[i]; + Object *oarg = args->tdata()[i]; ObjectToCBuffer(buf, hgs, oarg); } nest--; @@ -5081,7 +5081,7 @@ char *TemplateInstance::toChars() TemplateMixin::TemplateMixin(Loc loc, Identifier *ident, Type *tqual, Identifiers *idents, Objects *tiargs) - : TemplateInstance(loc, (Identifier *)idents->data[idents->dim - 1]) + : TemplateInstance(loc, idents->tdata()[idents->dim - 1]) { //printf("TemplateMixin(ident = '%s')\n", ident ? ident->toChars() : ""); this->ident = ident; @@ -5097,7 +5097,7 @@ Dsymbol *TemplateMixin::syntaxCopy(Dsymbol *s) ids->setDim(idents->dim); for (int i = 0; i < idents->dim; i++) { // Matches TypeQualified::syntaxCopyHelper() - Identifier *id = (Identifier *)idents->data[i]; + Identifier *id = idents->tdata()[i]; if (id->dyncast() == DYNCAST_DSYMBOL) { TemplateInstance *ti = (TemplateInstance *)id; @@ -5105,7 +5105,7 @@ Dsymbol *TemplateMixin::syntaxCopy(Dsymbol *s) ti = (TemplateInstance *)ti->syntaxCopy(NULL); id = (Identifier *)ti; } - ids->data[i] = id; + ids->tdata()[i] = id; } tm = new TemplateMixin(loc, ident, @@ -5162,7 +5162,7 @@ void TemplateMixin::semantic(Scope *sc) else { i = 1; - id = (Identifier *)idents->data[0]; + id = idents->tdata()[0]; switch (id->dyncast()) { case DYNCAST_IDENTIFIER: @@ -5185,7 +5185,7 @@ void TemplateMixin::semantic(Scope *sc) { if (!s) break; - id = (Identifier *)idents->data[i]; + id = idents->tdata()[i]; s = s->searchX(loc, sc, id); } if (!s) @@ -5263,11 +5263,11 @@ void TemplateMixin::semantic(Scope *sc) continue; for (int i = 0; i < tiargs->dim; i++) - { Object *o = (Object *)tiargs->data[i]; + { Object *o = tiargs->tdata()[i]; Type *ta = isType(o); Expression *ea = isExpression(o); Dsymbol *sa = isDsymbol(o); - Object *tmo = (Object *)tm->tiargs->data[i]; + Object *tmo = tm->tiargs->tdata()[i]; if (ta) { Type *tmta = isType(tmo); @@ -5334,7 +5334,7 @@ void TemplateMixin::semantic(Scope *sc) for (unsigned i = 0; i < members->dim; i++) { Dsymbol *s; - s = (Dsymbol *)members->data[i]; + s = members->tdata()[i]; s->addMember(argscope, this, i); //sc->insert(s); //printf("sc->parent = %p, sc->scopesym = %p\n", sc->parent, sc->scopesym); @@ -5360,7 +5360,7 @@ void TemplateMixin::semantic(Scope *sc) for (int i = 0; i < members->dim; i++) { - Dsymbol *s = (Dsymbol *)members->data[i]; + Dsymbol *s = members->tdata()[i]; s->semantic(sc2); } @@ -5416,7 +5416,7 @@ void TemplateMixin::semantic2(Scope *sc) sc = sc->push(this); for (i = 0; i < members->dim; i++) { - Dsymbol *s = (Dsymbol *)members->data[i]; + Dsymbol *s = members->tdata()[i]; #if LOG printf("\tmember '%s', kind = '%s'\n", s->toChars(), s->kind()); #endif @@ -5445,7 +5445,7 @@ void TemplateMixin::semantic3(Scope *sc) sc = sc->push(this); for (i = 0; i < members->dim; i++) { - Dsymbol *s = (Dsymbol *)members->data[i]; + Dsymbol *s = members->tdata()[i]; s->semantic3(sc); } sc = sc->pop(); @@ -5473,7 +5473,7 @@ int TemplateMixin::hasPointers() //printf("TemplateMixin::hasPointers() %s\n", toChars()); for (size_t i = 0; i < members->dim; i++) { - Dsymbol *s = (Dsymbol *)members->data[i]; + Dsymbol *s = members->tdata()[i]; //printf(" s = %s %s\n", s->kind(), s->toChars()); if (s->hasPointers()) { @@ -5500,7 +5500,7 @@ void TemplateMixin::toCBuffer(OutBuffer *buf, HdrGenState *hgs) buf->writestring("mixin "); for (int i = 0; i < idents->dim; i++) - { Identifier *id = (Identifier *)idents->data[i]; + { Identifier *id = idents->tdata()[i]; if (i) buf->writeByte('.'); @@ -5512,7 +5512,7 @@ void TemplateMixin::toCBuffer(OutBuffer *buf, HdrGenState *hgs) for (int i = 0; i < tiargs->dim; i++) { if (i) buf->writebyte(','); - Object *oarg = (Object *)tiargs->data[i]; + Object *oarg = tiargs->tdata()[i]; Type *t = isType(oarg); Expression *e = isExpression(oarg); Dsymbol *s = isDsymbol(oarg); diff --git a/src/tk/mem.c b/src/tk/mem.c index 89f8e82007b6..462b2aacc55f 100644 --- a/src/tk/mem.c +++ b/src/tk/mem.c @@ -342,7 +342,7 @@ static struct mem_debug #define mem_ptrtodl(p) ((struct mem_debug *) ((char *)p - offsetof(struct mem_debug,data[0]))) /* Convert from a mem_debug struct to a mem_ptr. */ -#define mem_dltoptr(dl) ((void *) &((dl)->data[0])) +#define mem_dltoptr(dl) ( &((dl)->tdata()[0])) /***************************** * Set new value of file,line @@ -439,9 +439,9 @@ void *mem_calloc_debug(unsigned n, const char *fil, int lin) dl->Mnbytes = n; dl->Mbeforeval = BEFOREVAL; #if SUN || SUN386 /* bus error if we store a long at an odd address */ - memcpy(&(dl->data[n]),&afterval,sizeof(AFTERVAL)); + memcpy(&(dl->tdata()[n]),&afterval,sizeof(AFTERVAL)); #else - *(long *) &(dl->data[n]) = AFTERVAL; + * &(dl->tdata()[n]) = AFTERVAL; #endif /* Add dl to start of allocation list */ @@ -476,9 +476,9 @@ void mem_free_debug(void *ptr, const char *fil, int lin) goto err2; } #if SUN || SUN386 /* Bus error if we read a long from an odd address */ - if (memcmp(&dl->data[dl->Mnbytes],&afterval,sizeof(AFTERVAL)) != 0) + if (memcmp(&dl->tdata()[dl->Mnbytes],&afterval,sizeof(AFTERVAL)) != 0) #else - if (*(long *) &dl->data[dl->Mnbytes] != AFTERVAL) + if (* &dl->tdata()[dl->Mnbytes] != AFTERVAL) #endif { PRINT "Pointer x%lx overrun\n",(long)ptr); @@ -563,9 +563,9 @@ static void mem_checkdl(struct mem_debug *dl) goto err2; } #if SUN || SUN386 /* Bus error if we read a long from an odd address */ - if (memcmp(&dl->data[dl->Mnbytes],&afterval,sizeof(AFTERVAL)) != 0) + if (memcmp(&dl->tdata()[dl->Mnbytes],&afterval,sizeof(AFTERVAL)) != 0) #else - if (*(long *) &dl->data[dl->Mnbytes] != AFTERVAL) + if (* &dl->tdata()[dl->Mnbytes] != AFTERVAL) #endif { PRINT "Pointer x%lx overrun\n",(long)p); @@ -600,7 +600,7 @@ void mem_checkptr(void *p) for (dl = mem_alloclist.Mnext; dl != NULL; dl = dl->Mnext) { - if (p >= (void *) &(dl->data[0]) && + if (p >= &(dl->tdata()[0]) && p < (void *)((char *)dl + sizeof(struct mem_debug)-1 + dl->Mnbytes)) goto L1; } diff --git a/src/tocsym.c b/src/tocsym.c index 43eec3ebd707..ef7fc475be0f 100644 --- a/src/tocsym.c +++ b/src/tocsym.c @@ -785,7 +785,7 @@ Symbol *TypeAArray::aaGetSymbol(const char *func, int flags) // See if symbol is already in sarray for (i = 0; i < sarray->dim; i++) - { s = (Symbol *)sarray->data[i]; + { s = sarray->tdata()[i]; if (strcmp(id, s->Sident) == 0) return s; // use existing Symbol } diff --git a/src/toctype.c b/src/toctype.c index ddc181a2f3bb..6a3c49589269 100644 --- a/src/toctype.c +++ b/src/toctype.c @@ -378,7 +378,7 @@ type *TypeStruct::toCtype() */ if (global.params.symdebug) for (int i = 0; i < sym->fields.dim; i++) - { VarDeclaration *v = (VarDeclaration *)sym->fields.data[i]; + { VarDeclaration *v = sym->fields.tdata()[i]; Symbol *s2 = symbol_name(v->ident->toChars(), SCmember, v->type->toCtype()); s2->Smemoff = v->offset; @@ -505,7 +505,7 @@ type *TypeClass::toCtype() */ if (global.params.symdebug) for (int i = 0; i < sym->fields.dim; i++) - { VarDeclaration *v = (VarDeclaration *)sym->fields.data[i]; + { VarDeclaration *v = sym->fields.tdata()[i]; Symbol *s2 = symbol_name(v->ident->toChars(), SCmember, v->type->toCtype()); s2->Smemoff = v->offset; diff --git a/src/tocvdebug.c b/src/tocvdebug.c index 14ad2a7a730a..3311f16c26c7 100644 --- a/src/tocvdebug.c +++ b/src/tocvdebug.c @@ -148,7 +148,7 @@ unsigned cv4_Denum(EnumDeclaration *e) if (e->members) { for (i = 0; i < e->members->dim; i++) - { EnumMember *sf = ((Dsymbol *)e->members->data[i])->isEnumMember(); + { EnumMember *sf = (e->members->tdata()[i])->isEnumMember(); dinteger_t value; if (sf) @@ -187,7 +187,7 @@ unsigned cv4_Denum(EnumDeclaration *e) int j = 2; int fieldi = 0; for (i = 0; i < e->members->dim; i++) - { EnumMember *sf = ((Dsymbol *)e->members->data[i])->isEnumMember(); + { EnumMember *sf = (e->members->tdata()[i])->isEnumMember(); dinteger_t value; if (sf) @@ -363,7 +363,7 @@ void StructDeclaration::toDebug() count = nfields; for (i = 0; i < members->dim; i++) - { Dsymbol *s = (Dsymbol *)members->data[i]; + { Dsymbol *s = members->tdata()[i]; int nwritten; nwritten = s->cvMember(NULL); @@ -386,7 +386,7 @@ void StructDeclaration::toDebug() TOWORD(p,LF_FIELDLIST); p += 2; for (i = 0; i < members->dim; i++) - { Dsymbol *s = (Dsymbol *)members->data[i]; + { Dsymbol *s = members->tdata()[i]; p += s->cvMember(p); } @@ -496,7 +496,7 @@ void ClassDeclaration::toDebug() //if (intsize == 4) descriptor |= 5; - vshape->data[4 + n / 2] = descriptor; + vshape->tdata()[4 + n / 2] = descriptor; descriptor <<= 4; n++; } @@ -528,7 +528,7 @@ void ClassDeclaration::toDebug() // Add in base classes for (i = 0; i < baseclasses->dim; i++) - { BaseClass *bc = (BaseClass *)baseclasses->data[i]; + { BaseClass *bc = baseclasses->tdata()[i]; nfields++; fnamelen += 6 + cv4_numericbytes(bc->offset); @@ -536,7 +536,7 @@ void ClassDeclaration::toDebug() count = nfields; for (i = 0; i < members->dim; i++) - { Dsymbol *s = (Dsymbol *)members->data[i]; + { Dsymbol *s = members->tdata()[i]; int nwritten; nwritten = s->cvMember(NULL); @@ -561,7 +561,7 @@ void ClassDeclaration::toDebug() // Add in base classes for (i = 0; i < baseclasses->dim; i++) - { BaseClass *bc = (BaseClass *)baseclasses->data[i]; + { BaseClass *bc = baseclasses->tdata()[i]; idx_t typidx; unsigned attribute; @@ -581,7 +581,7 @@ void ClassDeclaration::toDebug() for (i = 0; i < members->dim; i++) - { Dsymbol *s = (Dsymbol *)members->data[i]; + { Dsymbol *s = members->tdata()[i]; p += s->cvMember(p); } diff --git a/src/todt.c b/src/todt.c index 1dcee1f77c8a..b45338412536 100644 --- a/src/todt.c +++ b/src/todt.c @@ -80,20 +80,20 @@ dt_t *StructInitializer::toDt() for (i = 0; i < vars.dim; i++) { - VarDeclaration *v = (VarDeclaration *)vars.data[i]; - Initializer *val = (Initializer *)value.data[i]; + VarDeclaration *v = vars.tdata()[i]; + Initializer *val = value.tdata()[i]; //printf("vars[%d] = %s\n", i, v->toChars()); for (j = 0; 1; j++) { assert(j < dts.dim); - //printf(" adfield[%d] = %s\n", j, ((VarDeclaration *)ad->fields.data[j])->toChars()); - if ((VarDeclaration *)ad->fields.data[j] == v) + //printf(" adfield[%d] = %s\n", j, (ad->fields.tdata()[j])->toChars()); + if (ad->fields.tdata()[j] == v) { - if (dts.data[j]) + if (dts.tdata()[j]) error(loc, "field %s of %s already initialized", v->toChars(), ad->toChars()); - dts.data[j] = (void *)val->toDt(); + dts.tdata()[j] = val->toDt(); break; } } @@ -104,14 +104,14 @@ dt_t *StructInitializer::toDt() offset = 0; for (j = 0; j < dts.dim; j++) { - VarDeclaration *v = (VarDeclaration *)ad->fields.data[j]; + VarDeclaration *v = ad->fields.tdata()[j]; - d = (dt_t *)dts.data[j]; + d = dts.tdata()[j]; if (!d) { // An instance specific initializer was not provided. // Look to see if there's a default initializer from the // struct definition - VarDeclaration *v = (VarDeclaration *)ad->fields.data[j]; + VarDeclaration *v = ad->fields.tdata()[j]; if (v->init) { @@ -130,9 +130,9 @@ dt_t *StructInitializer::toDt() v->type->toDt(&d); break; } - VarDeclaration *v2 = (VarDeclaration *)ad->fields.data[k]; + VarDeclaration *v2 = ad->fields.tdata()[k]; - if (v2->offset < offset2 && dts.data[k]) + if (v2->offset < offset2 && dts.tdata()[k]) break; // overlap } } @@ -214,17 +214,17 @@ dt_t *ArrayInitializer::toDt() { Expression *idx; Initializer *val; - idx = (Expression *)index.data[i]; + idx = index.tdata()[i]; if (idx) length = idx->toInteger(); //printf("\tindex[%d] = %p, length = %u, dim = %u\n", i, idx, length, dim); assert(length < dim); - val = (Initializer *)value.data[i]; + val = value.tdata()[i]; dt = val->toDt(); - if (dts.data[length]) + if (dts.tdata()[length]) error(loc, "duplicate initializations for index %d", length); - dts.data[length] = (void *)dt; + dts.tdata()[length] = dt; length++; } @@ -241,7 +241,7 @@ dt_t *ArrayInitializer::toDt() pdtend = &d; for (i = 0; i < dim; i++) { - dt = (dt_t *)dts.data[i]; + dt = dts.tdata()[i]; if (dt) pdtend = dtcat(pdtend, dt); else @@ -341,7 +341,7 @@ dt_t *ArrayInitializer::toDtBit() if (tb->nextOf()->defaultInit()->toInteger()) databits.set(); - size = sizeof(databits.data[0]); + size = sizeof(databits.tdata()[0]); length = 0; for (i = 0; i < index.dim; i++) @@ -349,7 +349,7 @@ dt_t *ArrayInitializer::toDtBit() Initializer *val; Expression *eval; - idx = (Expression *)index.data[i]; + idx = index.tdata()[i]; if (idx) { dinteger_t value; value = idx->toInteger(); @@ -361,7 +361,7 @@ dt_t *ArrayInitializer::toDtBit() } assert(length < dim); - val = (Initializer *)value.data[i]; + val = value.tdata()[i]; eval = val->toExpression(); if (initbits.test(length)) error(loc, "duplicate initializations for index %d", length); @@ -589,7 +589,7 @@ dt_t **ArrayLiteralExp::toDt(dt_t **pdt) d = NULL; pdtend = &d; for (int i = 0; i < elements->dim; i++) - { Expression *e = (Expression *)elements->data[i]; + { Expression *e = elements->tdata()[i]; pdtend = e->toDt(pdtend); } @@ -642,25 +642,25 @@ dt_t **StructLiteralExp::toDt(dt_t **pdt) for (i = 0; i < elements->dim; i++) { - Expression *e = (Expression *)elements->data[i]; + Expression *e = elements->tdata()[i]; if (!e) continue; dt = NULL; e->toDt(&dt); - dts.data[i] = (void *)dt; + dts.tdata()[i] = dt; } offset = 0; for (j = 0; j < dts.dim; j++) { - VarDeclaration *v = (VarDeclaration *)sd->fields.data[j]; + VarDeclaration *v = sd->fields.tdata()[j]; - d = (dt_t *)dts.data[j]; + d = dts.tdata()[j]; if (!d) { // An instance specific initializer was not provided. // Look to see if there's a default initializer from the // struct definition - VarDeclaration *v = (VarDeclaration *)sd->fields.data[j]; + VarDeclaration *v = sd->fields.tdata()[j]; if (v->init) { @@ -679,9 +679,9 @@ dt_t **StructLiteralExp::toDt(dt_t **pdt) v->type->toDt(&d); break; } - VarDeclaration *v2 = (VarDeclaration *)sd->fields.data[k]; + VarDeclaration *v2 = sd->fields.tdata()[k]; - if (v2->offset < offset2 && dts.data[k]) + if (v2->offset < offset2 && dts.tdata()[k]) break; // overlap } } @@ -836,7 +836,7 @@ void ClassDeclaration::toDt2(dt_t **pdt, ClassDeclaration *cd) // Note equivalence of this loop to struct's for (i = 0; i < fields.dim; i++) { - VarDeclaration *v = (VarDeclaration *)fields.data[i]; + VarDeclaration *v = fields.tdata()[i]; Initializer *init; //printf("\t\tv = '%s' v->offset = %2d, offset = %2d\n", v->toChars(), v->offset, offset); @@ -873,7 +873,7 @@ void ClassDeclaration::toDt2(dt_t **pdt, ClassDeclaration *cd) toSymbol(); // define csym for (i = 0; i < vtblInterfaces->dim; i++) - { BaseClass *b = (BaseClass *)vtblInterfaces->data[i]; + { BaseClass *b = vtblInterfaces->tdata()[i]; #if 1 || INTERFACE_VIRTUAL for (ClassDeclaration *cd2 = cd; 1; cd2 = cd2->baseClass) @@ -914,7 +914,7 @@ void StructDeclaration::toDt(dt_t **pdt) // Note equivalence of this loop to class's for (i = 0; i < fields.dim; i++) { - VarDeclaration *v = (VarDeclaration *)fields.data[i]; + VarDeclaration *v = fields.tdata()[i]; //printf("\tfield '%s' voffset %d, offset = %d\n", v->toChars(), v->offset, offset); dt = NULL; int sz; diff --git a/src/toir.c b/src/toir.c index 79c698a8e526..819f0af60918 100644 --- a/src/toir.c +++ b/src/toir.c @@ -732,7 +732,7 @@ void FuncDeclaration::buildClosure(IRState *irs) unsigned offset = PTRSIZE; // leave room for previous sthis for (int i = 0; i < closureVars.dim; i++) - { VarDeclaration *v = (VarDeclaration *)closureVars.data[i]; + { VarDeclaration *v = closureVars.tdata()[i]; assert(v->isVarDeclaration()); #if DMDV2 @@ -812,7 +812,7 @@ void FuncDeclaration::buildClosure(IRState *irs) // Copy function parameters into closure for (int i = 0; i < closureVars.dim; i++) - { VarDeclaration *v = (VarDeclaration *)closureVars.data[i]; + { VarDeclaration *v = closureVars.tdata()[i]; if (!v->isParameter()) continue; diff --git a/src/toobj.c b/src/toobj.c index eac158e4ed3e..dc4cbf2708e0 100644 --- a/src/toobj.c +++ b/src/toobj.c @@ -69,7 +69,7 @@ void Module::genmoduleinfo() //printf("members->dim = %d\n", members->dim); for (int i = 0; i < members->dim; i++) - { Dsymbol *member = (Dsymbol *)members->data[i]; + { Dsymbol *member = members->tdata()[i]; //printf("\tmember '%s'\n", member->toChars()); member->addLocalClass(&aclasses); @@ -78,7 +78,7 @@ void Module::genmoduleinfo() // importedModules[] int aimports_dim = aimports.dim; for (int i = 0; i < aimports.dim; i++) - { Module *m = (Module *)aimports.data[i]; + { Module *m = aimports.tdata()[i]; if (!m->needmoduleinfo) aimports_dim--; } @@ -142,7 +142,7 @@ void Module::genmoduleinfo() { dtsize_t(&dt, aimports_dim); for (int i = 0; i < aimports.dim; i++) - { Module *m = (Module *)aimports.data[i]; + { Module *m = aimports.tdata()[i]; if (m->needmoduleinfo) { Symbol *s = m->toSymbol(); @@ -163,7 +163,7 @@ void Module::genmoduleinfo() dtsize_t(&dt, aclasses.dim); for (int i = 0; i < aclasses.dim; i++) { - ClassDeclaration *cd = (ClassDeclaration *)aclasses.data[i]; + ClassDeclaration *cd = aclasses.tdata()[i]; dtxoff(&dt, cd->toSymbol(), 0, TYnptr); } } @@ -216,7 +216,7 @@ void Module::genmoduleinfo() //printf("members->dim = %d\n", members->dim); for (int i = 0; i < members->dim; i++) - { Dsymbol *member = (Dsymbol *)members->data[i]; + { Dsymbol *member = members->tdata()[i]; //printf("\tmember '%s'\n", member->toChars()); member->addLocalClass(&aclasses); @@ -225,7 +225,7 @@ void Module::genmoduleinfo() // importedModules[] int aimports_dim = aimports.dim; for (int i = 0; i < aimports.dim; i++) - { Module *m = (Module *)aimports.data[i]; + { Module *m = aimports.tdata()[i]; if (!m->needModuleInfo()) aimports_dim--; } @@ -294,7 +294,7 @@ void Module::genmoduleinfo() ////////////////////////////////////////////// for (int i = 0; i < aimports.dim; i++) - { Module *m = (Module *)aimports.data[i]; + { Module *m = aimports.tdata()[i]; if (m->needModuleInfo()) { Symbol *s = m->toSymbol(); @@ -312,7 +312,7 @@ void Module::genmoduleinfo() for (int i = 0; i < aclasses.dim; i++) { - ClassDeclaration *cd = (ClassDeclaration *)aclasses.data[i]; + ClassDeclaration *cd = aclasses.data()[i]; dtxoff(&dt, cd->toSymbol(), 0, TYnptr); } #endif @@ -369,7 +369,7 @@ void ClassDeclaration::toObjFile(int multiobj) { Dsymbol *member; - member = (Dsymbol *)members->data[i]; + member = members->tdata()[i]; member->toObjFile(0); } @@ -384,7 +384,7 @@ void ClassDeclaration::toObjFile(int multiobj) case 1: // One destructor, just use it directly - sdtor = ((DtorDeclaration *)dtors.data[0])->toSymbol(); + sdtor = dtors.tdata()[0]->toSymbol(); break; default: @@ -405,7 +405,7 @@ void ClassDeclaration::toObjFile(int multiobj) // Call each of the destructors in dtors[] // in reverse order for (i = 0; i < dtors.dim; i++) - { DtorDeclaration *d = (DtorDeclaration *)dtors.data[i]; + { DtorDeclaration *d = dtors.tdata()[i]; Symbol *s = d->toSymbol(); elem *e = el_bin(OPcall, TYvoid, el_var(s), el_var(sthis)); edtor = el_combine(e, edtor); @@ -561,7 +561,7 @@ void ClassDeclaration::toObjFile(int multiobj) { for (size_t i = 0; i < cd->members->dim; i++) { - Dsymbol *sm = (Dsymbol *)cd->members->data[i]; + Dsymbol *sm = cd->members->tdata()[i]; //printf("sm = %s %s\n", sm->kind(), sm->toChars()); if (sm->hasPointers()) goto L2; @@ -601,12 +601,12 @@ void ClassDeclaration::toObjFile(int multiobj) ////////////////////////////////////////////// - // Put out vtblInterfaces->data[]. Must immediately follow csym, because + // Put out vtblInterfaces->tdata()[]. Must immediately follow csym, because // of the fixup (*) offset += vtblInterfaces->dim * (4 * PTRSIZE); for (i = 0; i < vtblInterfaces->dim; i++) - { BaseClass *b = (BaseClass *)vtblInterfaces->data[i]; + { BaseClass *b = vtblInterfaces->tdata()[i]; ClassDeclaration *id = b->base; /* The layout is: @@ -632,11 +632,11 @@ void ClassDeclaration::toObjFile(int multiobj) offset += id->vtbl.dim * PTRSIZE; } - // Put out the vtblInterfaces->data[].vtbl[] + // Put out the vtblInterfaces->tdata()[].vtbl[] // This must be mirrored with ClassDeclaration::baseVtblOffset() //printf("putting out %d interface vtbl[]s for '%s'\n", vtblInterfaces->dim, toChars()); for (i = 0; i < vtblInterfaces->dim; i++) - { BaseClass *b = (BaseClass *)vtblInterfaces->data[i]; + { BaseClass *b = vtblInterfaces->tdata()[i]; ClassDeclaration *id = b->base; //printf(" interface[%d] is '%s'\n", i, id->toChars()); @@ -655,7 +655,7 @@ void ClassDeclaration::toObjFile(int multiobj) { assert(j < b->vtbl.dim); #if 0 - Object *o = (Object *)b->vtbl.data[j]; + Object *o = b->vtbl.tdata()[j]; if (o) { printf("o = %p\n", o); @@ -664,7 +664,7 @@ void ClassDeclaration::toObjFile(int multiobj) printf("s->kind() = '%s'\n", s->kind()); } #endif - FuncDeclaration *fd = (FuncDeclaration *)b->vtbl.data[j]; + FuncDeclaration *fd = b->vtbl.tdata()[j]; if (fd) dtxoff(&dt, fd->toThunkSymbol(b->offset), 0, TYnptr); else @@ -682,7 +682,7 @@ void ClassDeclaration::toObjFile(int multiobj) for (cd = this->baseClass; cd; cd = cd->baseClass) { for (int k = 0; k < cd->vtblInterfaces->dim; k++) - { BaseClass *bs = (BaseClass *)cd->vtblInterfaces->data[k]; + { BaseClass *bs = cd->vtblInterfaces->tdata()[k]; if (bs->fillVtbl(this, &bvtbl, 0)) { @@ -705,7 +705,7 @@ void ClassDeclaration::toObjFile(int multiobj) FuncDeclaration *fd; assert(j < bvtbl.dim); - fd = (FuncDeclaration *)bvtbl.data[j]; + fd = bvtbl.tdata()[j]; if (fd) dtxoff(&dt, fd->toThunkSymbol(bs->offset), 0, TYnptr); else @@ -720,13 +720,13 @@ void ClassDeclaration::toObjFile(int multiobj) // This must be mirrored with ClassDeclaration::baseVtblOffset() //printf("putting out overriding interface vtbl[]s for '%s' at offset x%x\n", toChars(), offset); for (i = 0; i < vtblInterfaces->dim; i++) - { BaseClass *b = (BaseClass *)vtblInterfaces->data[i]; + { BaseClass *b = vtblInterfaces->tdata()[i]; ClassDeclaration *cd; for (cd = this->baseClass; cd; cd = cd->baseClass) { for (int k = 0; k < cd->vtblInterfaces->dim; k++) - { BaseClass *bs = (BaseClass *)cd->vtblInterfaces->data[k]; + { BaseClass *bs = cd->vtblInterfaces->tdata()[k]; if (b->base == bs->base) { @@ -747,7 +747,7 @@ void ClassDeclaration::toObjFile(int multiobj) for (; j < id->vtbl.dim; j++) { assert(j < b->vtbl.dim); - FuncDeclaration *fd = (FuncDeclaration *)b->vtbl.data[j]; + FuncDeclaration *fd = b->vtbl.tdata()[j]; if (fd) dtxoff(&dt, fd->toThunkSymbol(bs->offset), 0, TYnptr); else @@ -782,7 +782,7 @@ void ClassDeclaration::toObjFile(int multiobj) } for (; 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->fbody || !isAbstract())) @@ -805,7 +805,7 @@ void ClassDeclaration::toObjFile(int multiobj) for (int j = 1; j < vtbl.dim; j++) { if (j == i) continue; - FuncDeclaration *fd2 = ((Dsymbol *)vtbl.data[j])->isFuncDeclaration(); + FuncDeclaration *fd2 = vtbl.tdata()[j]->isFuncDeclaration(); if (!fd2->ident->equals(fd->ident)) continue; if (fd->leastAsSpecialized(fd2) || fd2->leastAsSpecialized(fd)) @@ -859,7 +859,7 @@ unsigned ClassDeclaration::baseVtblOffset(BaseClass *bc) for (i = 0; i < vtblInterfaces->dim; i++) { - BaseClass *b = (BaseClass *)vtblInterfaces->data[i]; + BaseClass *b = vtblInterfaces->tdata()[i]; if (b == bc) return csymoffset; @@ -876,7 +876,7 @@ unsigned ClassDeclaration::baseVtblOffset(BaseClass *bc) for (cd = this->baseClass; cd; cd = cd->baseClass) { for (int k = 0; k < cd->vtblInterfaces->dim; k++) - { BaseClass *bs = (BaseClass *)cd->vtblInterfaces->data[k]; + { BaseClass *bs = cd->vtblInterfaces->tdata()[k]; if (bs->fillVtbl(this, NULL, 0)) { @@ -891,14 +891,14 @@ unsigned ClassDeclaration::baseVtblOffset(BaseClass *bc) #endif #if INTERFACE_VIRTUAL for (i = 0; i < vtblInterfaces->dim; i++) - { BaseClass *b = (BaseClass *)vtblInterfaces->data[i]; + { BaseClass *b = vtblInterfaces->tdata()[i]; ClassDeclaration *cd; for (cd = this->baseClass; cd; cd = cd->baseClass) { //printf("\tbase class %s\n", cd->toChars()); for (int k = 0; k < cd->vtblInterfaces->dim; k++) - { BaseClass *bs = (BaseClass *)cd->vtblInterfaces->data[k]; + { BaseClass *bs = cd->vtblInterfaces->tdata()[k]; if (bc == bs) { //printf("\tcsymoffset = x%x\n", csymoffset); @@ -935,7 +935,7 @@ void InterfaceDeclaration::toObjFile(int multiobj) // Put out the members for (i = 0; i < members->dim; i++) - { Dsymbol *member = (Dsymbol *)members->data[i]; + { Dsymbol *member = members->tdata()[i]; member->toObjFile(0); } @@ -998,7 +998,7 @@ void InterfaceDeclaration::toObjFile(int multiobj) dtsize_t(&dt, 0); dtsize_t(&dt, 0); - // vtblInterfaces->data[] + // vtblInterfaces->tdata()[] unsigned offset; dtsize_t(&dt, vtblInterfaces->dim); if (vtblInterfaces->dim) @@ -1051,12 +1051,12 @@ void InterfaceDeclaration::toObjFile(int multiobj) ////////////////////////////////////////////// - // Put out vtblInterfaces->data[]. Must immediately follow csym, because + // Put out vtblInterfaces->tdata()[]. Must immediately follow csym, because // of the fixup (*) offset += vtblInterfaces->dim * (4 * PTRSIZE); for (i = 0; i < vtblInterfaces->dim; i++) - { BaseClass *b = (BaseClass *)vtblInterfaces->data[i]; + { BaseClass *b = vtblInterfaces->tdata()[i]; ClassDeclaration *id = b->base; // ClassInfo @@ -1156,7 +1156,7 @@ void StructDeclaration::toObjFile(int multiobj) { Dsymbol *member; - member = (Dsymbol *)members->data[i]; + member = members->tdata()[i]; member->toObjFile(0); } } diff --git a/src/traits.c b/src/traits.c index e3e18b5a9685..1f8684bb5033 100644 --- a/src/traits.c +++ b/src/traits.c @@ -88,7 +88,7 @@ Expression *TraitsExp::semantic(Scope *sc) #define ISTYPE(cond) \ for (size_t i = 0; i < dim; i++) \ - { Type *t = getType((Object *)args->data[i]); \ + { Type *t = getType(args->tdata()[i]); \ if (!t) \ goto Lfalse; \ if (!(cond)) \ @@ -100,7 +100,7 @@ Expression *TraitsExp::semantic(Scope *sc) #define ISDSYMBOL(cond) \ for (size_t i = 0; i < dim; i++) \ - { Dsymbol *s = getDsymbol((Object *)args->data[i]); \ + { Dsymbol *s = getDsymbol(args->tdata()[i]); \ if (!s) \ goto Lfalse; \ if (!(cond)) \ @@ -186,7 +186,7 @@ Expression *TraitsExp::semantic(Scope *sc) if (dim != 1) goto Ldimerror; - Object *o = (Object *)args->data[0]; + Object *o = args->tdata()[0]; Dsymbol *s = getDsymbol(o); if (!s || !s->ident) { @@ -200,7 +200,7 @@ Expression *TraitsExp::semantic(Scope *sc) { if (dim != 1) goto Ldimerror; - Object *o = (Object *)args->data[0]; + Object *o = args->tdata()[0]; Dsymbol *s = getDsymbol(o); if (s) s = s->toParent(); @@ -220,8 +220,8 @@ Expression *TraitsExp::semantic(Scope *sc) { if (dim != 2) goto Ldimerror; - Object *o = (Object *)args->data[0]; - Expression *e = isExpression((Object *)args->data[1]); + Object *o = args->tdata()[0]; + Expression *e = isExpression(args->tdata()[1]); if (!e) { error("expression expected as second argument of __traits %s", ident->toChars()); goto Lfalse; @@ -312,7 +312,7 @@ Expression *TraitsExp::semantic(Scope *sc) { if (dim != 1) goto Ldimerror; - Object *o = (Object *)args->data[0]; + Object *o = args->tdata()[0]; Dsymbol *s = getDsymbol(o); ClassDeclaration *cd; if (!s || (cd = s->isClassDeclaration()) == NULL) @@ -326,7 +326,7 @@ Expression *TraitsExp::semantic(Scope *sc) { if (dim != 1) goto Ldimerror; - Object *o = (Object *)args->data[0]; + Object *o = args->tdata()[0]; Dsymbol *s = getDsymbol(o); ScopeDsymbol *sd; if (!s) @@ -354,7 +354,7 @@ Expression *TraitsExp::semantic(Scope *sc) /* Skip if already present in exps[] */ for (size_t j = 0; j < exps->dim; j++) - { StringExp *se2 = (StringExp *)exps->data[j]; + { StringExp *se2 = (StringExp *)exps->tdata()[j]; if (strcmp(str, (char *)se2->string) == 0) goto Lnext; } @@ -393,7 +393,7 @@ Expression *TraitsExp::semantic(Scope *sc) goto Lfalse; for (size_t i = 0; i < dim; i++) - { Object *o = (Object *)args->data[i]; + { Object *o = args->tdata()[i]; Expression *e; unsigned errors = global.errors; @@ -433,8 +433,8 @@ Expression *TraitsExp::semantic(Scope *sc) if (dim != 2) goto Ldimerror; TemplateInstance::semanticTiargs(loc, sc, args, 0); - Object *o1 = (Object *)args->data[0]; - Object *o2 = (Object *)args->data[1]; + Object *o1 = args->tdata()[0]; + Object *o2 = args->tdata()[1]; Dsymbol *s1 = getDsymbol(o1); Dsymbol *s2 = getDsymbol(o2); diff --git a/src/typinf.c b/src/typinf.c index b07235fa24be..e6a96779d840 100644 --- a/src/typinf.c +++ b/src/typinf.c @@ -641,7 +641,7 @@ void TypeInfoStructDeclaration::toDt(dt_t **pdt) { if (i < tup->arguments->dim) { - Type *targ = ((Parameter *)tup->arguments->data[i])->type; + Type *targ = (tup->arguments->tdata()[i])->type; targ = targ->merge(); targ->getTypeInfo(NULL); dtxoff(pdt, targ->vtinfo->toSymbol(), 0, TYnptr); // m_argi @@ -712,7 +712,7 @@ void TypeInfoTupleDeclaration::toDt(dt_t **pdt) dt_t *d = NULL; for (size_t i = 0; i < dim; i++) - { Parameter *arg = (Parameter *)tu->arguments->data[i]; + { Parameter *arg = tu->arguments->tdata()[i]; Expression *e = arg->type->getTypeInfo(NULL); e = e->optimize(WANTvalue); e->toDt(&d); @@ -839,7 +839,7 @@ Expression *createTypeInfoArray(Scope *sc, Expression *exps[], int dim) args->setDim(dim); for (size_t i = 0; i < dim; i++) { Parameter *arg = new Parameter(STCin, exps[i]->type, NULL, NULL); - args->data[i] = (void *)arg; + args->tdata()[i] = arg; } TypeTuple *tup = new TypeTuple(args); Expression *e = tup->getTypeInfo(sc); diff --git a/src/version.c b/src/version.c index d4a48dd8989f..37f33c066e14 100644 --- a/src/version.c +++ b/src/version.c @@ -63,7 +63,7 @@ int DebugSymbol::addMember(Scope *sc, ScopeDsymbol *sd, int memnum) if (findCondition(m->debugidsNot, ident)) error("defined after use"); if (!m->debugids) - m->debugids = new Identifiers(); + m->debugids = new Strings(); m->debugids->push(ident->toChars()); } } @@ -144,7 +144,7 @@ int VersionSymbol::addMember(Scope *sc, ScopeDsymbol *sd, int memnum) if (findCondition(m->versionidsNot, ident)) error("defined after use"); if (!m->versionids) - m->versionids = new Identifiers(); + m->versionids = new Strings(); m->versionids->push(ident->toChars()); } }