# HG changeset patch # User Trass3r # Date 1283286540 -7200 # Node ID 12c0c84d13fd5858809fb2326ecef4f88e2c7b20 # Parent ceda59b4d2557be595ec852e2b58187056cfefa7# Parent a1cf34da9ebe6f5b6dfa5f779b9e810a381502fc merged in 2.036 changes diff -r ceda59b4d255 -r 12c0c84d13fd dmd/Array.d --- a/dmd/Array.d Tue Aug 31 22:08:52 2010 +0200 +++ b/dmd/Array.d Tue Aug 31 22:29:00 2010 +0200 @@ -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 ceda59b4d255 -r 12c0c84d13fd dmd/ArrayTypes.d --- a/dmd/ArrayTypes.d Tue Aug 31 22:08:52 2010 +0200 +++ b/dmd/ArrayTypes.d Tue Aug 31 22:29:00 2010 +0200 @@ -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 ceda59b4d255 -r 12c0c84d13fd dmd/ClassInfoDeclaration.d --- a/dmd/ClassInfoDeclaration.d Tue Aug 31 22:08:52 2010 +0200 +++ b/dmd/ClassInfoDeclaration.d Tue Aug 31 22:29:00 2010 +0200 @@ -19,9 +19,9 @@ class ClassInfoDeclaration : VarDeclaration { - ClassDeclaration cd; + ClassDeclaration cd; - this(ClassDeclaration cd) + this(ClassDeclaration cd) { super(Loc(0), ClassDeclaration.classinfo.type, cd.ident, null); @@ -29,26 +29,25 @@ storage_class = STC.STCstatic | STC.STCgshared; } - override Dsymbol syntaxCopy(Dsymbol) + override Dsymbol syntaxCopy(Dsymbol) { - assert(false); + assert(false); // should never be produced by syntax + return null; } - override void semantic(Scope sc) + override void semantic(Scope sc) { - assert(false); } - override void emitComment(Scope sc) + override void emitComment(Scope sc) { - assert(false); } override void toJsonBuffer(OutBuffer buf) { } - - override Symbol* toSymbol() + + override Symbol* toSymbol() { return cd.toSymbol(); } diff -r ceda59b4d255 -r 12c0c84d13fd dmd/FileName.d --- a/dmd/FileName.d Tue Aug 31 22:08:52 2010 +0200 +++ b/dmd/FileName.d Tue Aug 31 22:29:00 2010 +0200 @@ -114,7 +114,7 @@ { return (name[0] == '\\') || (name[0] == '/') || - (name[0] && name[1] == ':'); + ((name.length > 1) && (name[1] == ':')); } else version (POSIX) { diff -r ceda59b4d255 -r 12c0c84d13fd dmd/FuncDeclaration.d --- a/dmd/FuncDeclaration.d Tue Aug 31 22:08:52 2010 +0200 +++ b/dmd/FuncDeclaration.d Tue Aug 31 22:29:00 2010 +0200 @@ -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 ceda59b4d255 -r 12c0c84d13fd dmd/IsExp.d --- a/dmd/IsExp.d Tue Aug 31 22:08:52 2010 +0200 +++ b/dmd/IsExp.d Tue Aug 31 22:29:00 2010 +0200 @@ -241,7 +241,7 @@ 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 ceda59b4d255 -r 12c0c84d13fd dmd/ModuleInfoDeclaration.d --- a/dmd/ModuleInfoDeclaration.d Tue Aug 31 22:08:52 2010 +0200 +++ b/dmd/ModuleInfoDeclaration.d Tue Aug 31 22:29:00 2010 +0200 @@ -11,34 +11,32 @@ class ModuleInfoDeclaration : VarDeclaration { - Module mod; + Module mod; - this(Module mod) + this(Module mod) { - assert(false); - super(Loc(0), null, null, null); + super(Loc(0), Module.moduleinfo.type, mod.ident, null); } - override Dsymbol syntaxCopy(Dsymbol) + override Dsymbol syntaxCopy(Dsymbol) { - assert(false); + assert(false); // should never be produced by syntax + return null; } - override void semantic(Scope sc) + override void semantic(Scope sc) { - assert(false); } - void emitComment(Scope *sc) + void emitComment(Scope *sc) { - assert(false); } override void toJsonBuffer(OutBuffer buf) { } - override Symbol* toSymbol() + override Symbol* toSymbol() { assert(false); } diff -r ceda59b4d255 -r 12c0c84d13fd dmd/Parser.d --- a/dmd/Parser.d Tue Aug 31 22:08:52 2010 +0200 +++ b/dmd/Parser.d Tue Aug 31 22:29:00 2010 +0200 @@ -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 ceda59b4d255 -r 12c0c84d13fd dmd/PragmaStatement.d --- a/dmd/PragmaStatement.d Tue Aug 31 22:08:52 2010 +0200 +++ b/dmd/PragmaStatement.d Tue Aug 31 22:29:00 2010 +0200 @@ -1,7 +1,11 @@ module dmd.PragmaStatement; +import dmd.expression.Util; import dmd.Statement; +import dmd.StringExp; +import dmd.Id; import dmd.Identifier; +import dmd.Dsymbol; import dmd.Expression; import dmd.Loc; import dmd.Identifier; @@ -10,44 +14,168 @@ import dmd.HdrGenState; import dmd.IRState; import dmd.BE; +import dmd.TOK; +import dmd.WANT; class PragmaStatement : Statement { - Identifier ident; - Expressions args; // array of Expression's - Statement body_; + Identifier ident; + Expressions args; // array of Expression's + Statement body_; - this(Loc loc, Identifier ident, Expressions args, Statement body_) + this(Loc loc, Identifier ident, Expressions args, Statement body_) { super(loc); + this.ident = ident; + this.args = args; + this.body_ = body_; } - override Statement syntaxCopy() + override Statement syntaxCopy() { - assert(false); + Statement b = null; + if (body_) + b = body_.syntaxCopy(); + PragmaStatement s = new PragmaStatement(loc, + ident, Expression.arraySyntaxCopy(args), b); + return s; + } - override Statement semantic(Scope sc) + override Statement semantic(Scope sc) { - assert(false); - } + // Should be merged with PragmaDeclaration + //writef("PragmaStatement.semantic() %s\n", toChars()); + //writef("body = %p\n", body_); + if (ident == Id.msg) + { + if (args) + { + foreach (Expression e; args) + { + e = e.semantic(sc); + e = e.optimize(WANTvalue | WANTinterpret); + if (e.op == TOK.TOKstring) + { + StringExp se = cast(StringExp)e; + writef("%.*s", se.len, cast(char*)se.string_); + } + else + writef(e.toChars()); + } + writef("\n"); + } + } + else if (ident == Id.lib) + { +static if (true) +{ + /* Should this be allowed? + */ + error("pragma(lib) not allowed as statement"); +} +else +{ + if (!args || args.dim != 1) + error("string expected for library name"); + else + { + Expression e = args[0]; - override bool usesEH() - { - assert(false); + e = e.semantic(sc); + e = e.optimize(WANTvalue | WANTinterpret); + args[0] = e; + if (e.op != TOKstring) + error("string expected for library name, not '%s'", e.toChars()); + else if (global.params.verbose) + { + StringExp se = cast(StringExp)e; + writef("library %.*s\n", se.len, se.string_); + } + } +} + } +//version(DMDV2) // TODO: +//{ + else if (ident == Id.startaddress) + { + if (!args || args.dim != 1) + error("function name expected for start address"); + else + { + Expression e = args[0]; + e = e.semantic(sc); + e = e.optimize(WANTvalue | WANTinterpret); + args[0] = e; + Dsymbol sa = getDsymbol(e); + if (!sa || !sa.isFuncDeclaration()) + error("function name expected for start address, not '%s'", e.toChars()); + if (body_) + { + body_ = body_.semantic(sc); + } + return this; + } + } +//} + else + error("unrecognized pragma(%s)", ident.toChars()); + + if (body_) + { + body_ = body_.semantic(sc); + } + return body_; } - override BE blockExit() + override bool usesEH() + { + return body_ && body_.usesEH(); + } + + override BE blockExit() { - assert(false); + BE result = BEfallthru; +static if (false) // currently, no code is generated for Pragma's, so it's just fallthru +{ + if (arrayExpressionCanThrow(args)) + result |= BEthrow; + if (body_) + result |= body_.blockExit(); +} + return result; } - override void toCBuffer(OutBuffer buf, HdrGenState* hgs) + override void toCBuffer(OutBuffer buf, HdrGenState* hgs) { - assert(false); + buf.writestring("pragma ("); + buf.writestring(ident.toChars()); + if (args && args.dim) + { + buf.writestring(", "); + argsToCBuffer(buf, args, hgs); + } + buf.writeByte(')'); + if (body_) + { + buf.writenl(); + buf.writeByte('{'); + buf.writenl(); + + body_.toCBuffer(buf, hgs); + + buf.writeByte('}'); + buf.writenl(); + } + else + { + buf.writeByte(';'); + buf.writenl(); + } + } - override void toIR(IRState* irs) + override void toIR(IRState* irs) { assert(false); } diff -r ceda59b4d255 -r 12c0c84d13fd dmd/StaticDtorDeclaration.d --- a/dmd/StaticDtorDeclaration.d Tue Aug 31 22:08:52 2010 +0200 +++ b/dmd/StaticDtorDeclaration.d Tue Aug 31 22:29:00 2010 +0200 @@ -42,7 +42,7 @@ { assert(!s); StaticDtorDeclaration sdd = new StaticDtorDeclaration(loc, endloc); - return FuncDeclaration.syntaxCopy(sdd); + return super.syntaxCopy(sdd); } override void semantic(Scope sc) diff -r ceda59b4d255 -r 12c0c84d13fd dmd/TemplateAliasParameter.d --- a/dmd/TemplateAliasParameter.d Tue Aug 31 22:08:52 2010 +0200 +++ b/dmd/TemplateAliasParameter.d Tue Aug 31 22:29:00 2010 +0200 @@ -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 ceda59b4d255 -r 12c0c84d13fd dmd/TemplateDeclaration.d --- a/dmd/TemplateDeclaration.d Tue Aug 31 22:08:52 2010 +0200 +++ b/dmd/TemplateDeclaration.d Tue Aug 31 22:29:00 2010 +0200 @@ -53,35 +53,35 @@ TemplateTupleParameter isVariadic(TemplateParameters parameters) { size_t dim = parameters.dim; - TemplateTupleParameter tp = null; + TemplateTupleParameter tp = null; - if (dim) + if (dim) tp = (cast(TemplateParameter)parameters.data[dim - 1]).isTemplateTupleParameter(); - return tp; + return tp; } void ObjectToCBuffer(OutBuffer buf, HdrGenState* hgs, Object oarg) { - //printf("ObjectToCBuffer()\n"); - Type t = isType(oarg); - Expression e = isExpression(oarg); - Dsymbol s = isDsymbol(oarg); - Tuple v = isTuple(oarg); - if (t) - { + //printf("ObjectToCBuffer()\n"); + Type t = isType(oarg); + Expression e = isExpression(oarg); + Dsymbol s = isDsymbol(oarg); + Tuple v = isTuple(oarg); + if (t) + { //printf("\tt: %s ty = %d\n", t.toChars(), t.ty); t.toCBuffer(buf, null, hgs); - } - else if (e) + } + else if (e) e.toCBuffer(buf, hgs); - else if (s) - { + else if (s) + { string p = s.ident ? s.ident.toChars() : s.toChars(); buf.writestring(p); - } - else if (v) - { + } + else if (v) + { Objects args = v.objects; for (size_t i = 0; i < args.dim; i++) { @@ -90,36 +90,36 @@ Object o = cast(Object)args.data[i]; ObjectToCBuffer(buf, hgs, o); } - } - else if (!oarg) - { + } + else if (!oarg) + { buf.writestring("null"); - } - else - { + } + else + { debug writef("bad Object = %p\n", oarg); assert(0); - } + } } class TemplateDeclaration : ScopeDsymbol { - TemplateParameters parameters; // array of TemplateParameter's + TemplateParameters parameters; // array of TemplateParameter's - TemplateParameters origParameters; // originals for Ddoc - Expression constraint; - Array instances; // array of TemplateInstance's + TemplateParameters origParameters; // originals for Ddoc + Expression constraint; + Array instances; // array of TemplateInstance's - TemplateDeclaration overnext; // next overloaded TemplateDeclaration - TemplateDeclaration overroot; // first in overnext list + TemplateDeclaration overnext; // next overloaded TemplateDeclaration + TemplateDeclaration overroot; // first in overnext list - int semanticRun; // 1 semantic() run + int semanticRun; // 1 semantic() run - Dsymbol onemember; // if !=NULL then one member of this template + Dsymbol onemember; // if !=NULL then one member of this template - int literal; // this template declaration is a literal + int literal; // this template declaration is a literal - this(Loc loc, Identifier id, TemplateParameters parameters, Expression constraint, Dsymbols decldefs) + this(Loc loc, Identifier id, TemplateParameters parameters, Expression constraint, Dsymbols decldefs) { super(id); @@ -150,7 +150,7 @@ instances = new Array(); } - override Dsymbol syntaxCopy(Dsymbol) + override Dsymbol syntaxCopy(Dsymbol) { //printf("TemplateDeclaration.syntaxCopy()\n"); TemplateDeclaration td; @@ -177,7 +177,7 @@ return td; } - override void semantic(Scope sc) + override void semantic(Scope sc) { version (LOG) { printf("TemplateDeclaration.semantic(this = %p, id = '%s')\n", this, ident.toChars()); @@ -273,7 +273,7 @@ * Overload existing TemplateDeclaration 'this' with the new one 's'. * Return !=0 if successful; i.e. no conflict. */ - override bool overloadInsert(Dsymbol s) + override bool overloadInsert(Dsymbol s) { TemplateDeclaration *pf; TemplateDeclaration f; @@ -323,9 +323,49 @@ return true; } - override void toCBuffer(OutBuffer buf, HdrGenState* hgs) + override void toCBuffer(OutBuffer buf, HdrGenState* hgs) { - assert(false); +static if (false) // Should handle template functions +{ + if (onemember && onemember.isFuncDeclaration()) + buf.writestring("foo "); +} + buf.writestring(kind()); + buf.writeByte(' '); + buf.writestring(ident.toChars()); + buf.writeByte('('); + for (int i = 0; i < parameters.dim; i++) + { + TemplateParameter tp = cast(TemplateParameter)parameters.data[i]; + if (hgs.ddoc) + tp = cast(TemplateParameter)origParameters.data[i]; + if (i) + buf.writeByte(','); + tp.toCBuffer(buf, hgs); + } + buf.writeByte(')'); +version(DMDV2) +{ + if (constraint) + { buf.writestring(" if ("); + constraint.toCBuffer(buf, hgs); + buf.writeByte(')'); + } +} + + if (hgs.hdrgen) + { + hgs.tpltMember++; + buf.writenl(); + buf.writebyte('{'); + buf.writenl(); + foreach (Dsymbol s; members) + s.toCBuffer(buf, hgs); + + buf.writebyte('}'); + buf.writenl(); + hgs.tpltMember--; + } } override void toJsonBuffer(OutBuffer buf) @@ -359,14 +399,14 @@ buf.writestring("}\n"); } - override string kind() + override string kind() { return (onemember && onemember.isAggregateDeclaration()) ? onemember.kind() : "template"; } - override string toChars() + override string toChars() { OutBuffer buf = new OutBuffer(); HdrGenState hgs; @@ -394,12 +434,12 @@ return buf.extractString(); } - override void emitComment(Scope sc) + override void emitComment(Scope sc) { assert(false); } -// void toDocBuffer(OutBuffer *buf); +// void toDocBuffer(OutBuffer *buf); /*************************************** * Given that ti is an instance of this TemplateDeclaration, @@ -412,7 +452,7 @@ * dedtypes deduced arguments * Return match level. */ - MATCH matchWithInstance(TemplateInstance ti, Objects dedtypes, int flag) + MATCH matchWithInstance(TemplateInstance ti, Objects dedtypes, int flag) { MATCH m; int dedtypes_dim = dedtypes.dim; @@ -574,9 +614,9 @@ * match this is at least as specialized as td2 * 0 td2 is more specialized than this */ - MATCH leastAsSpecialized(TemplateDeclaration td2) + MATCH leastAsSpecialized(TemplateDeclaration td2) { - /* This works by taking the template parameters to this template + /* This works by taking the template parameters to this template * declaration and feeding them to td2 as if it were a template * instance. * If it works, then this template is at least as specialized @@ -598,9 +638,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); } @@ -643,7 +683,7 @@ * Returns: * match level */ - MATCH deduceFunctionTemplateMatch(Loc loc, Objects targsi, Expression ethis, Expressions fargs, Objects dedargs) + MATCH deduceFunctionTemplateMatch(Loc loc, Objects targsi, Expression ethis, Expressions fargs, Objects dedargs) { size_t nfparams; size_t nfargs; @@ -711,15 +751,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); } @@ -786,9 +826,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; } @@ -816,15 +856,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; @@ -1039,14 +1079,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()); } } @@ -1057,7 +1097,7 @@ goto Lnomatch; } declareParameter(paramscope, tp2, oded); - dedargs.data[i] = cast(void*)oded; + dedargs[i] = oded; } } @@ -1097,7 +1137,7 @@ //printf("\tnomatch\n"); return MATCHnomatch; } - + /************************************************* * Given function arguments, figure out which template function * to expand, and return that function. @@ -1121,7 +1161,7 @@ static if (false) { printf("TemplateDeclaration.deduceFunctionTemplate() %s\n", toChars()); - printf(" targsi:\n"); + printf(" targsi:\n"); if (targsi) { for (int i = 0; i < targsi.dim; i++) @@ -1130,7 +1170,7 @@ printf("\t%s\n", arg.toChars()); } } - printf(" fargs:\n"); + printf(" fargs:\n"); for (int i = 0; i < fargs.dim; i++) { Expression arg = cast(Expression)fargs.data[i]; @@ -1249,7 +1289,7 @@ /************************************************** * Declare template parameter tp with value o, and install it in the scope sc. */ - void declareParameter(Scope sc, TemplateParameter tp, Object o) + void declareParameter(Scope sc, TemplateParameter tp, Object o) { //printf("TemplateDeclaration.declareParameter('%s', o = %p)\n", tp.ident.toChars(), o); @@ -1317,9 +1357,9 @@ s.semantic(sc); } - override TemplateDeclaration isTemplateDeclaration() { return this; } + override TemplateDeclaration isTemplateDeclaration() { return this; } - TemplateTupleParameter isVariadic() + TemplateTupleParameter isVariadic() { return .isVariadic(parameters); } @@ -1327,8 +1367,8 @@ /*********************************** * We can overload templates. */ - override bool isOverloadable() + override bool isOverloadable() { - return 1; + return true; } } diff -r ceda59b4d255 -r 12c0c84d13fd dmd/TemplateInstance.d --- a/dmd/TemplateInstance.d Tue Aug 31 22:08:52 2010 +0200 +++ b/dmd/TemplateInstance.d Tue Aug 31 22:29:00 2010 +0200 @@ -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 ceda59b4d255 -r 12c0c84d13fd dmd/TemplateParameter.d --- a/dmd/TemplateParameter.d Tue Aug 31 22:08:52 2010 +0200 +++ b/dmd/TemplateParameter.d Tue Aug 31 22:29:00 2010 +0200 @@ -83,5 +83,5 @@ /* Create dummy argument based on parameter. */ - abstract void* dummyArg(); + abstract Object dummyArg(); } \ No newline at end of file diff -r ceda59b4d255 -r 12c0c84d13fd dmd/TemplateTupleParameter.d --- a/dmd/TemplateTupleParameter.d Tue Aug 31 22:08:52 2010 +0200 +++ b/dmd/TemplateTupleParameter.d Tue Aug 31 22:29:00 2010 +0200 @@ -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 ceda59b4d255 -r 12c0c84d13fd dmd/TemplateTypeParameter.d --- a/dmd/TemplateTypeParameter.d Tue Aug 31 22:08:52 2010 +0200 +++ b/dmd/TemplateTypeParameter.d Tue Aug 31 22:29:00 2010 +0200 @@ -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 ceda59b4d255 -r 12c0c84d13fd dmd/TemplateValueParameter.d --- a/dmd/TemplateValueParameter.d Tue Aug 31 22:08:52 2010 +0200 +++ b/dmd/TemplateValueParameter.d Tue Aug 31 22:29:00 2010 +0200 @@ -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 ceda59b4d255 -r 12c0c84d13fd dmd/Type.d --- a/dmd/Type.d Tue Aug 31 22:08:52 2010 +0200 +++ b/dmd/Type.d Tue Aug 31 22:29:00 2010 +0200 @@ -1928,7 +1928,7 @@ // foo(U:U) shared(T) => shared(T) // foo(U:U) const(shared(T)) => const(shared(T)) if (!at) - { dedtypes.data[i] = cast(void *)tt; + { dedtypes[i] = tt; goto Lexact; } break; @@ -1943,7 +1943,8 @@ // foo(U:const(shared(U)) const(shared(T))=> T tt = mutableOf().unSharedOf(); if (!at) - { dedtypes.data[i] = cast(void *)tt; + { + dedtypes[i] = tt; goto Lexact; } break; @@ -1958,7 +1959,7 @@ // foo(U:const(shared(U)) immutable(T) => T tt = mutableOf(); if (!at) - { dedtypes.data[i] = cast(void *)tt; + { dedtypes[i] = tt; goto Lconst; } break; @@ -1969,7 +1970,7 @@ // foo(U:const(shared(U)) shared(T) => T tt = unSharedOf(); if (!at) - { dedtypes.data[i] = cast(void *)tt; + { dedtypes[i] = tt; goto Lconst; } break; diff -r ceda59b4d255 -r 12c0c84d13fd dmd/TypeExp.d --- a/dmd/TypeExp.d Tue Aug 31 22:08:52 2010 +0200 +++ b/dmd/TypeExp.d Tue Aug 31 22:29:00 2010 +0200 @@ -1,6 +1,8 @@ module dmd.TypeExp; import dmd.Expression; +import dmd.backend.TYM; +import dmd.backend.Util; import dmd.backend.elem; import dmd.Type; import dmd.OutBuffer; @@ -41,7 +43,7 @@ override void rvalue() { - assert(false); + error("type %s has no value", toChars()); } override void toCBuffer(OutBuffer buf, HdrGenState* hgs) @@ -56,7 +58,11 @@ override elem* toElem(IRState* irs) { - assert(false); + debug + writef("TypeExp.toElem()\n"); + + error("type %s is not an expression", toChars()); + return el_long(TYint, 0); } } diff -r ceda59b4d255 -r 12c0c84d13fd dmd/TypeInfoDeclaration.d --- a/dmd/TypeInfoDeclaration.d Tue Aug 31 22:08:52 2010 +0200 +++ b/dmd/TypeInfoDeclaration.d Tue Aug 31 22:29:00 2010 +0200 @@ -24,9 +24,9 @@ class TypeInfoDeclaration : VarDeclaration { - Type tinfo; + Type tinfo; - this(Type tinfo, int internal) + this(Type tinfo, int internal) { super(Loc(0), Type.typeinfo.type, tinfo.getTypeInfoIdent(internal), null); this.tinfo = tinfo; @@ -42,22 +42,22 @@ assert(false); } } - override Dsymbol syntaxCopy(Dsymbol) + override Dsymbol syntaxCopy(Dsymbol) { - assert(false); + assert(false); // should never be produced by syntax + return null; } - override void semantic(Scope sc) + override void semantic(Scope sc) { - assert(false); + assert(linkage == LINKc); } - override void emitComment(Scope sc) + override void emitComment(Scope sc) { - assert(false); } - override Symbol* toSymbol() + override Symbol* toSymbol() { //printf("TypeInfoDeclaration::toSymbol(%s), linkage = %d\n", toChars(), linkage); return VarDeclaration.toSymbol(); @@ -67,7 +67,7 @@ { } - override void toObjFile(int multiobj) // compile to .obj file + override void toObjFile(int multiobj) // compile to .obj file { Symbol* s; uint sz; @@ -113,7 +113,7 @@ obj_export(s,0); } - void toDt(dt_t** pdt) + void toDt(dt_t** pdt) { assert(false); } diff -r ceda59b4d255 -r 12c0c84d13fd dmd/TypeInstance.d --- a/dmd/TypeInstance.d Tue Aug 31 22:08:52 2010 +0200 +++ b/dmd/TypeInstance.d Tue Aug 31 22:29:00 2010 +0200 @@ -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 ceda59b4d255 -r 12c0c84d13fd dmd/TypeSArray.d --- a/dmd/TypeSArray.d Tue Aug 31 22:08:52 2010 +0200 +++ b/dmd/TypeSArray.d Tue Aug 31 22:29:00 2010 +0200 @@ -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 ceda59b4d255 -r 12c0c84d13fd dmd/Util.d --- a/dmd/Util.d Tue Aug 31 22:08:52 2010 +0200 +++ b/dmd/Util.d Tue Aug 31 22:29:00 2010 +0200 @@ -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 ceda59b4d255 -r 12c0c84d13fd dmd/VarDeclaration.d --- a/dmd/VarDeclaration.d Tue Aug 31 22:08:52 2010 +0200 +++ b/dmd/VarDeclaration.d Tue Aug 31 22:29:00 2010 +0200 @@ -293,10 +293,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;