Mercurial > projects > ddmd
view dmd/TupleDeclaration.d @ 72:2e2a5c3f943a
reduced warnings by adding override to the methods
think this also normalizes different line endings used all over the place
author | Trass3r |
---|---|
date | Sat, 28 Aug 2010 16:19:48 +0200 |
parents | 81796b717a39 |
children | 5c859d5fbe27 |
line wrap: on
line source
module dmd.TupleDeclaration; import dmd.Declaration; import dmd.Argument; import dmd.ArrayTypes; import dmd.TypeTuple; import dmd.Loc; import dmd.STC; import dmd.TOK; import dmd.Identifier; import dmd.Dsymbol; import dmd.Type; import dmd.DYNCAST; import dmd.OutBuffer; import dmd.Expression; import dmd.DsymbolExp; class TupleDeclaration : Declaration { Objects objects; int isexp; // 1: expression tuple TypeTuple tupletype; // !=NULL if this is a type tuple this(Loc loc, Identifier ident, Objects objects) { super(ident); this.type = null; this.objects = objects; this.isexp = 0; this.tupletype = null; } override Dsymbol syntaxCopy(Dsymbol) { assert(false); } override string kind() { return "tuple"; } override Type getType() { /* If this tuple represents a type, return that type */ //printf("TupleDeclaration::getType() %s\n", toChars()); if (isexp) return null; if (!tupletype) { /* It's only a type tuple if all the Object's are types */ for (size_t i = 0; i < objects.dim; i++) { Object o = cast(Object)objects.data[i]; if (cast(Type)o is null) { //printf("\tnot[%d], %p, %d\n", i, o, o->dyncast()); return null; } } /* We know it's a type tuple, so build the TypeTuple */ Arguments args = new Arguments(); args.setDim(objects.dim); OutBuffer buf = new OutBuffer(); for (size_t i = 0; i < objects.dim; i++) { Type t = cast(Type)objects.data[i]; //printf("type = %s\n", t->toChars()); static if (0) { buf.printf("_%s_%d", ident.toChars(), i); char *name = cast(char *)buf.extractData(); Identifier id = new Identifier(name, TOKidentifier); Argument arg = new Argument(STCin, t, id, null); } else { Argument arg = new Argument(STCundefined, t, null, null); } args.data[i] = cast(void *)arg; } tupletype = new TypeTuple(args); } return tupletype; } override bool needThis() { //printf("TupleDeclaration::needThis(%s)\n", toChars()); for (size_t i = 0; i < objects.dim; i++) { Object o = cast(Object)objects.data[i]; if (auto e = cast(Expression)o) { if (e.op == TOKdsymbol) { DsymbolExp ve = cast(DsymbolExp)e; Declaration d = ve.s.isDeclaration(); if (d && d.needThis()) { return 1; } } } } return 0; } override TupleDeclaration isTupleDeclaration() { return this; } }