Mercurial > projects > ddmd
view dmd/AttribDeclaration.d @ 32:81796b717a39
A few bad cast fixed. TODO: either get rid of dyncast(), or derive all objects from intermediate supertype.
author | korDen |
---|---|
date | Tue, 18 May 2010 17:51:46 +0400 |
parents | 427f8aa74d28 |
children | 0aa7d1437ada |
line wrap: on
line source
module dmd.AttribDeclaration; import dmd.Dsymbol; import dmd.Array; import dmd.Scope; import dmd.ScopeDsymbol; import dmd.LINK; import dmd.STC; import dmd.PROT; import dmd.ArrayTypes; import dmd.OutBuffer; import dmd.HdrGenState; class AttribDeclaration : Dsymbol { Array decl; // array of Dsymbol's this(Array decl) { this.decl = decl; } Array include(Scope sc, ScopeDsymbol sd) { return decl; } bool addMember(Scope sc, ScopeDsymbol sd, bool memnum) { bool m = false; Array d = include(sc, sd); if (d) { for (uint i = 0; i < d.dim; i++) { Dsymbol s = cast(Dsymbol)d.data[i]; m |= s.addMember(sc, sd, m | memnum); } } return m; } void setScopeNewSc(Scope sc, STC stc, LINK linkage, PROT protection, int explicitProtection, uint structalign) { if (decl) { Scope newsc = sc; if (stc != sc.stc || linkage != sc.linkage || protection != sc.protection || explicitProtection != sc.explicitProtection || structalign != sc.structalign) { // create new one for changes newsc = new Scope(sc); newsc.offset = sc.offset; newsc.scopesym = sc.scopesym; newsc.flags &= ~SCOPE.SCOPEfree; newsc.stc = stc; newsc.linkage = linkage; newsc.protection = protection; newsc.explicitProtection = explicitProtection; newsc.structalign = structalign; } for (uint i = 0; i < decl.dim; i++) { Dsymbol s = cast(Dsymbol)decl.data[i]; s.setScope(newsc); // yes, the only difference from semanticNewSc() } if (newsc != sc) { sc.offset = newsc.offset; newsc.pop(); } } } void semanticNewSc(Scope sc, STC stc, LINK linkage, PROT protection, int explicitProtection, uint structalign) { if (decl) { Scope newsc = sc; if (stc != sc.stc || linkage != sc.linkage || protection != sc.protection || explicitProtection != sc.explicitProtection || structalign != sc.structalign) { // create new one for changes newsc = new Scope(sc); newsc.offset = sc.offset; newsc.scopesym = sc.scopesym; newsc.flags &= ~SCOPE.SCOPEfree; newsc.stc = stc; newsc.linkage = linkage; newsc.protection = protection; newsc.explicitProtection = explicitProtection; newsc.structalign = structalign; } for (uint i = 0; i < decl.dim; i++) { Dsymbol s = cast(Dsymbol)decl.data[i]; s.semantic(newsc); } if (newsc != sc) { sc.offset = newsc.offset; newsc.pop(); } } } void semantic(Scope sc) { Array d = include(sc, null); //printf("\tAttribDeclaration::semantic '%s', d = %p\n",toChars(), d); if (d) { for (uint i = 0; i < d.dim; i++) { Dsymbol s = cast(Dsymbol)d.data[i]; s.semantic(sc); } } } void semantic2(Scope sc) { Array d = include(sc, null); if (d) { for (uint i = 0; i < d.dim; i++) { Dsymbol s = cast(Dsymbol)d.data[i]; s.semantic2(sc); } } } void semantic3(Scope sc) { Array d = include(sc, null); if (d) { for (uint i = 0; i < d.dim; i++) { Dsymbol s = cast(Dsymbol)d.data[i]; s.semantic3(sc); } } } void inlineScan() { Array d = include(null, null); if (d) { for (uint i = 0; i < d.dim; i++) { Dsymbol s = cast(Dsymbol)d.data[i]; //printf("AttribDeclaration.inlineScan %s\n", s.toChars()); s.inlineScan(); } } } void addComment(ubyte* comment) { if (comment !is null) { Array d = include(null, null); if (d) { for (uint i = 0; i < d.dim; i++) { Dsymbol s = cast(Dsymbol)d.data[i]; //printf("AttribDeclaration::addComment %s\n", s.toChars()); s.addComment(comment); } } } } void emitComment(Scope sc) { assert(false); } string kind() { assert(false); } bool oneMember(Dsymbol* ps) { assert(false); } bool hasPointers() { Array d = include(null, null); if (d) { for (size_t i = 0; i < d.dim; i++) { Dsymbol s = cast(Dsymbol)d.data[i]; if (s.hasPointers()) return true; } } return 0; } void checkCtorConstInit() { Array d = include(null, null); if (d) { for (uint i = 0; i < d.dim; i++) { Dsymbol s = cast(Dsymbol)d.data[i]; s.checkCtorConstInit(); } } } void addLocalClass(ClassDeclarations aclasses) { Array d = include(null, null); if (d) { for (uint i = 0; i < d.dim; i++) { Dsymbol s = cast(Dsymbol)d.data[i]; s.addLocalClass(aclasses); } } } void toCBuffer(OutBuffer buf, HdrGenState* hgs) { assert(false); } AttribDeclaration isAttribDeclaration() { return this; } void toObjFile(int multiobj) // compile to .obj file { Array d = include(null, null); if (d) { for (uint i = 0; i < d.dim; i++) { Dsymbol s = cast(Dsymbol)d.data[i]; s.toObjFile(multiobj); } } } int cvMember(ubyte* p) { assert(false); } }