# HG changeset patch # User Eldar Insafutdinov # Date 1283205634 -3600 # Node ID 3a0b150c9841aa11c3a33df27760e9978c682c68 # Parent df6d0f96768007dc90f1a24dd4f338fc22bf771b Objects -> Vector!Object iteration 1 diff -r df6d0f967680 -r 3a0b150c9841 dmd/Array.d --- a/dmd/Array.d Mon Aug 30 22:50:30 2010 +0200 +++ b/dmd/Array.d Mon Aug 30 23:00:34 2010 +0100 @@ -245,6 +245,12 @@ _data[_dim++] = elem; } + final void zero() + { + memset(_data, 0, dim * T.sizeof); + // TODO fix to assign T.init + } + final void reserve(size_t nentries) { //printf("Array::reserve: size = %d, offset = %d, nbytes = %d\n", size, offset, nbytes); diff -r df6d0f967680 -r 3a0b150c9841 dmd/ArrayTypes.d --- a/dmd/ArrayTypes.d Mon Aug 30 22:50:30 2010 +0200 +++ b/dmd/ArrayTypes.d Mon Aug 30 23:00:34 2010 +0100 @@ -12,7 +12,8 @@ //class Dsymbols : Array { final typeof(this) copy() { auto a = new typeof(this); copyTo(a); return a; } } -class Objects : Array { final typeof(this) copy() { auto a = new typeof(this); copyTo(a); return a; } } +alias Vector!Object Objects; +//class Objects : Array { final typeof(this) copy() { auto a = new typeof(this); copyTo(a); return a; } } class Arguments : Array { final typeof(this) copy() { auto a = new typeof(this); copyTo(a); return a; } } diff -r df6d0f967680 -r 3a0b150c9841 dmd/FuncDeclaration.d --- a/dmd/FuncDeclaration.d Mon Aug 30 22:50:30 2010 +0200 +++ b/dmd/FuncDeclaration.d Mon Aug 30 23:00:34 2010 +0100 @@ -1129,10 +1129,10 @@ VarDeclaration v = sc2.search(Loc(0), narg.ident, null).isVarDeclaration(); assert(v); Expression e = new VarExp(v.loc, v); - exps.data[j] = cast(void*)e; + exps[j] = e; } assert(arg.ident); - TupleDeclaration v = new TupleDeclaration(loc, arg.ident, exps); + auto v = new TupleDeclaration(loc, arg.ident, exps); //printf("declaring tuple %s\n", v.toChars()); v.isexp = 1; if (!sc2.insert(v)) diff -r df6d0f967680 -r 3a0b150c9841 dmd/IsExp.d --- a/dmd/IsExp.d Mon Aug 30 22:50:30 2010 +0200 +++ b/dmd/IsExp.d Mon Aug 30 23:00:34 2010 +0100 @@ -241,7 +241,7 @@ MATCH m; assert(parameters && parameters.dim); - scope Objects dedtypes = new Objects(); + scope dedtypes = new Objects(); dedtypes.setDim(parameters.dim); dedtypes.zero(); @@ -259,7 +259,7 @@ scope Objects tiargs = new Objects(); tiargs.setDim(1); - tiargs.data[0] = cast(void*)targ; + tiargs[0] = targ; /* Declare trailing parameters */ diff -r df6d0f967680 -r 3a0b150c9841 dmd/Parser.d --- a/dmd/Parser.d Mon Aug 30 22:50:30 2010 +0200 +++ b/dmd/Parser.d Mon Aug 30 23:00:34 2010 +0100 @@ -1202,7 +1202,7 @@ if (isDeclaration(&token, 0, TOKreserved, null)) { // Template argument is a type Type ta = parseType(); - tiargs.push(cast(void*)ta); + tiargs.push(ta); } else { // Template argument is an expression @@ -1251,13 +1251,13 @@ decldefs.push(fd); auto tempdecl = new TemplateDeclaration(fd.loc, fd.ident, tpl, null, decldefs); tempdecl.literal = 1; // it's a template 'literal' - tiargs.push(cast(void*)tempdecl); + tiargs.push(tempdecl); goto L1; } } } - tiargs.push(cast(void*)ea); + tiargs.push(ea); } L1: if (token.value != TOKcomma) @@ -1310,7 +1310,7 @@ case TOKwchar: ta = Type.twchar; goto LabelX; case TOKdchar: ta = Type.tdchar; goto LabelX; LabelX: - tiargs.push(cast(void*)ta); + tiargs.push(ta); nextToken(); break; @@ -1336,7 +1336,7 @@ { // Template argument is an expression Expression ea = parsePrimaryExp(); - tiargs.push(cast(void*)ea); + tiargs.push(ea); break; } diff -r df6d0f967680 -r 3a0b150c9841 dmd/TemplateAliasParameter.d --- a/dmd/TemplateAliasParameter.d Mon Aug 30 22:50:30 2010 +0200 +++ b/dmd/TemplateAliasParameter.d Mon Aug 30 23:00:34 2010 +0100 @@ -226,7 +226,7 @@ if (!sa || s_ != sa) goto Lnomatch; } - dedtypes.data[i] = cast(void*)sa; + dedtypes[i] = sa; s = isDsymbol(sa); if (s) @@ -250,7 +250,7 @@ return MATCHnomatch; } - override void* dummyArg() + override Object dummyArg() { Object s; @@ -261,6 +261,6 @@ sdummy = new Dsymbol(); s = sdummy; } - return cast(void*)s; + return s; } } diff -r df6d0f967680 -r 3a0b150c9841 dmd/TemplateDeclaration.d --- a/dmd/TemplateDeclaration.d Mon Aug 30 22:50:30 2010 +0200 +++ b/dmd/TemplateDeclaration.d Mon Aug 30 23:00:34 2010 +0100 @@ -597,9 +597,9 @@ { TemplateParameter tp = cast(TemplateParameter)parameters.data[i]; - void* p = tp.dummyArg(); + auto p = tp.dummyArg(); if (p) - ti.tiargs.data[i] = p; + ti.tiargs[i] = p; else ti.tiargs.setDim(i); } @@ -710,15 +710,15 @@ /* The extra initial template arguments * now form the tuple argument. */ - Tuple t = new Tuple(); + auto t = new Tuple(); assert(parameters.dim); - dedargs.data[parameters.dim - 1] = cast(void*)t; + dedargs[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] = cast(void*)targsi.data[n + i]; + t.objects[i] = targsi[n + i]; } declareParameter(paramscope, tp, t); } @@ -785,9 +785,9 @@ { if (nfparams == 0 && nfargs != 0) // if no function parameters { - Tuple t = new Tuple(); + auto t = new Tuple(); //printf("t = %p\n", t); - dedargs.data[parameters.dim - 1] = cast(void*)t; + dedargs[parameters.dim - 1] = t; declareParameter(paramscope, tp, t); goto L2; } @@ -815,15 +815,15 @@ /* The types of the function arguments * now form the tuple argument. */ - Tuple t = new Tuple(); - dedargs.data[parameters.dim - 1] = cast(void*)t; + auto t = new Tuple(); + dedargs[parameters.dim - 1] = t; tuple_dim = nfargs - (nfparams - 1); t.objects.setDim(tuple_dim); for (size_t i = 0; i < tuple_dim; i++) { auto farg = fargs[fptupindex + i]; - t.objects.data[i] = cast(void*)farg.type; + t.objects[i] = farg.type; } declareParameter(paramscope, tp, t); goto L2; @@ -1038,14 +1038,14 @@ * the oded == oarg */ Declaration sparam; - dedargs.data[i] = cast(void*)oded; + dedargs[i] = oded; MATCH m2 = tp2.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] !is cast(void*)oded) + if (dedtypes[i] !is oded) error("specialization not allowed for deduced parameter %s", tp2.ident.toChars()); } } @@ -1056,7 +1056,7 @@ goto Lnomatch; } declareParameter(paramscope, tp2, oded); - dedargs.data[i] = cast(void*)oded; + dedargs[i] = oded; } } diff -r df6d0f967680 -r 3a0b150c9841 dmd/TemplateInstance.d --- a/dmd/TemplateInstance.d Mon Aug 30 22:50:30 2010 +0200 +++ b/dmd/TemplateInstance.d Mon Aug 30 23:00:34 2010 +0100 @@ -236,7 +236,7 @@ a.setDim(objs.dim); for (size_t i = 0; i < objs.dim; i++) { - a.data[i] = cast(void*)objectSyntaxCopy(cast(Object)objs.data[i]); + a[i] = objectSyntaxCopy(objs[i]); } } return a; @@ -847,11 +847,11 @@ if (ea.op != TOKvar || flags & 1) ea = ea.optimize(WANTvalue | WANTinterpret); - tiargs.data[j] = cast(void*)ea; + tiargs[j] = ea; } else if (sa) { - tiargs.data[j] = cast(void*)sa; + tiargs[j] = sa; TupleDeclaration d = sa.toAlias().isTupleDeclaration(); if (d) { @@ -875,19 +875,19 @@ tiargs.reserve(dim); for (size_t i = 0; i < dim; i++) { - Argument arg = cast(Argument)tt.arguments.data[i]; - tiargs.insert(j + i, cast(void*)arg.type); + auto arg = cast(Argument)tt.arguments.data[i]; + tiargs.insert(j + i, arg.type); } } j--; } else - tiargs.data[j] = cast(void*)ta; + tiargs[j] = ta; } else { assert(global.errors); - tiargs.data[j] = cast(void*)Type.terror; + tiargs[j] = Type.terror; } } else if (ea) @@ -901,7 +901,7 @@ ea = ea.semantic(sc); if (ea.op != TOKvar || flags & 1) ea = ea.optimize(WANTvalue | WANTinterpret); - tiargs.data[j] = cast(void*)ea; + tiargs[j] = ea; if (ea.op == TOKtype) { ta = ea.type; @@ -917,7 +917,7 @@ { tiargs.reserve(dim); for (size_t i = 0; i < dim; i++) - tiargs.insert(j + i, cast(void*)te.exps.data[i]); + tiargs.insert(j + i, te.exps[i]); } j--; } diff -r df6d0f967680 -r 3a0b150c9841 dmd/TemplateParameter.d --- a/dmd/TemplateParameter.d Mon Aug 30 22:50:30 2010 +0200 +++ b/dmd/TemplateParameter.d Mon Aug 30 23:00:34 2010 +0100 @@ -83,5 +83,5 @@ /* Create dummy argument based on parameter. */ - abstract void* dummyArg(); + abstract Object dummyArg(); } \ No newline at end of file diff -r df6d0f967680 -r 3a0b150c9841 dmd/TemplateTupleParameter.d --- a/dmd/TemplateTupleParameter.d Mon Aug 30 22:50:30 2010 +0200 +++ b/dmd/TemplateTupleParameter.d Mon Aug 30 23:00:34 2010 +0100 @@ -137,12 +137,12 @@ } } *psparam = new TupleDeclaration(loc, ident, ovar.objects); - dedtypes.data[i] = cast(void*)ovar; + dedtypes[i] = ovar; return MATCH.MATCHexact; } - override void* dummyArg() + override Object dummyArg() { return null; } diff -r df6d0f967680 -r 3a0b150c9841 dmd/TemplateTypeParameter.d --- a/dmd/TemplateTypeParameter.d Mon Aug 30 22:50:30 2010 +0200 +++ b/dmd/TemplateTypeParameter.d Mon Aug 30 23:00:34 2010 +0100 @@ -199,7 +199,7 @@ if (!t) { - dedtypes.data[i] = cast(void*)ta; + dedtypes[i] = ta; t = ta; } @@ -213,7 +213,7 @@ return MATCHnomatch; } - override void* dummyArg() + override Object dummyArg() { Type t; @@ -224,6 +224,6 @@ // Use this for alias-parameter's too (?) t = new TypeIdentifier(loc, ident); } - return cast(void *)t; + return t; } } diff -r df6d0f967680 -r 3a0b150c9841 dmd/TemplateValueParameter.d --- a/dmd/TemplateValueParameter.d Mon Aug 30 22:50:30 2010 +0200 +++ b/dmd/TemplateValueParameter.d Mon Aug 30 23:00:34 2010 +0100 @@ -246,7 +246,7 @@ if (!m) goto Lnomatch; } - dedtypes.data[i] = cast(void*)ei; + dedtypes[i] = ei; init = new ExpInitializer(loc, ei); sparam = new VarDeclaration(loc, vt, ident, init); @@ -260,7 +260,7 @@ return MATCHnomatch; } - override void* dummyArg() + override Object dummyArg() { Expression e; @@ -272,6 +272,6 @@ edummy = valType.defaultInit(Loc(0)); e = edummy; } - return cast(void*)e; + return e; } } diff -r df6d0f967680 -r 3a0b150c9841 dmd/Type.d --- a/dmd/Type.d Mon Aug 30 22:50:30 2010 +0200 +++ b/dmd/Type.d Mon Aug 30 23:00:34 2010 +0100 @@ -1957,7 +1957,7 @@ // foo(U:U) invariant(T) => invariant(T) if (!at) { - dedtypes.data[i] = cast(void*)this; + dedtypes[i] = this; goto Lexact; } } @@ -1967,7 +1967,7 @@ tt = mutableOf(); if (!at) { - dedtypes.data[i] = cast(void*)tt; + dedtypes[i] = tt; goto Lexact; } } @@ -1977,7 +1977,7 @@ tt = mutableOf(); if (!at) { - dedtypes.data[i] = cast(void*)tt; + dedtypes[i] = tt; goto Lconst; } } diff -r df6d0f967680 -r 3a0b150c9841 dmd/TypeInstance.d --- a/dmd/TypeInstance.d Mon Aug 30 22:50:30 2010 +0200 +++ b/dmd/TypeInstance.d Mon Aug 30 23:00:34 2010 +0100 @@ -214,7 +214,7 @@ if (s != sa) goto Lnomatch; } - dedtypes.data[i] = cast(void*)sa; + dedtypes[i] = sa; } } else if (tempinst.tempdecl != tp.tempinst.tempdecl) @@ -286,16 +286,16 @@ int vtdim = tempinst.tiargs.dim - i; vt.objects.setDim(vtdim); for (size_t k = 0; k < vtdim; k++) - vt.objects.data[k] = cast(void *)tempinst.tiargs.data[i + k]; + vt.objects[k] = tempinst.tiargs[i + k]; - Tuple v = cast(Tuple)dedtypes.data[j]; + auto v = cast(Tuple)dedtypes[j]; if (v) { if (!match(v, vt, tempinst.tempdecl, sc)) goto Lnomatch; } else - dedtypes.data[j] = cast(void*)vt; + dedtypes[j] = vt; break; //return MATCHexact; } @@ -340,7 +340,7 @@ MATCH m = cast(MATCH)e1.implicitConvTo(vt); if (!m) goto Lnomatch; - dedtypes.data[j] = cast(void*)e1; + dedtypes[j] = e1; } } else if (s1 && t2 && t2.ty == Tident) @@ -361,7 +361,7 @@ } else { - dedtypes.data[j] = cast(void*)s1; + dedtypes[j] = s1; } } else if (s1 && s2) diff -r df6d0f967680 -r 3a0b150c9841 dmd/TypeSArray.d --- a/dmd/TypeSArray.d Mon Aug 30 22:50:30 2010 +0200 +++ b/dmd/TypeSArray.d Mon Aug 30 23:00:34 2010 +0100 @@ -272,11 +272,11 @@ * Do it this way because TemplateInstance.semanticTiargs() * can handle unresolved Objects this way. */ - Objects objects = new Objects; + auto objects = new Objects; objects.setDim(1); - objects.data[0] = cast(void*)o; + objects[0] = o; - TupleDeclaration tds = new TupleDeclaration(loc, td.ident, objects); + auto tds = new TupleDeclaration(loc, td.ident, objects); *ps = tds; } else @@ -523,7 +523,7 @@ MATCH m = cast(MATCH)dim.implicitConvTo(vt); if (!m) goto Lnomatch; - dedtypes.data[i] = cast(void*)dim; + dedtypes[i] = dim; } } else if (dim.toInteger() != tp.dim.toInteger()) @@ -531,10 +531,10 @@ } else if (tparam.ty == Taarray) { - TypeAArray tp = cast(TypeAArray)tparam; + auto tp = cast(TypeAArray)tparam; if (tp.index.ty == Tident) { - TypeIdentifier tident = cast(TypeIdentifier)tp.index; + auto tident = cast(TypeIdentifier)tp.index; if (tident.idents.dim == 0) { @@ -542,7 +542,7 @@ for (size_t i = 0; i < parameters.dim; i++) { - TemplateParameter tp2 = cast(TemplateParameter)parameters.data[i]; + auto tp2 = cast(TemplateParameter)parameters.data[i]; if (tp2.ident.equals(id)) { @@ -557,7 +557,7 @@ goto Lnomatch; } else - { dedtypes.data[i] = cast(void*)dim; + { dedtypes[i] = dim; } return next.deduceType(sc, tparam.nextOf(), parameters, dedtypes); } diff -r df6d0f967680 -r 3a0b150c9841 dmd/Util.d --- a/dmd/Util.d Mon Aug 30 22:50:30 2010 +0200 +++ b/dmd/Util.d Mon Aug 30 23:00:34 2010 +0100 @@ -1057,7 +1057,7 @@ if (status) { if (status == -1) - printf("Can't run '%s', check PATH\n", cmd); + printf("Can't run '%.*s', check PATH\n", cmd); else printf("--- errorlevel %d\n", status); } diff -r df6d0f967680 -r 3a0b150c9841 dmd/VarDeclaration.d --- a/dmd/VarDeclaration.d Mon Aug 30 22:50:30 2010 +0200 +++ b/dmd/VarDeclaration.d Mon Aug 30 23:00:34 2010 +0100 @@ -275,10 +275,10 @@ sc.scopesym.members.push(v); } - Expression e = new DsymbolExp(loc, v); - exps.data[i] = cast(void*)e; + auto e = new DsymbolExp(loc, v); + exps[i] = e; } - TupleDeclaration v2 = new TupleDeclaration(loc, ident, exps); + auto v2 = new TupleDeclaration(loc, ident, exps); v2.isexp = 1; aliassym = v2; return;